direct-io.hg

changeset 11405:37a42856e8d9

[XEN] Include CR2 and CR4 in register dumps.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 01 01:07:45 2006 +0100 (2006-09-01)
parents 90d3ca978b40
children 765b7e23d979
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/processor.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Sep 01 00:42:14 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Sep 01 01:07:45 2006 +0100
     1.3 @@ -243,6 +243,7 @@ static void svm_store_cpu_guest_regs(
     1.4      {
     1.5          /* Returning the guest's regs */
     1.6          crs[0] = v->arch.hvm_svm.cpu_shadow_cr0;
     1.7 +        crs[2] = v->arch.hvm_svm.cpu_cr2;
     1.8          crs[3] = v->arch.hvm_svm.cpu_cr3;
     1.9          crs[4] = v->arch.hvm_svm.cpu_shadow_cr4;
    1.10      }
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 01 00:42:14 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 01 01:07:45 2006 +0100
     2.3 @@ -520,6 +520,7 @@ static void vmx_store_cpu_guest_regs(
     2.4      if ( crs != NULL )
     2.5      {
     2.6          __vmread(CR0_READ_SHADOW, &crs[0]);
     2.7 +        crs[2] = v->arch.hvm_vmx.cpu_cr2;
     2.8          __vmread(GUEST_CR3, &crs[3]);
     2.9          __vmread(CR4_READ_SHADOW, &crs[4]);
    2.10      }
     3.1 --- a/xen/arch/x86/traps.c	Fri Sep 01 00:42:14 2006 +0100
     3.2 +++ b/xen/arch/x86/traps.c	Fri Sep 01 01:07:45 2006 +0100
     3.3 @@ -339,7 +339,6 @@ void show_execution_state(struct cpu_use
     3.4  asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs)
     3.5  {
     3.6      int cpu = smp_processor_id();
     3.7 -    unsigned long cr2;
     3.8      static char *trapstr[] = { 
     3.9          "divide error", "debug", "nmi", "bkpt", "overflow", "bounds", 
    3.10          "invalid opcode", "device not available", "double fault", 
    3.11 @@ -356,7 +355,7 @@ asmlinkage void fatal_trap(int trapnr, s
    3.12  
    3.13      if ( trapnr == TRAP_page_fault )
    3.14      {
    3.15 -        __asm__ __volatile__ ("mov %%cr2,%0" : "=r" (cr2) : );
    3.16 +        unsigned long cr2 = read_cr2();
    3.17          printk("Faulting linear address: %p\n", _p(cr2));
    3.18          show_page_walk(cr2);
    3.19      }
    3.20 @@ -911,7 +910,7 @@ asmlinkage int do_page_fault(struct cpu_
    3.21  
    3.22      ASSERT(!in_irq());
    3.23  
    3.24 -    __asm__ __volatile__ ("mov %%cr2,%0" : "=r" (addr) : );
    3.25 +    addr = read_cr2();
    3.26  
    3.27      DEBUGGER_trap_entry(TRAP_page_fault, regs);
    3.28  
     4.1 --- a/xen/arch/x86/x86_32/traps.c	Fri Sep 01 00:42:14 2006 +0100
     4.2 +++ b/xen/arch/x86/x86_32/traps.c	Fri Sep 01 01:07:45 2006 +0100
     4.3 @@ -35,20 +35,26 @@ void show_registers(struct cpu_user_regs
     4.4      }
     4.5      else
     4.6      {
     4.7 -        context = guest_mode(regs) ? "guest" : "hypervisor";
     4.8 -
     4.9          if ( !guest_mode(regs) )
    4.10          {
    4.11 +            context = "hypervisor";
    4.12              fault_regs.esp = (unsigned long)&regs->esp;
    4.13              fault_regs.ss = read_segment_register(ss);
    4.14              fault_regs.ds = read_segment_register(ds);
    4.15              fault_regs.es = read_segment_register(es);
    4.16              fault_regs.fs = read_segment_register(fs);
    4.17              fault_regs.gs = read_segment_register(gs);
    4.18 +            fault_crs[2] = read_cr2();
    4.19 +        }
    4.20 +        else
    4.21 +        {
    4.22 +            context = "guest";
    4.23 +            fault_crs[2] = current->vcpu_info->arch.cr2;
    4.24          }
    4.25  
    4.26          fault_crs[0] = read_cr0();
    4.27          fault_crs[3] = read_cr3();
    4.28 +        fault_crs[4] = read_cr4();
    4.29      }
    4.30  
    4.31      printk("----[ Xen-%d.%d%s    %s ]----\n",
    4.32 @@ -63,7 +69,8 @@ void show_registers(struct cpu_user_regs
    4.33             fault_regs.eax, fault_regs.ebx, fault_regs.ecx, fault_regs.edx);
    4.34      printk("esi: %08x   edi: %08x   ebp: %08x   esp: %08x\n",
    4.35             fault_regs.esi, fault_regs.edi, fault_regs.ebp, fault_regs.esp);
    4.36 -    printk("cr0: %08lx   cr3: %08lx\n", fault_crs[0], fault_crs[3]);
    4.37 +    printk("cr0: %08lx   cr4: %08lx   cr3: %08lx   cr2: %08lx\n",
    4.38 +           fault_crs[0], fault_crs[4], fault_crs[3], fault_crs[2]);
    4.39      printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   "
    4.40             "ss: %04x   cs: %04x\n",
    4.41             fault_regs.ds, fault_regs.es, fault_regs.fs,
     5.1 --- a/xen/arch/x86/x86_64/traps.c	Fri Sep 01 00:42:14 2006 +0100
     5.2 +++ b/xen/arch/x86/x86_64/traps.c	Fri Sep 01 01:07:45 2006 +0100
     5.3 @@ -35,9 +35,20 @@ void show_registers(struct cpu_user_regs
     5.4      }
     5.5      else
     5.6      {
     5.7 -        context = guest_mode(regs) ? "guest" : "hypervisor";
     5.8 +        if ( guest_mode(regs) )
     5.9 +        {
    5.10 +            context = "guest";
    5.11 +            fault_crs[2] = current->vcpu_info->arch.cr2;
    5.12 +        }
    5.13 +        else
    5.14 +        {
    5.15 +            context = "hypervisor";
    5.16 +            fault_crs[2] = read_cr2();
    5.17 +        }
    5.18 +
    5.19          fault_crs[0] = read_cr0();
    5.20          fault_crs[3] = read_cr3();
    5.21 +        fault_crs[4] = read_cr4();
    5.22          fault_regs.ds = read_segment_register(ds);
    5.23          fault_regs.es = read_segment_register(es);
    5.24          fault_regs.fs = read_segment_register(fs);
    5.25 @@ -62,8 +73,9 @@ void show_registers(struct cpu_user_regs
    5.26             fault_regs.r9,  fault_regs.r10, fault_regs.r11);
    5.27      printk("r12: %016lx   r13: %016lx   r14: %016lx\n",
    5.28             fault_regs.r12, fault_regs.r13, fault_regs.r14);
    5.29 -    printk("r15: %016lx   cr0: %016lx   cr3: %016lx\n",
    5.30 -           fault_regs.r15, fault_crs[0], fault_crs[3]);
    5.31 +    printk("r15: %016lx   cr0: %016lx   cr4: %016lx\n",
    5.32 +           fault_regs.r15, fault_crs[0], fault_crs[4]);
    5.33 +    printk("cr3: %016lx   cr2: %016lx\n", fault_crs[3], fault_crs[2]);
    5.34      printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   "
    5.35             "ss: %04x   cs: %04x\n",
    5.36             fault_regs.ds, fault_regs.es, fault_regs.fs,
     6.1 --- a/xen/include/asm-x86/processor.h	Fri Sep 01 00:42:14 2006 +0100
     6.2 +++ b/xen/include/asm-x86/processor.h	Fri Sep 01 01:07:45 2006 +0100
     6.3 @@ -290,6 +290,13 @@ static inline void write_cr0(unsigned lo
     6.4  	__asm__("mov %0,%%cr0": :"r" ((unsigned long)val));
     6.5  }
     6.6  
     6.7 +static inline unsigned long read_cr2(void)
     6.8 +{
     6.9 +    unsigned long __cr2;
    6.10 +    __asm__("mov %%cr2,%0\n\t" :"=r" (__cr2));
    6.11 +    return __cr2;
    6.12 +}
    6.13 +
    6.14  static inline unsigned long read_cr4(void)
    6.15  {
    6.16      unsigned long __cr4;