Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_FTRACE_H
3#define _ASM_X86_FTRACE_H
4
5#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
11#endif
12#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
13
14#ifdef CONFIG_DYNAMIC_FTRACE
15#define ARCH_SUPPORTS_FTRACE_OPS 1
16#endif
17
18#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
19
20#ifndef __ASSEMBLY__
21extern void mcount(void);
22extern atomic_t modifying_ftrace_code;
23extern void __fentry__(void);
24
25static inline unsigned long ftrace_call_adjust(unsigned long addr)
26{
27 /*
28 * addr is the address of the mcount call instruction.
29 * recordmcount does the necessary offset calculation.
30 */
31 return addr;
32}
33
34#ifdef CONFIG_DYNAMIC_FTRACE
35
36struct dyn_arch_ftrace {
37 /* No extra data needed for x86 */
38};
39
40int ftrace_int3_handler(struct pt_regs *regs);
41
42#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
43
44#endif /* CONFIG_DYNAMIC_FTRACE */
45#endif /* __ASSEMBLY__ */
46#endif /* CONFIG_FUNCTION_TRACER */
47
48
49#ifndef __ASSEMBLY__
50
51#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
52static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
53{
54 /*
55 * Compare the symbol name with the system call name. Skip the
56 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
57 */
58 return !strcmp(sym + 3, name + 3) ||
59 (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
60 (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
61}
62
63#ifndef COMPILE_OFFSETS
64
65#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
66#include <asm/compat.h>
67
68/*
69 * Because ia32 syscalls do not map to x86_64 syscall numbers
70 * this screws up the trace output when tracing a ia32 task.
71 * Instead of reporting bogus syscalls, just do not trace them.
72 *
73 * If the user really wants these, then they should use the
74 * raw syscall tracepoints with filtering.
75 */
76#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
77static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
78{
79 if (in_compat_syscall())
80 return true;
81 return false;
82}
83#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
84#endif /* !COMPILE_OFFSETS */
85#endif /* !__ASSEMBLY__ */
86
87#endif /* _ASM_X86_FTRACE_H */
1#ifndef _ASM_X86_FTRACE_H
2#define _ASM_X86_FTRACE_H
3
4#ifdef __ASSEMBLY__
5
6 .macro MCOUNT_SAVE_FRAME
7 /* taken from glibc */
8 subq $0x38, %rsp
9 movq %rax, (%rsp)
10 movq %rcx, 8(%rsp)
11 movq %rdx, 16(%rsp)
12 movq %rsi, 24(%rsp)
13 movq %rdi, 32(%rsp)
14 movq %r8, 40(%rsp)
15 movq %r9, 48(%rsp)
16 .endm
17
18 .macro MCOUNT_RESTORE_FRAME
19 movq 48(%rsp), %r9
20 movq 40(%rsp), %r8
21 movq 32(%rsp), %rdi
22 movq 24(%rsp), %rsi
23 movq 16(%rsp), %rdx
24 movq 8(%rsp), %rcx
25 movq (%rsp), %rax
26 addq $0x38, %rsp
27 .endm
28
29#endif
30
31#ifdef CONFIG_FUNCTION_TRACER
32#define MCOUNT_ADDR ((long)(mcount))
33#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
34
35#ifndef __ASSEMBLY__
36extern void mcount(void);
37
38static inline unsigned long ftrace_call_adjust(unsigned long addr)
39{
40 /*
41 * addr is the address of the mcount call instruction.
42 * recordmcount does the necessary offset calculation.
43 */
44 return addr;
45}
46
47#ifdef CONFIG_DYNAMIC_FTRACE
48
49struct dyn_arch_ftrace {
50 /* No extra data needed for x86 */
51};
52
53#endif /* CONFIG_DYNAMIC_FTRACE */
54#endif /* __ASSEMBLY__ */
55#endif /* CONFIG_FUNCTION_TRACER */
56
57#endif /* _ASM_X86_FTRACE_H */