KVM: VMX: Drop explicit 'nested' check from vmx_set_cr4()
authorSean Christopherson <sean.j.christopherson@intel.com>
Wed, 7 Oct 2020 01:44:13 +0000 (18:44 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 15 Nov 2020 14:49:06 +0000 (09:49 -0500)
Drop vmx_set_cr4()'s explicit check on the 'nested' module param now
that common x86 handles the check by incorporating VMXE into the CR4
reserved bits, via kvm_cpu_caps.  X86_FEATURE_VMX is set in kvm_cpu_caps
(by vmx_set_cpu_caps()), if and only if 'nested' is true.

No functional change intended.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20201007014417.29276-3-sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/vmx.c

index 7ebf08d..d9a4526 100644 (file)
@@ -3123,18 +3123,13 @@ int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
                }
        }
 
-       if (cr4 & X86_CR4_VMXE) {
-               /*
-                * To use VMXON (and later other VMX instructions), a guest
-                * 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.  Note, guest CPUID is
-                * intentionally ignored, it's handled by cr4_guest_rsvd_bits.
-                */
-               if (!nested || is_smm(vcpu))
-                       return 1;
-       }
+       /*
+        * We operate under the default treatment of SMM, so VMX cannot be
+        * enabled under SMM.  Note, whether or not VMXE is allowed at all is
+        * handled by kvm_valid_cr4().
+        */
+       if ((cr4 & X86_CR4_VMXE) && is_smm(vcpu))
+               return 1;
 
        if (vmx->nested.vmxon && !nested_cr4_valid(vcpu, cr4))
                return 1;