Skip to content

Commit 51844b0

Browse files
committed
Merge git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fix from Marcelo Tosatti: "A correction for oops on module init with older Intel hosts." * git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: Fix invalid secondary exec controls in vmx_cpuid_update()
2 parents 0cad3ff + 29282fd commit 51844b0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

arch/x86/kvm/vmx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6549,19 +6549,22 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
65496549
}
65506550
}
65516551

6552-
exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
65536552
/* Exposing INVPCID only when PCID is exposed */
65546553
best = kvm_find_cpuid_entry(vcpu, 0x7, 0);
65556554
if (vmx_invpcid_supported() &&
65566555
best && (best->ebx & bit(X86_FEATURE_INVPCID)) &&
65576556
guest_cpuid_has_pcid(vcpu)) {
6557+
exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
65586558
exec_control |= SECONDARY_EXEC_ENABLE_INVPCID;
65596559
vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
65606560
exec_control);
65616561
} else {
6562-
exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
6563-
vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6564-
exec_control);
6562+
if (cpu_has_secondary_exec_ctrls()) {
6563+
exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6564+
exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
6565+
vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6566+
exec_control);
6567+
}
65656568
if (best)
65666569
best->ebx &= ~bit(X86_FEATURE_INVPCID);
65676570
}

0 commit comments

Comments
 (0)