mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-31 23:27:20 +00:00

Most architectures use pt_regs within ftrace_regs making a lot of the accessor functions just calls to the pt_regs internally. Instead of duplication this effort, use a HAVE_ARCH_FTRACE_REGS for architectures that have their own ftrace_regs that is not based on pt_regs and will define all the accessor functions, and for the architectures that just use pt_regs, it will leave it undefined, and the default accessor functions will be used. Note, this will also make it easier to add new accessor functions to ftrace_regs as it will mean having to touch less architectures. Cc: <linux-arch@vger.kernel.org> Cc: "x86@kernel.org" <x86@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: Naveen N Rao <naveen@kernel.org> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/20241010202114.2289f6fd@gandalf.local.home Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Acked-by: Heiko Carstens <hca@linux.ibm.com> # s390 Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Michael Ellerman <mpe@ellerman.id.au> # powerpc Suggested-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
103 lines
2.4 KiB
C
103 lines
2.4 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
|
|
|
|
#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 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;
|
|
|
|
#include <linux/ftrace_regs.h>
|
|
|
|
static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
|
|
{
|
|
return &arch_ftrace_regs(fregs)->regs;
|
|
}
|
|
|
|
static __always_inline void
|
|
ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, unsigned long ip)
|
|
{
|
|
instruction_pointer_set(&arch_ftrace_regs(fregs)->regs, ip);
|
|
}
|
|
|
|
#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);
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
|
|
static inline void
|
|
__arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
|
|
{
|
|
regs->regs[13] = addr; /* t1 */
|
|
}
|
|
|
|
#define arch_ftrace_set_direct_caller(fregs, addr) \
|
|
__arch_ftrace_set_direct_caller(&arch_ftrace_regs(fregs)->regs, addr)
|
|
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
|
|
|
|
#endif
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* CONFIG_FUNCTION_TRACER */
|
|
|
|
#ifndef __ASSEMBLY__
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
struct fgraph_ret_regs {
|
|
/* a0 - a1 */
|
|
unsigned long regs[2];
|
|
|
|
unsigned long fp;
|
|
unsigned long __unused;
|
|
};
|
|
|
|
static inline unsigned long fgraph_ret_regs_return_value(struct fgraph_ret_regs *ret_regs)
|
|
{
|
|
return ret_regs->regs[0];
|
|
}
|
|
|
|
static inline unsigned long fgraph_ret_regs_frame_pointer(struct fgraph_ret_regs *ret_regs)
|
|
{
|
|
return ret_regs->fp;
|
|
}
|
|
#endif /* ifdef CONFIG_FUNCTION_GRAPH_TRACER */
|
|
#endif
|
|
|
|
#endif /* _ASM_LOONGARCH_FTRACE_H */
|