arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack

The structure of the ret_stack array on the task struct is going to
change, and accessing it directly via the curr_ret_stack index will no
longer give the ret_stack entry that holds the return address. To access
that, architectures must now use ftrace_graph_get_ret_stack() to get the
associated ret_stack that matches the saved return address.

Cc: linux-arm-kernel@lists.infradead.org
Cc: Will Deacon <will.deacon@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt (VMware) 2018-12-07 13:13:28 -05:00
parent cec8d0e7f0
commit a448276ce5
6 changed files with 12 additions and 10 deletions

View File

@ -164,7 +164,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
frame.fp = regs->regs[29]; frame.fp = regs->regs[29];
frame.pc = regs->pc; frame.pc = regs->pc;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = current->curr_ret_stack; frame.graph = 0;
#endif #endif
walk_stackframe(current, &frame, callchain_trace, entry); walk_stackframe(current, &frame, callchain_trace, entry);

View File

@ -459,7 +459,7 @@ unsigned long get_wchan(struct task_struct *p)
frame.fp = thread_saved_fp(p); frame.fp = thread_saved_fp(p);
frame.pc = thread_saved_pc(p); frame.pc = thread_saved_pc(p);
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = p->curr_ret_stack; frame.graph = 0;
#endif #endif
do { do {
if (unwind_frame(p, &frame)) if (unwind_frame(p, &frame))

View File

@ -44,7 +44,7 @@ void *return_address(unsigned int level)
frame.fp = (unsigned long)__builtin_frame_address(0); frame.fp = (unsigned long)__builtin_frame_address(0);
frame.pc = (unsigned long)return_address; /* dummy */ frame.pc = (unsigned long)return_address; /* dummy */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = current->curr_ret_stack; frame.graph = 0;
#endif #endif
walk_stackframe(current, &frame, save_return_addr, &data); walk_stackframe(current, &frame, save_return_addr, &data);

View File

@ -59,15 +59,17 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
if (tsk->ret_stack && if (tsk->ret_stack &&
(frame->pc == (unsigned long)return_to_handler)) { (frame->pc == (unsigned long)return_to_handler)) {
if (WARN_ON_ONCE(frame->graph == -1)) struct ftrace_ret_stack *ret_stack;
return -EINVAL;
/* /*
* This is a case where function graph tracer has * This is a case where function graph tracer has
* modified a return address (LR) in a stack frame * modified a return address (LR) in a stack frame
* to hook a function return. * to hook a function return.
* So replace it to an original value. * So replace it to an original value.
*/ */
frame->pc = tsk->ret_stack[frame->graph--].ret; ret_stack = ftrace_graph_get_ret_stack(tsk, frame->graph++);
if (WARN_ON_ONCE(!ret_stack))
return -EINVAL;
frame->pc = ret_stack->ret;
} }
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
@ -134,7 +136,7 @@ void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
frame.fp = regs->regs[29]; frame.fp = regs->regs[29];
frame.pc = regs->pc; frame.pc = regs->pc;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = current->curr_ret_stack; frame.graph = 0;
#endif #endif
walk_stackframe(current, &frame, save_trace, &data); walk_stackframe(current, &frame, save_trace, &data);
@ -165,7 +167,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
frame.pc = (unsigned long)__save_stack_trace; frame.pc = (unsigned long)__save_stack_trace;
} }
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = tsk->curr_ret_stack; frame.graph = 0;
#endif #endif
walk_stackframe(tsk, &frame, save_trace, &data); walk_stackframe(tsk, &frame, save_trace, &data);

View File

@ -52,7 +52,7 @@ unsigned long profile_pc(struct pt_regs *regs)
frame.fp = regs->regs[29]; frame.fp = regs->regs[29];
frame.pc = regs->pc; frame.pc = regs->pc;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = current->curr_ret_stack; frame.graph = 0;
#endif #endif
do { do {
int ret = unwind_frame(NULL, &frame); int ret = unwind_frame(NULL, &frame);

View File

@ -122,7 +122,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
frame.pc = thread_saved_pc(tsk); frame.pc = thread_saved_pc(tsk);
} }
#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_FUNCTION_GRAPH_TRACER
frame.graph = tsk->curr_ret_stack; frame.graph = 0;
#endif #endif
skip = !!regs; skip = !!regs;