Batch register restore on MSHV and WHP - #1774
Merged
Merged
Conversation
ludfjig
force-pushed
the
batch_register
branch
2 times, most recently
from
August 26, 2026 22:50
a1f08a2 to
11799f4
Compare
ludfjig
marked this pull request as ready for review
August 27, 2026 00:20
ludfjig
requested review from
andreiltd,
dblnz,
devigned,
jprendes,
jsturtevant,
simongdavies,
squillace and
syntactically
as code owners
August 27, 2026 00:20
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces x86_64 snapshot-restore overhead by batching general/debug/special/XCR0/MSR register writes into a single backend call when running on MSHV or WHP, avoiding multiple hypercalls during vCPU reset.
Changes:
- Extend the
VirtualMachinetrait with a batched-register write API and plumb newRegisterErrorvariants for it. - Implement batched register restore for WHP and MSHV, with KVM/HVF reporting the capability as unsupported.
- Fold MSR restore into
HyperlightVm::reset_vcpuand update sandbox restore to pass snapshot MSRs into the reset path.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hyperlight_host/src/sandbox/initialized_multi_use.rs | Pass snapshot MSRs into reset_vcpu so restore can batch state updates. |
| src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs | Add WHP batched register write implementation via set_registers. |
| src/hyperlight_host/src/hypervisor/virtual_machine/mshv/x86_64.rs | Add MSHV batched register write implementation via set_reg. |
| src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs | Define the batched-register capability + API on the backend trait and add new error variants. |
| src/hyperlight_host/src/hypervisor/virtual_machine/kvm/x86_64.rs | Explicitly mark batching as unsupported on KVM. |
| src/hyperlight_host/src/hypervisor/virtual_machine/hvf/mod.rs | Explicitly mark batching as unsupported on HVF. |
| src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs | Use the new capability to batch reset writes and incorporate MSR restore into reset. |
| src/hyperlight_host/src/hypervisor/hyperlight_vm/test_support.rs | Forward the new trait methods through the fault-injecting VM wrapper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ludfjig
force-pushed
the
batch_register
branch
from
August 27, 2026 00:35
11799f4 to
78cc180
Compare
jsturtevant
reviewed
Aug 27, 2026
jsturtevant
reviewed
Aug 27, 2026
danbugs
reviewed
Aug 27, 2026
jsturtevant
reviewed
Aug 27, 2026
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
ludfjig
force-pushed
the
batch_register
branch
from
August 27, 2026 17:21
78cc180 to
f1e46c9
Compare
jsturtevant
approved these changes
Aug 27, 2026
danbugs
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch general, debug, special, XCR0, and MSR writes during x86_64 vCPU restore on MSHV and WHP.
benchmarks (vs main branch):
MSHV:
snapshots/restore/default
time: [83.550 µs 84.031 µs 84.443 µs]
change: [−29.780% −28.618% −27.365%] (p = 0.00 < 0.05)
Performance has improved.
snapshots/restore/small time: [91.355 µs 92.208 µs 93.294 µs]
change: [−24.927% −22.241% −19.535%] (p = 0.00 < 0.05)
Performance has improved.
snapshots/restore/medium
time: [105.37 µs 105.78 µs 106.27 µs]
change: [−28.331% −21.040% −12.627%] (p = 0.00 < 0.05)
Performance has improved.
snapshots/restore/large time: [167.54 µs 169.86 µs 172.89 µs]
change: [−31.405% −9.3155% +20.327%] (p = 0.53 > 0.05)
No change in performance detected.
WHP:
my windows machine is too noisy to measure
KVM:
no difference