KVM: VMX: Check for full VMX support when verifying CPU compatibility
authorSean Christopherson <sean.j.christopherson@intel.com>
Sat, 21 Dec 2019 04:45:10 +0000 (20:45 -0800)
committerBorislav Petkov <bp@suse.de>
Mon, 13 Jan 2020 18:26:58 +0000 (19:26 +0100)
Explicitly check the current CPU's IA32_FEAT_CTL and VMX feature flags
when verifying compatibility across physical CPUs.  This effectively
adds a check on IA32_FEAT_CTL to ensure that VMX is fully enabled on
all CPUs.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20191221044513.21680-17-sean.j.christopherson@intel.com
arch/x86/kvm/vmx/vmx.c

index 06e0e526270421a89febee5343202556ed7318c6..cdb4bf50ee14e29d76f40cd9cfa528c664c8257e 100644 (file)
@@ -6838,6 +6838,12 @@ static int __init vmx_check_processor_compat(void)
        struct vmcs_config vmcs_conf;
        struct vmx_capability vmx_cap;
 
+       if (!this_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) ||
+           !this_cpu_has(X86_FEATURE_VMX)) {
+               pr_err("kvm: VMX is disabled on CPU %d\n", smp_processor_id());
+               return -EIO;
+       }
+
        if (setup_vmcs_config(&vmcs_conf, &vmx_cap) < 0)
                return -EIO;
        if (nested)