Skip to content

Commit

Permalink
KVM: VMX: Drop guest CPUID check for VMXE in vmx_set_cr4()
Browse files Browse the repository at this point in the history
Drop vmx_set_cr4()'s somewhat hidden guest_cpuid_has() check on VMXE now
that common x86 handles the check by incorporating VMXE into the CR4
reserved bits, i.e. in cr4_guest_rsvd_bits.  This fixes a bug where KVM
incorrectly rejects KVM_SET_SREGS with CR4.VMXE=1 if it's executed
before KVM_SET_CPUID{,2}.

Fixes: 5e1746d ("KVM: nVMX: Allow setting the VMXE bit in CR4")
Reported-by: Stas Sergeev <[email protected]>
Signed-off-by: Sean Christopherson <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Sean Christopherson authored and bonzini committed Nov 15, 2020
1 parent c887c9b commit d3a9e41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/kvm/vmx/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3129,9 +3129,10 @@ int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
* must first be able to turn on cr4.VMXE (see handle_vmon()).
* So basically the check on whether to allow nested VMX
* is here. We operate under the default treatment of SMM,
* so VMX cannot be enabled under SMM.
* so VMX cannot be enabled under SMM. Note, guest CPUID is
* intentionally ignored, it's handled by cr4_guest_rsvd_bits.
*/
if (!nested_vmx_allowed(vcpu) || is_smm(vcpu))
if (!nested || is_smm(vcpu))
return 1;
}

Expand Down

0 comments on commit d3a9e41

Please sign in to comment.