Re: [PATCH v3 05/16] x86/virt: Force-clear X86_FEATURE_VMX if configuring root VMCS fails

From: dan.j.williams

Date: Mon Feb 16 2026 - 15:54:11 EST


Sean Christopherson wrote:
> 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).
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
[..]
> diff --git a/arch/x86/virt/hw.c b/arch/x86/virt/hw.c
> index 56972f594d90..40495872fdfb 100644
> --- a/arch/x86/virt/hw.c
> +++ b/arch/x86/virt/hw.c
[..]
> @@ -56,7 +56,7 @@ static __init int x86_vmx_init(void)
> struct vmcs *vmcs;
>
> page = __alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
> - if (!page) {
> + if (WARN_ON_ONCE(!page)) {

Is the warn_alloc() deep in this path not sufficient? Either way, this
patch looks good to me.