ftrace.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifdef __ASSEMBLY__
  9. /* Based off of objdump optput from glibc */
  10. #define MCOUNT_SAVE_FRAME \
  11. stwu r1,-48(r1); \
  12. stw r3, 12(r1); \
  13. stw r4, 16(r1); \
  14. stw r5, 20(r1); \
  15. stw r6, 24(r1); \
  16. mflr r3; \
  17. lwz r4, 52(r1); \
  18. mfcr r5; \
  19. stw r7, 28(r1); \
  20. stw r8, 32(r1); \
  21. stw r9, 36(r1); \
  22. stw r10,40(r1); \
  23. stw r3, 44(r1); \
  24. stw r5, 8(r1)
  25. #define MCOUNT_RESTORE_FRAME \
  26. lwz r6, 8(r1); \
  27. lwz r0, 44(r1); \
  28. lwz r3, 12(r1); \
  29. mtctr r0; \
  30. lwz r4, 16(r1); \
  31. mtcr r6; \
  32. lwz r5, 20(r1); \
  33. lwz r6, 24(r1); \
  34. lwz r0, 52(r1); \
  35. lwz r7, 28(r1); \
  36. lwz r8, 32(r1); \
  37. mtlr r0; \
  38. lwz r9, 36(r1); \
  39. lwz r10,40(r1); \
  40. addi r1, r1, 48
  41. #else /* !__ASSEMBLY__ */
  42. extern void _mcount(void);
  43. #ifdef CONFIG_DYNAMIC_FTRACE
  44. # define FTRACE_ADDR ((unsigned long)ftrace_caller)
  45. # define FTRACE_REGS_ADDR FTRACE_ADDR
  46. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  47. {
  48. /* reloction of mcount call site is the same as the address */
  49. return addr;
  50. }
  51. struct dyn_arch_ftrace {
  52. struct module *mod;
  53. };
  54. #endif /* CONFIG_DYNAMIC_FTRACE */
  55. #endif /* __ASSEMBLY__ */
  56. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  57. #define ARCH_SUPPORTS_FTRACE_OPS 1
  58. #endif
  59. #endif
  60. #if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
  61. /*
  62. * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
  63. * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
  64. * those.
  65. */
  66. #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
  67. #ifdef PPC64_ELF_ABI_v1
  68. static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
  69. {
  70. /* We need to skip past the initial dot, and the __se_sys alias */
  71. return !strcmp(sym + 1, name) ||
  72. (!strncmp(sym, ".__se_sys", 9) && !strcmp(sym + 6, name)) ||
  73. (!strncmp(sym, ".ppc_", 5) && !strcmp(sym + 5, name + 4)) ||
  74. (!strncmp(sym, ".ppc32_", 7) && !strcmp(sym + 7, name + 4)) ||
  75. (!strncmp(sym, ".ppc64_", 7) && !strcmp(sym + 7, name + 4));
  76. }
  77. #else
  78. static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
  79. {
  80. return !strcmp(sym, name) ||
  81. (!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
  82. (!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
  83. (!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
  84. (!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
  85. }
  86. #endif
  87. #endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
  88. #endif /* _ASM_POWERPC_FTRACE */