[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/hvm: Don't emulate all instructions hitting the #UD intercept



commit 8867a48e058ab04bd269cab12ef4de5ee8ad5b7b
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Dec 19 12:05:20 2016 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Dec 20 11:38:41 2016 +0000

    x86/hvm: Don't emulate all instructions hitting the #UD intercept
    
    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@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 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 @@ gp_fault:
 
 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:
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.