Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
312862f
Update guest Cargo.lock
syntactically Jan 27, 2026
58d5506
[nix] include miri for the nightly toolchain
syntactically Jan 27, 2026
0839184
[nix] hack to make libgit2-sys builds more reliable
syntactically Jan 27, 2026
22b433a
[just] Bring `just like-ci` in line with CI changes
syntactically Jan 27, 2026
415823f
[kvm] Better document the cpuid leaf used to set GPA width
syntactically Jan 27, 2026
665a86f
[whp] Remove initial_memory_setup_done, which is no longer used
syntactically Jan 28, 2026
2cc3e55
Make scratch region writable again
syntactically Jan 27, 2026
7fccad6
Use MAP_SHARED for shared memory creation again
syntactically Jan 28, 2026
a9355b1
Modify guest physical page allocator to allocate from the scratch region
syntactically Jan 27, 2026
b6b839d
i686: add layout, vmem, etc stubs
syntactically Jan 27, 2026
f38272f
Move guest-written page tables to the scratch region
syntactically Jan 27, 2026
5bbb393
Make the snapshot page table mapping readonly
syntactically Jan 27, 2026
93faff9
snapshot: handle the scratch region correctly
syntactically Jan 28, 2026
350a605
Explicitly specify the physical addresses of snapshot page tables
syntactically Jan 28, 2026
b1274bd
fixup! Explicitly specify the physical addresses of snapshot page tables
syntactically Jan 28, 2026
2f5a4fb
fixup! snapshot: handle the scratch region correctly
syntactically Jan 29, 2026
638bcb7
fixup! snapshot: handle the scratch region correctly
syntactically Jan 29, 2026
2a2b444
fixup! snapshot: handle the scratch region correctly
syntactically Jan 29, 2026
54cd065
fixup! Modify guest physical page allocator to allocate from the scra…
syntactically Jan 29, 2026
a2ece56
Neaten up page table operations structures
syntactically Jan 30, 2026
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
72 changes: 55 additions & 17 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,10 @@ test-like-ci config=default-target hypervisor="kvm":
@# test the tracing related features
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

like-ci config=default-target hypervisor="kvm":
code-checks-like-ci config=default-target hypervisor="kvm":
@# Ensure up-to-date Cargo.lock
cargo fetch --locked

@# typos
typos

@# check licence headers
just check-license-headers

@# fmt
just fmt-check

Expand All @@ -122,6 +116,17 @@ like-ci config=default-target hypervisor="kvm":
@# Verify MSRV
./dev/verify-msrv.sh hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro hyperlight-guest-tracing

@# Check 32-bit guests
{{ if os() == "linux" { "just check-i686 " + config } else { "" } }}

@# Check cargo features compile
just check

@# Check compilation with no default features
just test-compilation-no-default-features debug
just test-compilation-no-default-features release

build-guests-like-ci config=default-target hypervisor="kvm":
@# Build and move Rust guests
just build-rust-guests {{config}}
just move-rust-guests {{config}}
Expand All @@ -130,29 +135,62 @@ like-ci config=default-target hypervisor="kvm":
just build-c-guests {{config}}
just move-c-guests {{config}}

build-test-like-ci config=default-target hypervisor="kvm":
@# Build
just build {{config}}

@# Run Miri tests
{{ if os() == "linux" { "just miri-tests" } else { "" } }}

@# Run Rust tests
just test-like-ci {{config}} {{hypervisor}}
just test {{config}}

