ia64/xen-unstable

changeset 10477:8d75d4e0af1e

[XEN] Improve double-fault tracing -- print backtrace
on stack overflow.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Mon Jun 19 11:21:40 2006 +0100 (2006-06-19)
parents db37448ffe97
children f3561b1ee7a3
files xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/processor.h
line diff
     1.1 --- a/xen/arch/x86/traps.c	Mon Jun 19 11:10:10 2006 +0100
     1.2 +++ b/xen/arch/x86/traps.c	Mon Jun 19 11:21:40 2006 +0100
     1.3 @@ -276,6 +276,36 @@ void show_stack(struct cpu_user_regs *re
     1.4      show_trace(regs);
     1.5  }
     1.6  
     1.7 +void show_stack_overflow(unsigned long esp)
     1.8 +{
     1.9 +#ifdef MEMORY_GUARD
    1.10 +    unsigned long esp_top = get_stack_bottom() & PAGE_MASK;
    1.11 +    unsigned long *stack, addr;
    1.12 +
    1.13 +    /* Trigger overflow trace if %esp is within 100 bytes of the guard page. */
    1.14 +    if ( ((esp - esp_top) > 100) && ((esp_top - esp) > 100) )
    1.15 +        return;
    1.16 +
    1.17 +    if ( esp < esp_top )
    1.18 +        esp = esp_top;
    1.19 +
    1.20 +    printk("Xen stack overflow:\n   ");
    1.21 +
    1.22 +    stack = (unsigned long *)esp;
    1.23 +    while ( ((long)stack & (STACK_SIZE-BYTES_PER_LONG)) != 0 )
    1.24 +    {
    1.25 +        addr = *stack++;
    1.26 +        if ( is_kernel_text(addr) )
    1.27 +        {
    1.28 +            printk("%p: [<%p>]", stack, _p(addr));
    1.29 +            print_symbol(" %s\n   ", addr);
    1.30 +        }
    1.31 +    }
    1.32 +
    1.33 +    printk("\n");
    1.34 +#endif
    1.35 +}
    1.36 +
    1.37  /*
    1.38   * This is called for faults at very unexpected times (e.g., when interrupts
    1.39   * are disabled). In such situations we can't do much that is safe. We try to
     2.1 --- a/xen/arch/x86/x86_32/traps.c	Mon Jun 19 11:10:10 2006 +0100
     2.2 +++ b/xen/arch/x86/x86_32/traps.c	Mon Jun 19 11:21:40 2006 +0100
     2.3 @@ -139,6 +139,7 @@ asmlinkage void do_double_fault(void)
     2.4             tss->esi, tss->edi, tss->ebp, tss->esp);
     2.5      printk("ds: %04x   es: %04x   fs: %04x   gs: %04x   ss: %04x\n",
     2.6             tss->ds, tss->es, tss->fs, tss->gs, tss->ss);
     2.7 +    show_stack_overflow(tss->esp);
     2.8      printk("************************************\n");
     2.9      printk("CPU%d DOUBLE FAULT -- system shutdown\n", cpu);
    2.10      printk("System needs manual reset.\n");
     3.1 --- a/xen/arch/x86/x86_64/traps.c	Mon Jun 19 11:10:10 2006 +0100
     3.2 +++ b/xen/arch/x86/x86_64/traps.c	Mon Jun 19 11:21:40 2006 +0100
     3.3 @@ -21,7 +21,7 @@
     3.4  
     3.5  #include <public/callback.h>
     3.6  
     3.7 -void show_registers(struct cpu_user_regs *regs)
     3.8 +static void __show_registers(struct cpu_user_regs *regs)
     3.9  {
    3.10      struct cpu_user_regs fault_regs = *regs;
    3.11      unsigned long fault_crs[8];
    3.12 @@ -68,7 +68,11 @@ void show_registers(struct cpu_user_regs
    3.13             "ss: %04x   cs: %04x\n",
    3.14             fault_regs.ds, fault_regs.es, fault_regs.fs,
    3.15             fault_regs.gs, fault_regs.ss, fault_regs.cs);
    3.16 +}
    3.17  
    3.18 +void show_registers(struct cpu_user_regs *regs)
    3.19 +{
    3.20 +    __show_registers(regs);
    3.21      show_stack(regs);
    3.22  }
    3.23  
    3.24 @@ -124,7 +128,8 @@ asmlinkage void do_double_fault(struct c
    3.25  
    3.26      /* Find information saved during fault and dump it to the console. */
    3.27      printk("************************************\n");
    3.28 -    show_registers(regs);
    3.29 +    __show_registers(regs);
    3.30 +    show_stack_overflow(regs->rsp);
    3.31      printk("************************************\n");
    3.32      printk("CPU%d DOUBLE FAULT -- system shutdown\n", smp_processor_id());
    3.33      printk("System needs manual reset.\n");
     4.1 --- a/xen/include/asm-x86/processor.h	Mon Jun 19 11:10:10 2006 +0100
     4.2 +++ b/xen/include/asm-x86/processor.h	Mon Jun 19 11:21:40 2006 +0100
     4.3 @@ -529,6 +529,7 @@ extern always_inline void prefetchw(cons
     4.4  #endif
     4.5  
     4.6  void show_stack(struct cpu_user_regs *regs);
     4.7 +void show_stack_overflow(unsigned long esp);
     4.8  void show_registers(struct cpu_user_regs *regs);
     4.9  void show_page_walk(unsigned long addr);
    4.10  asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs);