1
2#ifndef _ASM_X86_FTRACE_H
3#define _ASM_X86_FTRACE_H
4
5#ifdef CONFIG_FUNCTION_TRACER
6#ifndef CC_USING_FENTRY
7# error Compiler does not support fentry?
8#endif
9# define MCOUNT_ADDR ((unsigned long)(__fentry__))
10#define MCOUNT_INSN_SIZE 5
11
12#ifdef CONFIG_DYNAMIC_FTRACE
13#define ARCH_SUPPORTS_FTRACE_OPS 1
14#endif
15
16#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
17
18#ifndef __ASSEMBLY__
19extern atomic_t modifying_ftrace_code;
20extern void __fentry__(void);
21
22static inline unsigned long ftrace_call_adjust(unsigned long addr)
23{
24
25
26
27
28 return addr;
29}
30
31
32
33
34
35
36
37
38static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
39{
40
41 regs->orig_ax = addr;
42}
43
44#ifdef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
45struct ftrace_regs {
46 struct pt_regs regs;
47};
48
49static __always_inline struct pt_regs *
50arch_ftrace_get_regs(struct ftrace_regs *fregs)
51{
52
53 if (!fregs->regs.cs)
54 return NULL;
55 return &fregs->regs;
56}
57
58#define ftrace_instruction_pointer_set(fregs, _ip) \
59 do { (fregs)->regs.ip = (_ip); } while (0)
60#endif
61
62#ifdef CONFIG_DYNAMIC_FTRACE
63
64struct dyn_arch_ftrace {
65
66};
67
68#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
69
70#endif
71#endif
72#endif
73
74
75#ifndef __ASSEMBLY__
76
77#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
78extern void set_ftrace_ops_ro(void);
79#else
80static inline void set_ftrace_ops_ro(void) { }
81#endif
82
83#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
84static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
85{
86
87
88
89
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));
94}
95
96#ifndef COMPILE_OFFSETS
97
98#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
99#include <linux/compat.h>
100
101
102
103
104
105
106
107
108
109#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
110static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
111{
112 return in_32bit_syscall();
113}
114#endif
115#endif
116#endif
117
118#endif
119