]> xenbits.xensource.com Git - xen.git/commitdiff
x86/emul: Hold x86_emulate() to strict X86EMUL_EXCEPTION requirements
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 2 Mar 2017 11:41:17 +0000 (11:41 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Mar 2017 11:46:37 +0000 (11:46 +0000)
All known paths raising faults behind the back of the emulator have been
fixed.  Reinstate the original intended assertion concerning the behaviour of
X86EMUL_EXCEPTION and ctxt->event_pending.

As x86_emulate_wrapper() now covers both PV and HVM guests properly, there is
no need for the PV assertions following calls to x86_emulate().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm.c
xen/arch/x86/traps.c
xen/arch/x86/x86_emulate/x86_emulate.c

index 1661e663d036c75529546e3405c19721f8f85245..7bc951dc1bf2026e761dfd1e6f421be72a9bdee1 100644 (file)
@@ -5420,9 +5420,6 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long addr,
     page_unlock(page);
     put_page(page);
 
-    /* More strict than x86_emulate_wrapper(), as this is now true for PV. */
-    ASSERT(ptwr_ctxt.ctxt.event_pending == (rc == X86EMUL_EXCEPTION));
-
     switch ( rc )
     {
     case X86EMUL_EXCEPTION:
@@ -5574,9 +5571,6 @@ int mmio_ro_do_page_fault(struct vcpu *v, unsigned long addr,
     else
         rc = x86_emulate(&ctxt, &mmio_ro_emulate_ops);
 
-    /* More strict than x86_emulate_wrapper(), as this is now true for PV. */
-    ASSERT(ctxt.event_pending == (rc == X86EMUL_EXCEPTION));
-
     switch ( rc )
     {
     case X86EMUL_EXCEPTION:
index 13a609b3b4de282761518386ed5c88a1a018e432..08b00708be23ccd06825f6074d570c977f0f5dea 100644 (file)
@@ -3004,9 +3004,6 @@ static int emulate_privileged_op(struct cpu_user_regs *regs)
     regs->eflags |= X86_EFLAGS_IF;
     regs->eflags &= ~X86_EFLAGS_IOPL;
 
-    /* More strict than x86_emulate_wrapper(). */
-    ASSERT(ctxt.ctxt.event_pending == (rc == X86EMUL_EXCEPTION));
-
     switch ( rc )
     {
     case X86EMUL_OKAY:
index 667049df2f36fe4df4e33b4a734ff7230d97d994..ad624205795ab271596dff2d7dc2080c1c8b21d8 100644 (file)
@@ -6307,17 +6307,12 @@ int x86_emulate_wrapper(
         ASSERT(ctxt->regs->r(ip) == orig_ip);
 
     /*
-     * TODO: Make this true:
-     *
-    ASSERT(ctxt->event_pending == (rc == X86EMUL_EXCEPTION));
-     *
-     * Some codepaths still raise exceptions behind the back of the
-     * emulator. (i.e. return X86EMUL_EXCEPTION but without
-     * event_pending being set).  In the meantime, use a slightly
-     * relaxed check...
+     * An event being pending should exactly match returning
+     * X86EMUL_EXCEPTION.  (If this trips, the chances are a codepath has
+     * called hvm_inject_hw_exception() rather than using
+     * x86_emul_hw_exception().)
      */
-    if ( ctxt->event_pending )
-        ASSERT(rc == X86EMUL_EXCEPTION);
+    ASSERT(ctxt->event_pending == (rc == X86EMUL_EXCEPTION));
 
     return rc;
 }