aboutsummaryrefslogtreecommitdiff
path: root/arch/loongarch/kernel/ftrace_dyn.c
diff options
context:
space:
mode:
authorGravatar Qing Zhang <zhangqing@loongson.cn> 2022-12-10 22:40:16 +0800
committerGravatar Huacai Chen <chenhuacai@loongson.cn> 2022-12-14 08:41:53 +0800
commitac7127e1cc65aeb578998c992a05dbc80fa18f0f (patch)
tree3cc8f20d43cf9a78558dfe799d3b4fe1bcad6fec /arch/loongarch/kernel/ftrace_dyn.c
parentLoongArch/ftrace: Add HAVE_DYNAMIC_FTRACE_WITH_REGS support (diff)
downloadlinux-ac7127e1cc65aeb578998c992a05dbc80fa18f0f.tar.gz
linux-ac7127e1cc65aeb578998c992a05dbc80fa18f0f.tar.bz2
linux-ac7127e1cc65aeb578998c992a05dbc80fa18f0f.zip
LoongArch/ftrace: Add HAVE_DYNAMIC_FTRACE_WITH_ARGS support
Allow for arguments to be passed in to ftrace_regs by default. If this is set, then arguments and stack can be found from the pt_regs. 1. HAVE_DYNAMIC_FTRACE_WITH_ARGS don't need special hook for graph tracer entry point, but instead we can use graph_ops::func function to install the return_hooker. 2. Livepatch requires this option in the future. Signed-off-by: Qing Zhang <zhangqing@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel/ftrace_dyn.c')
-rw-r--r--arch/loongarch/kernel/ftrace_dyn.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/ftrace_dyn.c b/arch/loongarch/kernel/ftrace_dyn.c
index d6f30918f94f..439ba829b9fd 100644
--- a/arch/loongarch/kernel/ftrace_dyn.c
+++ b/arch/loongarch/kernel/ftrace_dyn.c
@@ -139,6 +139,16 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent)
*parent = return_hooker;
}
+#ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
+void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
+ struct ftrace_ops *op, struct ftrace_regs *fregs)
+{
+ struct pt_regs *regs = &fregs->regs;
+ unsigned long *parent = (unsigned long *)&regs->regs[1];
+
+ prepare_ftrace_return(ip, (unsigned long *)parent);
+}
+#else
static int ftrace_modify_graph_caller(bool enable)
{
u32 branch, nop;
@@ -166,4 +176,5 @@ int ftrace_disable_ftrace_graph_caller(void)
{
return ftrace_modify_graph_caller(false);
}
+#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */