162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_ARM_FTRACE
362306a36Sopenharmony_ci#define _ASM_ARM_FTRACE
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#define HAVE_FUNCTION_GRAPH_FP_TEST
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
862306a36Sopenharmony_ci#define ARCH_SUPPORTS_FTRACE_OPS 1
962306a36Sopenharmony_ci#endif
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifdef CONFIG_FUNCTION_TRACER
1262306a36Sopenharmony_ci#define MCOUNT_ADDR		((unsigned long)(__gnu_mcount_nc))
1362306a36Sopenharmony_ci#define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1662306a36Sopenharmony_ciextern void __gnu_mcount_nc(void);
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#ifdef CONFIG_DYNAMIC_FTRACE
1962306a36Sopenharmony_cistruct dyn_arch_ftrace {
2062306a36Sopenharmony_ci#ifdef CONFIG_ARM_MODULE_PLTS
2162306a36Sopenharmony_ci	struct module *mod;
2262306a36Sopenharmony_ci#endif
2362306a36Sopenharmony_ci};
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_cistatic inline unsigned long ftrace_call_adjust(unsigned long addr)
2662306a36Sopenharmony_ci{
2762306a36Sopenharmony_ci	/* With Thumb-2, the recorded addresses have the lsb set */
2862306a36Sopenharmony_ci	return addr & ~1;
2962306a36Sopenharmony_ci}
3062306a36Sopenharmony_ci#endif
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci#endif
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#ifndef __ASSEMBLY__
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
3962306a36Sopenharmony_ci/*
4062306a36Sopenharmony_ci * return_address uses walk_stackframe to do it's work.  If both
4162306a36Sopenharmony_ci * CONFIG_FRAME_POINTER=y and CONFIG_ARM_UNWIND=y walk_stackframe uses unwind
4262306a36Sopenharmony_ci * information.  For this to work in the function tracer many functions would
4362306a36Sopenharmony_ci * have to be marked with __notrace.  So for now just depend on
4462306a36Sopenharmony_ci * !CONFIG_ARM_UNWIND.
4562306a36Sopenharmony_ci */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_civoid *return_address(unsigned int);
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#else
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_cistatic inline void *return_address(unsigned int level)
5262306a36Sopenharmony_ci{
5362306a36Sopenharmony_ci       return NULL;
5462306a36Sopenharmony_ci}
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#endif
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci#define ftrace_return_address(n) return_address(n)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistatic inline bool arch_syscall_match_sym_name(const char *sym,
6362306a36Sopenharmony_ci					       const char *name)
6462306a36Sopenharmony_ci{
6562306a36Sopenharmony_ci	if (!strcmp(sym, "sys_mmap2"))
6662306a36Sopenharmony_ci		sym = "sys_mmap_pgoff";
6762306a36Sopenharmony_ci	else if (!strcmp(sym, "sys_statfs64_wrapper"))
6862306a36Sopenharmony_ci		sym = "sys_statfs64";
6962306a36Sopenharmony_ci	else if (!strcmp(sym, "sys_fstatfs64_wrapper"))
7062306a36Sopenharmony_ci		sym = "sys_fstatfs64";
7162306a36Sopenharmony_ci	else if (!strcmp(sym, "sys_arm_fadvise64_64"))
7262306a36Sopenharmony_ci		sym = "sys_fadvise64_64";
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci	/* Ignore case since sym may start with "SyS" instead of "sys" */
7562306a36Sopenharmony_ci	return !strcasecmp(sym, name);
7662306a36Sopenharmony_ci}
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_civoid prepare_ftrace_return(unsigned long *parent, unsigned long self,
7962306a36Sopenharmony_ci			   unsigned long frame_pointer,
8062306a36Sopenharmony_ci			   unsigned long stack_pointer);
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci#endif /* ifndef __ASSEMBLY__ */
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#endif /* _ASM_ARM_FTRACE */
85