Repository navigation
feat(runtime): support nested virtualization on Windows x86_64 hosts - #10
Draft
olebhansen wants to merge 2 commits into
Draft
olebhansen wants to merge 2 commits into
olebhansen wants to merge 2 commits into
Conversation
martinothamar
force-pushed
the
main-digdir
branch
from
October 25, 2026 22:59
29be50d to
9e43b12
Compare
msb_krun 0.1.42 can enable nested virtualization in WHP partitions, which Windows hosts need before a sandbox can opt in to it. It also changes Windows x86_64 full snapshots: WHP execution state now carries the emulated PIT and uses backend state ABI 2. This runtime refuses earlier Windows full snapshots with libkrun's missing-PIT error, and earlier runtimes refuse the new ABI; disk-only snapshots and other hosts are unchanged. Windows guests also boot with tsc_early_khz from the WHP processor clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows host check now accepts Windows x86_64 when the Windows Hypervisor Platform sets up a one-vCPU partition with nesting and xAPIC emulation enabled, the configuration libkrun uses. WHP refuses nesting at setup without the local APIC emulation. WinHvPlatform.dll is loaded at run time, as Hypervisor.framework is on macOS, so processes that link the runtime still start on hosts without the optional feature. Older Windows runtimes advertise the nested_virt capability but refuse nesting once the VM starts, after replace or a modify restart has already changed the sandbox. Runtimes now also advertise nested_virt_windows, and on Windows x86_64 the SDK requires it before replacing, changing or starting a nested sandbox. The launch key and record field are unchanged. The Windows CI job runs the host check tests, which accept either result on hosted runners. MSB_TEST_EXPECT_NESTED_VIRT now also makes the unit test fail when a host expected to nest is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
olebhansen
force-pushed
the
feat/windows-nested-virt
branch
from
October 26, 2026 10:10
50eb730 to
ba6de0e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
This is a draft for local use, not intended to be merged. As agreed in digdir/digdir-agents#173, Windows support should come from upstream. Upstream's open pull request for nested virtualization covers Windows x86_64 on
msb_krun0.1.42. It goes further than this PR, with complete Windows timer state in snapshots, nested snapshots, and a Hyper-V-enabled Windows firmware bundle. Until that work reaches a fork sync, this branch lets Windows users patch digdir-agents locally to getnestedSandboxes. Close it when the fork syncs to an upstream release that contains that work.The branch is rebased onto
0.7.11-digdir.1(9e43b128). Builds pinned to the earlier commit50eb730eshould move to the new head.Changes
Nested virtualization (
nested_virt) is refused on Windows onmain-digdir, becausecrates/runtime/lib/nested_virt.rsonly accepts Linux x86_64 and Apple silicon hosts.chore(deps): bump libkrun to 0.1.42.msb_krun0.1.42 setsWHvPartitionPropertyCodeNestedVirtualizationon WHP partitions when nesting is enabled. 0.1.41 only left VMX/SVM in the guest CPUID. The bump also changes Windows x86_64 full snapshots (see Compatibility).feat(runtime): support nested virtualization on Windows x86_64 hosts.host_support()on Windows x86_64 creates a one-vCPU WHP partition with nesting and xAPIC emulation, sets it up and deletes it. That is the configuration libkrun uses, and WHP refuses nesting at setup without the local APIC emulation.WinHvPlatform.dllis loaded at run time, asHypervisor.frameworkis on macOS.nested_virt_windows. Older Windows runtimes advertisenested_virtbut refuse nesting only once the VM starts, so on Windows x86_64 the SDK requiresnested_virt_windowsbefore replacing, changing or starting a nested sandbox.COMPATIBILITY.md, and a step in the Windows CI job that runs the host-check tests.The guest kernel needs no change. The released
libkrunfw-windows-x86_64.dllis built from the Linux x86_64 config and already haskvm_intelandkvm_amdbuilt in.Compatibility
v0.7.8-digdir.2msb.exe. Other hosts ignore the new capability.Evidence
On Windows 11 Enterprise 26200, Intel Core Ultra 7 155H, VBS/HVCI on:
0.7.11-digdir.1:MSB_TEST_EXPECT_NESTED_VIRT=1 cargo test -p microsandbox-runtime --lib nested_virtpasses, as do the SDK'snested_virtlib tests andcargo clippy -p microsandbox-cli -p microsandbox-runtime -p microsandbox -- -D warnings.sdk/rust/tests/nested_virt.rspass against themsb.exebuilt from this branch, with thelibkrunfw-windows-x86_64.dllfromv0.7.11-digdir.1andMSB_TEST_EXPECT_NESTED_VIRT=1. Run the test binary directly, not throughcargo test(see Known gaps).msbfromv0.7.8-digdir.2ranmsb run alpinein about 3 s. The inner guest logsHypervisor detected: KVM.nestedSandboxes: required, started by a host agentd built against this branch, ran T3 Code. T3 Code created nested worker Agents throughagentctlinside it (L1 Linux microsandbox on the guest's/dev/kvm), and the first was Ready in about a minute, including the runtime download and image pull. T3 Code then connected to a worker over SSH.Known gaps:
cargo testruns tests inside a kill-on-close job object that does not allow breakaway. The SDK spawns detached runtimes withCREATE_BREAKAWAY_FROM_JOB, so undercargo test,create_detached()andmodify().restart()fail withPermissionDenied(os error 5). That madenested_virt_can_be_modified_on_an_existing_sandboxlook broken in the first version of this description; it passes when the test binary runs directly. This is unrelated to nesting and exists onmain-digdirtoo. A fallback without breakaway would be a separate change.馃 Generated with Claude Code