@@ -74,6 +74,7 @@ config ARM
select HAVE_CONTEXT_TRACKING
select HAVE_C_RECORDMCOUNT
select HAVE_DEBUG_KMEMLEAK
+ select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DMA_CONTIGUOUS if MMU
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
@@ -41,6 +41,7 @@
#include <asm/mach/arch.h>
#include <asm/mach/irq.h>
#include <asm/mach/time.h>
+#include <asm/thread_info.h>
unsigned long irq_err_count;
@@ -56,6 +57,23 @@ int arch_show_interrupts(struct seq_file *p, int prec)
return 0;
}
+#ifdef CONFIG_DEBUG_STACKOVERFLOW
+#define STACK_WARN (THREAD_SIZE / 8)
+static inline void check_stack_overflow(void)
+{
+ unsigned long remaining_stack =
+ current_stack_pointer & (THREAD_SIZE - 1);
+
+ if (remaining_stack < sizeof(struct thread_info) + STACK_WARN) {
+ pr_err("handle_IRQ: stack overflow: %ld\n",
+ remaining_stack - sizeof(struct thread_info));
+ dump_stack();
+ }
+}
+#else
+static inline void check_stack_overflow(void) {}
+#endif
+
/*
* handle_IRQ handles all hardware IRQ's. Decoded IRQs should
* not come via this function. Instead, they should provide their
@@ -64,6 +82,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
*/
void handle_IRQ(unsigned int irq, struct pt_regs *regs)
{
+ check_stack_overflow();
__handle_domain_irq(NULL, irq, false, regs);
}
This is similar to the checks done for mips that were introduced in 334c86c494b9 ("MIPS: IRQ: Add stackoverflow detection") and helps detecting stack overflows in combination with interrupts. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> --- Hello, this is for now only lightly tested (it compiles and doesn't trigger on my test machine). Best regards Uwe arch/arm/Kconfig | 1 + arch/arm/kernel/irq.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)