Skip to content

Commit a448276

Browse files
committed
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>
1 parent cec8d0e commit a448276

6 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎arch/arm64/kernel/perf_callchain.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
164164
frame.fp = regs->regs[29];
165165
frame.pc = regs->pc;
166166
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
167-
frame.graph = current->curr_ret_stack;
167+
frame.graph = 0;
168168
#endif
169169

170170
walk_stackframe(current, &frame, callchain_trace, entry);

‎arch/arm64/kernel/process.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ unsigned long get_wchan(struct task_struct *p)
459459
frame.fp = thread_saved_fp(p);
460460
frame.pc = thread_saved_pc(p);
461461
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
462-
frame.graph = p->curr_ret_stack;
462+
frame.graph = 0;
463463
#endif
464464
do {
465465
if (unwind_frame(p, &frame))

‎arch/arm64/kernel/return_address.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void *return_address(unsigned int level)
4444
frame.fp = (unsigned long)__builtin_frame_address(0);
4545
frame.pc = (unsigned long)return_address; /* dummy */
4646
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
47-
frame.graph = current->curr_ret_stack;
47+
frame.graph = 0;
4848
#endif
4949

5050
walk_stackframe(current, &frame, save_return_addr, &data);

‎arch/arm64/kernel/stacktrace.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
5959
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
6060
if (tsk->ret_stack &&
6161
(frame->pc == (unsigned long)return_to_handler)) {
62-
if (WARN_ON_ONCE(frame->graph == -1))
63-
return -EINVAL;
62+
struct ftrace_ret_stack *ret_stack;
6463
/*
6564
* This is a case where function graph tracer has
6665
* modified a return address (LR) in a stack frame
6766
* to hook a function return.
6867
* So replace it to an original value.
6968
*/
70-
frame->pc = tsk->ret_stack[frame->graph--].ret;
69+
ret_stack = ftrace_graph_get_ret_stack(tsk, frame->graph++);
70+
if (WARN_ON_ONCE(!ret_stack))
71+
return -EINVAL;
72+
frame->pc = ret_stack->ret;
7173
}
7274
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
7375

@@ -134,7 +136,7 @@ void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
134136
frame.fp = regs->regs[29];
135137
frame.pc = regs->pc;
136138
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
137-
frame.graph = current->curr_ret_stack;
139+
frame.graph = 0;
138140
#endif
139141

140142
walk_stackframe(current, &frame, save_trace, &data);
@@ -165,7 +167,7 @@ static noinline void __save_stack_trace(struct task_struct *tsk,
165167
frame.pc = (unsigned long)__save_stack_trace;
166168
}
167169
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
168-
frame.graph = tsk->curr_ret_stack;
170+
frame.graph = 0;
169171
#endif
170172

171173
walk_stackframe(tsk, &frame, save_trace, &data);

‎arch/arm64/kernel/time.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ unsigned long profile_pc(struct pt_regs *regs)
5252
frame.fp = regs->regs[29];
5353
frame.pc = regs->pc;
5454
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
55-
frame.graph = current->curr_ret_stack;
55+
frame.graph = 0;
5656
#endif
5757
do {
5858
int ret = unwind_frame(NULL, &frame);

‎arch/arm64/kernel/traps.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
122122
frame.pc = thread_saved_pc(tsk);
123123
}
124124
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
125-
frame.graph = tsk->curr_ret_stack;
125+
frame.graph = 0;
126126
#endif
127127

128128
skip = !!regs;

0 commit comments

Comments
 (0)