Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dep_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ jobs:
cargo check -p hyperlight-host --features print_debug
cargo check -p hyperlight-host --features gdb

# without any driver (shouldn't compile)
just test-compilation-fail ${{ matrix.config }}
# without any features
just test-compilation-no-default-features ${{ matrix.config }}

# One of the examples is flaky on Windows GH runners, so this allows us to disable it for now
- name: Run Rust examples - windows
Expand Down
16 changes: 11 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test-like-ci config=default-target hypervisor="kvm":
cargo check -p hyperlight-host --features gdb

@# without any driver (should fail to compile)
just test-compilation-fail {{config}}
just test-compilation-no-default-features {{config}}

@# test the crashdump feature
just test-rust-crashdump {{config}}
Expand Down Expand Up @@ -121,10 +121,16 @@ test-seccomp target=default-target features="":
cargo test --profile={{ if target == "debug" { "dev" } else { target } }} -p hyperlight-host test_violate_seccomp_filters --lib {{ if features =="" {''} else { "--features " + features } }} -- --ignored
cargo test --profile={{ if target == "debug" { "dev" } else { target } }} -p hyperlight-host test_violate_seccomp_filters --no-default-features {{ if features =~"mshv3" {"--features init-paging,mshv3"} else {"--features mshv2,init-paging,kvm" } }} --lib -- --ignored

# runs tests that ensure compilation fails when it should
test-compilation-fail target=default-target:
@# the following should fail on linux because one of kvm, mshv, or mshv3 feature must be specified, which is why the exit code is inverted with an !.
{{ if os() == "linux" { "! cargo check -p hyperlight-host --no-default-features 2> /dev/null"} else { "" } }}
# tests compilation with no default features on different platforms
test-compilation-no-default-features target=default-target:
@# Linux should fail without a hypervisor feature (kvm, mshv, or mshv3)
{{ if os() == "linux" { "! cargo check -p hyperlight-host --no-default-features 2> /dev/null" } else { "" } }}
@# Windows should succeed even without default features
{{ if os() == "windows" { "cargo check -p hyperlight-host --no-default-features" } else { "" } }}
@# Linux should succeed with a hypervisor driver but without init-paging
{{ if os() == "linux" { "cargo check -p hyperlight-host --no-default-features --features kvm" } else { "" } }}
{{ if os() == "linux" { "cargo check -p hyperlight-host --no-default-features --features mshv2" } else { "" } }}
{{ if os() == "linux" { "cargo check -p hyperlight-host --no-default-features --features mshv3" } else { "" } }}

# runs tests that exercise gdb debugging
test-rust-gdb-debugging target=default-target features="":
Expand Down
22 changes: 22 additions & 0 deletions src/hyperlight_host/src/hypervisor/hyperv_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,28 @@ impl HypervLinuxDriver {
cs: SegmentRegister {
base: 0,
selector: 0,
limit: 0xFFFF,
type_: 11,
present: 1,
s: 1,
..Default::default()
},
ds: SegmentRegister {
base: 0,
selector: 0,
limit: 0xFFFF,
type_: 3,
present: 1,
s: 1,
..Default::default()
},
tr: SegmentRegister {
base: 0,
selector: 0,
limit: 0xFFFF,
type_: 11,
present: 1,
s: 0,
..Default::default()
},
..Default::default()
Expand Down
31 changes: 20 additions & 11 deletions src/hyperlight_host/src/hypervisor/hyperv_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ use tracing::{Span, instrument};
use windows::Win32::System::Hypervisor::{
WHV_MEMORY_ACCESS_TYPE, WHV_PARTITION_HANDLE, WHV_REGISTER_VALUE, WHV_RUN_VP_EXIT_CONTEXT,
WHV_RUN_VP_EXIT_REASON, WHV_X64_SEGMENT_REGISTER, WHV_X64_SEGMENT_REGISTER_0,
WHvCancelRunVirtualProcessor, WHvX64RegisterCr0, WHvX64RegisterCr3, WHvX64RegisterCr4,
WHvX64RegisterCs, WHvX64RegisterEfer,
WHvCancelRunVirtualProcessor, WHvX64RegisterCs,
};
#[cfg(feature = "init-paging")]
use windows::Win32::System::Hypervisor::{
WHvX64RegisterCr0, WHvX64RegisterCr3, WHvX64RegisterCr4, WHvX64RegisterEfer,
};
#[cfg(crashdump)]
use {super::crashdump, std::path::Path};
Expand Down Expand Up @@ -399,16 +402,22 @@ impl HypervWindowsDriver {
])?;

#[cfg(not(feature = "init-paging"))]
proc.set_registers(&[(
WHvX64RegisterCs,
WHV_REGISTER_VALUE {
Segment: WHV_X64_SEGMENT_REGISTER {
Base: 0,
Selector: 0,
..Default::default()
{
proc.set_registers(&[(
WHvX64RegisterCs,
WHV_REGISTER_VALUE {
Segment: WHV_X64_SEGMENT_REGISTER {
Base: 0,
Selector: 0,
Limit: 0xFFFF,
Anonymous: WHV_X64_SEGMENT_REGISTER_0 {
Attributes: 0b1011 | (1 << 4) | (1 << 7), // Type (11: Execute/Read, accessed) | S (code segment) | P (present)
},
..Default::default()
},
},
},
)])?;
)])?;
}

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_host/src/sandbox/uninitialized_evolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::mem::mgr::SandboxMemoryManager;
use crate::mem::ptr::{GuestPtr, RawPtr};
use crate::mem::ptr_offset::Offset;
use crate::mem::shared_mem::GuestSharedMemory;
#[cfg(feature = "init-paging")]
#[cfg(any(feature = "init-paging", target_os = "windows"))]
use crate::mem::shared_mem::SharedMemory;
#[cfg(gdb)]
use crate::sandbox::config::DebugInfo;
Expand Down
Loading