WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XEN] Include CR2 and CR4 in register dum

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XEN] Include CR2 and CR4 in register dumps.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 01 Sep 2006 01:30:19 +0000
Delivery-date: Thu, 31 Aug 2006 18:31:38 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 37a42856e8d99345d62171bb650d21cbe5104b39
# Parent  90d3ca978b4090c3ac3ad7586fa71362352ea8ae
[XEN] Include CR2 and CR4 in register dumps.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/svm.c      |    1 +
 xen/arch/x86/hvm/vmx/vmx.c      |    1 +
 xen/arch/x86/traps.c            |    5 ++---
 xen/arch/x86/x86_32/traps.c     |   13 ++++++++++---
 xen/arch/x86/x86_64/traps.c     |   18 +++++++++++++++---
 xen/include/asm-x86/processor.h |    7 +++++++
 6 files changed, 36 insertions(+), 9 deletions(-)

diff -r 90d3ca978b40 -r 37a42856e8d9 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c        Fri Sep 01 01:07:45 2006 +0100
@@ -243,6 +243,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;
     }
diff -r 90d3ca978b40 -r 37a42856e8d9 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Fri Sep 01 01:07:45 2006 +0100
@@ -520,6 +520,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]);
     }
diff -r 90d3ca978b40 -r 37a42856e8d9 xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/arch/x86/traps.c      Fri Sep 01 01:07:45 2006 +0100
@@ -339,7 +339,6 @@ asmlinkage void fatal_trap(int trapnr, s
 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", 
@@ -356,7 +355,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);
     }
@@ -911,7 +910,7 @@ asmlinkage int do_page_fault(struct cpu_
 
     ASSERT(!in_irq());
 
-    __asm__ __volatile__ ("mov %%cr2,%0" : "=r" (addr) : );
+    addr = read_cr2();
 
     DEBUGGER_trap_entry(TRAP_page_fault, regs);
 
diff -r 90d3ca978b40 -r 37a42856e8d9 xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c       Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/arch/x86/x86_32/traps.c       Fri Sep 01 01:07:45 2006 +0100
@@ -35,20 +35,26 @@ 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)&regs->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] = current->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 +69,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,
diff -r 90d3ca978b40 -r 37a42856e8d9 xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c       Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/arch/x86/x86_64/traps.c       Fri Sep 01 01:07:45 2006 +0100
@@ -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] = current->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,
diff -r 90d3ca978b40 -r 37a42856e8d9 xen/include/asm-x86/processor.h
--- a/xen/include/asm-x86/processor.h   Fri Sep 01 00:42:14 2006 +0100
+++ b/xen/include/asm-x86/processor.h   Fri Sep 01 01:07:45 2006 +0100
@@ -288,6 +288,13 @@ static inline void write_cr0(unsigned lo
 static inline void write_cr0(unsigned long val)
 {
        __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)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XEN] Include CR2 and CR4 in register dumps., Xen patchbot-unstable <=