aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2016-08-19 07:53:01 -0400
committerIngo Molnar <mingo@kernel.org>2016-08-24 06:15:15 -0400
commit6f727b84e23421721025f4eb1b4f6cea1d4d723a (patch)
tree577a5a74db26f6352ee838f357e58e31bdfe24af /arch/x86/kernel
parent471bd10f5e2880bd91a2627d887f6062494cfe9c (diff)
x86/dumpstack/ftrace: Mark function graph handler function as unreliable
When function graph tracing is enabled for a function, its return address on the stack is replaced with the address of an ftrace handler (return_to_handler). Currently 'return_to_handler' can be reported as reliable. That's not ideal, and can actually be misleading. When saving or dumping the stack, you normally only care about what led up to that point (the call path), rather than what will happen in the future (the return path). That's especially true in the non-oops stack trace case, which isn't used for debugging. For example, in a perf profiling operation, reporting return_to_handler() in the trace would just be confusing. And in the oops case, where debugging is important, "unreliable" is also more appropriate there because it serves as a hint that graph tracing was involved, instead of trying to imply that return_to_handler() was the real caller. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Byungchul Park <byungchul.park@lge.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Nilay Vaish <nilayvaish@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/f8af15749c7d632d3e7f815995831d5b7f82950d.1471607358.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/dumpstack.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index 9bf3d021609c..6aad8d4e2ea6 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -87,12 +87,21 @@ print_context_stack(struct task_struct *task,
87 bp = (unsigned long) frame; 87 bp = (unsigned long) frame;
88 } 88 }
89 89
90 ops->address(data, addr, reliable); 90 /*
91 91 * When function graph tracing is enabled for a
92 * function, its return address on the stack is
93 * replaced with the address of an ftrace handler
94 * (return_to_handler). In that case, before printing
95 * the "real" address, we want to print the handler
96 * address as an "unreliable" hint that function graph
97 * tracing was involved.
98 */
92 real_addr = ftrace_graph_ret_addr(task, graph, addr, 99 real_addr = ftrace_graph_ret_addr(task, graph, addr,
93 stack); 100 stack);
94 if (real_addr != addr) 101 if (real_addr != addr)
95 ops->address(data, real_addr, 1); 102 ops->address(data, addr, 0);
103
104 ops->address(data, real_addr, reliable);
96 } 105 }
97 stack++; 106 stack++;
98 } 107 }
@@ -116,12 +125,11 @@ print_context_stack_bp(struct task_struct *task,
116 if (!__kernel_text_address(addr)) 125 if (!__kernel_text_address(addr))
117 break; 126 break;
118 127
119 if (ops->address(data, addr, 1))
120 break;
121
122 real_addr = ftrace_graph_ret_addr(task, graph, addr, retp); 128 real_addr = ftrace_graph_ret_addr(task, graph, addr, retp);
123 if (real_addr != addr) 129 if (real_addr != addr && ops->address(data, addr, 0))
124 ops->address(data, real_addr, 1); 130 break;
131 if (ops->address(data, real_addr, 1))
132 break;
125 133
126 frame = frame->next_frame; 134 frame = frame->next_frame;
127 retp = &frame->return_address; 135 retp = &frame->return_address;