From: Arjan van de Ven Date: Wed, 30 Jan 2008 12:33:06 +0000 (+0100) Subject: x86: fix 32-bit FRAME_POINTER chasing code X-Git-Tag: v2.6.25-rc1~1143^2~317 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=3d1f7cae883ce4aac99c661562111a25d52effe0;p=linux-2.6-omap-h63xx.git x86: fix 32-bit FRAME_POINTER chasing code The current x86 32 bit FRAME_POINTER chasing code has a nasty bug in that the EBP tracer doesn't actually update the value of EBP it is tracing, so that the code doesn't actually switch to the irq stack properly. The result is a truncated backtrace: WARNING: at timeroops.c:8 kerneloops_regression_test() (Not tainted) Pid: 0, comm: swapper Not tainted 2.6.24-0.77.rc4.git4.fc9 #1 [] show_trace_log_lvl+0x1a/0x2f [] show_trace+0x12/0x14 [] dump_stack+0x6c/0x72 [] kerneloops_regression_test+0x44/0x46 [timeroops] [] run_timer_softirq+0x127/0x18f [] __do_softirq+0x78/0xff [] do_softirq+0x74/0xf7 ======================= This patch fixes the code to update EBP properly, and to check the EIP before printing (as the non-framepointer backtracer does) so that the same test backtrace now looks like this: WARNING: at timeroops.c:8 kerneloops_regression_test() Pid: 0, comm: swapper Not tainted 2.6.24-rc7 #4 [] show_trace_log_lvl+0x1a/0x2f [] show_trace+0x12/0x14 [] dump_stack+0x6a/0x70 [] kerneloops_regression_test+0x3b/0x3d [timeroops] [] run_timer_softirq+0x11b/0x17c [] __do_softirq+0x42/0x94 [] do_softirq+0x50/0xb6 [] irq_exit+0x37/0x67 [] do_IRQ+0x9a/0xaf [] common_interrupt+0x2e/0x34 [] cpuidle_idle_call+0x52/0x78 [] cpu_idle+0x46/0x60 [] rest_init+0x43/0x45 [] start_kernel+0x279/0x27f ======================= This shows that the backtrace goes all the way down to user context now. This bug was found during the port to 64 bit of the frame pointer backtracer. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner --- diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c index 83df0f37ba7..acc9af260fa 100644 --- a/arch/x86/kernel/traps_32.c +++ b/arch/x86/kernel/traps_32.c @@ -125,7 +125,8 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo, unsigned long addr; addr = frame->return_address; - ops->address(data, addr); + if (__kernel_text_address(addr)) + ops->address(data, addr); /* * break out of recursive entries (such as * end_of_stack_stop_unwind_function). Also, @@ -133,6 +134,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo, * move downwards! */ next = frame->next_frame; + bp = (unsigned long) next; if (next <= frame) break; frame = next;