Skip to content

Commit

Permalink
x86_64: fix the check in stack_overflow_check
Browse files Browse the repository at this point in the history
Impact: make stack overflow debug check and printout narrower

stack_overflow_check() should consider the stack usage of pt_regs, and
thus it could warn us in advance. Additionally, it looks better for
the warning time to start at INITIAL_JIFFIES.

Assuming that rsp gets close to the check point before interrupt
arrives: when interrupt really happens, thread_info will be partly
overrode.

Signed-off-by: jia zhang <jia.zhang2008@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
jia zhang authored and Ingo Molnar committed Nov 23, 2008
1 parent ca9eed7 commit 3aeb95d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/x86/kernel/irq_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
static inline void stack_overflow_check(struct pt_regs *regs)
{
u64 curbase = (u64)task_stack_page(current);
static unsigned long warned = -60*HZ;
static unsigned long warned = INITIAL_JIFFIES - 60*HZ;

if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE &&
regs->sp < curbase + sizeof(struct thread_info) + 128 &&
time_after(jiffies, warned + 60*HZ)) {
regs->sp < curbase + sizeof(struct thread_info) +
sizeof(struct pt_regs) + 128 &&
time_after(jiffies, warned + 60*HZ)) {
printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
current->comm, curbase, regs->sp);
show_stack(NULL,NULL);
Expand Down

0 comments on commit 3aeb95d

Please sign in to comment.