[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] domain_crash_synchronous() on x86_64 causes Xen to crash because



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 69bf4490062faf91521565b5bda9662af4e30e57
# Parent  0fad07d67e758290d5921a82f6099fa6c186099f
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>
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 0fad07d67e75 -r 69bf4490062f xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Tue Sep 13 10:05:49 2005
+++ b/xen/arch/x86/traps.c      Tue Sep 13 10:12:40 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)
@@ -238,7 +238,7 @@
     unsigned long *stack = ESP_BEFORE_EXCEPTION(regs), addr;
     int i;
 
-    if ( GUEST_MODE(regs) )
+    if ( GUEST_CONTEXT(current, regs) )
         return show_guest_stack(regs);
 
     printk("Xen stack trace from "__OP"sp=%p:\n   ", stack);
diff -r 0fad07d67e75 -r 69bf4490062f xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c       Tue Sep 13 10:05:49 2005
+++ b/xen/arch/x86/x86_64/traps.c       Tue Sep 13 10:12:40 2005
@@ -12,25 +12,51 @@
 #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();
+        rsp     = regs->rsp;
+        cs      = regs->cs & 0xffff;
+        context = GUEST_MODE(regs) ? "guest" : "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("r15: %016lx   cr0: %016lx   cr3: %016lx\n",
+           regs->r15, cr0, cr3);
 
     show_stack(regs);
 }
@@ -194,3 +220,13 @@
 
     return 0;
 }
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.