Skip to content

x86_64: lock IA32_FEATURE_CONTROL with VMXON enabled at boot#438

Open
CMGS wants to merge 1 commit into
cloud-hypervisor:mainfrom
cocoonstack:feat/lock-vmxon-feature-control
Open

x86_64: lock IA32_FEATURE_CONTROL with VMXON enabled at boot#438
CMGS wants to merge 1 commit into
cloud-hypervisor:mainfrom
cocoonstack:feat/lock-vmxon-feature-control

Conversation

@CMGS

@CMGS CMGS commented Jun 28, 2026

Copy link
Copy Markdown

Guest hypervisors (Windows Hyper-V, WSL2) check IA32_FEATURE_CONTROL (MSR
0x3A) at boot and refuse VMXON unless the firmware has set the lock bit
with VMXON-outside-SMX enabled — otherwise they report "virtualization not
enabled in firmware". rust-hypervisor-firmware never touched this MSR, so a
Windows guest saw VMX in CPUID (VMMonitorModeExtensions=True) but
VirtualizationFirmwareEnabled=False, and Hyper-V launch failed with Event 41
"Either VMX not present or not enabled in BIOS". Nested virtualization was
therefore unusable.

Set the MSR the way real firmware does: in rust64_start, when CPUID.1:ECX.VMX
reports VMX support, lock IA32_FEATURE_CONTROL with bit 0 (LOCKED) and bit 2
(VMXON-outside-SMX), before handing control to the OS. The write is skipped when
the lock bit is already set (idempotent) and when VMX is absent (AMD / nested
off), so AMD and non-nested guests are unaffected. Other architectures
(aarch64, riscv64) are not touched.

Verified on a Cloud Hypervisor Windows 11 guest: VirtualizationFirmwareEnabled
flips False to True and the guest boots normally.

Signed-off-by: tonic tonicbupt@gmail.com

Guest hypervisors (Windows Hyper-V, WSL2) check IA32_FEATURE_CONTROL at
boot and refuse VMXON unless firmware has set the lock bit with
VMXON-outside-SMX enabled -- otherwise they report "virtualization not
enabled in firmware". rust-hypervisor-firmware never touched this MSR,
so a Windows guest saw VMX in CPUID (VMMonitorModeExtensions=True) but
VirtualizationFirmwareEnabled=False, and Hyper-V launch failed with
Event 41 "Either VMX not present or not enabled in BIOS". Nested
virtualization was therefore unusable.

Set the MSR the way real firmware does: when CPUID reports VMX, lock
IA32_FEATURE_CONTROL with VMXON-outside-SMX enabled, before handing
control to the OS. Skipped when the lock bit is already set
(idempotent) and when VMX is absent (AMD / nested off), so AMD and
non-nested guests are unaffected.

Verified on a Cloud Hypervisor Windows 11 guest:
VirtualizationFirmwareEnabled flips False to True and the guest boots
normally.

Signed-off-by: tonic <tonicbupt@gmail.com>
@CMGS CMGS force-pushed the feat/lock-vmxon-feature-control branch from 0c6a309 to 5eda674 Compare June 28, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants