ia64/xen-unstable

changeset 10795:37f206c7405a

[XEN] Increase debug stack size from 4kB to 8kB.
Also fix double-fault handlers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 25 19:38:56 2006 +0100 (2006-07-25)
parents 79f4c91c5628
children 77ec02027c17
files xen/arch/x86/mm.c xen/arch/x86/traps.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/traps.c xen/include/asm-x86/config.h
line diff
     1.1 --- a/xen/arch/x86/mm.c	Tue Jul 25 17:01:49 2006 +0100
     1.2 +++ b/xen/arch/x86/mm.c	Tue Jul 25 19:38:56 2006 +0100
     1.3 @@ -3881,6 +3881,13 @@ void memguard_unguard_range(void *p, uns
     1.4  
     1.5  #endif
     1.6  
     1.7 +void memguard_guard_stack(void *p)
     1.8 +{
     1.9 +    BUILD_BUG_ON((DEBUG_STACK_SIZE + PAGE_SIZE) > STACK_SIZE);
    1.10 +    p = (void *)((unsigned long)p + STACK_SIZE - DEBUG_STACK_SIZE - PAGE_SIZE);
    1.11 +    memguard_guard_range(p, PAGE_SIZE);
    1.12 +}
    1.13 +
    1.14  /*
    1.15   * Local variables:
    1.16   * mode: C
     2.1 --- a/xen/arch/x86/traps.c	Tue Jul 25 17:01:49 2006 +0100
     2.2 +++ b/xen/arch/x86/traps.c	Tue Jul 25 19:38:56 2006 +0100
     2.3 @@ -279,11 +279,14 @@ void show_stack(struct cpu_user_regs *re
     2.4  void show_stack_overflow(unsigned long esp)
     2.5  {
     2.6  #ifdef MEMORY_GUARD
     2.7 -    unsigned long esp_top = get_stack_bottom() & PAGE_MASK;
     2.8 +    unsigned long esp_top;
     2.9      unsigned long *stack, addr;
    2.10  
    2.11 -    /* Trigger overflow trace if %esp is within 100 bytes of the guard page. */
    2.12 -    if ( ((esp - esp_top) > 100) && ((esp_top - esp) > 100) )
    2.13 +    esp_top = (esp | (STACK_SIZE - 1)) - DEBUG_STACK_SIZE;
    2.14 +
    2.15 +    /* Trigger overflow trace if %esp is within 512 bytes of the guard page. */
    2.16 +    if ( ((unsigned long)(esp - esp_top) > 512) &&
    2.17 +         ((unsigned long)(esp_top - esp) > 512) )
    2.18          return;
    2.19  
    2.20      if ( esp < esp_top )
     3.1 --- a/xen/arch/x86/x86_32/mm.c	Tue Jul 25 17:01:49 2006 +0100
     3.2 +++ b/xen/arch/x86/x86_32/mm.c	Tue Jul 25 19:38:56 2006 +0100
     3.3 @@ -345,11 +345,6 @@ int check_descriptor(struct desc_struct 
     3.4      return 0;
     3.5  }
     3.6  
     3.7 -void memguard_guard_stack(void *p)
     3.8 -{
     3.9 -    memguard_guard_range(p, PAGE_SIZE);
    3.10 -}
    3.11 -
    3.12  /*
    3.13   * Local variables:
    3.14   * mode: C
     4.1 --- a/xen/arch/x86/x86_32/traps.c	Tue Jul 25 17:01:49 2006 +0100
     4.2 +++ b/xen/arch/x86/x86_32/traps.c	Tue Jul 25 19:38:56 2006 +0100
     4.3 @@ -122,6 +122,7 @@ asmlinkage void do_double_fault(void)
     4.4  {
     4.5      struct tss_struct *tss = &doublefault_tss;
     4.6      unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1;
     4.7 +    char taint_str[TAINT_STRING_MAX_LEN];
     4.8  
     4.9      watchdog_disable();
    4.10  
    4.11 @@ -129,6 +130,9 @@ asmlinkage void do_double_fault(void)
    4.12  
    4.13      /* Find information saved during fault and dump it to the console. */
    4.14      tss = &init_tss[cpu];
    4.15 +    printk("*** DOUBLE FAULT: Xen-%d.%d%s    %s\n",
    4.16 +           XEN_VERSION, XEN_SUBVERSION, XEN_EXTRAVERSION,
    4.17 +           print_tainted(taint_str));
    4.18      printk("CPU:    %d\nEIP:    %04x:[<%08x>]",
    4.19             cpu, tss->cs, tss->eip);
    4.20      print_symbol(" %s\n", tss->eip);
     5.1 --- a/xen/arch/x86/x86_64/entry.S	Tue Jul 25 17:01:49 2006 +0100
     5.2 +++ b/xen/arch/x86/x86_64/entry.S	Tue Jul 25 19:38:56 2006 +0100
     5.3 @@ -471,8 +471,10 @@ ENTRY(spurious_interrupt_bug)
     5.4  	jmp   handle_exception
     5.5  
     5.6  ENTRY(double_fault)
     5.7 -        movl  $TRAP_double_fault,4(%rsp)
     5.8 -        jmp   handle_exception
     5.9 +        SAVE_ALL
    5.10 +        movq  %rsp,%rdi
    5.11 +        call  do_double_fault
    5.12 +        ud2
    5.13  
    5.14  ENTRY(nmi)
    5.15          pushq $0
    5.16 @@ -518,7 +520,7 @@ ENTRY(exception_table)
    5.17          .quad do_bounds
    5.18          .quad do_invalid_op
    5.19          .quad math_state_restore
    5.20 -        .quad do_double_fault
    5.21 +        .quad 0 # double_fault
    5.22          .quad do_coprocessor_segment_overrun
    5.23          .quad do_invalid_TSS
    5.24          .quad do_segment_not_present
     6.1 --- a/xen/arch/x86/x86_64/mm.c	Tue Jul 25 17:01:49 2006 +0100
     6.2 +++ b/xen/arch/x86/x86_64/mm.c	Tue Jul 25 19:38:56 2006 +0100
     6.3 @@ -323,12 +323,6 @@ int check_descriptor(struct desc_struct 
     6.4      return 0;
     6.5  }
     6.6  
     6.7 -void memguard_guard_stack(void *p)
     6.8 -{
     6.9 -    p = (void *)((unsigned long)p + PAGE_SIZE);
    6.10 -    memguard_guard_range(p, 2 * PAGE_SIZE);
    6.11 -}
    6.12 -
    6.13  /*
    6.14   * Local variables:
    6.15   * mode: C
     7.1 --- a/xen/arch/x86/x86_64/traps.c	Tue Jul 25 17:01:49 2006 +0100
     7.2 +++ b/xen/arch/x86/x86_64/traps.c	Tue Jul 25 19:38:56 2006 +0100
     7.3 @@ -116,16 +116,38 @@ void show_page_walk(unsigned long addr)
     7.4  asmlinkage void double_fault(void);
     7.5  asmlinkage void do_double_fault(struct cpu_user_regs *regs)
     7.6  {
     7.7 +    unsigned int cpu, tr;
     7.8 +    char taint_str[TAINT_STRING_MAX_LEN];
     7.9 +
    7.10 +    asm ( "str %0" : "=r" (tr) );
    7.11 +    cpu = ((tr >> 3) - __FIRST_TSS_ENTRY) >> 2;
    7.12 +
    7.13      watchdog_disable();
    7.14  
    7.15      console_force_unlock();
    7.16  
    7.17      /* Find information saved during fault and dump it to the console. */
    7.18 -    printk("************************************\n");
    7.19 -    show_registers(regs);
    7.20 +    printk("*** DOUBLE FAULT: Xen-%d.%d%s    %s\n",
    7.21 +           XEN_VERSION, XEN_SUBVERSION, XEN_EXTRAVERSION,
    7.22 +           print_tainted(taint_str));
    7.23 +    printk("CPU:    %d\nRIP:    %04x:[<%016lx>]",
    7.24 +           cpu, regs->cs, regs->rip);
    7.25 +    print_symbol(" %s", regs->rip);
    7.26 +    printk("\nRFLAGS: %016lx\n", regs->rflags);
    7.27 +    printk("rax: %016lx   rbx: %016lx   rcx: %016lx\n",
    7.28 +           regs->rax, regs->rbx, regs->rcx);
    7.29 +    printk("rdx: %016lx   rsi: %016lx   rdi: %016lx\n",
    7.30 +           regs->rdx, regs->rsi, regs->rdi);
    7.31 +    printk("rbp: %016lx   rsp: %016lx   r8:  %016lx\n",
    7.32 +           regs->rbp, regs->rsp, regs->r8);
    7.33 +    printk("r9:  %016lx   r10: %016lx   r11: %016lx\n",
    7.34 +           regs->r9,  regs->r10, regs->r11);
    7.35 +    printk("r12: %016lx   r13: %016lx   r14: %016lx\n",
    7.36 +           regs->r12, regs->r13, regs->r14);
    7.37 +    printk("r15: %016lx\n", regs->r15);
    7.38      show_stack_overflow(regs->rsp);
    7.39      printk("************************************\n");
    7.40 -    printk("CPU%d DOUBLE FAULT -- system shutdown\n", smp_processor_id());
    7.41 +    printk("CPU%d DOUBLE FAULT -- system shutdown\n", cpu);
    7.42      printk("System needs manual reset.\n");
    7.43      printk("************************************\n");
    7.44  
     8.1 --- a/xen/include/asm-x86/config.h	Tue Jul 25 17:01:49 2006 +0100
     8.2 +++ b/xen/include/asm-x86/config.h	Tue Jul 25 19:38:56 2006 +0100
     8.3 @@ -67,16 +67,14 @@
     8.4  
     8.5  #ifndef NDEBUG
     8.6  #define MEMORY_GUARD
     8.7 -#ifdef __x86_64__
     8.8 -#define STACK_ORDER 2
     8.9 -#endif
    8.10  #endif
    8.11  
    8.12 -#ifndef STACK_ORDER
    8.13 -#define STACK_ORDER 1
    8.14 -#endif
    8.15 +#define STACK_ORDER 2
    8.16  #define STACK_SIZE  (PAGE_SIZE << STACK_ORDER)
    8.17  
    8.18 +/* Debug stack is restricted to 8kB by guard pages. */
    8.19 +#define DEBUG_STACK_SIZE 8192
    8.20 +
    8.21  #define MAX_DMADOM_PFN 0x7FFFFUL /* 31 addressable bits */
    8.22  
    8.23  #ifndef __ASSEMBLY__