From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 2/2] x86/emul: Hold x86_emulate() to strict X86EMUL_EXCEPTION requirements
Date: Thu, 2 Mar 2017 14:59:38 +0000 [thread overview]
Message-ID: <1488466778-10163-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1488466778-10163-1-git-send-email-andrew.cooper3@citrix.com>
All known paths raising faults behind the back of the emulator have 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>
---
CC: Jan Beulich <JBeulich@suse.com>
---
xen/arch/x86/mm.c | 6 ------
xen/arch/x86/traps.c | 3 ---
xen/arch/x86/x86_emulate/x86_emulate.c | 15 +++++----------
3 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 1661e66..7bc951d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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:
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 8ba7ed0..cffbf0e 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -3003,9 +3003,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:
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index a65026a..b4889b7 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6298,17 +6298,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;
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-02 14:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 14:59 [PATCH 1/2] x86/hvm: Don't raise #GP behind the emulators back for CR accesses Andrew Cooper
2017-03-02 14:59 ` Andrew Cooper [this message]
2017-03-03 10:18 ` [PATCH 2/2] x86/emul: Hold x86_emulate() to strict X86EMUL_EXCEPTION requirements Jan Beulich
2017-03-02 15:58 ` [PATCH 1/2] x86/hvm: Don't raise #GP behind the emulators back for CR accesses Paul Durrant
2017-03-02 16:06 ` Boris Ostrovsky
2017-03-03 8:02 ` Tian, Kevin
2017-03-03 10:16 ` Jan Beulich
2017-03-03 10:30 ` Andrew Cooper
2017-03-03 10:36 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488466778-10163-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).