@# Run Rust tests with single driver
{{ if os() == "linux" { "just test " + config+ " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}

@# Run Rust Gdb tests
just test-rust-gdb-debugging {{config}}

@# Run Rust Crashdump tests
just test-rust-crashdump {{config}}

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

run-examples-like-ci config=default-target hypervisor="kvm":
@# Run Rust examples - Windows
{{ if os() == "windows" { "just run-rust-examples " + config } else { "" } }}

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

@# Run Rust Gdb tests
just test-rust-gdb-debugging {{ config }} {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
benchmarks-like-ci config=default-target hypervisor="$vm":
@# Run benchmarks
{{ if config == "release" { "just bench-ci main" } else { "" } }}

@# Run Rust Crashdump tests
just test-rust-crashdump {{config}} {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }}
like-ci config=default-target hypervisor="kvm":
@# .github/workflows/dep_code_checks.yml
just code-checks-like-ci {{config}} {{hypervisor}}

@# Run Rust Tracing tests - linux
{{ if os() == "linux" { "just test-rust-tracing " + config + " " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
@# .github/workflows/dep_build_guests.yml
just build-guests-like-ci {{config}} {{hypervisor}}

@# Run benchmarks
{{ if config == "release" { "just bench-ci main " + if hypervisor == "mshv3" { "mshv3" } else { "kvm" } } else { "" } }}
@# .github/workflows/dep_build_test.yml
just build-test-like-ci {{config}} {{hypervisor}}

@# .github/workflows/dep_run_examples.yml
just run-examples-like-ci {{config}} {{hypervisor}}

@# .github/workflows/dep_benchmarks.yml
just benchmarks-like-ci {{config}} {{hypervisor}}

@# can't run fuzzing locally

@# spelling
typos

@# license-headers
just check-license-headers

# 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
85 changes: 51 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
patchRustPkg = pkg: (pkg.overrideAttrs (oA: {
buildCommand = (builtins.replaceStrings
[ "rustc,rustdoc" ]
[ "rustc,rustdoc,clippy-driver,cargo-clippy" ]
[ "rustc,rustdoc,clippy-driver,cargo-clippy,miri,cargo-miri" ]
oA.buildCommand) + (let
wrapperPath = pkgs.path + "/pkgs/build-support/bintools-wrapper/ld-wrapper.sh";
baseOut = pkgs.clangStdenv.cc.bintools.out;
Expand Down Expand Up @@ -67,8 +67,9 @@
"x86_64-unknown-linux-gnu"
"x86_64-pc-windows-msvc" "x86_64-unknown-none"
"wasm32-wasip1" "wasm32-wasip2" "wasm32-unknown-unknown"
"i686-unknown-linux-gnu"
];
extensions = [ "rust-src" ];
extensions = [ "rust-src" ] ++ (if args.channel == "nightly" then [ "miri-preview" ] else []);
});

# Hyperlight needs a variety of toolchains, since we use Nightly
Expand Down Expand Up @@ -96,6 +97,31 @@
rustc = toolchains.stable.rust;
};

# when building a guest with cargo-hyperlight, or when
# building a miri sysroot for the main workspace, we need to
# include any crates.io dependencies of the standard library
# (e.g. rustc-literal-escaper)
stdlibLocks = lib.mapAttrsToList (_: toolchain:
"${toolchain.rust}/lib/rustlib/src/rust/library/Cargo.lock"
) toolchains;
stdlibDeps = builtins.map (lockFile:
rust-platform.importCargoLock { inherit lockFile; }) stdlibLocks;
withStdlibLock = lockFile:
pkgs.symlinkJoin {
name = "cargo-deps";
paths = stdlibDeps ++ [
(rust-platform.importCargoLock {
inherit lockFile;
})
];
};
deps = {
"Cargo.toml" = withStdlibLock ./Cargo.lock;
"src/tests/rust_guests/dummyguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/dummyguest/Cargo.lock;
"src/tests/rust_guests/simpleguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/simpleguest/Cargo.lock;
"src/tests/rust_guests/witguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/witguest/Cargo.lock;
};

# Script snippet, used in the cargo/rustc wrappers below,
# which creates a number of .cargo/config.toml files in
# order to allow using Nix-fetched dependencies (this must
Expand All @@ -105,7 +131,7 @@
# unfortunately that tends not to play well with subcommands
# like `cargo clippy` and `cargo hyperlight` (see
# https://github.com/rust-lang/cargo/issues/11031).
materialiseDeps = deps: let
materialiseDeps = let
sortedNames = lib.lists.reverseList (builtins.attrNames deps);
matchClause = path: '' */${path}) root="''${manifest%${path}}" ;;'';
matchClauses = lib.strings.concatStringsSep "\n"
Expand All @@ -127,14 +153,28 @@
makeClauses = lib.strings.concatStringsSep "\n"
(lib.mapAttrsToList makeClause deps);
in ''
manifest=$(''${base}/bin/cargo locate-project --message-format plain --workspace)
base_cargo() {
PATH="$base/bin:$PATH" "$base/bin/cargo" "$@"
}

manifest=$(base_cargo locate-project --message-format plain --workspace)
case "$manifest" in
${matchClauses}
esac
if [ -f ''${root}/flake.nix ]; then
sed -i '/# vendor dependency configuration generated by nix/{N;d;}' $root/.git/info/exclude
${makeClauses}
fi

# libgit2-sys copies a vendored git2 into the target/
# directory somewhere. In certain, rare, cases,
# libgit2-sys is rebuilt in the same incremental dep
# directory as it was before, and then this copy fails,
# because the files, copied from the nix store, already
# exist and do not have w permission. Hack around this
# issue by making any existing libgit2-sys vendored git2
# files writable before a build can be run
find "$(base_cargo metadata --format-version 1 | jq -r '.target_directory')" -path '*/build/libgit2-sys-*/out/include' -print0 | xargs -r -0 chmod u+w -R
'';

# Hyperlight scripts use cargo in a bunch of ways that don't
Expand All @@ -144,28 +184,28 @@
# scripts also use `rustup toolchain install` in some cases, in
# order to work in CI, so we provide a fake rustup that does
# nothing as well.
rustup-like-wrapper = name: deps: pkgs.writeShellScriptBin name
rustup-like-wrapper = name: pkgs.writeShellScriptBin name
(let
clause = name: toolchain:
"+${name}) base=\"${toolchain.rust}\"; shift 1; ;;";
clauses = lib.strings.concatStringsSep "\n"
(lib.mapAttrsToList clause toolchains);
in ''
base="${toolchains.stable.rust}"
${materialiseDeps deps}
${materialiseDeps}
case "$1" in
${clauses}
install) exit 0; ;;
esac
export PATH="$base/bin:$PATH"
exec "$base/bin/${name}" "$@"
'');
fake-rustup = deps: pkgs.symlinkJoin {
fake-rustup = pkgs.symlinkJoin {
name = "fake-rustup";
paths = [
(pkgs.writeShellScriptBin "rustup" "")
(rustup-like-wrapper "rustc" deps)
(rustup-like-wrapper "cargo" deps)
(rustup-like-wrapper "rustc")
(rustup-like-wrapper "cargo")
];
};

Expand All @@ -182,34 +222,11 @@
};
cargoHash = "sha256-muiMVrK1TydQiMitihfo7xYidqUIIQ+Hw3BIeo5rLFw=";
};
# when building a guest with cargo-hyperlight, we need to
# include any crates.io dependencies of the standard library
# (e.g. rustc-literal-escaper)
stdlibLocks = lib.mapAttrsToList (_: toolchain:
"${toolchain.rust}/lib/rustlib/src/rust/library/Cargo.lock"
) toolchains;
stdlibDeps = builtins.map (lockFile:
rust-platform.importCargoLock { inherit lockFile; }) stdlibLocks;
withStdlibLock = lockFile:
pkgs.symlinkJoin {
name = "cargo-deps";
paths = stdlibDeps ++ [
(rust-platform.importCargoLock {
inherit lockFile;
})
];
};
deps = finalRootVendor: {
"Cargo.toml" = finalRootVendor;
"src/tests/rust_guests/dummyguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/dummyguest/Cargo.lock;
"src/tests/rust_guests/simpleguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/simpleguest/Cargo.lock;
"src/tests/rust_guests/witguest/Cargo.toml" = withStdlibLock ./src/tests/rust_guests/witguest/Cargo.lock;
};
in (buildRustPackageClang (mkDerivationAttrs: {
pname = "hyperlight";
version = "0.0.0";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoDeps = deps."Cargo.toml";

nativeBuildInputs = [
azure-cli
Expand Down Expand Up @@ -246,7 +263,7 @@
# Set this through shellHook rather than nativeBuildInputs to be
# really sure that it overrides the real cargo.
postHook = ''
export PATH="${fake-rustup (deps mkDerivationAttrs.cargoDeps)}/bin:$PATH"
export PATH="${fake-rustup}/bin:$PATH"
'';
})).overrideAttrs(oA: {
hardeningDisable = [ "all" ];
Expand Down
3 changes: 2 additions & 1 deletion src/hyperlight_common/src/arch/amd64/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ limitations under the License.
/// to make working with start/end ptrs in a few places more
/// convenient (not needing to worry about overflow)
pub const MAX_GVA: usize = 0xffff_ffff_ffff_efff;
pub const SNAPSHOT_PT_GVA: usize = 0xffff_8000_0000_0000;
pub const SNAPSHOT_PT_GVA_MIN: usize = 0xffff_8000_0000_0000;
pub const SNAPSHOT_PT_GVA_MAX: usize = 0xffff_80ff_ffff_ffff;

/// We assume 36-bit IPAs for now, since every amd64 processor
/// supports at least 36 bits. Almost all of them support at least 40
Expand Down
Loading