xref: /openbmc/linux/arch/arm64/include/asm/ftrace.h (revision 22d55f02)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * arch/arm64/include/asm/ftrace.h
4  *
5  * Copyright (C) 2013 Linaro Limited
6  * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
7  */
8 #ifndef __ASM_FTRACE_H
9 #define __ASM_FTRACE_H
10 
11 #include <asm/insn.h>
12 
13 #define HAVE_FUNCTION_GRAPH_FP_TEST
14 #define MCOUNT_ADDR		((unsigned long)_mcount)
15 #define MCOUNT_INSN_SIZE	AARCH64_INSN_SIZE
16 
17 #ifndef __ASSEMBLY__
18 #include <linux/compat.h>
19 
20 extern void _mcount(unsigned long);
21 extern void *return_address(unsigned int);
22 
23 struct dyn_arch_ftrace {
24 	/* No extra data needed for arm64 */
25 };
26 
27 extern unsigned long ftrace_graph_call;
28 
29 extern void return_to_handler(void);
30 
31 static inline unsigned long ftrace_call_adjust(unsigned long addr)
32 {
33 	/*
34 	 * addr is the address of the mcount call instruction.
35 	 * recordmcount does the necessary offset calculation.
36 	 */
37 	return addr;
38 }
39 
40 #define ftrace_return_address(n) return_address(n)
41 
42 /*
43  * Because AArch32 mode does not share the same syscall table with AArch64,
44  * tracing compat syscalls may result in reporting bogus syscalls or even
45  * hang-up, so just do not trace them.
46  * See kernel/trace/trace_syscalls.c
47  *
48  * x86 code says:
49  * If the user really wants these, then they should use the
50  * raw syscall tracepoints with filtering.
51  */
52 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
53 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
54 {
55 	return is_compat_task();
56 }
57 
58 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
59 
60 static inline bool arch_syscall_match_sym_name(const char *sym,
61 					       const char *name)
62 {
63 	/*
64 	 * Since all syscall functions have __arm64_ prefix, we must skip it.
65 	 * However, as we described above, we decided to ignore compat
66 	 * syscalls, so we don't care about __arm64_compat_ prefix here.
67 	 */
68 	return !strcmp(sym + 8, name);
69 }
70 #endif /* ifndef __ASSEMBLY__ */
71 
72 #endif /* __ASM_FTRACE_H */
73