mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
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>
This commit is contained in:
parent
8778ba2c8a
commit
ac7127e1cc
@ -89,6 +89,7 @@ config LOONGARCH
|
|||||||
select HAVE_DEBUG_STACKOVERFLOW
|
select HAVE_DEBUG_STACKOVERFLOW
|
||||||
select HAVE_DMA_CONTIGUOUS
|
select HAVE_DMA_CONTIGUOUS
|
||||||
select HAVE_DYNAMIC_FTRACE
|
select HAVE_DYNAMIC_FTRACE
|
||||||
|
select HAVE_DYNAMIC_FTRACE_WITH_ARGS
|
||||||
select HAVE_DYNAMIC_FTRACE_WITH_REGS
|
select HAVE_DYNAMIC_FTRACE_WITH_REGS
|
||||||
select HAVE_EBPF_JIT
|
select HAVE_EBPF_JIT
|
||||||
select HAVE_EXIT_THREAD
|
select HAVE_EXIT_THREAD
|
||||||
|
@ -37,6 +37,23 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent);
|
|||||||
|
|
||||||
#endif /* CONFIG_DYNAMIC_FTRACE */
|
#endif /* CONFIG_DYNAMIC_FTRACE */
|
||||||
|
|
||||||
|
#ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
|
||||||
|
struct ftrace_ops;
|
||||||
|
|
||||||
|
struct ftrace_regs {
|
||||||
|
struct pt_regs regs;
|
||||||
|
};
|
||||||
|
|
||||||
|
static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
|
||||||
|
{
|
||||||
|
return &fregs->regs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ftrace_graph_func ftrace_graph_func
|
||||||
|
void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
|
||||||
|
struct ftrace_ops *op, struct ftrace_regs *fregs);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
|
||||||
#endif /* CONFIG_FUNCTION_TRACER */
|
#endif /* CONFIG_FUNCTION_TRACER */
|
||||||
|
@ -139,6 +139,16 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent)
|
|||||||
*parent = return_hooker;
|
*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 *)®s->regs[1];
|
||||||
|
|
||||||
|
prepare_ftrace_return(ip, (unsigned long *)parent);
|
||||||
|
}
|
||||||
|
#else
|
||||||
static int ftrace_modify_graph_caller(bool enable)
|
static int ftrace_modify_graph_caller(bool enable)
|
||||||
{
|
{
|
||||||
u32 branch, nop;
|
u32 branch, nop;
|
||||||
@ -166,4 +176,5 @@ int ftrace_disable_ftrace_graph_caller(void)
|
|||||||
{
|
{
|
||||||
return ftrace_modify_graph_caller(false);
|
return ftrace_modify_graph_caller(false);
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS */
|
||||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||||
|
Loading…
Reference in New Issue
Block a user