0001
0002 #ifndef _ASM_X86_FTRACE_H
0003 #define _ASM_X86_FTRACE_H
0004
0005 #ifdef CONFIG_FUNCTION_TRACER
0006 #ifndef CC_USING_FENTRY
0007 # error Compiler does not support fentry?
0008 #endif
0009 # define MCOUNT_ADDR ((unsigned long)(__fentry__))
0010 #define MCOUNT_INSN_SIZE 5
0011
0012
0013 #ifdef CONFIG_HAVE_FENTRY
0014 # include <asm/ibt.h>
0015
0016 # define FTRACE_MCOUNT_MAX_OFFSET ENDBR_INSN_SIZE
0017 #endif
0018
0019 #ifdef CONFIG_DYNAMIC_FTRACE
0020 #define ARCH_SUPPORTS_FTRACE_OPS 1
0021 #endif
0022
0023 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
0024
0025 #ifndef __ASSEMBLY__
0026 extern atomic_t modifying_ftrace_code;
0027 extern void __fentry__(void);
0028
0029 static inline unsigned long ftrace_call_adjust(unsigned long addr)
0030 {
0031
0032
0033
0034
0035 return addr;
0036 }
0037
0038
0039
0040
0041
0042
0043
0044
0045 static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
0046 {
0047
0048 regs->orig_ax = addr;
0049 }
0050
0051 #ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
0052 struct ftrace_regs {
0053 struct pt_regs regs;
0054 };
0055
0056 static __always_inline struct pt_regs *
0057 arch_ftrace_get_regs(struct ftrace_regs *fregs)
0058 {
0059
0060 if (!fregs->regs.cs)
0061 return NULL;
0062 return &fregs->regs;
0063 }
0064
0065 #define ftrace_instruction_pointer_set(fregs, _ip) \
0066 do { (fregs)->regs.ip = (_ip); } while (0)
0067
0068 struct ftrace_ops;
0069 #define ftrace_graph_func ftrace_graph_func
0070 void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
0071 struct ftrace_ops *op, struct ftrace_regs *fregs);
0072 #else
0073 #define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
0074 #endif
0075
0076 #ifdef CONFIG_DYNAMIC_FTRACE
0077
0078 struct dyn_arch_ftrace {
0079
0080 };
0081
0082 #endif
0083 #endif
0084 #endif
0085
0086
0087 #ifndef __ASSEMBLY__
0088
0089 #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
0090 extern void set_ftrace_ops_ro(void);
0091 #else
0092 static inline void set_ftrace_ops_ro(void) { }
0093 #endif
0094
0095 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
0096 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
0097 {
0098
0099
0100
0101
0102 return !strcmp(sym + 3, name + 3) ||
0103 (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
0104 (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
0105 (!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
0106 }
0107
0108 #ifndef COMPILE_OFFSETS
0109
0110 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
0111 #include <linux/compat.h>
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
0122 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
0123 {
0124 return in_32bit_syscall();
0125 }
0126 #endif
0127 #endif
0128 #endif
0129
0130 #endif