Index: 2006-08-16/xen/arch/x86/hvm/svm/svm.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/hvm/svm/svm.c 2006-08-23 11:39:37.000000000 +0200 +++ 2006-08-16/xen/arch/x86/hvm/svm/svm.c 2006-08-23 11:39:59.000000000 +0200 @@ -246,6 +246,7 @@ static void svm_store_cpu_guest_regs( { /* Returning the guest's regs */ crs[0] = v->arch.hvm_svm.cpu_shadow_cr0; + crs[2] = v->arch.hvm_svm.cpu_cr2; crs[3] = v->arch.hvm_svm.cpu_cr3; crs[4] = v->arch.hvm_svm.cpu_shadow_cr4; } Index: 2006-08-16/xen/arch/x86/hvm/vmx/vmx.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/hvm/vmx/vmx.c 2006-08-23 11:39:37.000000000 +0200 +++ 2006-08-16/xen/arch/x86/hvm/vmx/vmx.c 2006-08-23 11:39:59.000000000 +0200 @@ -523,6 +523,7 @@ static void vmx_store_cpu_guest_regs( if ( crs != NULL ) { __vmread(CR0_READ_SHADOW, &crs[0]); + crs[2] = v->arch.hvm_vmx.cpu_cr2; __vmread(GUEST_CR3, &crs[3]); __vmread(CR4_READ_SHADOW, &crs[4]); } Index: 2006-08-16/xen/arch/x86/traps.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/traps.c 2006-08-23 11:52:26.000000000 +0200 +++ 2006-08-16/xen/arch/x86/traps.c 2006-08-23 12:02:40.000000000 +0200 @@ -324,7 +324,6 @@ void show_execution_state(struct cpu_use asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs) { int cpu = smp_processor_id(); - unsigned long cr2; static char *trapstr[] = { "divide error", "debug", "nmi", "bkpt", "overflow", "bounds", "invalid opcode", "device not available", "double fault", @@ -341,7 +340,7 @@ asmlinkage void fatal_trap(int trapnr, s if ( trapnr == TRAP_page_fault ) { - __asm__ __volatile__ ("mov %%cr2,%0" : "=r" (cr2) : ); + unsigned long cr2 = read_cr2(); printk("Faulting linear address: %p\n", _p(cr2)); show_page_walk(cr2); } Index: 2006-08-16/xen/arch/x86/x86_32/traps.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/x86_32/traps.c 2006-08-23 11:37:24.000000000 +0200 +++ 2006-08-16/xen/arch/x86/x86_32/traps.c 2006-08-23 12:03:40.000000000 +0200 @@ -35,20 +35,27 @@ void show_registers(struct cpu_user_regs } else { - context = guest_mode(regs) ? "guest" : "hypervisor"; - if ( !guest_mode(regs) ) { + context = "hypervisor"; fault_regs.esp = (unsigned long)®s->esp; fault_regs.ss = read_segment_register(ss); fault_regs.ds = read_segment_register(ds); fault_regs.es = read_segment_register(es); fault_regs.fs = read_segment_register(fs); fault_regs.gs = read_segment_register(gs); + fault_crs[2] = read_cr2(); + } + else + { + context = "guest"; + fault_crs[2] = container_of(regs, struct cpu_info, guest_cpu_user_regs) + ->current_vcpu->vcpu_info->arch.cr2; } fault_crs[0] = read_cr0(); fault_crs[3] = read_cr3(); + fault_crs[4] = read_cr4(); } printk("----[ Xen-%d.%d%s %s ]----\n", @@ -63,7 +70,8 @@ void show_registers(struct cpu_user_regs fault_regs.eax, fault_regs.ebx, fault_regs.ecx, fault_regs.edx); printk("esi: %08x edi: %08x ebp: %08x esp: %08x\n", fault_regs.esi, fault_regs.edi, fault_regs.ebp, fault_regs.esp); - printk("cr0: %08lx cr3: %08lx\n", fault_crs[0], fault_crs[3]); + printk("cr0: %08lx cr4: %08lx cr3: %08lx cr2: %08lx\n", + fault_crs[0], fault_crs[4], fault_crs[3], fault_crs[2]); printk("ds: %04x es: %04x fs: %04x gs: %04x " "ss: %04x cs: %04x\n", fault_regs.ds, fault_regs.es, fault_regs.fs, Index: 2006-08-16/xen/arch/x86/x86_64/traps.c =================================================================== --- 2006-08-16.orig/xen/arch/x86/x86_64/traps.c 2006-08-23 11:37:24.000000000 +0200 +++ 2006-08-16/xen/arch/x86/x86_64/traps.c 2006-08-23 12:03:51.000000000 +0200 @@ -35,9 +35,20 @@ void show_registers(struct cpu_user_regs } else { - context = guest_mode(regs) ? "guest" : "hypervisor"; + if ( guest_mode(regs) ) + { + context = "guest"; + fault_crs[2] = container_of(regs, struct cpu_info, guest_cpu_user_regs) + ->current_vcpu->vcpu_info->arch.cr2; + } + else + { + context = "hypervisor"; + fault_crs[2] = read_cr2(); + } fault_crs[0] = read_cr0(); fault_crs[3] = read_cr3(); + fault_crs[4] = read_cr4(); fault_regs.ds = read_segment_register(ds); fault_regs.es = read_segment_register(es); fault_regs.fs = read_segment_register(fs); @@ -62,8 +73,9 @@ void show_registers(struct cpu_user_regs fault_regs.r9, fault_regs.r10, fault_regs.r11); printk("r12: %016lx r13: %016lx r14: %016lx\n", fault_regs.r12, fault_regs.r13, fault_regs.r14); - printk("r15: %016lx cr0: %016lx cr3: %016lx\n", - fault_regs.r15, fault_crs[0], fault_crs[3]); + printk("r15: %016lx cr0: %016lx cr4: %016lx\n", + fault_regs.r15, fault_crs[0], fault_crs[4]); + printk("cr3: %016lx cr2: %016lx\n", fault_crs[3], fault_crs[2]); printk("ds: %04x es: %04x fs: %04x gs: %04x " "ss: %04x cs: %04x\n", fault_regs.ds, fault_regs.es, fault_regs.fs, Index: 2006-08-16/xen/include/asm-x86/processor.h =================================================================== --- 2006-08-16.orig/xen/include/asm-x86/processor.h 2006-08-23 11:52:26.000000000 +0200 +++ 2006-08-16/xen/include/asm-x86/processor.h 2006-08-23 12:02:40.000000000 +0200 @@ -290,6 +290,13 @@ static inline void write_cr0(unsigned lo __asm__("mov %0,%%cr0": :"r" ((unsigned long)val)); } +static inline unsigned long read_cr2(void) +{ + unsigned long __cr2; + __asm__("mov %%cr2,%0\n\t" :"=r" (__cr2)); + return __cr2; +} + static inline unsigned long read_cr4(void) { unsigned long __cr4;