ftrace.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_POWERPC_FTRACE
  3. #define _ASM_POWERPC_FTRACE
  4. #include <asm/types.h>
  5. #ifdef CONFIG_FUNCTION_TRACER
  6. #define MCOUNT_ADDR ((unsigned long)(_mcount))
  7. #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
  8. #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
  9. #ifndef __ASSEMBLY__
  10. extern void _mcount(void);
  11. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  12. {
  13. /* relocation of mcount call site is the same as the address */
  14. return addr;
  15. }
  16. unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
  17. unsigned long sp);
  18. struct dyn_arch_ftrace {
  19. struct module *mod;
  20. };
  21. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
  22. struct ftrace_regs {
  23. struct pt_regs regs;
  24. };
  25. static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
  26. {
  27. /* We clear regs.msr in ftrace_call */
  28. return fregs->regs.msr ? &fregs->regs : NULL;
  29. }
  30. static __always_inline void ftrace_instruction_pointer_set(struct ftrace_regs *fregs,
  31. unsigned long ip)
  32. {
  33. regs_set_return_ip(&fregs->regs, ip);
  34. }
  35. struct ftrace_ops;
  36. #define ftrace_graph_func ftrace_graph_func
  37. void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
  38. struct ftrace_ops *op, struct ftrace_regs *fregs);
  39. #endif
  40. #endif /* __ASSEMBLY__ */
  41. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  42. #define ARCH_SUPPORTS_FTRACE_OPS 1
  43. #endif
  44. #endif /* CONFIG_FUNCTION_TRACER */
  45. #ifndef __ASSEMBLY__
  46. #ifdef CONFIG_FTRACE_SYSCALLS
  47. /*
  48. * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
  49. * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
  50. * those.
  51. */
  52. #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
  53. static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
  54. {
  55. return !strcmp(sym, name) ||
  56. (!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
  57. (!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
  58. (!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
  59. (!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
  60. }
  61. #endif /* CONFIG_FTRACE_SYSCALLS */
  62. #if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
  63. #include <asm/paca.h>
  64. static inline void this_cpu_disable_ftrace(void)
  65. {
  66. get_paca()->ftrace_enabled = 0;
  67. }
  68. static inline void this_cpu_enable_ftrace(void)
  69. {
  70. get_paca()->ftrace_enabled = 1;
  71. }
  72. /* Disable ftrace on this CPU if possible (may not be implemented) */
  73. static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
  74. {
  75. get_paca()->ftrace_enabled = ftrace_enabled;
  76. }
  77. static inline u8 this_cpu_get_ftrace_enabled(void)
  78. {
  79. return get_paca()->ftrace_enabled;
  80. }
  81. void ftrace_free_init_tramp(void);
  82. #else /* CONFIG_PPC64 */
  83. static inline void this_cpu_disable_ftrace(void) { }
  84. static inline void this_cpu_enable_ftrace(void) { }
  85. static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
  86. static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
  87. static inline void ftrace_free_init_tramp(void) { }
  88. #endif /* CONFIG_PPC64 */
  89. #endif /* !__ASSEMBLY__ */
  90. #endif /* _ASM_POWERPC_FTRACE */