@@ -2207,24 +2207,26 @@ static __init int vmx_disabled_by_bios(void)
u64 msr;
rdmsrl(MSR_IA32_FEAT_CTL, msr);
- if (msr & FEAT_CTL_LOCKED) {
- /* launched w/ TXT and VMX disabled */
- if (!(msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX)
- && tboot_enabled())
- return 1;
- /* launched w/o TXT and VMX only enabled w/ TXT */
- if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX)
- && (msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX)
- && !tboot_enabled()) {
- printk(KERN_WARNING "kvm: disable TXT in the BIOS or "
- "activate TXT before enabling KVM\n");
- return 1;
- }
- /* launched w/o TXT and VMX disabled */
- if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX)
- && !tboot_enabled())
- return 1;
+
+ if (unlikely(!(msr & FEAT_CTL_LOCKED)))
+ return 1;
+
+ /* launched w/ TXT and VMX disabled */
+ if (!(msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX) &&
+ tboot_enabled())
+ return 1;
+ /* launched w/o TXT and VMX only enabled w/ TXT */
+ if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX) &&
+ (msr & FEAT_CTL_VMX_ENABLED_INSIDE_SMX) &&
+ !tboot_enabled()) {
+ pr_warn("kvm: disable TXT in the BIOS or "
+ "activate TXT before enabling KVM\n");
+ return 1;
}
+ /* launched w/o TXT and VMX disabled */
+ if (!(msr & FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX) &&
+ !tboot_enabled())
+ return 1;
return 0;
}
@@ -2241,7 +2243,6 @@ static int hardware_enable(void)
{
int cpu = raw_smp_processor_id();
u64 phys_addr = __pa(per_cpu(vmxarea, cpu));
- u64 old, test_bits;
if (cr4_read_shadow() & X86_CR4_VMXE)
return -EBUSY;
@@ -2269,17 +2270,6 @@ static int hardware_enable(void)
*/
crash_enable_local_vmclear(cpu);
- rdmsrl(MSR_IA32_FEAT_CTL, old);
-
- test_bits = FEAT_CTL_LOCKED;
- test_bits |= FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX;
- if (tboot_enabled())
- test_bits |= FEAT_CTL_VMX_ENABLED_INSIDE_SMX;
-
- if ((old & test_bits) != test_bits) {
- /* enable and lock */
- wrmsrl(MSR_IA32_FEAT_CTL, old | test_bits);
- }
kvm_cpu_vmxon(phys_addr);
if (enable_ept)
ept_sync_global();