-
Notifications
You must be signed in to change notification settings - Fork 154
Reset more vcpu state on snapshot::restore #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9cfcc9c to
8507c7a
Compare
| } | ||
|
|
||
| #[cfg(test)] | ||
| #[cfg(feature = "init-paging")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be valid for more than just init paging feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes will fix before publishing pr
| xsave | ||
| } | ||
|
|
||
| fn hyperlight_vm(code: &[u8]) -> Result<HyperlightVm> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this duplicating alot of the configuration code we do during VM setup in the test? how will we maintain this with the actual setup? What if there is a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is calling HyperlightVm::new so they should be the same
b522e52 to
b9dfb2a
Compare
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
f7c0224 to
d09b1fc
Compare
Signed-off-by: Ludvig Liljenberg <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances vCPU state management during snapshot restoration by adding debug register abstraction and ensuring all vCPU state is properly reset. The changes follow the established Common* struct pattern for hypervisor abstraction and include comprehensive test coverage across KVM, MSHV, and WHP hypervisors.
Key changes:
- Added
CommonDebugRegsabstraction with implementations for all supported hypervisors (KVM, MSHV, WHP) - Removed padding fields from
CommonFputo simplify comparisons while maintaining correct conversions to hypervisor-specific types - Implemented
reset_vcpu()to reset general purpose registers, debug registers, FPU/XSAVE state, and special registers - Added
reset_vcpu()call inMultiUseSandbox::restore()to ensure clean state after snapshot restoration - Added extensive tests covering all reset scenarios with both direct state setting and actual code execution
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/hyperlight_host/src/hypervisor/regs/debug_regs.rs |
New file implementing CommonDebugRegs abstraction with conversions for KVM, MSHV, and WHP |
src/hyperlight_host/src/hypervisor/regs/fpu.rs |
Removed pad1 and pad2 fields from CommonFpu; updated all conversions to use literal 0 for padding |
src/hyperlight_host/src/hypervisor/regs.rs |
Added debug_regs module export |
src/hyperlight_host/src/hypervisor/mod.rs |
Added debug_regs, set_debug_regs, reset_xsave, and set_xsave methods to Hypervisor trait |
src/hyperlight_host/src/hypervisor/kvm.rs |
Implemented debug register and xsave methods for KVM hypervisor |
src/hyperlight_host/src/hypervisor/hyperv_linux.rs |
Implemented debug register and xsave methods for MSHV hypervisor |
src/hyperlight_host/src/hypervisor/hyperv_windows.rs |
Implemented debug register and xsave methods for WHP; refactored gdb breakpoint code to use new abstractions |
src/hyperlight_host/src/hypervisor/hyperlight_vm.rs |
Added reset_vcpu() method and comprehensive test suite covering all vCPU state reset scenarios |
src/hyperlight_host/src/sandbox/initialized_multi_use.rs |
Added reset_vcpu() call in restore() and test to verify debug registers are reset |
src/hyperlight_host/src/sandbox/hypervisor.rs |
Added Copy and Clone derives to HypervisorType enum |
src/hyperlight_host/src/mem/layout.rs |
Changed visibility from pub(super) to pub(crate) for methods used by tests |
src/tests/rust_guests/simpleguest/src/main.rs |
Added SetDr0 and GetDr0 guest functions for testing debug register reset |
.github/workflows/ValidatePullRequest.yml |
Changed fail-fast from true to false for build-test job to allow all matrix combinations to complete |
MSRs will be added in another PR.
into()implementation for kvm/mshv due to single memcyp, but that seems like premature optimization to me