]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/virt: Force-clear X86_FEATURE_VMX if configuring root VMCS fails
authorSean Christopherson <seanjc@google.com>
Sat, 14 Feb 2026 01:26:51 +0000 (17:26 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 4 Mar 2026 16:52:39 +0000 (08:52 -0800)
commit95e4adb24ff6e876f6d2b960cf922d3c969d4dc4
treebe7247280c9ca5c3e62c153e531d31aa75da1e96
parent405b7c27934eaabbcc52ccfbaeb22ef966b6b5f0
x86/virt: Force-clear X86_FEATURE_VMX if configuring root VMCS fails

If allocating and configuring a root VMCS fails, clear X86_FEATURE_VMX in
all CPUs so that KVM doesn't need to manually check root_vmcs.  As added
bonuses, clearing VMX will reflect that VMX is unusable in /proc/cpuinfo,
and will avoid a futile auto-probe of kvm-intel.ko.

WARN if allocating a root VMCS page fails, e.g. to help users figure out
why VMX is broken in the unlikely scenario something goes sideways during
boot (and because the allocation should succeed unless there's a kernel
bug).  Tweak KVM's error message to suggest checking kernel logs if VMX is
unsupported (in addition to checking BIOS).

Tested-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Tested-by: Sagi Shahar <sagis@google.com>
Link: https://patch.msgid.link/20260214012702.2368778-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/vmx.c
arch/x86/virt/hw.c