WIP FPC-III support
[linux/fpc-iii.git] / arch / arm64 / include / asm / ftrace.h
blob91fa4baa1a936859a82a837a7a629624749582b2
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * arch/arm64/include/asm/ftrace.h
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
11 #include <asm/insn.h>
13 #define HAVE_FUNCTION_GRAPH_FP_TEST
15 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
16 #define ARCH_SUPPORTS_FTRACE_OPS 1
17 #else
18 #define MCOUNT_ADDR ((unsigned long)_mcount)
19 #endif
21 /* The BL at the callsite's adjusted rec->ip */
22 #define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE
24 #define FTRACE_PLT_IDX 0
25 #define FTRACE_REGS_PLT_IDX 1
26 #define NR_FTRACE_PLTS 2
29 * Currently, gcc tends to save the link register after the local variables
30 * on the stack. This causes the max stack tracer to report the function
31 * frame sizes for the wrong functions. By defining
32 * ARCH_FTRACE_SHIFT_STACK_TRACER, it will tell the stack tracer to expect
33 * to find the return address on the stack after the local variables have
34 * been set up.
36 * Note, this may change in the future, and we will need to deal with that
37 * if it were to happen.
39 #define ARCH_FTRACE_SHIFT_STACK_TRACER 1
41 #ifndef __ASSEMBLY__
42 #include <linux/compat.h>
44 extern void _mcount(unsigned long);
45 extern void *return_address(unsigned int);
47 struct dyn_arch_ftrace {
48 /* No extra data needed for arm64 */
51 extern unsigned long ftrace_graph_call;
53 extern void return_to_handler(void);
55 static inline unsigned long ftrace_call_adjust(unsigned long addr)
58 * Adjust addr to point at the BL in the callsite.
59 * See ftrace_init_nop() for the callsite sequence.
61 if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
62 return addr + AARCH64_INSN_SIZE;
64 * addr is the address of the mcount call instruction.
65 * recordmcount does the necessary offset calculation.
67 return addr;
70 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
71 struct dyn_ftrace;
72 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
73 #define ftrace_init_nop ftrace_init_nop
74 #endif
76 #define ftrace_return_address(n) return_address(n)
79 * Because AArch32 mode does not share the same syscall table with AArch64,
80 * tracing compat syscalls may result in reporting bogus syscalls or even
81 * hang-up, so just do not trace them.
82 * See kernel/trace/trace_syscalls.c
84 * x86 code says:
85 * If the user really wants these, then they should use the
86 * raw syscall tracepoints with filtering.
88 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
89 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
91 return is_compat_task();
94 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
96 static inline bool arch_syscall_match_sym_name(const char *sym,
97 const char *name)
100 * Since all syscall functions have __arm64_ prefix, we must skip it.
101 * However, as we described above, we decided to ignore compat
102 * syscalls, so we don't care about __arm64_compat_ prefix here.
104 return !strcmp(sym + 8, name);
106 #endif /* ifndef __ASSEMBLY__ */
108 #endif /* __ASM_FTRACE_H */