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

[Xen-changelog] [xen-unstable] [XEN] Add emulator tracing diagnostic on error path.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 7826e5482d421cf3bfd2a3e54800f7a21ca2a9f9
# Parent  1c51c580dc051f66f0bc145773b4e96583fca85e
[XEN] Add emulator tracing diagnostic on error path.
Simplify shadow-mode entry protocol to emulator.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/mm/shadow/multi.c |   29 +++++------------------------
 xen/arch/x86/x86_emulate.c     |   28 ++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 24 deletions(-)

diff -r 1c51c580dc05 -r 7826e5482d42 xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c    Tue Nov 28 14:24:20 2006 +0000
+++ b/xen/arch/x86/mm/shadow/multi.c    Tue Nov 28 14:27:13 2006 +0000
@@ -2582,7 +2582,6 @@ static int sh_page_fault(struct vcpu *v,
     mfn_t gmfn, sl1mfn=_mfn(0);
     shadow_l1e_t sl1e, *ptr_sl1e;
     paddr_t gpa;
-    struct cpu_user_regs emul_regs;
     struct x86_emulate_ctxt emul_ctxt;
     int r, mmio;
     fetch_type_t ft = 0;
@@ -2810,18 +2809,14 @@ static int sh_page_fault(struct vcpu *v,
 
  emulate:
     /* Take the register set we were called with */
-    emul_regs = *regs;
     if ( is_hvm_domain(d) )
-    {
-        /* Add the guest's segment selectors, rip, rsp. rflags */ 
-        hvm_store_cpu_guest_regs(v, &emul_regs, NULL);
-    }
-    emul_ctxt.regs = &emul_regs;
-    emul_ctxt.cr2 = va;
+        hvm_store_cpu_guest_regs(v, regs, NULL);
+    emul_ctxt.regs = regs;
+    emul_ctxt.cr2  = va;
     emul_ctxt.mode = (is_hvm_domain(d) ?
                       hvm_guest_x86_mode(v) : X86EMUL_MODE_HOST);
 
-    SHADOW_PRINTK("emulate: eip=%#lx\n", emul_regs.eip);
+    SHADOW_PRINTK("emulate: eip=%#lx\n", regs->eip);
 
     v->arch.shadow.propagate_fault = 0;
 
@@ -2852,21 +2847,7 @@ static int sh_page_fault(struct vcpu *v,
 
     /* Emulator has changed the user registers: write back */
     if ( is_hvm_domain(d) )
-    {
-        /* Write back the guest's segment selectors, rip, rsp. rflags */ 
-        hvm_load_cpu_guest_regs(v, &emul_regs);
-        /* And don't overwrite those in the caller's regs. */
-        emul_regs.eip = regs->eip;
-        emul_regs.cs = regs->cs;
-        emul_regs.eflags = regs->eflags;
-        emul_regs.esp = regs->esp;
-        emul_regs.ss = regs->ss;
-        emul_regs.es = regs->es;
-        emul_regs.ds = regs->ds;
-        emul_regs.fs = regs->fs;
-        emul_regs.gs = regs->gs;
-    }
-    *regs = emul_regs;
+        hvm_load_cpu_guest_regs(v, regs);
 
     goto done;
 
diff -r 1c51c580dc05 -r 7826e5482d42 xen/arch/x86/x86_emulate.c
--- a/xen/arch/x86/x86_emulate.c        Tue Nov 28 14:24:20 2006 +0000
+++ b/xen/arch/x86/x86_emulate.c        Tue Nov 28 14:27:13 2006 +0000
@@ -445,6 +445,31 @@ decode_register(
     return p;
 }
 
+static void
+dump_instr(
+    struct x86_emulate_ctxt *ctxt,
+    struct x86_emulate_ops  *ops)
+{
+#ifdef __XEN__
+    int i;
+    unsigned long x, pc;
+
+    pc = ctxt->regs->eip;
+    if ( ctxt->mode == X86EMUL_MODE_REAL )
+        pc += ctxt->regs->cs << 4;
+
+    dprintf("Instr:");
+    for ( i = 0; i < 16; i++, pc++ )
+    {
+        if ( ops->read_std(pc, &x, 1, ctxt) != 0 )
+            printk(" ??");
+        else
+            printk(" %02x", (uint8_t)x);
+    }
+    printk("\n");
+#endif
+}
+
 int
 x86_emulate_memop(
     struct x86_emulate_ctxt *ctxt,
@@ -1192,10 +1217,13 @@ x86_emulate_memop(
 
  cannot_emulate:
     dprintf("Cannot emulate %02x\n", b);
+    dump_instr(ctxt, ops);
     return -1;
 
  bad_ea:
     dprintf("Access faulted on page boundary (cr2=%lx,ea=%lx).\n", cr2, ea);
+    dump_instr(ctxt, ops);
+    show_execution_state(ctxt->regs);
     return -1;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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