Skip to content

Commit a4d0b2f

Browse files
Sean Christophersonsuryasaimadhu
authored andcommitted
KVM: VMX: Use VMX feature flag to query BIOS enabling
Replace KVM's manual checks on IA32_FEAT_CTL with a query on the boot CPU's MSR_IA32_FEAT_CTL and VMX feature flags. The MSR_IA32_FEAT_CTL indicates that IA32_FEAT_CTL has been configured and that dependent features are accurately reflected in cpufeatures, e.g. the VMX flag is now cleared during boot if VMX isn't fully enabled via IA32_FEAT_CTL, including the case where the MSR isn't supported. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 21bd346 commit a4d0b2f

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,31 +2204,8 @@ static __init int cpu_has_kvm_support(void)
22042204

22052205
static __init int vmx_disabled_by_bios(void)
22062206
{
2207-
u64 msr;
2208-
2209-
rdmsrl(MSR_IA32_FEAT_CTL, msr);
2210-
2211-
if (unlikely(!(msr & FEAT_CTL_LOCKED)))
2212-
return 1;
2213-
2214-
/* launched w/ TXT and VMX disabled */
2215-
if (!(msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX) &&
2216-
tboot_enabled())
2217-
return 1;
2218-
/* launched w/o TXT and VMX only enabled w/ TXT */
2219-
if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX) &&
2220-
(msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX) &&
2221-
!tboot_enabled()) {
2222-
pr_warn("kvm: disable TXT in the BIOS or "
2223-
"activate TXT before enabling KVM\n");
2224-
return 1;
2225-
}
2226-
/* launched w/o TXT and VMX disabled */
2227-
if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX) &&
2228-
!tboot_enabled())
2229-
return 1;
2230-
2231-
return 0;
2207+
return !boot_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) ||
2208+
!boot_cpu_has(X86_FEATURE_VMX);
22322209
}
22332210

22342211
static void kvm_cpu_vmxon(u64 addr)

0 commit comments

Comments
 (0)