ftrace.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_FTRACE_H
  3. #define _ASM_S390_FTRACE_H
  4. #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
  5. #define ARCH_SUPPORTS_FTRACE_OPS 1
  6. #define MCOUNT_INSN_SIZE 6
  7. #ifndef __ASSEMBLY__
  8. #ifdef CONFIG_CC_IS_CLANG
  9. /* https://bugs.llvm.org/show_bug.cgi?id=41424 */
  10. #define ftrace_return_address(n) 0UL
  11. #else
  12. #define ftrace_return_address(n) __builtin_return_address(n)
  13. #endif
  14. void ftrace_caller(void);
  15. extern void *ftrace_func;
  16. struct dyn_arch_ftrace { };
  17. #define MCOUNT_ADDR 0
  18. #define FTRACE_ADDR ((unsigned long)ftrace_caller)
  19. #define KPROBE_ON_FTRACE_NOP 0
  20. #define KPROBE_ON_FTRACE_CALL 1
  21. struct module;
  22. struct dyn_ftrace;
  23. bool ftrace_need_init_nop(void);
  24. #define ftrace_need_init_nop ftrace_need_init_nop
  25. int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
  26. #define ftrace_init_nop ftrace_init_nop
  27. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  28. {
  29. return addr;
  30. }
  31. struct ftrace_regs {
  32. struct pt_regs regs;
  33. };
  34. static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
  35. {
  36. struct pt_regs *regs = &fregs->regs;
  37. if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS))
  38. return regs;
  39. return NULL;
  40. }
  41. static __always_inline void ftrace_instruction_pointer_set(struct ftrace_regs *fregs,
  42. unsigned long ip)
  43. {
  44. fregs->regs.psw.addr = ip;
  45. }
  46. /*
  47. * When an ftrace registered caller is tracing a function that is
  48. * also set by a register_ftrace_direct() call, it needs to be
  49. * differentiated in the ftrace_caller trampoline. To do this,
  50. * place the direct caller in the ORIG_GPR2 part of pt_regs. This
  51. * tells the ftrace_caller that there's a direct caller.
  52. */
  53. static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
  54. {
  55. regs->orig_gpr2 = addr;
  56. }
  57. /*
  58. * Even though the system call numbers are identical for s390/s390x a
  59. * different system call table is used for compat tasks. This may lead
  60. * to e.g. incorrect or missing trace event sysfs files.
  61. * Therefore simply do not trace compat system calls at all.
  62. * See kernel/trace/trace_syscalls.c.
  63. */
  64. #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
  65. static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
  66. {
  67. return is_compat_task();
  68. }
  69. #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
  70. static inline bool arch_syscall_match_sym_name(const char *sym,
  71. const char *name)
  72. {
  73. /*
  74. * Skip __s390_ and __s390x_ prefix - due to compat wrappers
  75. * and aliasing some symbols of 64 bit system call functions
  76. * may get the __s390_ prefix instead of the __s390x_ prefix.
  77. */
  78. return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
  79. }
  80. #endif /* __ASSEMBLY__ */
  81. #ifdef CONFIG_FUNCTION_TRACER
  82. #define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */
  83. #ifndef CC_USING_HOTPATCH
  84. #define FTRACE_GEN_MCOUNT_RECORD(name) \
  85. .section __mcount_loc, "a", @progbits; \
  86. .quad name; \
  87. .previous;
  88. #else /* !CC_USING_HOTPATCH */
  89. #define FTRACE_GEN_MCOUNT_RECORD(name)
  90. #endif /* !CC_USING_HOTPATCH */
  91. #define FTRACE_GEN_NOP_ASM(name) \
  92. FTRACE_GEN_MCOUNT_RECORD(name) \
  93. FTRACE_NOP_INSN
  94. #else /* CONFIG_FUNCTION_TRACER */
  95. #define FTRACE_GEN_NOP_ASM(name)
  96. #endif /* CONFIG_FUNCTION_TRACER */
  97. #endif /* _ASM_S390_FTRACE_H */