]> xenbits.xensource.com Git - xen.git/commitdiff
x86/hvm: Don't let hvm_set_efer() raise #GP itself
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 24 Feb 2017 09:22:09 +0000 (09:22 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 24 Feb 2017 14:34:41 +0000 (14:34 +0000)
c/s 49de10f3c "x86/hvm: Don't raise #GP behind the emulators back for MSR
accesses" missed an edge case.

hvm_set_efer() raises #GP itself, so deliberately avoided the goto gp_fault
path in hvm_msr_write_intercept().

With the above change, guest updates to MSR_EFER which end up faulting raises
hvm_msr_write_intercept() returning X86EMUL_EXCEPTION.  The second #GP gets
combined to #DF and handed back to the guest.

Update hvm_set_efer() to avoid raising #GP, requiring its callers to do so.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/svm/nestedsvm.c

index 5372a9af398db2477dc2b1412eecbba8228e9933..9eeb0a2ff2e82f57025482e57d7549c4762c6b8c 100644 (file)
@@ -1989,7 +1989,6 @@ int hvm_set_efer(uint64_t value)
         printk(XENLOG_G_WARNING
                "%pv: Invalid EFER update: %#"PRIx64" -> %#"PRIx64" - %s\n",
                v, v->arch.hvm_vcpu.guest_efer, value, errstr);
-        hvm_inject_hw_exception(TRAP_gp_fault, 0);
         return X86EMUL_EXCEPTION;
     }
 
@@ -1998,7 +1997,6 @@ int hvm_set_efer(uint64_t value)
     {
         gdprintk(XENLOG_WARNING,
                  "Trying to change EFER.LME with paging enabled\n");
-        hvm_inject_hw_exception(TRAP_gp_fault, 0);
         return X86EMUL_EXCEPTION;
     }
 
index ca11b967b3bb53ddb98a495d91a94f7aa3620807..5979b56b5764f1b469b08298b7f5ecca59d04621 100644 (file)
@@ -278,6 +278,8 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
     /* EFER */
     v->arch.hvm_vcpu.guest_efer = n1vmcb->_efer;
     rc = hvm_set_efer(n1vmcb->_efer);
+    if ( rc == X86EMUL_EXCEPTION )
+        hvm_inject_hw_exception(TRAP_gp_fault, 0);
     if (rc != X86EMUL_OKAY)
         gdprintk(XENLOG_ERR, "hvm_set_efer failed, rc: %u\n", rc);
 
@@ -538,6 +540,8 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
     /* EFER */
     v->arch.hvm_vcpu.guest_efer = ns_vmcb->_efer;
     rc = hvm_set_efer(ns_vmcb->_efer);
+    if ( rc == X86EMUL_EXCEPTION )
+        hvm_inject_hw_exception(TRAP_gp_fault, 0);
     if (rc != X86EMUL_OKAY)
         gdprintk(XENLOG_ERR, "hvm_set_efer failed, rc: %u\n", rc);