1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_FTRACE_H
3 #define _ASM_X86_FTRACE_H
5 #ifdef CONFIG_FUNCTION_TRACER
6 #ifndef CC_USING_FENTRY
7 # error Compiler does not support fentry?
9 # define MCOUNT_ADDR ((unsigned long)(__fentry__))
10 #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
12 #ifdef CONFIG_DYNAMIC_FTRACE
13 #define ARCH_SUPPORTS_FTRACE_OPS 1
16 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
19 extern atomic_t modifying_ftrace_code
;
20 extern void __fentry__(void);
22 static inline unsigned long ftrace_call_adjust(unsigned long addr
)
25 * addr is the address of the mcount call instruction.
26 * recordmcount does the necessary offset calculation.
32 * When a ftrace registered caller is tracing a function that is
33 * also set by a register_ftrace_direct() call, it needs to be
34 * differentiated in the ftrace_caller trampoline. To do this, we
35 * place the direct caller in the ORIG_AX part of pt_regs. This
36 * tells the ftrace_caller that there's a direct caller.
38 static inline void arch_ftrace_set_direct_caller(struct pt_regs
*regs
, unsigned long addr
)
44 #ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
49 static __always_inline
struct pt_regs
*
50 arch_ftrace_get_regs(struct ftrace_regs
*fregs
)
52 /* Only when FL_SAVE_REGS is set, cs will be non zero */
58 #define ftrace_instruction_pointer_set(fregs, _ip) \
59 do { (fregs)->regs.ip = (_ip); } while (0)
62 #ifdef CONFIG_DYNAMIC_FTRACE
64 struct dyn_arch_ftrace
{
65 /* No extra data needed for x86 */
68 #define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
70 #endif /* CONFIG_DYNAMIC_FTRACE */
71 #endif /* __ASSEMBLY__ */
72 #endif /* CONFIG_FUNCTION_TRACER */
77 #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
78 extern void set_ftrace_ops_ro(void);
80 static inline void set_ftrace_ops_ro(void) { }
83 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
84 static inline bool arch_syscall_match_sym_name(const char *sym
, const char *name
)
87 * Compare the symbol name with the system call name. Skip the
88 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
90 return !strcmp(sym
+ 3, name
+ 3) ||
91 (!strncmp(sym
, "__x64_", 6) && !strcmp(sym
+ 9, name
+ 3)) ||
92 (!strncmp(sym
, "__ia32_", 7) && !strcmp(sym
+ 10, name
+ 3)) ||
93 (!strncmp(sym
, "__do_sys", 8) && !strcmp(sym
+ 8, name
+ 3));
96 #ifndef COMPILE_OFFSETS
98 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
99 #include <linux/compat.h>
102 * Because ia32 syscalls do not map to x86_64 syscall numbers
103 * this screws up the trace output when tracing a ia32 task.
104 * Instead of reporting bogus syscalls, just do not trace them.
106 * If the user really wants these, then they should use the
107 * raw syscall tracepoints with filtering.
109 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
110 static inline bool arch_trace_is_compat_syscall(struct pt_regs
*regs
)
112 return in_32bit_syscall();
114 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
115 #endif /* !COMPILE_OFFSETS */
116 #endif /* !__ASSEMBLY__ */
118 #endif /* _ASM_X86_FTRACE_H */