ia64/xen-unstable

changeset 12622:7826e5482d42

[XEN] Add emulator tracing diagnostic on error path.
Simplify shadow-mode entry protocol to emulator.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Nov 28 14:27:13 2006 +0000 (2006-11-28)
parents 1c51c580dc05
children 4f4d358aa5e4 6c2c7ff6265a 223470316756
files xen/arch/x86/mm/shadow/multi.c xen/arch/x86/x86_emulate.c
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/multi.c	Tue Nov 28 14:24:20 2006 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Tue Nov 28 14:27:13 2006 +0000
     1.3 @@ -2582,7 +2582,6 @@ static int sh_page_fault(struct vcpu *v,
     1.4      mfn_t gmfn, sl1mfn=_mfn(0);
     1.5      shadow_l1e_t sl1e, *ptr_sl1e;
     1.6      paddr_t gpa;
     1.7 -    struct cpu_user_regs emul_regs;
     1.8      struct x86_emulate_ctxt emul_ctxt;
     1.9      int r, mmio;
    1.10      fetch_type_t ft = 0;
    1.11 @@ -2810,18 +2809,14 @@ static int sh_page_fault(struct vcpu *v,
    1.12  
    1.13   emulate:
    1.14      /* Take the register set we were called with */
    1.15 -    emul_regs = *regs;
    1.16      if ( is_hvm_domain(d) )
    1.17 -    {
    1.18 -        /* Add the guest's segment selectors, rip, rsp. rflags */ 
    1.19 -        hvm_store_cpu_guest_regs(v, &emul_regs, NULL);
    1.20 -    }
    1.21 -    emul_ctxt.regs = &emul_regs;
    1.22 -    emul_ctxt.cr2 = va;
    1.23 +        hvm_store_cpu_guest_regs(v, regs, NULL);
    1.24 +    emul_ctxt.regs = regs;
    1.25 +    emul_ctxt.cr2  = va;
    1.26      emul_ctxt.mode = (is_hvm_domain(d) ?
    1.27                        hvm_guest_x86_mode(v) : X86EMUL_MODE_HOST);
    1.28  
    1.29 -    SHADOW_PRINTK("emulate: eip=%#lx\n", emul_regs.eip);
    1.30 +    SHADOW_PRINTK("emulate: eip=%#lx\n", regs->eip);
    1.31  
    1.32      v->arch.shadow.propagate_fault = 0;
    1.33  
    1.34 @@ -2852,21 +2847,7 @@ static int sh_page_fault(struct vcpu *v,
    1.35  
    1.36      /* Emulator has changed the user registers: write back */
    1.37      if ( is_hvm_domain(d) )
    1.38 -    {
    1.39 -        /* Write back the guest's segment selectors, rip, rsp. rflags */ 
    1.40 -        hvm_load_cpu_guest_regs(v, &emul_regs);
    1.41 -        /* And don't overwrite those in the caller's regs. */
    1.42 -        emul_regs.eip = regs->eip;
    1.43 -        emul_regs.cs = regs->cs;
    1.44 -        emul_regs.eflags = regs->eflags;
    1.45 -        emul_regs.esp = regs->esp;
    1.46 -        emul_regs.ss = regs->ss;
    1.47 -        emul_regs.es = regs->es;
    1.48 -        emul_regs.ds = regs->ds;
    1.49 -        emul_regs.fs = regs->fs;
    1.50 -        emul_regs.gs = regs->gs;
    1.51 -    }
    1.52 -    *regs = emul_regs;
    1.53 +        hvm_load_cpu_guest_regs(v, regs);
    1.54  
    1.55      goto done;
    1.56  
     2.1 --- a/xen/arch/x86/x86_emulate.c	Tue Nov 28 14:24:20 2006 +0000
     2.2 +++ b/xen/arch/x86/x86_emulate.c	Tue Nov 28 14:27:13 2006 +0000
     2.3 @@ -445,6 +445,31 @@ decode_register(
     2.4      return p;
     2.5  }
     2.6  
     2.7 +static void
     2.8 +dump_instr(
     2.9 +    struct x86_emulate_ctxt *ctxt,
    2.10 +    struct x86_emulate_ops  *ops)
    2.11 +{
    2.12 +#ifdef __XEN__
    2.13 +    int i;
    2.14 +    unsigned long x, pc;
    2.15 +
    2.16 +    pc = ctxt->regs->eip;
    2.17 +    if ( ctxt->mode == X86EMUL_MODE_REAL )
    2.18 +        pc += ctxt->regs->cs << 4;
    2.19 +
    2.20 +    dprintf("Instr:");
    2.21 +    for ( i = 0; i < 16; i++, pc++ )
    2.22 +    {
    2.23 +        if ( ops->read_std(pc, &x, 1, ctxt) != 0 )
    2.24 +            printk(" ??");
    2.25 +        else
    2.26 +            printk(" %02x", (uint8_t)x);
    2.27 +    }
    2.28 +    printk("\n");
    2.29 +#endif
    2.30 +}
    2.31 +
    2.32  int
    2.33  x86_emulate_memop(
    2.34      struct x86_emulate_ctxt *ctxt,
    2.35 @@ -1192,10 +1217,13 @@ x86_emulate_memop(
    2.36  
    2.37   cannot_emulate:
    2.38      dprintf("Cannot emulate %02x\n", b);
    2.39 +    dump_instr(ctxt, ops);
    2.40      return -1;
    2.41  
    2.42   bad_ea:
    2.43      dprintf("Access faulted on page boundary (cr2=%lx,ea=%lx).\n", cr2, ea);
    2.44 +    dump_instr(ctxt, ops);
    2.45 +    show_execution_state(ctxt->regs);
    2.46      return -1;
    2.47  }
    2.48