blob: c38a66661576bf7f800de5860b16bd8bae02ccf0 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
H. Peter Anvin1965aae2008-10-22 22:26:29 -07002#ifndef _ASM_X86_FTRACE_H
3#define _ASM_X86_FTRACE_H
Abhishek Sagar395a59d2008-06-21 23:47:27 +05304
Ingo Molnar4944dd62008-10-27 10:50:54 +01005#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedt (VMware)562e14f2019-05-09 15:32:05 -04006#ifndef CC_USING_FENTRY
7# error Compiler does not support fentry?
Steven Rostedtd57c5d52011-02-09 13:32:18 -05008#endif
Steven Rostedt (VMware)562e14f2019-05-09 15:32:05 -04009# define MCOUNT_ADDR ((unsigned long)(__fentry__))
Abhishek Sagar395a59d2008-06-21 23:47:27 +053010#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
11
Steven Rostedt28fb5df2011-08-10 22:00:55 -040012#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -040013#define ARCH_SUPPORTS_FTRACE_OPS 1
Steven Rostedt08f6fba2012-04-30 16:20:23 -040014#endif
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -040015
Josh Poimboeuf471bd102016-08-19 06:53:00 -050016#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
17
Abhishek Sagar395a59d2008-06-21 23:47:27 +053018#ifndef __ASSEMBLY__
Steven Rostedta192cd02012-05-30 13:26:37 -040019extern atomic_t modifying_ftrace_code;
Steven Rostedtd57c5d52011-02-09 13:32:18 -050020extern void __fentry__(void);
Steven Rostedt68bf21a2008-08-14 15:45:08 -040021
22static inline unsigned long ftrace_call_adjust(unsigned long addr)
23{
24 /*
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020025 * addr is the address of the mcount call instruction.
26 * recordmcount does the necessary offset calculation.
Steven Rostedt68bf21a2008-08-14 15:45:08 -040027 */
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020028 return addr;
Steven Rostedt68bf21a2008-08-14 15:45:08 -040029}
Steven Rostedt31e88902008-11-14 16:21:19 -080030
31#ifdef CONFIG_DYNAMIC_FTRACE
32
33struct dyn_arch_ftrace {
34 /* No extra data needed for x86 */
35};
36
Steven Rostedt08d636b2011-08-16 09:57:10 -040037int ftrace_int3_handler(struct pt_regs *regs);
38
Steven Rostedt (Red Hat)1026ff92014-07-11 23:23:53 -040039#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
40
Steven Rostedt31e88902008-11-14 16:21:19 -080041#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedta26a2a22008-10-31 00:03:22 -040042#endif /* __ASSEMBLY__ */
Ingo Molnar4944dd62008-10-27 10:50:54 +010043#endif /* CONFIG_FUNCTION_TRACER */
Abhishek Sagar395a59d2008-06-21 23:47:27 +053044
Steven Rostedtf431b632013-02-12 16:18:59 -050045
Steven Rostedt (VMware)1c758a22018-04-17 17:41:28 -040046#ifndef __ASSEMBLY__
47
48#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
49static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
50{
51 /*
52 * Compare the symbol name with the system call name. Skip the
53 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
54 */
55 return !strcmp(sym + 3, name + 3) ||
56 (!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
57 (!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
58}
59
60#ifndef COMPILE_OFFSETS
Steven Rostedtf431b632013-02-12 16:18:59 -050061
62#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
Deepa Dinamani0d553032018-03-13 21:03:25 -070063#include <linux/compat.h>
Steven Rostedtf431b632013-02-12 16:18:59 -050064
65/*
66 * Because ia32 syscalls do not map to x86_64 syscall numbers
67 * this screws up the trace output when tracing a ia32 task.
68 * Instead of reporting bogus syscalls, just do not trace them.
69 *
Adam Buchbinder6a6256f2016-02-23 15:34:30 -080070 * If the user really wants these, then they should use the
Steven Rostedtf431b632013-02-12 16:18:59 -050071 * raw syscall tracepoints with filtering.
72 */
73#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
74static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
75{
Dmitry Safonova8464462018-10-12 14:42:52 +010076 return in_32bit_syscall();
Steven Rostedtf431b632013-02-12 16:18:59 -050077}
78#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
Steven Rostedt (VMware)1c758a22018-04-17 17:41:28 -040079#endif /* !COMPILE_OFFSETS */
80#endif /* !__ASSEMBLY__ */
Steven Rostedtf431b632013-02-12 16:18:59 -050081
H. Peter Anvin1965aae2008-10-22 22:26:29 -070082#endif /* _ASM_X86_FTRACE_H */