From: Steven Rostedt <rostedt@goodmis.org>
To: Dave Jones <davej@redhat.com>
Cc: "H. Peter Anvin" <hpa@linux.intel.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>, Andi Kleen <ak@linux.intel.com>
Subject: Re: BUG - function tracing with breakpoints
Date: Tue, 29 May 2012 07:37:21 -0400 [thread overview]
Message-ID: <1338291441.13348.291.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1337979086.13348.269.camel@gandalf.stny.rr.com>
On Fri, 2012-05-25 at 16:51 -0400, Steven Rostedt wrote:
>
> /me continues his search.
Found it!
The int3 handler uses paranoidzeroentry_ist:
.macro paranoidzeroentry_ist sym do_sym ist
ENTRY(\sym)
INTR_FRAME
PARAVIRT_ADJUST_EXCEPTION_FRAME
pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
subq $ORIG_RAX-R15, %rsp
CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
call save_paranoid
TRACE_IRQS_OFF
movq %rsp,%rdi /* pt_regs pointer */
xorl %esi,%esi /* no error code */
subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
call \do_sym
addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
jmp paranoid_exit /* %ebx: no swapgs flag */
CFI_ENDPROC
END(\sym)
Which calls paranoid_exit, which does:
paranoid_restore:
TRACE_IRQS_IRETQ 0
RESTORE_ALL 8
jmp irq_return
The problem is with TRACE_IRQS_IRETQ which happens to call into lockdep.
Now we are still using the debug stack here outside that little
subtraction trick of the INIT_TSS_IST.
.macro TRACE_IRQS_IRETQ offset=ARGOFFSET
#ifdef CONFIG_TRACE_IRQFLAGS
bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
jnc 1f
TRACE_IRQS_ON
1:
#endif
.endm
# define TRACE_IRQS_ON call trace_hardirqs_on_thunk;
THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
which eventually leads to:
trace_hardirqs_on_caller {
__trace_hardirqs_on_caller(ip) {
mark_locks_held() {
mark_lock() {
save_trace() {
save_stack_trace()...
Unfortunately, the save_stack_trace() is traced by the function tracer.
Which means that it will hit a breakpoint and jump into the breakpoint
code. But here it will reset the stack and corrupt the current stack,
causing strange hard-to-debug bugs.
There's no reason to function trace stack dumps, and this stops the bug
from triggering when I apply it.
Dave, can you give this a try too?
Thanks!
-- Steve
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 532d2e0..0026999 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -14,6 +14,10 @@ CFLAGS_REMOVE_paravirt-spinlocks.o = -pg
CFLAGS_REMOVE_pvclock.o = -pg
CFLAGS_REMOVE_kvmclock.o = -pg
CFLAGS_REMOVE_ftrace.o = -pg
+CFLAGS_REMOVE_dumpstack.o = -pg
+CFLAGS_REMOVE_dumpstack_32.o = -pg
+CFLAGS_REMOVE_dumpstack_64.o = -pg
+CFLAGS_REMOVE_stacktrace.o = -pg
CFLAGS_REMOVE_early_printk.o = -pg
endif
next prev parent reply other threads:[~2012-05-29 11:37 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 16:01 tracing ring_buffer_resize oops Dave Jones
2012-05-24 16:19 ` Steven Rostedt
2012-05-24 17:22 ` Dave Jones
2012-05-24 17:35 ` Steven Rostedt
2012-05-24 18:47 ` Dave Jones
2012-05-24 18:54 ` Steven Rostedt
2012-05-24 19:11 ` Dave Jones
2012-05-24 19:24 ` Steven Rostedt
2012-05-24 20:05 ` Dave Jones
2012-05-24 20:18 ` Steven Rostedt
2012-05-24 20:33 ` Steven Rostedt
2012-05-24 21:15 ` Dave Jones
2012-05-24 21:25 ` Steven Rostedt
2012-05-24 22:49 ` Steven Rostedt
2012-05-24 22:57 ` Dave Jones
2012-05-24 23:40 ` Steven Rostedt
2012-05-24 23:53 ` H. Peter Anvin
2012-05-25 1:32 ` Steven Rostedt
2012-05-25 1:39 ` Steven Rostedt
2012-05-25 1:41 ` Steven Rostedt
2012-05-25 14:31 ` BUG - function tracing with breakpoints (was: Re: tracing ring_buffer_resize oops.) Steven Rostedt
2012-05-25 15:29 ` Steven Rostedt
2012-05-25 17:40 ` BUG - function tracing with breakpoints H. Peter Anvin
2012-05-25 18:46 ` Steven Rostedt
2012-05-25 20:51 ` Steven Rostedt
2012-05-26 1:36 ` Steven Rostedt
2012-05-29 11:37 ` Steven Rostedt [this message]
2012-05-29 13:26 ` Steven Rostedt
2012-05-25 0:14 ` tracing ring_buffer_resize oops Andi Kleen
2012-05-25 1:31 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338291441.13348.291.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=ak@linux.intel.com \
--cc=davej@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®