ia64/xen-unstable

changeset 6776:69bf4490062f

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@watson.ibm.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Sep 13 10:12:40 2005 +0000 (2005-09-13)
parents 0fad07d67e75
children bd951d23d713
files xen/arch/x86/traps.c xen/arch/x86/x86_64/traps.c
line diff
     1.1 --- a/xen/arch/x86/traps.c	Tue Sep 13 10:05:49 2005 +0000
     1.2 +++ b/xen/arch/x86/traps.c	Tue Sep 13 10:12:40 2005 +0000
     1.3 @@ -106,7 +106,7 @@ integer_param("debug_stack_lines", debug
     1.4  #define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)&regs->esp)
     1.5  #else
     1.6  #define stack_words_per_line 4
     1.7 -#define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)regs->esp)
     1.8 +#define ESP_BEFORE_EXCEPTION(regs) ((unsigned long *)regs->rsp)
     1.9  #endif
    1.10  
    1.11  int is_kernel_text(unsigned long addr)
    1.12 @@ -238,7 +238,7 @@ void show_stack(struct cpu_user_regs *re
    1.13      unsigned long *stack = ESP_BEFORE_EXCEPTION(regs), addr;
    1.14      int i;
    1.15  
    1.16 -    if ( GUEST_MODE(regs) )
    1.17 +    if ( GUEST_CONTEXT(current, regs) )
    1.18          return show_guest_stack(regs);
    1.19  
    1.20      printk("Xen stack trace from "__OP"sp=%p:\n   ", stack);
     2.1 --- a/xen/arch/x86/x86_64/traps.c	Tue Sep 13 10:05:49 2005 +0000
     2.2 +++ b/xen/arch/x86/x86_64/traps.c	Tue Sep 13 10:12:40 2005 +0000
     2.3 @@ -12,25 +12,51 @@
     2.4  #include <asm/current.h>
     2.5  #include <asm/flushtlb.h>
     2.6  #include <asm/msr.h>
     2.7 +#include <asm/vmx.h>
     2.8  
     2.9  void show_registers(struct cpu_user_regs *regs)
    2.10  {
    2.11 -    printk("CPU:    %d\nRIP:    %04x:[<%016lx>]",
    2.12 -           smp_processor_id(), 0xffff & regs->cs, regs->rip);
    2.13 +    unsigned long rip, rsp, rflags, cs, cr0, cr3;
    2.14 +    const char *context;
    2.15 +
    2.16 +    if ( VMX_DOMAIN(current) && (regs->eflags == 0) )
    2.17 +    {
    2.18 +        __vmread(GUEST_RIP, &rip);
    2.19 +        __vmread(GUEST_RSP, &rsp);
    2.20 +        __vmread(GUEST_RFLAGS, &rflags);
    2.21 +        __vmread(GUEST_CS_SELECTOR, &cs);
    2.22 +        __vmread(CR0_READ_SHADOW, &cr0);
    2.23 +        __vmread(GUEST_CR3, &cr3);
    2.24 +        context = "vmx guest";
    2.25 +    }
    2.26 +    else
    2.27 +    {
    2.28 +        rip     = regs->rip;
    2.29 +        rflags  = regs->rflags;
    2.30 +        cr0     = read_cr0();
    2.31 +        cr3     = read_cr3();
    2.32 +        rsp     = regs->rsp;
    2.33 +        cs      = regs->cs & 0xffff;
    2.34 +        context = GUEST_MODE(regs) ? "guest" : "hypervisor";
    2.35 +    }
    2.36 +
    2.37 +    printk("CPU:    %d\nRIP:    %04lx:[<%016lx>]",
    2.38 +           smp_processor_id(), cs, rip);
    2.39      if ( !GUEST_MODE(regs) )
    2.40 -        print_symbol(" %s", regs->rip);
    2.41 -    printk("\nRFLAGS: %016lx\n", regs->eflags);
    2.42 +        print_symbol(" %s", rip);
    2.43 +    printk("\nRFLAGS: %016lx   CONTEXT: %s\n", rflags, context);
    2.44      printk("rax: %016lx   rbx: %016lx   rcx: %016lx\n",
    2.45             regs->rax, regs->rbx, regs->rcx);
    2.46      printk("rdx: %016lx   rsi: %016lx   rdi: %016lx\n",
    2.47             regs->rdx, regs->rsi, regs->rdi);
    2.48      printk("rbp: %016lx   rsp: %016lx   r8:  %016lx\n",
    2.49 -           regs->rbp, regs->rsp, regs->r8);
    2.50 +           regs->rbp, rsp, regs->r8);
    2.51      printk("r9:  %016lx   r10: %016lx   r11: %016lx\n",
    2.52             regs->r9,  regs->r10, regs->r11);
    2.53      printk("r12: %016lx   r13: %016lx   r14: %016lx\n",
    2.54             regs->r12, regs->r13, regs->r14);
    2.55 -    printk("r15: %016lx\n", regs->r15);
    2.56 +    printk("r15: %016lx   cr0: %016lx   cr3: %016lx\n",
    2.57 +           regs->r15, cr0, cr3);
    2.58  
    2.59      show_stack(regs);
    2.60  }
    2.61 @@ -194,3 +220,13 @@ long do_set_callbacks(unsigned long even
    2.62  
    2.63      return 0;
    2.64  }
    2.65 +
    2.66 +/*
    2.67 + * Local variables:
    2.68 + * mode: C
    2.69 + * c-set-style: "BSD"
    2.70 + * c-basic-offset: 4
    2.71 + * tab-width: 4
    2.72 + * indent-tabs-mode: nil
    2.73 + * End:
    2.74 + */