arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 7 Dec 2018 18:13:28 +0000 (13:13 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Sat, 22 Dec 2018 13:21:02 +0000 (08:21 -0500)
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>
arch/arm64/kernel/perf_callchain.c
arch/arm64/kernel/process.c
arch/arm64/kernel/return_address.c
arch/arm64/kernel/stacktrace.c
arch/arm64/kernel/time.c
arch/arm64/kernel/traps.c

index bcafd7d..1b792b4 100644 (file)
@@ -164,7 +164,7 @@ void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry,
        frame.fp = regs->regs[29];
        frame.pc = regs->pc;
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = current->curr_ret_stack;
+       frame.graph = 0;
 #endif
 
        walk_stackframe(current, &frame, callchain_trace, entry);
index d9a4c2d..37a6639 100644 (file)
@@ -459,7 +459,7 @@ unsigned long get_wchan(struct task_struct *p)
        frame.fp = thread_saved_fp(p);
        frame.pc = thread_saved_pc(p);
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = p->curr_ret_stack;
+       frame.graph = 0;
 #endif
        do {
                if (unwind_frame(p, &frame))
index 933adbc..53c4019 100644 (file)
@@ -44,7 +44,7 @@ void *return_address(unsigned int level)
        frame.fp = (unsigned long)__builtin_frame_address(0);
        frame.pc = (unsigned long)return_address; /* dummy */
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = current->curr_ret_stack;
+       frame.graph = 0;
 #endif
 
        walk_stackframe(current, &frame, save_return_addr, &data);
index 7723dad..1a29f26 100644 (file)
@@ -59,15 +59,17 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
        if (tsk->ret_stack &&
                        (frame->pc == (unsigned long)return_to_handler)) {
-               if (WARN_ON_ONCE(frame->graph == -1))
-                       return -EINVAL;
+               struct ftrace_ret_stack *ret_stack;
                /*
                 * This is a case where function graph tracer has
                 * modified a return address (LR) in a stack frame
                 * to hook a function return.
                 * 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 */
 
@@ -134,7 +136,7 @@ void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
        frame.fp = regs->regs[29];
        frame.pc = regs->pc;
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = current->curr_ret_stack;
+       frame.graph = 0;
 #endif
 
        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;
        }
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = tsk->curr_ret_stack;
+       frame.graph = 0;
 #endif
 
        walk_stackframe(tsk, &frame, save_trace, &data);
index f258636..a777ae9 100644 (file)
@@ -52,7 +52,7 @@ unsigned long profile_pc(struct pt_regs *regs)
        frame.fp = regs->regs[29];
        frame.pc = regs->pc;
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = current->curr_ret_stack;
+       frame.graph = 0;
 #endif
        do {
                int ret = unwind_frame(NULL, &frame);
index 5f4d9ac..49ebf37 100644 (file)
@@ -122,7 +122,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
                frame.pc = thread_saved_pc(tsk);
        }
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       frame.graph = tsk->curr_ret_stack;
+       frame.graph = 0;
 #endif
 
        skip = !!regs;