kvm: nVMX: Reorder error checks for emulated VMXON
authorJim Mattson <jmattson@google.com>
Thu, 22 Dec 2016 23:49:55 +0000 (15:49 -0800)
committerRadim Krčmář <rkrcmar@redhat.com>
Mon, 9 Jan 2017 13:48:04 +0000 (14:48 +0100)
Checks on the operand to VMXON are performed after the check for
legacy mode operation and the #GP checks, according to the pseudo-code
in Intel's SDM.

Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
arch/x86/kvm/vmx.c

index 94fda2010f5f29611b2cc39bfcbb4daa1b9f0bf0..4e691035a32d392bc050a98ff216e77d495469c3 100644 (file)
@@ -7180,9 +7180,6 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
                return 1;
        }
 
-       if (nested_vmx_check_vmptr(vcpu, EXIT_REASON_VMON, NULL))
-               return 1;
-
        if (vmx->nested.vmxon) {
                nested_vmx_failValid(vcpu, VMXERR_VMXON_IN_VMX_ROOT_OPERATION);
                return kvm_skip_emulated_instruction(vcpu);
@@ -7194,6 +7191,9 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
                return 1;
        }
 
+       if (nested_vmx_check_vmptr(vcpu, EXIT_REASON_VMON, NULL))
+               return 1;
+
        if (cpu_has_vmx_msr_bitmap()) {
                vmx->nested.msr_bitmap =
                                (unsigned long *)__get_free_page(GFP_KERNEL);