ftrace.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_ARM_FTRACE
  3. #define _ASM_ARM_FTRACE
  4. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  5. #define ARCH_SUPPORTS_FTRACE_OPS 1
  6. #endif
  7. #ifdef CONFIG_FUNCTION_TRACER
  8. #define MCOUNT_ADDR ((unsigned long)(__gnu_mcount_nc))
  9. #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
  10. #ifndef __ASSEMBLY__
  11. extern void mcount(void);
  12. extern void __gnu_mcount_nc(void);
  13. #ifdef CONFIG_DYNAMIC_FTRACE
  14. struct dyn_arch_ftrace {
  15. #ifdef CONFIG_OLD_MCOUNT
  16. bool old_mcount;
  17. #endif
  18. };
  19. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  20. {
  21. /* With Thumb-2, the recorded addresses have the lsb set */
  22. return addr & ~1;
  23. }
  24. extern void ftrace_caller_old(void);
  25. extern void ftrace_call_old(void);
  26. #endif
  27. #endif
  28. #endif
  29. #ifndef __ASSEMBLY__
  30. #if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
  31. /*
  32. * return_address uses walk_stackframe to do it's work. If both
  33. * CONFIG_FRAME_POINTER=y and CONFIG_ARM_UNWIND=y walk_stackframe uses unwind
  34. * information. For this to work in the function tracer many functions would
  35. * have to be marked with __notrace. So for now just depend on
  36. * !CONFIG_ARM_UNWIND.
  37. */
  38. void *return_address(unsigned int);
  39. #else
  40. static inline void *return_address(unsigned int level)
  41. {
  42. return NULL;
  43. }
  44. #endif
  45. #define ftrace_return_address(n) return_address(n)
  46. #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
  47. static inline bool arch_syscall_match_sym_name(const char *sym,
  48. const char *name)
  49. {
  50. if (!strcmp(sym, "sys_mmap2"))
  51. sym = "sys_mmap_pgoff";
  52. else if (!strcmp(sym, "sys_statfs64_wrapper"))
  53. sym = "sys_statfs64";
  54. else if (!strcmp(sym, "sys_fstatfs64_wrapper"))
  55. sym = "sys_fstatfs64";
  56. else if (!strcmp(sym, "sys_arm_fadvise64_64"))
  57. sym = "sys_fadvise64_64";
  58. /* Ignore case since sym may start with "SyS" instead of "sys" */
  59. return !strcasecmp(sym, name);
  60. }
  61. #endif /* ifndef __ASSEMBLY__ */
  62. #endif /* _ASM_ARM_FTRACE */