Skip to content

Commit 411d76a

Browse files
committed
Use WHvResetPartition on windows
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent 3517c0c commit 411d76a

File tree

11 files changed

+241
-136
lines changed

11 files changed

+241
-136
lines changed

.github/workflows/ValidatePullRequest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
# See: https://github.com/actions/runner/issues/2205
9090
if: ${{ !cancelled() && !failure() }}
9191
strategy:
92-
fail-fast: true
92+
fail-fast: false
9393
matrix:
9494
hypervisor: ['hyperv-ws2025', mshv3, kvm]
9595
cpu: [amd, intel]
@@ -112,7 +112,7 @@ jobs:
112112
# See: https://github.com/actions/runner/issues/2205
113113
if: ${{ !cancelled() && !failure() }}
114114
strategy:
115-
fail-fast: true
115+
fail-fast: false
116116
matrix:
117117
hypervisor: ['hyperv-ws2025', mshv3, kvm]
118118
cpu: [amd, intel]

.github/workflows/dep_build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defaults:
3737
jobs:
3838
build-and-test:
3939
if: ${{ inputs.docs_only == 'false' }}
40-
timeout-minutes: 45
40+
timeout-minutes: 60
4141
runs-on: ${{ fromJson(
4242
format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-{2}"]',
4343
inputs.hypervisor == 'hyperv-ws2025' && 'Windows' || 'Linux',

Justfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ test-integration target=default-target features="":
235235
{{ cargo-cmd }} test {{ if features =="" {"--features executable_heap"} else if features=="no-default-features" {"--no-default-features --features executable_heap"} else {"--no-default-features -F executable_heap," + features } }} --profile={{ if target == "debug" { "dev" } else { target } }} {{ target-triple-flag }} --test integration_test execute_on_heap
236236

237237
@# run the rest of the integration tests
238-
{{ cargo-cmd }} test -p hyperlight-host {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }} {{ target-triple-flag }} --test '*'
238+
{{ cargo-cmd }} test -p hyperlight-host {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" { "dev" } else { target } }} {{ target-triple-flag }} --test '*' -- --nocapture
239239

240240
# tests compilation with no default features on different platforms
241241
test-compilation-no-default-features target=default-target:
@@ -323,6 +323,11 @@ clippy target=default-target: (witguest-wit)
323323
clippyw target=default-target: (witguest-wit)
324324
{{ cargo-cmd }} clippy --all-targets --all-features --target x86_64-pc-windows-gnu --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
325325

326+
# Cross-check for linux from a windows host using clippy (no linking needed).
327+
# Only checks lib targets to avoid dev-dependencies (criterion->alloca) that need a C cross-compiler.
328+
clippyl target=default-target:
329+
{{ cargo-cmd }} clippy --lib --all-features --target x86_64-unknown-linux-gnu --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
330+
326331
clippy-guests target=default-target: (witguest-wit) (ensure-cargo-hyperlight)
327332
cd src/tests/rust_guests/simpleguest && cargo hyperlight clippy --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings
328333
cd src/tests/rust_guests/witguest && cargo hyperlight clippy --profile={{ if target == "debug" { "dev" } else { target } }} -- -D warnings

src/hyperlight_guest_bin/src/guest_function/call.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ pub(crate) fn internal_dispatch_function() {
8686
};
8787

8888
let handle = unsafe { GUEST_HANDLE };
89+
let canary = unsafe { crate::GUEST_HANDLE_CANARY };
90+
91+
if handle.peb().is_none() || canary != 0xDEAD_BEEF {
92+
panic!(
93+
"GUEST_HANDLE is None! canary={:#x} (expected 0xDEADBEEF), peb={:#x}. \
94+
If canary is also 0, snapshot memory was not restored for this page.",
95+
canary,
96+
handle.peb().map_or(0, |p| p as u64),
97+
);
98+
}
8999

90100
let function_call = handle
91101
.try_pop_shared_input_data_into::<FunctionCall>()

src/hyperlight_guest_bin/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ pub(crate) static HEAP_ALLOCATOR: ProfiledLockedHeap<32> =
116116
ProfiledLockedHeap(LockedHeap::<32>::empty());
117117

118118
pub static mut GUEST_HANDLE: GuestHandle = GuestHandle::new();
119+
/// Canary value set to 0xDEAD_BEEF during init. If this reads as 0
120+
/// after snapshot restore while GUEST_HANDLE is None, the snapshot
121+
/// memory for this region was not properly restored.
122+
pub static mut GUEST_HANDLE_CANARY: u64 = 0;
119123
pub(crate) static mut REGISTERED_GUEST_FUNCTIONS: GuestFunctionRegister<GuestFunc> =
120124
GuestFunctionRegister::new();
121125

@@ -205,6 +209,7 @@ pub(crate) extern "C" fn generic_init(
205209
) -> u64 {
206210
unsafe {
207211
GUEST_HANDLE = GuestHandle::init(peb_address as *mut HyperlightPEB);
212+
GUEST_HANDLE_CANARY = 0xDEAD_BEEF;
208213
#[allow(static_mut_refs)]
209214
let peb_ptr = GUEST_HANDLE.peb().unwrap();
210215

src/hyperlight_host/src/hypervisor/hyperlight_vm/aarch64.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,15 @@ impl HyperlightVm {
8989
unimplemented!("get_snapshot_sregs")
9090
}
9191

92-
pub(crate) fn reset_vcpu(
92+
pub(crate) fn reset_vm_state(&mut self) -> std::result::Result<(), RegisterError> {
93+
unimplemented!("reset_vm_state")
94+
}
95+
96+
pub(crate) fn restore_sregs(
9397
&mut self,
9498
_cr3: u64,
9599
_sregs: &CommonSpecialRegisters,
96100
) -> std::result::Result<(), RegisterError> {
97-
unimplemented!("reset_vcpu")
101+
unimplemented!("restore_sregs")
98102
}
99103
}

0 commit comments

Comments
 (0)