18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_ARM_FTRACE 38c2ecf20Sopenharmony_ci#define _ASM_ARM_FTRACE 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS 68c2ecf20Sopenharmony_ci#define ARCH_SUPPORTS_FTRACE_OPS 1 78c2ecf20Sopenharmony_ci#endif 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifdef CONFIG_FUNCTION_TRACER 108c2ecf20Sopenharmony_ci#define MCOUNT_ADDR ((unsigned long)(__gnu_mcount_nc)) 118c2ecf20Sopenharmony_ci#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 148c2ecf20Sopenharmony_ciextern void __gnu_mcount_nc(void); 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#ifdef CONFIG_DYNAMIC_FTRACE 178c2ecf20Sopenharmony_cistruct dyn_arch_ftrace { 188c2ecf20Sopenharmony_ci#ifdef CONFIG_ARM_MODULE_PLTS 198c2ecf20Sopenharmony_ci struct module *mod; 208c2ecf20Sopenharmony_ci#endif 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistatic inline unsigned long ftrace_call_adjust(unsigned long addr) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci /* With Thumb-2, the recorded addresses have the lsb set */ 268c2ecf20Sopenharmony_ci return addr & ~1; 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci#endif 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#endif 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#endif 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * return_address uses walk_stackframe to do it's work. If both 398c2ecf20Sopenharmony_ci * CONFIG_FRAME_POINTER=y and CONFIG_ARM_UNWIND=y walk_stackframe uses unwind 408c2ecf20Sopenharmony_ci * information. For this to work in the function tracer many functions would 418c2ecf20Sopenharmony_ci * have to be marked with __notrace. So for now just depend on 428c2ecf20Sopenharmony_ci * !CONFIG_ARM_UNWIND. 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_civoid *return_address(unsigned int); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#else 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline void *return_address(unsigned int level) 508c2ecf20Sopenharmony_ci{ 518c2ecf20Sopenharmony_ci return NULL; 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#endif 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define ftrace_return_address(n) return_address(n) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic inline bool arch_syscall_match_sym_name(const char *sym, 618c2ecf20Sopenharmony_ci const char *name) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci if (!strcmp(sym, "sys_mmap2")) 648c2ecf20Sopenharmony_ci sym = "sys_mmap_pgoff"; 658c2ecf20Sopenharmony_ci else if (!strcmp(sym, "sys_statfs64_wrapper")) 668c2ecf20Sopenharmony_ci sym = "sys_statfs64"; 678c2ecf20Sopenharmony_ci else if (!strcmp(sym, "sys_fstatfs64_wrapper")) 688c2ecf20Sopenharmony_ci sym = "sys_fstatfs64"; 698c2ecf20Sopenharmony_ci else if (!strcmp(sym, "sys_arm_fadvise64_64")) 708c2ecf20Sopenharmony_ci sym = "sys_fadvise64_64"; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci /* Ignore case since sym may start with "SyS" instead of "sys" */ 738c2ecf20Sopenharmony_ci return !strcasecmp(sym, name); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#endif /* ifndef __ASSEMBLY__ */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#endif /* _ASM_ARM_FTRACE */ 79