diff options
-rw-r--r-- | arch/blackfin/Kconfig.debug | 16 | ||||
-rw-r--r-- | arch/blackfin/include/asm/processor.h | 8 | ||||
-rw-r--r-- | arch/blackfin/include/asm/thread_info.h | 1 | ||||
-rw-r--r-- | arch/blackfin/kernel/irqchip.c | 16 |
4 files changed, 40 insertions, 1 deletions
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug index 3ad25983ec97..bfd712ab125c 100644 --- a/arch/blackfin/Kconfig.debug +++ b/arch/blackfin/Kconfig.debug | |||
@@ -2,6 +2,22 @@ menu "Kernel hacking" | |||
2 | 2 | ||
3 | source "lib/Kconfig.debug" | 3 | source "lib/Kconfig.debug" |
4 | 4 | ||
5 | config DEBUG_STACKOVERFLOW | ||
6 | bool "Check for stack overflows" | ||
7 | depends on DEBUG_KERNEL | ||
8 | help | ||
9 | This option will cause messages to be printed if free stack space | ||
10 | drops below a certain limit. | ||
11 | |||
12 | config DEBUG_STACK_USAGE | ||
13 | bool "Enable stack utilization instrumentation" | ||
14 | depends on DEBUG_KERNEL | ||
15 | help | ||
16 | Enables the display of the minimum amount of free stack which each | ||
17 | task has ever had available in the sysrq-T output. | ||
18 | |||
19 | This option will slow down process creation somewhat. | ||
20 | |||
5 | config HAVE_ARCH_KGDB | 21 | config HAVE_ARCH_KGDB |
6 | def_bool y | 22 | def_bool y |
7 | 23 | ||
diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h index 2cb0b8711fa4..83d57a85b14f 100644 --- a/arch/blackfin/include/asm/processor.h +++ b/arch/blackfin/include/asm/processor.h | |||
@@ -24,6 +24,14 @@ static inline void wrusp(unsigned long usp) | |||
24 | __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); | 24 | __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); |
25 | } | 25 | } |
26 | 26 | ||
27 | static inline unsigned long __get_SP(void) | ||
28 | { | ||
29 | unsigned long sp; | ||
30 | |||
31 | __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp)); | ||
32 | return sp; | ||
33 | } | ||
34 | |||
27 | /* | 35 | /* |
28 | * User space process size: 1st byte beyond user address space. | 36 | * User space process size: 1st byte beyond user address space. |
29 | * Fairly meaningless on nommu. Parts of user programs can be scattered | 37 | * Fairly meaningless on nommu. Parts of user programs can be scattered |
diff --git a/arch/blackfin/include/asm/thread_info.h b/arch/blackfin/include/asm/thread_info.h index 642769329d12..1d380def2410 100644 --- a/arch/blackfin/include/asm/thread_info.h +++ b/arch/blackfin/include/asm/thread_info.h | |||
@@ -44,6 +44,7 @@ | |||
44 | */ | 44 | */ |
45 | #define THREAD_SIZE_ORDER 1 | 45 | #define THREAD_SIZE_ORDER 1 |
46 | #define THREAD_SIZE 8192 /* 2 pages */ | 46 | #define THREAD_SIZE 8192 /* 2 pages */ |
47 | #define STACK_WARN (THREAD_SIZE/8) | ||
47 | 48 | ||
48 | #ifndef __ASSEMBLY__ | 49 | #ifndef __ASSEMBLY__ |
49 | 50 | ||
diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c index 5ad07525ea3f..1624e1129681 100644 --- a/arch/blackfin/kernel/irqchip.c +++ b/arch/blackfin/kernel/irqchip.c | |||
@@ -120,7 +120,21 @@ asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs) | |||
120 | desc = &bad_irq_desc; | 120 | desc = &bad_irq_desc; |
121 | 121 | ||
122 | irq_enter(); | 122 | irq_enter(); |
123 | 123 | #ifdef CONFIG_DEBUG_STACKOVERFLOW | |
124 | /* Debugging check for stack overflow: is there less than STACK_WARN free? */ | ||
125 | { | ||
126 | long sp; | ||
127 | |||
128 | sp = __get_SP() & (THREAD_SIZE-1); | ||
129 | |||
130 | if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) { | ||
131 | dump_stack(); | ||
132 | printk(KERN_EMERG "%s: possible stack overflow while handling irq %i " | ||
133 | " only %ld bytes free\n", | ||
134 | __func__, irq, sp - sizeof(struct thread_info)); | ||
135 | } | ||
136 | } | ||
137 | #endif | ||
124 | generic_handle_irq(irq); | 138 | generic_handle_irq(irq); |
125 | 139 | ||
126 | /* If we're the only interrupt running (ignoring IRQ15 which is for | 140 | /* If we're the only interrupt running (ignoring IRQ15 which is for |