xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
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 1/2] x86/hvm: Don't emulate all instructions hitting the #UD intercept
Date: Mon, 19 Dec 2016 16:37:54 +0000	[thread overview]
Message-ID: <1482165475-26302-1-git-send-email-andrew.cooper3@citrix.com> (raw)

Having the instruction emulator fill in all #UDs when using FEP is unhelpful
when trying to test emulation behaviour against hardware.

Restrict emulation from the #UD intercept to the cross-vendor case, and when a
postive Forced Emulation Prefix has been identified.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 73d24df..12a6f46 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4002,13 +4002,15 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,
 
 void hvm_ud_intercept(struct cpu_user_regs *regs)
 {
+    struct vcpu *cur = current;
+    bool should_emulate =
+        cur->domain->arch.x86_vendor != boot_cpu_data.x86_vendor;
     struct hvm_emulate_ctxt ctxt;
 
     hvm_emulate_init_once(&ctxt, regs);
 
     if ( opt_hvm_fep )
     {
-        struct vcpu *cur = current;
         const struct segment_register *cs = &ctxt.seg_reg[x86_seg_cs];
         uint32_t walk = (ctxt.seg_reg[x86_seg_ss].attr.fields.dpl == 3)
             ? PFEC_user_mode : 0;
@@ -4032,9 +4034,17 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
                 regs->eip = regs->_eip;
 
             add_taint(TAINT_HVM_FEP);
+
+            should_emulate = true;
         }
     }
 
+    if ( !should_emulate )
+    {
+        hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
+        return;
+    }
+
     switch ( hvm_emulate_one(&ctxt) )
     {
     case X86EMUL_UNHANDLEABLE:
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2016-12-19 16:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 16:37 Andrew Cooper [this message]
2016-12-19 16:37 ` [PATCH 2/2] x86/emul: Bugfixes to SYSCALL emulation Andrew Cooper
2016-12-20  8:22   ` Jan Beulich
2016-12-20 12:14     ` Andrew Cooper
2016-12-20 13:00       ` Jan Beulich
2016-12-20  8:09 ` [PATCH 1/2] x86/hvm: Don't emulate all instructions hitting the #UD intercept 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=1482165475-26302-1-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).