From 784a7108a45328a1dfc768bf950f1faa7270ec47 Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:16:32 +0000 Subject: [PATCH 1/2] [nix] Updates - Update Nightly rust toolchain to 1.100 - Use binary wasi-sdk since Docker is no longer used to build wasm modules - Support `RUSTUP_TOOLCHAIN` env var Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com> --- flake.lock | 6 +++--- flake.nix | 46 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index faf4c21f..7e83754f 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1782723713, - "narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=", + "lastModified": 1794537146, + "narHash": "sha256-Wpz/7x/YWnDIBu7yj6ixe8j6fIMsidd9Y+o1PqPF3iM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8", + "rev": "d5cc6833999746cffdfe0598f7bc801a57b887a9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 3f162ab9..501188c2 100644 --- a/flake.nix +++ b/flake.nix @@ -96,9 +96,9 @@ sha256 = "sha256-qqF33vNuAdU5vua96VKVIwuc43j4EFeEXbjQ6+l4mO4="; }; nightly = { - date = "2026-09-22"; + date = "2026-11-01"; channel = "nightly"; - sha256 = "sha256-7qsyGDZErke6MdrngELbKaqs1Xgx8ols/e/HIygUIXg="; + sha256 = "sha256-2wqUa1sFNg8sdadO5YXcUSwpoBek+e+viCiSqnpUbdM="; }; "1.89" = { date = "2025-08-07"; @@ -187,7 +187,7 @@ # and a subsequent copy of the same file to the same place will # fail. Hack around this issue by making any existing vendored # 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' -or -path '*/sysroot/include' -or -path '*/libwit_bindgen_cabi*' \) -print0 | xargs -r -0 chmod u+w -R + find "$(base_cargo metadata --format-version 1 | jq -r '.target_directory')" \( -path '*/build/libgit2-sys-*/out/include' -or -path '*/build/libgit2-sys/*/out/include' -or -path '*/sysroot/include' -or -path '*/libwit_bindgen_cabi*' -or -path '*/build/hyperlight-libc-*/include' -or -path '*/build/hyperlight-libc/*/out/include' \) -print0 | xargs -r -0 chmod u+w -R ''; # Hyperlight scripts use cargo in a bunch of ways that don't @@ -200,14 +200,21 @@ rustup-like-wrapper = name: pkgs.writeShellScriptBin name (let clause = name: toolchain: '' - +${name}) base="${toolchain.rust}"; shift 1; ;; - +${name}-${toolchain.rust.toolchainVersionAttrs.date}) base="${toolchain.rust}"; shift 1; ;; + +${name}) base="${toolchain.rust}"; shift $shift; ;; + +${name}-${toolchain.rust.toolchainVersionAttrs.date}) base="${toolchain.rust}"; shift $shift; ;; ''; clauses = lib.strings.concatStringsSep "\n" (lib.mapAttrsToList clause toolchains); in '' base="${toolchains.stable.rust}" ${materialiseDeps} + if [ -v RUSTUP_TOOLCHAIN ]; then + shift=0 + case +''${RUSTUP_TOOLCHAIN} in + ${clauses} + esac + fi + shift=1 case "$1" in ${clauses} install) exit 0; ;; @@ -248,6 +255,33 @@ }; doCheck = false; }; + + # TODO: replace with Nix toolchain when nixos/nixpkgs#537433 is done + wasi-sdk-bin = stdenvNoCC.mkDerivation (finalAttrs: let + major = lib.versions.major finalAttrs.version; + arch = if pkgs.stdenv.buildPlatform.isAarch64 then "arm64" else + if pkgs.stdenv.buildPlatform.isx86_64 then "x86_64" else + builtins.throw "wasi-sdk not supported on ${pkgs.stdenv.buildPlatform.system}"; + os = if pkgs.stdenv.buildPlatform.isLinux then "linux" else + if pkgs.stdenv.buildPlatform.isDarwin then "macos" else + builtins.throw "wasi-sdk not supported on ${pkgs.stdenv.buildPlatform.system}"; + in { + pname = "wasi-sdk"; + version = "25.0"; + src = pkgs.fetchurl { + url = "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${major}/wasi-sdk-${finalAttrs.version}-${arch}-${os}.tar.gz"; + hash = "sha256-R/zK2LJJjyI54F4RFcP/xlK/N+feL4j7ZLLWY8l2zi0="; + }; + nativeBuildInputs = [ + autoPatchelfHook + ]; + buildInputs = [ + stdenv.cc.cc.lib + ]; + installPhase = '' + cp -r . $out + ''; + }); in (buildRustPackageClang (mkDerivationAttrs: { pname = "hyperlight"; version = "0.0.0"; @@ -289,6 +323,8 @@ LIBCLANG_PATH = "${pkgs.llvmPackages_18.libclang.lib}/lib"; # Use unwrapped clang for compiling guests HYPERLIGHT_GUEST_clang = "${clang.cc}/bin/clang"; + # Use wasi-sdk built for Nix cross toolchain + WASI_SDK_PATH = "${wasi-sdk-bin}"; RUST_NIGHTLY = "${toolchains.nightly.rust}"; # Set this through shellHook rather than nativeBuildInputs to be From c59bb465edbcf8f8fc080dc993fb54df785ddb17 Mon Sep 17 00:00:00 2001 From: Lucy Menon <168595099+syntactically@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:29:33 +0000 Subject: [PATCH 2/2] dicachesync: aarch64: reset PSTATE.Z before `ic ivau` loop The data/instruction-cache synchronising routine used to ensure cache coherence uses a specific protocol to communicate with the host because KVM does not support cache maintenance operations on readonly memslots (see hyperlight_host:src/hypervisor/virtual_machine/kvm/aarch64.rs), which includes, among other things, the requirement that PSTATE.Z should be unset whenever a cache maintenance instruction is encountered. The assembly stub used for cache maintenance successfully ensured this was true during its first `dc cvau` loop, but the condition to exit that loop set the Z flag, so it was incorrect on the first iteration of the `ic ivau` loop. This could lead to difficult-to-diagnose failures in KVM. This commit modifies the assembly stub to correctly reset the Z flag before beginning the `ic ivau`-loop. Signed-off-by: Lucy Menon <168595099+syntactically@users.noreply.github.com> --- src/hyperlight_wasm_runtime/src/platform.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hyperlight_wasm_runtime/src/platform.rs b/src/hyperlight_wasm_runtime/src/platform.rs index 60d32392..9c3d71c3 100644 --- a/src/hyperlight_wasm_runtime/src/platform.rs +++ b/src/hyperlight_wasm_runtime/src/platform.rs @@ -394,6 +394,8 @@ fn dicachesync(_base: *mut u8, _len: usize) { dsb ish + msr nzcv, xzr + mov {tmp}, {addr} 4: ic ivau, {tmp}