]> git.ipfire.org Git - thirdparty/linux.git/blame - arch/x86/include/asm/ftrace.h
Merge tag 'io_uring-5.7-2020-05-22' of git://git.kernel.dk/linux-block
[thirdparty/linux.git] / arch / x86 / include / asm / ftrace.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1965aae3
PA
2#ifndef _ASM_X86_FTRACE_H
3#define _ASM_X86_FTRACE_H
395a59d0 4
606576ce 5#ifdef CONFIG_FUNCTION_TRACER
562e14f7
SRV
6#ifndef CC_USING_FENTRY
7# error Compiler does not support fentry?
d57c5d51 8#endif
562e14f7 9# define MCOUNT_ADDR ((unsigned long)(__fentry__))
395a59d0
AS
10#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
11
28fb5dfa 12#ifdef CONFIG_DYNAMIC_FTRACE
2f5f6ad9 13#define ARCH_SUPPORTS_FTRACE_OPS 1
08f6fba5 14#endif
2f5f6ad9 15
471bd10f
JP
16#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
17
395a59d0 18#ifndef __ASSEMBLY__
a192cd04 19extern atomic_t modifying_ftrace_code;
d57c5d51 20extern void __fentry__(void);
68bf21aa
SR
21
22static inline unsigned long ftrace_call_adjust(unsigned long addr)
23{
24 /*
521ccb5c
MS
25 * addr is the address of the mcount call instruction.
26 * recordmcount does the necessary offset calculation.
68bf21aa 27 */
521ccb5c 28 return addr;
68bf21aa 29}
31e88909 30
562955fe
SRV
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 */
38static 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
31e88909
SR
44#ifdef CONFIG_DYNAMIC_FTRACE
45
46struct dyn_arch_ftrace {
47 /* No extra data needed for x86 */
48};
49
1026ff9b
SRRH
50#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
51
31e88909 52#endif /* CONFIG_DYNAMIC_FTRACE */
a26a2a27 53#endif /* __ASSEMBLY__ */
606576ce 54#endif /* CONFIG_FUNCTION_TRACER */
395a59d0 55
f431b634 56
1c758a22
SRV
57#ifndef __ASSEMBLY__
58
59566b0b
SRV
59#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
60extern void set_ftrace_ops_ro(void);
61#else
62static inline void set_ftrace_ops_ro(void) { }
63#endif
64
1c758a22
SRV
65#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
66static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
67{
68 /*
69 * Compare the symbol name with the system call name. Skip the
fdc63ff0 70 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
1c758a22
SRV
71 */
72 return !strcmp(sym + 3, name + 3) ||
73 (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
fdc63ff0
KK
74 (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
75 (!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
1c758a22
SRV
76}
77
78#ifndef COMPILE_OFFSETS
f431b634
SR
79
80#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
0d55303c 81#include <linux/compat.h>
f431b634
SR
82
83/*
84 * Because ia32 syscalls do not map to x86_64 syscall numbers
85 * this screws up the trace output when tracing a ia32 task.
86 * Instead of reporting bogus syscalls, just do not trace them.
87 *
6a6256f9 88 * If the user really wants these, then they should use the
f431b634
SR
89 * raw syscall tracepoints with filtering.
90 */
91#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
92static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
93{
a846446b 94 return in_32bit_syscall();
f431b634
SR
95}
96#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
1c758a22
SRV
97#endif /* !COMPILE_OFFSETS */
98#endif /* !__ASSEMBLY__ */
f431b634 99
1965aae3 100#endif /* _ASM_X86_FTRACE_H */