@@ -3374,11 +3374,33 @@ static int sh_page_fault(struct vcpu *v,
r = x86_emulate(&emul_ctxt.ctxt, emul_ops);
/*
+ * TODO: Make this true:
+ *
+ ASSERT(emul_ctxt.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...
+ */
+ if ( emul_ctxt.ctxt.event_pending )
+ ASSERT(r == X86EMUL_EXCEPTION);
+
+ /*
* NB. We do not unshadow on X86EMUL_EXCEPTION. It's not clear that it
* would be a good unshadow hint. If we *do* decide to
unshadow-on-fault
* then it must be 'failable': we cannot require the unshadow to
succeed.
+ *
+ * Note: Despite the above comment, this path has actually been handing
+ * exception circumstances raised by the emulator itself (e.g.
singlestep)
+ * because of the lack of the inject_hw_exception() hook.
+ *
+ * With this change, exceptions raised behind the back of the emulator
+ * still return without setting event_pending, but exceptions raised by
+ * the emulator do. Force these exceptions back onto the UNHANDLEABLE
+ * path for now, so they are similarly ignored. A future change
will fix
+ * this properly.
*/