summaryrefslogtreecommitdiff
path: root/arch/csky/kernel/ftrace.c
diff options
context:
space:
mode:
authorGuo Ren <ren_guo@c-sky.com>2018-12-09 14:29:59 +0800
committerGuo Ren <ren_guo@c-sky.com>2018-12-31 23:16:46 +0800
commit230c77a5e92a29bf21e98ee35e22b0537f61c55b (patch)
tree78aa6ee2843c765edd87b1a9a824f50558c0888a /arch/csky/kernel/ftrace.c
parent17a68777bc883c8044c8b2d40aa112ff4e8a4fb1 (diff)
downloadlinux-sh-230c77a5e92a29bf21e98ee35e22b0537f61c55b.tar.gz
csky: basic ftrace supported
When gcc with -pg, it'll add _mcount stub in every function. We need implement the _mcount in kernel and ftrace depends on stackstrace. To do: call-graph, dynamic ftrace Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Diffstat (limited to 'arch/csky/kernel/ftrace.c')
-rw-r--r--arch/csky/kernel/ftrace.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
new file mode 100644
index 000000000000..ad054f7190f9
--- /dev/null
+++ b/arch/csky/kernel/ftrace.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
+
+#include <linux/ftrace.h>
+#include <linux/uaccess.h>
+
+extern void (*ftrace_trace_function)(unsigned long, unsigned long,
+ struct ftrace_ops*, struct pt_regs*);
+
+
+noinline void __naked ftrace_stub(unsigned long ip, unsigned long parent_ip,
+ struct ftrace_ops *op, struct pt_regs *regs)
+{
+ asm volatile ("\n");
+}
+
+noinline void csky_mcount(unsigned long from_pc, unsigned long self_pc)
+{
+ if (ftrace_trace_function != ftrace_stub)
+ ftrace_trace_function(self_pc, from_pc, NULL, NULL);
+}
+
+/* _mcount is defined in abi's mcount.S */
+EXPORT_SYMBOL(_mcount);