aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-28 14:27:13 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-11-28 14:27:13 +0000
commit1c804664cf63f0c2e80d0420e52d5f82c3956685 (patch)
tree2fd3200d196a0ac56cfc104848bf47752a665e06
parent44755869f74b3d2e92962eedaaf568fb630f4eb2 (diff)
downloadxen-1c804664cf63f0c2e80d0420e52d5f82c3956685.tar.gz
xen-1c804664cf63f0c2e80d0420e52d5f82c3956685.tar.bz2
xen-1c804664cf63f0c2e80d0420e52d5f82c3956685.zip
[XEN] Add emulator tracing diagnostic on error path.
Simplify shadow-mode entry protocol to emulator. Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r--xen/arch/x86/mm/shadow/multi.c29
-rw-r--r--xen/arch/x86/x86_emulate.c28
2 files changed, 33 insertions, 24 deletions
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 27323f856e..c582b82b51 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -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 --git a/xen/arch/x86/x86_emulate.c b/xen/arch/x86/x86_emulate.c
index 41ac06528c..2ce2dfb440 100644
--- a/xen/arch/x86/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate.c
@@ -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;
}