Author: lcapitulino
Date: Fri Feb 9 20:18:29 2007
New Revision: 118609
Added:
packages/updates/2007.0/kernel-2.6/current/PATCHES/patches/CA77_x86_64_stack_overflow_support.patch
Modified:
packages/updates/2007.0/kernel-2.6/current/PATCHES/configs/x86_64.config
packages/updates/2007.0/kernel-2.6/current/SPECS/kernel-2.6.spec
Log:
x86_64: Add stack overflow support. Disabled by default, but it's
something good to have at hand
Modified:
packages/updates/2007.0/kernel-2.6/current/PATCHES/configs/x86_64.config
==============================================================================
--- packages/updates/2007.0/kernel-2.6/current/PATCHES/configs/x86_64.config
(original)
+++ packages/updates/2007.0/kernel-2.6/current/PATCHES/configs/x86_64.config
Fri Feb 9 20:18:29 2007
@@ -3329,6 +3329,7 @@
CONFIG_FORCED_INLINING=y
# CONFIG_RCU_TORTURE_TEST is not set
# CONFIG_DEBUG_RODATA is not set
+# CONFIG_DEBUG_STACKOVERFLOW is not set
CONFIG_KDB=y
CONFIG_KDB_MODULES=m
# CONFIG_KDB_OFF is not set
Added:
packages/updates/2007.0/kernel-2.6/current/PATCHES/patches/CA77_x86_64_stack_overflow_support.patch
==============================================================================
--- (empty file)
+++
packages/updates/2007.0/kernel-2.6/current/PATCHES/patches/CA77_x86_64_stack_overflow_support.patch
Fri Feb 9 20:18:29 2007
@@ -0,0 +1,85 @@
+commit 4961f10e2205d0ededa291e12ec634efc58aa93c
+Author: Eric Sandeen <[EMAIL PROTECTED]>
+Date: Mon Jun 26 14:00:05 2006 +0200
+
+ [PATCH] x86_64: (resend) x86_64 stack overflow debugging
+
+ Take two, now without spurious whitespace :( Applies to git & 2.6.17-rc6
+
+ CONFIG_DEBUG_STACKOVERFLOW existed for x86_64 in 2.4, but seems to have
gone AWOL in 2.6.
+
+ I've pretty much just copied this over from the 2.4 code, with
+ appropriate tweaks for the 2.6 kernel, plus a bugfix. I'd personally
+ rather see it printed out the way other arches do it, i.e.
+ bytes-remaining-until-overflow, rather than having to do the subtraction
+ yourself. Also, only 128 bytes remaining seems awfully late to issue a
+ warning. But I'll start here :)
+
+ Signed-off-by: Eric Sandeen <[EMAIL PROTECTED]>
+ Signed-off-by: Andi Kleen <[EMAIL PROTECTED]>
+ Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
+
+diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug
+index 0226f08..087a048 100644
+--- a/arch/x86_64/Kconfig.debug
++++ b/arch/x86_64/Kconfig.debug
+@@ -35,6 +35,13 @@ config IOMMU_LEAK
+ Add a simple leak tracer to the IOMMU code. This is useful when you
+ are debugging a buggy device driver that leaks IOMMU mappings.
+
++config DEBUG_STACKOVERFLOW
++ bool "Check for stack overflows"
++ depends on DEBUG_KERNEL
++ help
++ This option will cause messages to be printed if free stack space
++ drops below a certain limit.
++
+ #config X86_REMOTE_DEBUG
+ # bool "kgdb debugging stub"
+
+diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
+index 207ecdc..59518d4 100644
+--- a/arch/x86_64/kernel/irq.c
++++ b/arch/x86_64/kernel/irq.c
+@@ -26,6 +26,30 @@ atomic_t irq_mis_count;
+ #endif
+ #endif
+
++#ifdef CONFIG_DEBUG_STACKOVERFLOW
++/*
++ * Probabilistic stack overflow check:
++ *
++ * Only check the stack in process context, because everything else
++ * runs on the big interrupt stacks. Checking reliably is too expensive,
++ * so we just check from interrupts.
++ */
++static inline void stack_overflow_check(struct pt_regs *regs)
++{
++ u64 curbase = (u64) current->thread_info;
++ static unsigned long warned = -60*HZ;
++
++ if (regs->rsp >= curbase && regs->rsp <= curbase + THREAD_SIZE &&
++ regs->rsp < curbase + sizeof(struct thread_info) + 128 &&
++ time_after(jiffies, warned + 60*HZ)) {
++ printk("do_IRQ: %s near stack overflow (cur:%Lx,rsp:%lx)\n",
++ current->comm, curbase, regs->rsp);
++ show_stack(NULL,NULL);
++ warned = jiffies;
++ }
++}
++#endif
++
+ /*
+ * Generic, controller-independent functions:
+ */
+@@ -96,7 +120,9 @@ asmlinkage unsigned int do_IRQ(struct pt
+
+ exit_idle();
+ irq_enter();
+-
++#ifdef CONFIG_DEBUG_STACKOVERFLOW
++ stack_overflow_check(regs);
++#endif
+ __do_IRQ(irq, regs);
+ irq_exit();
+
Modified: packages/updates/2007.0/kernel-2.6/current/SPECS/kernel-2.6.spec
==============================================================================
--- packages/updates/2007.0/kernel-2.6/current/SPECS/kernel-2.6.spec
(original)
+++ packages/updates/2007.0/kernel-2.6/current/SPECS/kernel-2.6.spec Fri Feb
9 20:18:29 2007
@@ -1034,6 +1034,8 @@
o Luiz Capitulino <[EMAIL PROTECTED]>
- x86_64: Add /proc/config.gz support (CONFIG_IKCONFIG)
+ - x86_64: Add stack overflow support. Disabled by default, but it's
+ something good to have at hand
* Fri Feb 02 2007 Luiz Capitulino <[EMAIL PROTECTED]> 2.6.17-10mdv2007.0
o Gwenole Beauchesne <[EMAIL PROTECTED]>