]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
riscv/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support
authorAlan Kao <alankao@andestech.com>
Tue, 13 Feb 2018 05:13:21 +0000 (13:13 +0800)
committerPalmer Dabbelt <palmer@sifive.com>
Tue, 3 Apr 2018 02:59:13 +0000 (19:59 -0700)
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>
arch/riscv/kernel/ftrace.c
arch/riscv/kernel/stacktrace.c

index 48b5353691c367bb06424ae402deacb3094659f4..1157b6b52d259fa79edf0d44f589022174aff18c 100644 (file)
@@ -151,7 +151,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
                return;
 
        err = ftrace_push_return_trace(old, self_addr, &trace.depth,
-                                      frame_pointer, NULL);
+                                      frame_pointer, parent);
        if (err == -EBUSY)
                return;
        *parent = return_hooker;
index 559aae78115448cdbf788a3328dbf7f831fa8309..a4b1d94371a0dbf6937bc0c8add512618ef1c5c6 100644 (file)
@@ -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
        }
 }