aboutsummaryrefslogtreecommitdiffstats
path: root/arch/riscv/kernel/stacktrace.c
diff options
context:
space:
mode:
authorAlan Kao <alankao@andestech.com>2018-02-13 13:13:21 +0800
committerPalmer Dabbelt <palmer@sifive.com>2018-04-02 19:59:13 -0700
commitb785ec129bd9498ecd6e221e45820b00c6ed4adf (patch)
treef62b6429a1853e0d9627733a2f9ea7b4baeed937 /arch/riscv/kernel/stacktrace.c
parentriscv/ftrace: Add DYNAMIC_FTRACE_WITH_REGS support (diff)
downloadlinux-dev-b785ec129bd9498ecd6e221e45820b00c6ed4adf.tar.xz
linux-dev-b785ec129bd9498ecd6e221e45820b00c6ed4adf.zip
riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support
In walk_stackframe, the pc now receives the address from calling ftrace_graph_ret_addr instead of manual calculation. Note that the original calculation, pc = frame->ra - 4 is buggy when the instruction at the return address happened to be a compressed inst. But since it is not a critical part of ftrace, it is ignored for now to ease the review process. Cc: Greentime Hu <greentime@andestech.com> Signed-off-by: Alan Kao <alankao@andestech.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to '')
-rw-r--r--arch/riscv/kernel/stacktrace.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 559aae781154..a4b1d94371a0 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -18,6 +18,7 @@
#include <linux/sched/debug.h>
#include <linux/sched/task_stack.h>
#include <linux/stacktrace.h>
+#include <linux/ftrace.h>
#ifdef CONFIG_FRAME_POINTER
@@ -63,7 +64,12 @@ static void notrace walk_stackframe(struct task_struct *task,
frame = (struct stackframe *)fp - 1;
sp = fp;
fp = frame->fp;
+#ifdef HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
+ pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
+ (unsigned long *)(fp - 8));
+#else
pc = frame->ra - 0x4;
+#endif
}
}