|
@@ -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_regs *regs)
|
|
|
|
|
|
exit_idle();
|
|
|
irq_enter();
|
|
|
-
|
|
|
+#ifdef CONFIG_DEBUG_STACKOVERFLOW
|
|
|
+ stack_overflow_check(regs);
|
|
|
+#endif
|
|
|
__do_IRQ(irq, regs);
|
|
|
irq_exit();
|
|
|
|