mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-22 17:52:09 +00:00
This patch implements ftrace trampolines through plt entry. Tested by forcing ftrace_make_call() to use the module PLT, and then loading up a module after setting up ftrace with: | echo ":mod:<module-name>" > set_ftrace_filter; | echo function > current_tracer; | modprobe <module-name> Since FTRACE_ADDR/FTRACE_REGS_ADDR is only defined when CONFIG_DYNAMIC_ FTRACE is selected, we wrap their usage in module_init_ftrace_plt() with ifdeffery rather than using IS_ENABLED(). Signed-off-by: Qing Zhang <zhangqing@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2022 Loongson Technology Corporation Limited
|
|
*/
|
|
|
|
#ifndef _ASM_LOONGARCH_FTRACE_H
|
|
#define _ASM_LOONGARCH_FTRACE_H
|
|
|
|
#define FTRACE_PLT_IDX 0
|
|
#define FTRACE_REGS_PLT_IDX 1
|
|
#define NR_FTRACE_PLTS 2
|
|
|
|
#define GRAPH_FAKE_OFFSET (sizeof(struct pt_regs) - offsetof(struct pt_regs, regs[1]))
|
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
|
|
|
#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifndef CONFIG_DYNAMIC_FTRACE
|
|
|
|
#define mcount _mcount
|
|
extern void _mcount(void);
|
|
extern void prepare_ftrace_return(unsigned long self_addr, unsigned long callsite_sp, unsigned long old);
|
|
|
|
#else
|
|
|
|
struct dyn_ftrace;
|
|
struct dyn_arch_ftrace { };
|
|
|
|
#define ARCH_SUPPORTS_FTRACE_OPS 1
|
|
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
|
|
|
|
#define ftrace_init_nop ftrace_init_nop
|
|
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
|
|
|
|
static inline unsigned long ftrace_call_adjust(unsigned long addr)
|
|
{
|
|
return addr;
|
|
}
|
|
|
|
void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent);
|
|
|
|
#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 /* CONFIG_FUNCTION_TRACER */
|
|
|
|
#endif /* _ASM_LOONGARCH_FTRACE_H */
|