xref: /linux/arch/arm/include/asm/ftrace.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
24baa9922SRussell King #ifndef _ASM_ARM_FTRACE
34baa9922SRussell King #define _ASM_ARM_FTRACE
44baa9922SRussell King 
5953f534aSArd Biesheuvel #define HAVE_FUNCTION_GRAPH_FP_TEST
6953f534aSArd Biesheuvel 
7620176f3SAbel Vesa #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
8620176f3SAbel Vesa #define ARCH_SUPPORTS_FTRACE_OPS 1
9620176f3SAbel Vesa #endif
10620176f3SAbel Vesa 
11606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
123b6c223bSRabin Vincent #define MCOUNT_ADDR		((unsigned long)(__gnu_mcount_nc))
134baa9922SRussell King #define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
144baa9922SRussell King 
154baa9922SRussell King #ifndef __ASSEMBLY__
16181f817eSUwe Kleine-König extern void __gnu_mcount_nc(void);
173b6c223bSRabin Vincent 
183b6c223bSRabin Vincent #ifdef CONFIG_DYNAMIC_FTRACE
193b6c223bSRabin Vincent struct dyn_arch_ftrace {
2079f32b22SAlex Sverdlin #ifdef CONFIG_ARM_MODULE_PLTS
2179f32b22SAlex Sverdlin 	struct module *mod;
2279f32b22SAlex Sverdlin #endif
233b6c223bSRabin Vincent };
243b6c223bSRabin Vincent 
ftrace_call_adjust(unsigned long addr)253b6c223bSRabin Vincent static inline unsigned long ftrace_call_adjust(unsigned long addr)
263b6c223bSRabin Vincent {
2772dc43a9SRabin Vincent 	/* With Thumb-2, the recorded addresses have the lsb set */
2872dc43a9SRabin Vincent 	return addr & ~1;
293b6c223bSRabin Vincent }
303b6c223bSRabin Vincent #endif
313b6c223bSRabin Vincent 
324baa9922SRussell King #endif
334baa9922SRussell King 
344baa9922SRussell King #endif
354baa9922SRussell King 
364bf1fa5aSUwe Kleine-König #ifndef __ASSEMBLY__
374bf1fa5aSUwe Kleine-König 
386845d64dSArd Biesheuvel #if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
396845d64dSArd Biesheuvel /*
406845d64dSArd Biesheuvel  * return_address uses walk_stackframe to do it's work.  If both
416845d64dSArd Biesheuvel  * CONFIG_FRAME_POINTER=y and CONFIG_ARM_UNWIND=y walk_stackframe uses unwind
426845d64dSArd Biesheuvel  * information.  For this to work in the function tracer many functions would
436845d64dSArd Biesheuvel  * have to be marked with __notrace.  So for now just depend on
446845d64dSArd Biesheuvel  * !CONFIG_ARM_UNWIND.
456845d64dSArd Biesheuvel  */
466845d64dSArd Biesheuvel 
474bf1fa5aSUwe Kleine-König void *return_address(unsigned int);
484bf1fa5aSUwe Kleine-König 
496845d64dSArd Biesheuvel #else
506845d64dSArd Biesheuvel 
return_address(unsigned int level)516845d64dSArd Biesheuvel static inline void *return_address(unsigned int level)
526845d64dSArd Biesheuvel {
536845d64dSArd Biesheuvel        return NULL;
546845d64dSArd Biesheuvel }
556845d64dSArd Biesheuvel 
566845d64dSArd Biesheuvel #endif
576845d64dSArd Biesheuvel 
581712ef43SSteven Rostedt #define ftrace_return_address(n) return_address(n)
594bf1fa5aSUwe Kleine-König 
60270c8cf1SRabin Vincent #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
61270c8cf1SRabin Vincent 
arch_syscall_match_sym_name(const char * sym,const char * name)62270c8cf1SRabin Vincent static inline bool arch_syscall_match_sym_name(const char *sym,
63270c8cf1SRabin Vincent 					       const char *name)
64270c8cf1SRabin Vincent {
65270c8cf1SRabin Vincent 	if (!strcmp(sym, "sys_mmap2"))
66270c8cf1SRabin Vincent 		sym = "sys_mmap_pgoff";
67270c8cf1SRabin Vincent 	else if (!strcmp(sym, "sys_statfs64_wrapper"))
68270c8cf1SRabin Vincent 		sym = "sys_statfs64";
69270c8cf1SRabin Vincent 	else if (!strcmp(sym, "sys_fstatfs64_wrapper"))
70270c8cf1SRabin Vincent 		sym = "sys_fstatfs64";
71270c8cf1SRabin Vincent 	else if (!strcmp(sym, "sys_arm_fadvise64_64"))
72270c8cf1SRabin Vincent 		sym = "sys_fadvise64_64";
73270c8cf1SRabin Vincent 
74270c8cf1SRabin Vincent 	/* Ignore case since sym may start with "SyS" instead of "sys" */
75270c8cf1SRabin Vincent 	return !strcasecmp(sym, name);
76270c8cf1SRabin Vincent }
77270c8cf1SRabin Vincent 
78*ae1f8d79SArnd Bergmann void prepare_ftrace_return(unsigned long *parent, unsigned long self,
79*ae1f8d79SArnd Bergmann 			   unsigned long frame_pointer,
80*ae1f8d79SArnd Bergmann 			   unsigned long stack_pointer);
81*ae1f8d79SArnd Bergmann 
824bf1fa5aSUwe Kleine-König #endif /* ifndef __ASSEMBLY__ */
834bf1fa5aSUwe Kleine-König 
844baa9922SRussell King #endif /* _ASM_ARM_FTRACE */
85