Skip to content

Use WHvResetPartition on Windows instead of manual vCPU state reset#1306

Draft
ludfjig wants to merge 4 commits intohyperlight-dev:mainfrom
ludfjig:windows_scrub
Draft

Use WHvResetPartition on Windows instead of manual vCPU state reset#1306
ludfjig wants to merge 4 commits intohyperlight-dev:mainfrom
ludfjig:windows_scrub

Conversation

@ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Mar 12, 2026

needs #1319
Replace the manual set_regs/set_debug_regs/reset_xsave calls in reset_vcpu on Windows with a single WHvResetPartition API call. This resets a bunch of state that wasn't reset before, including msrs, apic/lapic, interruptrs, vmcs/b internals, etc.

This will clear all guest visible state, at the expense of a little bit performance (rougly +~50 micro seconds compared to before on my local machine). WHvResetPartition is an internal API available from Win11 21H2, but qemu already uses it so I assume it's stable enough. WHvResetPartition has been shipped since Windows 11 21H2 (original Windows 11 release, October 2021) and Windows Server 2022 (released August 2021).

Our windows 2022 CI can't handle this it seems like, but our windows 2025 works

@ludfjig ludfjig changed the title Use WHvResetPartition to clear guest-visible state on restore() Use WHvResetPartition on Windows instead of manual vCPU state reset Mar 12, 2026
@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Mar 18, 2026
@ludfjig ludfjig force-pushed the windows_scrub branch 10 times, most recently from 0898b34 to 7cf4956 Compare March 19, 2026 23:03
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig force-pushed the windows_scrub branch 2 times, most recently from f8a2b80 to ed7efaa Compare March 20, 2026 20:18
ludfjig added 2 commits March 20, 2026 13:42
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant