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/Benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: true
matrix:
hypervisor: [hyperv, 'hyperv-ws2025', mshv, mshv3, kvm] # hyperv,hyperv-ws2025 are windows, mshv, mshv3 and kvm are linux
hypervisor: [hyperv, 'hyperv-ws2025', mshv3, kvm] # hyperv,hyperv-ws2025 are windows, mshv3 and kvm are linux
cpu: [amd, intel]
config: [release]
runs-on: ${{ fromJson(
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Benchmarks
run: just bench-ci main ${{ matrix.hypervisor == 'mshv' && 'mshv2' || ''}}
run: just bench-ci main

- uses: actions/upload-artifact@v5
with:
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/CreateRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ jobs:
# kvm
tar -zcvf benchmarks_Linux_kvm_amd.tar.gz benchmarks_Linux_kvm_amd
tar -zcvf benchmarks_Linux_kvm_intel.tar.gz benchmarks_Linux_kvm_intel
# mshv2
tar -zcvf benchmarks_Linux_mshv_intel.tar.gz benchmarks_Linux_mshv_intel
tar -zcvf benchmarks_Linux_mshv_amd.tar.gz benchmarks_Linux_mshv_amd
# mshv3
tar -zcvf benchmarks_Linux_mshv3_amd.tar.gz benchmarks_Linux_mshv3_amd
tar -zcvf benchmarks_Linux_mshv3_intel.tar.gz benchmarks_Linux_mshv3_intel
Expand All @@ -173,8 +170,6 @@ jobs:
benchmarks_Windows_hyperv_intel.tar.gz \
benchmarks_Linux_kvm_amd.tar.gz \
benchmarks_Linux_kvm_intel.tar.gz \
benchmarks_Linux_mshv_intel.tar.gz \
benchmarks_Linux_mshv_amd.tar.gz \
benchmarks_Linux_mshv3_amd.tar.gz \
benchmarks_Linux_mshv3_intel.tar.gz \
hyperlight-guest-c-api-linux.tar.gz \
Expand All @@ -191,8 +186,6 @@ jobs:
benchmarks_Windows_hyperv_intel.tar.gz \
benchmarks_Linux_kvm_amd.tar.gz \
benchmarks_Linux_kvm_intel.tar.gz \
benchmarks_Linux_mshv_intel.tar.gz \
benchmarks_Linux_mshv_amd.tar.gz \
benchmarks_Linux_mshv3_amd.tar.gz \
benchmarks_Linux_mshv3_intel.tar.gz \
hyperlight-guest-c-api-linux.tar.gz \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ValidatePullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: true
matrix:
hypervisor: [hyperv, 'hyperv-ws2025', mshv, mshv3, kvm]
hypervisor: [hyperv, 'hyperv-ws2025', mshv3, kvm]
cpu: [amd, intel]
config: [debug, release]
uses: ./.github/workflows/dep_rust.yml
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/dep_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
# use these commands in favor of build-and-move-c-guests to avoid building both configs
just build-c-guests ${{ inputs.config }}
just move-c-guests ${{ inputs.config }}

- name: Build
run: just build ${{ inputs.config }}
env:
Expand All @@ -144,10 +144,10 @@ jobs:
TARGET_TRIPLE: ${{ inputs.target_triple }}
run: |
# with default features
just test ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || '""'}}
just test ${{ inputs.config }}

# with only one driver enabled (driver mshv/kvm feature is ignored on windows)
just test ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || inputs.hypervisor == 'mshv3' && 'mshv3' || 'kvm' }}
just test ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv3' && 'mshv3' || 'kvm' }}

# make sure certain cargo features compile
just check
Expand All @@ -171,29 +171,29 @@ jobs:
CARGO_TERM_COLOR: always
RUST_LOG: debug
TARGET_TRIPLE: ${{ inputs.target_triple }}
run: just run-rust-examples-linux ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || '""'}}
run: just run-rust-examples-linux ${{ inputs.config }}

- name: Run Rust Gdb tests
env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
TARGET_TRIPLE: ${{ inputs.target_triple }}
run: just test-rust-gdb-debugging ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || '""'}}
run: just test-rust-gdb-debugging ${{ inputs.config }}

- name: Run Rust Crashdump tests
env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
TARGET_TRIPLE: ${{ inputs.target_triple }}
run: just test-rust-crashdump ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || '""'}}
run: just test-rust-crashdump ${{ inputs.config }}

- name: Run Rust Tracing tests - linux
if: runner.os == 'Linux'
env:
CARGO_TERM_COLOR: always
RUST_LOG: debug
TARGET_TRIPLE: ${{ inputs.target_triple }}
run: just test-rust-tracing ${{ inputs.config }} ${{ inputs.hypervisor == 'mshv' && 'mshv2' || '""'}}
run: just test-rust-tracing ${{ inputs.config }}

- name: Download benchmarks from "latest"
run: just bench-download ${{ runner.os }} ${{ inputs.hypervisor }} ${{ inputs.cpu}} dev-latest # compare to prerelease
Expand All @@ -204,5 +204,5 @@ jobs:

