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-devel

[Xen-devel] [PATCH] vmx-x86_64-show_stack.patch

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] vmx-x86_64-show_stack.patch
From: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>
Date: Sun, 11 Sep 2005 15:22:55 -0400
Cc: "Mallick, Asit K" <asit.k.mallick@xxxxxxxxx>, "Li, Chengyuan" <chengyuan.li@xxxxxxxxx>, "Nakajima, Jun" <jun.nakajima@xxxxxxxxx>
Delivery-date: Mon, 12 Sep 2005 00:19:04 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM T.J. Watson Research Center
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
domain_crash_synchronous() on x86_64 causes Xen to crash because
it tries to dereference an invalid stack address. The patch below
fixes this. The patch also updates show_registers() to print the
same information as its x86_32 equivalent.

Signed-Off-By: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>


diff -r 3feb7fa331ed xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Sun Sep 11 16:44:23 2005
+++ b/xen/arch/x86/traps.c      Sun Sep 11 19:48:23 2005
@@ -106,7 +106,7 @@
 #define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)&regs->esp)
 #else
 #define stack_words_per_line 4
-#define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)regs->esp)
+#define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)&regs->rsp)
 #endif
 
 int is_kernel_text(unsigned long addr)
diff -r 3feb7fa331ed xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c       Sun Sep 11 16:44:23 2005
+++ b/xen/arch/x86/x86_64/traps.c       Sun Sep 11 19:48:23 2005
@@ -12,25 +12,61 @@
 #include <asm/current.h>
 #include <asm/flushtlb.h>
 #include <asm/msr.h>
+#include <asm/vmx.h>
 
 void show_registers(struct cpu_user_regs *regs)
 {
-    printk("CPU:    %d\nRIP:    %04x:[<%016lx>]",
-           smp_processor_id(), 0xffff & regs->cs, regs->rip);
+    unsigned long rip, rsp, rflags, cs, cr0, cr3;
+    const char *context;
+
+    if ( VMX_DOMAIN(current) && regs->eflags == 0 )
+    {
+        __vmread(GUEST_RIP, &rip);
+        __vmread(GUEST_RSP, &rsp);
+        __vmread(GUEST_RFLAGS, &rflags);
+        __vmread(GUEST_CS_SELECTOR, &cs);
+        __vmread(CR0_READ_SHADOW, &cr0);
+        __vmread(GUEST_CR3, &cr3);
+        context = "vmx guest";
+    }
+    else
+    {
+        rip    = regs->rip;
+        rflags = regs->rflags;
+        cr0    = read_cr0();
+        cr3    = read_cr3();
+
+        if ( GUEST_MODE(regs) )
+        {
+            rsp = regs->rsp;
+            cs  = regs->cs & 0xffff;
+            context = "guest";
+        }
+        else
+       {
+            rsp = (unsigned long) &regs->rsp;
+            cs  = __HYPERVISOR_CS;
+            context = "hypervisor";
+        }
+    }
+
+    printk("CPU:    %d\nRIP:    %04lx:[<%016lx>]",
+           smp_processor_id(), cs, rip);
     if ( !GUEST_MODE(regs) )
-        print_symbol(" %s", regs->rip);
-    printk("\nRFLAGS: %016lx\n", regs->eflags);
+        print_symbol(" %s", rip);
+    printk("\nRFLAGS: %016lx   CONTEXT: %s\n", rflags, context);
     printk("rax: %016lx   rbx: %016lx   rcx: %016lx\n",
            regs->rax, regs->rbx, regs->rcx);
     printk("rdx: %016lx   rsi: %016lx   rdi: %016lx\n",
            regs->rdx, regs->rsi, regs->rdi);
     printk("rbp: %016lx   rsp: %016lx   r8:  %016lx\n",
-           regs->rbp, regs->rsp, regs->r8);
+           regs->rbp, rsp, regs->r8);
     printk("r9:  %016lx   r10: %016lx   r11: %016lx\n",
            regs->r9,  regs->r10, regs->r11);
     printk("r12: %016lx   r13: %016lx   r14: %016lx\n",
            regs->r12, regs->r13, regs->r14);
     printk("r15: %016lx\n", regs->r15);
+    printk("cr0: %08lx   cr3: %08lx\n", cr0, cr3);
 
     show_stack(regs);
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] vmx-x86_64-show_stack.patch, Leendert van Doorn <=