# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 37f206c7405a11765f767f58909cd84e473e4f3f
# Parent 79f4c91c562864d27a31515d0f7a79d77b2b12a5
[XEN] Increase debug stack size from 4kB to 8kB.
Also fix double-fault handlers.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
xen/arch/x86/mm.c | 7 +++++++
xen/arch/x86/traps.c | 9 ++++++---
xen/arch/x86/x86_32/mm.c | 5 -----
xen/arch/x86/x86_32/traps.c | 4 ++++
xen/arch/x86/x86_64/entry.S | 8 +++++---
xen/arch/x86/x86_64/mm.c | 6 ------
xen/arch/x86/x86_64/traps.c | 28 +++++++++++++++++++++++++---
xen/include/asm-x86/config.h | 12 +++++-------
8 files changed, 52 insertions(+), 27 deletions(-)
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/mm.c Tue Jul 25 19:38:56 2006 +0100
@@ -3881,6 +3881,13 @@ void memguard_unguard_range(void *p, uns
#endif
+void memguard_guard_stack(void *p)
+{
+ BUILD_BUG_ON((DEBUG_STACK_SIZE + PAGE_SIZE) > STACK_SIZE);
+ p = (void *)((unsigned long)p + STACK_SIZE - DEBUG_STACK_SIZE - PAGE_SIZE);
+ memguard_guard_range(p, PAGE_SIZE);
+}
+
/*
* Local variables:
* mode: C
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/traps.c Tue Jul 25 19:38:56 2006 +0100
@@ -279,11 +279,14 @@ void show_stack_overflow(unsigned long e
void show_stack_overflow(unsigned long esp)
{
#ifdef MEMORY_GUARD
- unsigned long esp_top = get_stack_bottom() & PAGE_MASK;
+ unsigned long esp_top;
unsigned long *stack, addr;
- /* Trigger overflow trace if %esp is within 100 bytes of the guard page. */
- if ( ((esp - esp_top) > 100) && ((esp_top - esp) > 100) )
+ esp_top = (esp | (STACK_SIZE - 1)) - DEBUG_STACK_SIZE;
+
+ /* Trigger overflow trace if %esp is within 512 bytes of the guard page. */
+ if ( ((unsigned long)(esp - esp_top) > 512) &&
+ ((unsigned long)(esp_top - esp) > 512) )
return;
if ( esp < esp_top )
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/x86_32/mm.c
--- a/xen/arch/x86/x86_32/mm.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/x86_32/mm.c Tue Jul 25 19:38:56 2006 +0100
@@ -345,11 +345,6 @@ int check_descriptor(struct desc_struct
return 0;
}
-void memguard_guard_stack(void *p)
-{
- memguard_guard_range(p, PAGE_SIZE);
-}
-
/*
* Local variables:
* mode: C
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/x86_32/traps.c Tue Jul 25 19:38:56 2006 +0100
@@ -122,6 +122,7 @@ asmlinkage void do_double_fault(void)
{
struct tss_struct *tss = &doublefault_tss;
unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1;
+ char taint_str[TAINT_STRING_MAX_LEN];
watchdog_disable();
@@ -129,6 +130,9 @@ asmlinkage void do_double_fault(void)
/* Find information saved during fault and dump it to the console. */
tss = &init_tss[cpu];
+ printk("*** DOUBLE FAULT: Xen-%d.%d%s %s\n",
+ XEN_VERSION, XEN_SUBVERSION, XEN_EXTRAVERSION,
+ print_tainted(taint_str));
printk("CPU: %d\nEIP: %04x:[<%08x>]",
cpu, tss->cs, tss->eip);
print_symbol(" %s\n", tss->eip);
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/x86_64/entry.S Tue Jul 25 19:38:56 2006 +0100
@@ -471,8 +471,10 @@ ENTRY(spurious_interrupt_bug)
jmp handle_exception
ENTRY(double_fault)
- movl $TRAP_double_fault,4(%rsp)
- jmp handle_exception
+ SAVE_ALL
+ movq %rsp,%rdi
+ call do_double_fault
+ ud2
ENTRY(nmi)
pushq $0
@@ -518,7 +520,7 @@ ENTRY(exception_table)
.quad do_bounds
.quad do_invalid_op
.quad math_state_restore
- .quad do_double_fault
+ .quad 0 # double_fault
.quad do_coprocessor_segment_overrun
.quad do_invalid_TSS
.quad do_segment_not_present
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/x86_64/mm.c Tue Jul 25 19:38:56 2006 +0100
@@ -323,12 +323,6 @@ int check_descriptor(struct desc_struct
return 0;
}
-void memguard_guard_stack(void *p)
-{
- p = (void *)((unsigned long)p + PAGE_SIZE);
- memguard_guard_range(p, 2 * PAGE_SIZE);
-}
-
/*
* Local variables:
* mode: C
diff -r 79f4c91c5628 -r 37f206c7405a xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/arch/x86/x86_64/traps.c Tue Jul 25 19:38:56 2006 +0100
@@ -116,16 +116,38 @@ asmlinkage void double_fault(void);
asmlinkage void double_fault(void);
asmlinkage void do_double_fault(struct cpu_user_regs *regs)
{
+ unsigned int cpu, tr;
+ char taint_str[TAINT_STRING_MAX_LEN];
+
+ asm ( "str %0" : "=r" (tr) );
+ cpu = ((tr >> 3) - __FIRST_TSS_ENTRY) >> 2;
+
watchdog_disable();
console_force_unlock();
/* Find information saved during fault and dump it to the console. */
- printk("************************************\n");
- show_registers(regs);
+ printk("*** DOUBLE FAULT: Xen-%d.%d%s %s\n",
+ XEN_VERSION, XEN_SUBVERSION, XEN_EXTRAVERSION,
+ print_tainted(taint_str));
+ printk("CPU: %d\nRIP: %04x:[<%016lx>]",
+ cpu, regs->cs, regs->rip);
+ print_symbol(" %s", regs->rip);
+ printk("\nRFLAGS: %016lx\n", regs->rflags);
+ 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);
+ 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);
show_stack_overflow(regs->rsp);
printk("************************************\n");
- printk("CPU%d DOUBLE FAULT -- system shutdown\n", smp_processor_id());
+ printk("CPU%d DOUBLE FAULT -- system shutdown\n", cpu);
printk("System needs manual reset.\n");
printk("************************************\n");
diff -r 79f4c91c5628 -r 37f206c7405a xen/include/asm-x86/config.h
--- a/xen/include/asm-x86/config.h Tue Jul 25 17:01:49 2006 +0100
+++ b/xen/include/asm-x86/config.h Tue Jul 25 19:38:56 2006 +0100
@@ -67,15 +67,13 @@
#ifndef NDEBUG
#define MEMORY_GUARD
-#ifdef __x86_64__
+#endif
+
#define STACK_ORDER 2
-#endif
-#endif
-
-#ifndef STACK_ORDER
-#define STACK_ORDER 1
-#endif
#define STACK_SIZE (PAGE_SIZE << STACK_ORDER)
+
+/* Debug stack is restricted to 8kB by guard pages. */
+#define DEBUG_STACK_SIZE 8192
#define MAX_DMADOM_PFN 0x7FFFFUL /* 31 addressable bits */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|