1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2819e50e2SAKASHI Takahiro /* 3819e50e2SAKASHI Takahiro * arch/arm64/include/asm/ftrace.h 4819e50e2SAKASHI Takahiro * 5819e50e2SAKASHI Takahiro * Copyright (C) 2013 Linaro Limited 6819e50e2SAKASHI Takahiro * Author: AKASHI Takahiro <takahiro.akashi@linaro.org> 7819e50e2SAKASHI Takahiro */ 8819e50e2SAKASHI Takahiro #ifndef __ASM_FTRACE_H 9819e50e2SAKASHI Takahiro #define __ASM_FTRACE_H 10819e50e2SAKASHI Takahiro 11819e50e2SAKASHI Takahiro #include <asm/insn.h> 12819e50e2SAKASHI Takahiro 135c176affSMark Rutland #define HAVE_FUNCTION_GRAPH_FP_TEST 14819e50e2SAKASHI Takahiro #define MCOUNT_ADDR ((unsigned long)_mcount) 15819e50e2SAKASHI Takahiro #define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE 16819e50e2SAKASHI Takahiro 17*f7edb451SSteven Rostedt (VMware) /* 18*f7edb451SSteven Rostedt (VMware) * Currently, gcc tends to save the link register after the local variables 19*f7edb451SSteven Rostedt (VMware) * on the stack. This causes the max stack tracer to report the function 20*f7edb451SSteven Rostedt (VMware) * frame sizes for the wrong functions. By defining 21*f7edb451SSteven Rostedt (VMware) * ARCH_FTRACE_SHIFT_STACK_TRACER, it will tell the stack tracer to expect 22*f7edb451SSteven Rostedt (VMware) * to find the return address on the stack after the local variables have 23*f7edb451SSteven Rostedt (VMware) * been set up. 24*f7edb451SSteven Rostedt (VMware) * 25*f7edb451SSteven Rostedt (VMware) * Note, this may change in the future, and we will need to deal with that 26*f7edb451SSteven Rostedt (VMware) * if it were to happen. 27*f7edb451SSteven Rostedt (VMware) */ 28*f7edb451SSteven Rostedt (VMware) #define ARCH_FTRACE_SHIFT_STACK_TRACER 1 29*f7edb451SSteven Rostedt (VMware) 30819e50e2SAKASHI Takahiro #ifndef __ASSEMBLY__ 31055b1212SAKASHI Takahiro #include <linux/compat.h> 32055b1212SAKASHI Takahiro 33819e50e2SAKASHI Takahiro extern void _mcount(unsigned long); 343711784eSAKASHI Takahiro extern void *return_address(unsigned int); 35bd7d38dbSAKASHI Takahiro 36bd7d38dbSAKASHI Takahiro struct dyn_arch_ftrace { 37bd7d38dbSAKASHI Takahiro /* No extra data needed for arm64 */ 38bd7d38dbSAKASHI Takahiro }; 39bd7d38dbSAKASHI Takahiro 40bd7d38dbSAKASHI Takahiro extern unsigned long ftrace_graph_call; 41bd7d38dbSAKASHI Takahiro 4220380bb3SAKASHI Takahiro extern void return_to_handler(void); 4320380bb3SAKASHI Takahiro 44bd7d38dbSAKASHI Takahiro static inline unsigned long ftrace_call_adjust(unsigned long addr) 45bd7d38dbSAKASHI Takahiro { 46bd7d38dbSAKASHI Takahiro /* 47bd7d38dbSAKASHI Takahiro * addr is the address of the mcount call instruction. 48bd7d38dbSAKASHI Takahiro * recordmcount does the necessary offset calculation. 49bd7d38dbSAKASHI Takahiro */ 50bd7d38dbSAKASHI Takahiro return addr; 51bd7d38dbSAKASHI Takahiro } 523711784eSAKASHI Takahiro 533711784eSAKASHI Takahiro #define ftrace_return_address(n) return_address(n) 54055b1212SAKASHI Takahiro 55055b1212SAKASHI Takahiro /* 56055b1212SAKASHI Takahiro * Because AArch32 mode does not share the same syscall table with AArch64, 57055b1212SAKASHI Takahiro * tracing compat syscalls may result in reporting bogus syscalls or even 58055b1212SAKASHI Takahiro * hang-up, so just do not trace them. 59055b1212SAKASHI Takahiro * See kernel/trace/trace_syscalls.c 60055b1212SAKASHI Takahiro * 61055b1212SAKASHI Takahiro * x86 code says: 62ef769e32SAdam Buchbinder * If the user really wants these, then they should use the 63055b1212SAKASHI Takahiro * raw syscall tracepoints with filtering. 64055b1212SAKASHI Takahiro */ 65055b1212SAKASHI Takahiro #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 66055b1212SAKASHI Takahiro static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) 67055b1212SAKASHI Takahiro { 68055b1212SAKASHI Takahiro return is_compat_task(); 69055b1212SAKASHI Takahiro } 70874bfc6eSMasami Hiramatsu 71874bfc6eSMasami Hiramatsu #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME 72874bfc6eSMasami Hiramatsu 73874bfc6eSMasami Hiramatsu static inline bool arch_syscall_match_sym_name(const char *sym, 74874bfc6eSMasami Hiramatsu const char *name) 75874bfc6eSMasami Hiramatsu { 76874bfc6eSMasami Hiramatsu /* 77874bfc6eSMasami Hiramatsu * Since all syscall functions have __arm64_ prefix, we must skip it. 78874bfc6eSMasami Hiramatsu * However, as we described above, we decided to ignore compat 79874bfc6eSMasami Hiramatsu * syscalls, so we don't care about __arm64_compat_ prefix here. 80874bfc6eSMasami Hiramatsu */ 81874bfc6eSMasami Hiramatsu return !strcmp(sym + 8, name); 82874bfc6eSMasami Hiramatsu } 833711784eSAKASHI Takahiro #endif /* ifndef __ASSEMBLY__ */ 84819e50e2SAKASHI Takahiro 85819e50e2SAKASHI Takahiro #endif /* __ASM_FTRACE_H */ 86