kvm: nVMX: Fix fault priority for VMX operations
authorJim Mattson <jmattson@google.com>
Fri, 27 Jul 2018 20:44:45 +0000 (13:44 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 6 Aug 2018 15:59:09 +0000 (17:59 +0200)
When checking emulated VMX instructions for faults, the #UD for "IF
(not in VMX operation)" should take precedence over the #GP for "ELSIF
CPL > 0."

Suggested-by: Eric Northup <digitaleric@google.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c

index d19bb60..ccc9d75 100644 (file)
@@ -8159,15 +8159,16 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
  */
 static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
 {
-       if (vmx_get_cpl(vcpu)) {
-               kvm_inject_gp(vcpu, 0);
+       if (!to_vmx(vcpu)->nested.vmxon) {
+               kvm_queue_exception(vcpu, UD_VECTOR);
                return 0;
        }
 
-       if (!to_vmx(vcpu)->nested.vmxon) {
-               kvm_queue_exception(vcpu, UD_VECTOR);
+       if (vmx_get_cpl(vcpu)) {
+               kvm_inject_gp(vcpu, 0);
                return 0;
        }
+
        return 1;
 }