- name: Run benchmarks
run: |
just bench-ci main ${{ inputs.hypervisor == 'mshv' && 'mshv2' || ''}}
just bench-ci main
if: ${{ inputs.config == 'release' && inputs.target_triple == '' }}
32 changes: 3 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ clean-rust:
# convenience recipe to run all tests with the given target and features (similar to CI)
test-like-ci config=default-target hypervisor="kvm":
@# with default features
just test {{config}} {{ if hypervisor == "mshv" {"mshv2"} else {""} }}
just test {{config}}

@# with only one driver enabled + build-metadata + init-paging
just test {{config}} build-metadata,init-paging,{{ if hypervisor == "mshv" {"mshv2"} else if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}
just test {{config}} build-metadata,init-paging,{{ if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}

@# make sure certain cargo features compile
just check
Expand All @@ -93,7 +93,7 @@ test-like-ci config=default-target hypervisor="kvm":
just test-rust-crashdump {{config}}

@# test the tracing related features
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

like-ci config=default-target hypervisor="kvm":
@# Ensure up-to-date Cargo.lock
Expand Down Expand Up @@ -130,19 +130,19 @@ like-ci config=default-target hypervisor="kvm":
{{ if os() == "windows" { "just run-rust-examples " + config } else { "" } }}

@# Run Rust examples - linux
{{ if os() == "linux" { "just run-rust-examples-linux " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
{{ if os() == "linux" { "just run-rust-examples-linux " + config + " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

@# Run Rust Gdb tests
just test-rust-gdb-debugging {{ config }} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
just test-rust-gdb-debugging {{ config }} {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}

@# Run Rust Crashdump tests
just test-rust-crashdump {{config}} {{ if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
just test-rust-crashdump {{config}} {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}

@# Run Rust Tracing tests - linux
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

@# Run benchmarks
{{ if config == "release" { "just bench-ci main " + if hypervisor == "mshv" { "mshv2" } else if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
{{ if config == "release" { "just bench-ci main " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

# runs all tests
test target=default-target features="": (test-unit target features) (test-isolated target features) (test-integration "rust" target features) (test-integration "c" target features) (test-doc target features)
Expand Down Expand Up @@ -172,13 +172,12 @@ test-integration guest target=default-target features="":

# 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)
@# Linux should fail without a hypervisor feature (kvm or mshv3)
{{ if os() == "linux" { "! " + cargo-cmd + " check -p hyperlight-host --no-default-features "+target-triple-flag+" 2> /dev/null" } else { "" } }}
@# Windows should succeed even without default features
{{ if os() == "windows" { cargo-cmd + " check -p hyperlight-host --no-default-features" } else { "" } }}
@# Linux should succeed with a hypervisor driver but without init-paging
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features kvm" } else { "" } }} {{ target-triple-flag }}
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features mshv2" } else { "" } }} {{ target-triple-flag }}
{{ if os() == "linux" { cargo-cmd + " check -p hyperlight-host --no-default-features --features mshv3" } else { "" } }} {{ target-triple-flag }}

# runs tests that exercise gdb debugging
Expand Down Expand Up @@ -308,7 +307,7 @@ tar-static-lib: (build-rust-capi "release") (build-rust-capi "debug")
# Downloads the benchmarks result from the given release tag.
# If tag is not given, defaults to latest release
# Options for os: "Windows", or "Linux"
# Options for Linux hypervisor: "kvm", "mshv", "mshv3"
# Options for Linux hypervisor: "kvm", "mshv3"
# Options for Windows hypervisor: "hyperv"
# Options for cpu: "amd", "intel"
bench-download os hypervisor cpu tag="":
Expand Down
10 changes: 3 additions & 7 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ lazy_static = "1.4.0"
[target.'cfg(unix)'.dependencies]
kvm-bindings = { version = "0.14", features = ["fam-wrappers"], optional = true }
kvm-ioctls = { version = "0.24", optional = true }
mshv-bindings2 = { package="mshv-bindings", version = "=0.2.1", optional = true }
mshv-ioctls2 = { package="mshv-ioctls", version = "=0.2.1", optional = true}
mshv-bindings3 = { package="mshv-bindings", version = "0.6.1", optional = true }
mshv-ioctls3 = { package="mshv-ioctls", version = "0.6.1", optional = true}
mshv-bindings = { version = "0.6.1", optional = true }
mshv-ioctls = { version = "0.6.1", optional = true}

[dev-dependencies]
uuid = { version = "1.18.1", features = ["v4"] }
Expand Down Expand Up @@ -135,9 +133,7 @@ crashdump = ["dep:chrono"]
trace_guest = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:hyperlight-guest-tracing", "hyperlight-common/trace_guest"]
mem_profile = [ "trace_guest", "dep:framehop", "dep:fallible-iterator", "hyperlight-common/mem_profile" ]
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
# This feature is deprecated in favor of mshv3
mshv2 = ["dep:mshv-bindings2", "dep:mshv-ioctls2"]
mshv3 = ["dep:mshv-bindings3", "dep:mshv-ioctls3"]
mshv3 = ["dep:mshv-bindings", "dep:mshv-ioctls"]
# This enables easy debug in the guest
gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
fuzzing = ["hyperlight-common/fuzzing"]
Expand Down
12 changes: 3 additions & 9 deletions src/hyperlight_host/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,15 @@ fn main() -> Result<()> {
}

// Makes #[cfg(kvm)] == #[cfg(all(feature = "kvm", target_os = "linux"))]
// and #[cfg(mshv)] == #[cfg(all(any(feature = "mshv2", feature = "mshv3"), target_os = "linux"))].
// Essentially the kvm and mshv features are ignored on windows as long as you use #[cfg(kvm)] and not #[cfg(feature = "kvm")].
// You should never use #[cfg(feature = "kvm")] or #[cfg(feature = "mshv")] in the codebase.
// Essentially the kvm and mshv3 features are ignored on windows as long as you use #[cfg(kvm)] and not #[cfg(feature = "kvm")].
// You should never use #[cfg(feature = "kvm")] or #[cfg(feature = "mshv3")] in the codebase.
cfg_aliases::cfg_aliases! {
gdb: { all(feature = "gdb", debug_assertions) },
kvm: { all(feature = "kvm", target_os = "linux") },
mshv: { all(any(feature = "mshv2", feature = "mshv3"), target_os = "linux") },
mshv3: { all(feature = "mshv3", target_os = "linux") },
crashdump: { all(feature = "crashdump") },
// print_debug feature is aliased with debug_assertions to make it only available in debug-builds.
print_debug: { all(feature = "print_debug", debug_assertions) },
// the following features are mutually exclusive but rather than enforcing that here we are enabling mshv2 to override mshv3 when both are enabled
// because mshv3 is in the default feature set we want to allow users to enable mshv2 without having to set --no-default-features and the re-enable
// the other features they want.
mshv2: { all(feature = "mshv2", target_os = "linux") },
mshv3: { all(feature = "mshv3", not(feature="mshv2"), target_os = "linux") },
}

#[cfg(feature = "build-metadata")]
Expand Down
3 changes: 0 additions & 3 deletions src/hyperlight_host/examples/guest-debugging/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ mod tests {

write_cmds_file(&cmd_file_path, cmd).expect("Failed to write gdb commands to file");

#[cfg(mshv2)] // mshv3 is a default feature is mutually exclusive with the mshv2 feature
let features = "gdb,mshv2";
#[cfg(not(mshv2))]
let features = "gdb";

// build it before running to avoid a race condition below
Expand Down
9 changes: 3 additions & 6 deletions src/hyperlight_host/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#[cfg(mshv2)]
extern crate mshv_ioctls2 as mshv_ioctls;

#[cfg(mshv3)]
extern crate mshv_ioctls3 as mshv_ioctls;
extern crate mshv_ioctls;

use std::array::TryFromSliceError;
use std::cell::{BorrowError, BorrowMutError};
Expand Down Expand Up @@ -172,7 +169,7 @@ pub enum HyperlightError {

/// mshv Error Occurred
#[error("mshv Error {0:?}")]
#[cfg(mshv)]
#[cfg(mshv3)]
MSHVError(#[from] mshv_ioctls::MshvError),

/// No Hypervisor was found for Sandbox.
Expand Down Expand Up @@ -382,7 +379,7 @@ impl HyperlightError {
HyperlightError::VmmSysError(_) => false,
#[cfg(kvm)]
HyperlightError::KVMError(_) => false,
#[cfg(mshv)]
#[cfg(mshv3)]
HyperlightError::MSHVError(_) => false,
#[cfg(gdb)]
HyperlightError::TranslateGuestAddress(_) => false,
Expand Down
4 changes: 2 additions & 2 deletions src/hyperlight_host/src/hypervisor/gdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod event_loop;
mod hyperv_debug;
#[cfg(kvm)]
mod kvm_debug;
#[cfg(mshv)]
#[cfg(mshv3)]
mod mshv_debug;
mod x86_64_target;

Expand All @@ -40,7 +40,7 @@ use hyperlight_common::mem::PAGE_SIZE;
pub(crate) use hyperv_debug::HypervDebug;
#[cfg(kvm)]
pub(crate) use kvm_debug::KvmDebug;
#[cfg(mshv)]
#[cfg(mshv3)]
pub(crate) use mshv_debug::MshvDebug;
use thiserror::Error;
use x86_64_target::HyperlightSandboxTarget;
Expand Down
9 changes: 2 additions & 7 deletions src/hyperlight_host/src/hypervisor/gdb/mshv_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#[cfg(mshv2)]
extern crate mshv_bindings2 as mshv_bindings;
#[cfg(mshv2)]
extern crate mshv_ioctls2 as mshv_ioctls;

#[cfg(mshv3)]
extern crate mshv_bindings3 as mshv_bindings;
extern crate mshv_bindings;
#[cfg(mshv3)]
extern crate mshv_ioctls3 as mshv_ioctls;
extern crate mshv_ioctls;

use std::collections::HashMap;

Expand Down
Loading
Loading