Title: [5790] trunk/arch/blackfin: [#4312] Add basic irq stack checking for Blackfin
- Revision
- 5790
- Author
- rgetz
- Date
- 2008-12-02 13:05:31 -0600 (Tue, 02 Dec 2008)
Log Message
[#4312] Add basic irq stack checking for Blackfin
Modified Paths
Diff
Modified: trunk/arch/blackfin/Kconfig.debug (5789 => 5790)
--- trunk/arch/blackfin/Kconfig.debug 2008-12-02 14:41:07 UTC (rev 5789)
+++ trunk/arch/blackfin/Kconfig.debug 2008-12-02 19:05:31 UTC (rev 5790)
@@ -2,6 +2,13 @@
source "lib/Kconfig.debug"
+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 HAVE_ARCH_KGDB
def_bool y
Modified: trunk/arch/blackfin/include/asm/processor.h (5789 => 5790)
--- trunk/arch/blackfin/include/asm/processor.h 2008-12-02 14:41:07 UTC (rev 5789)
+++ trunk/arch/blackfin/include/asm/processor.h 2008-12-02 19:05:31 UTC (rev 5790)
@@ -24,6 +24,14 @@
__asm__ __volatile__("usp = %0;\n\t"::"da"(usp));
}
+static inline unsigned long __get_SP(void)
+{
+ unsigned long sp;
+
+ __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp));
+ return sp;
+}
+
/*
* User space process size: 1st byte beyond user address space.
* Fairly meaningless on nommu. Parts of user programs can be scattered
Modified: trunk/arch/blackfin/include/asm/thread_info.h (5789 => 5790)
--- trunk/arch/blackfin/include/asm/thread_info.h 2008-12-02 14:41:07 UTC (rev 5789)
+++ trunk/arch/blackfin/include/asm/thread_info.h 2008-12-02 19:05:31 UTC (rev 5790)
@@ -44,6 +44,7 @@
*/
#define THREAD_SIZE_ORDER 1
#define THREAD_SIZE 8192 /* 2 pages */
+#define STACK_WARN (THREAD_SIZE/8)
#ifndef __ASSEMBLY__
Modified: trunk/arch/blackfin/kernel/irqchip.c (5789 => 5790)
--- trunk/arch/blackfin/kernel/irqchip.c 2008-12-02 14:41:07 UTC (rev 5789)
+++ trunk/arch/blackfin/kernel/irqchip.c 2008-12-02 19:05:31 UTC (rev 5790)
@@ -120,7 +120,21 @@
desc = &bad_irq_desc;
irq_enter();
+#ifdef CONFIG_DEBUG_STACKOVERFLOW
+ /* Debugging check for stack overflow: is there less than STACK_WARN free? */
+ {
+ long sp;
+ sp = __get_SP() & (THREAD_SIZE-1);
+
+ if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
+ dump_stack();
+ printk(KERN_EMERG "%s: possible stack overflow while handling irq %i "
+ " only %ld bytes free\n",
+ __func__, irq, sp - sizeof(struct thread_info));
+ }
+ }
+#endif
generic_handle_irq(irq);
/* If we're the only interrupt running (ignoring IRQ15 which is for
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
http://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits