hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/ftrace.h
....@@ -3,12 +3,10 @@
33 #define _ASM_X86_FTRACE_H
44
55 #ifdef CONFIG_FUNCTION_TRACER
6
-#ifdef CC_USING_FENTRY
7
-# define MCOUNT_ADDR ((unsigned long)(__fentry__))
8
-#else
9
-# define MCOUNT_ADDR ((unsigned long)(mcount))
10
-# define HAVE_FUNCTION_GRAPH_FP_TEST
6
+#ifndef CC_USING_FENTRY
7
+# error Compiler does not support fentry?
118 #endif
9
+# define MCOUNT_ADDR ((unsigned long)(__fentry__))
1210 #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
1311
1412 #ifdef CONFIG_DYNAMIC_FTRACE
....@@ -18,7 +16,6 @@
1816 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
1917
2018 #ifndef __ASSEMBLY__
21
-extern void mcount(void);
2219 extern atomic_t modifying_ftrace_code;
2320 extern void __fentry__(void);
2421
....@@ -31,13 +28,24 @@
3128 return addr;
3229 }
3330
31
+/*
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.
37
+ */
38
+static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
39
+{
40
+ /* Emulate a call */
41
+ regs->orig_ax = addr;
42
+}
43
+
3444 #ifdef CONFIG_DYNAMIC_FTRACE
3545
3646 struct dyn_arch_ftrace {
3747 /* No extra data needed for x86 */
3848 };
39
-
40
-int ftrace_int3_handler(struct pt_regs *regs);
4149
4250 #define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
4351
....@@ -48,16 +56,23 @@
4856
4957 #ifndef __ASSEMBLY__
5058
59
+#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
60
+extern void set_ftrace_ops_ro(void);
61
+#else
62
+static inline void set_ftrace_ops_ro(void) { }
63
+#endif
64
+
5165 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
5266 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
5367 {
5468 /*
5569 * Compare the symbol name with the system call name. Skip the
56
- * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
70
+ * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
5771 */
5872 return !strcmp(sym + 3, name + 3) ||
5973 (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
60
- (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
74
+ (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
75
+ (!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
6176 }
6277
6378 #ifndef COMPILE_OFFSETS
....@@ -76,9 +91,7 @@
7691 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
7792 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
7893 {
79
- if (in_compat_syscall())
80
- return true;
81
- return false;
94
+ return in_32bit_syscall();
8295 }
8396 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
8497 #endif /* !COMPILE_OFFSETS */