1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_FTRACE
3 #define _ASM_POWERPC_FTRACE
7 #ifdef CONFIG_FUNCTION_TRACER
8 #define MCOUNT_ADDR ((unsigned long)(_mcount))
9 #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
11 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
15 /* Based off of objdump output from glibc */
17 #define MCOUNT_SAVE_FRAME \
33 #define MCOUNT_RESTORE_FRAME \
50 #else /* !__ASSEMBLY__ */
51 extern void _mcount(void);
53 static inline unsigned long ftrace_call_adjust(unsigned long addr)
55 /* relocation of mcount call site is the same as the address */
59 struct dyn_arch_ftrace {
62 #endif /* __ASSEMBLY__ */
64 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
65 #define ARCH_SUPPORTS_FTRACE_OPS 1
67 #endif /* CONFIG_FUNCTION_TRACER */
70 #ifdef CONFIG_FTRACE_SYSCALLS
72 * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
73 * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
76 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
77 #ifdef PPC64_ELF_ABI_v1
78 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
80 /* We need to skip past the initial dot, and the __se_sys alias */
81 return !strcmp(sym + 1, name) ||
82 (!strncmp(sym, ".__se_sys", 9) && !strcmp(sym + 6, name)) ||
83 (!strncmp(sym, ".ppc_", 5) && !strcmp(sym + 5, name + 4)) ||
84 (!strncmp(sym, ".ppc32_", 7) && !strcmp(sym + 7, name + 4)) ||
85 (!strncmp(sym, ".ppc64_", 7) && !strcmp(sym + 7, name + 4));
88 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
90 return !strcmp(sym, name) ||
91 (!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
92 (!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
93 (!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
94 (!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
96 #endif /* PPC64_ELF_ABI_v1 */
97 #endif /* CONFIG_FTRACE_SYSCALLS */
99 #if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
100 #include <asm/paca.h>
102 static inline void this_cpu_disable_ftrace(void)
104 get_paca()->ftrace_enabled = 0;
107 static inline void this_cpu_enable_ftrace(void)
109 get_paca()->ftrace_enabled = 1;
112 /* Disable ftrace on this CPU if possible (may not be implemented) */
113 static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
115 get_paca()->ftrace_enabled = ftrace_enabled;
118 static inline u8 this_cpu_get_ftrace_enabled(void)
120 return get_paca()->ftrace_enabled;
123 void ftrace_free_init_tramp(void);
124 #else /* CONFIG_PPC64 */
125 static inline void this_cpu_disable_ftrace(void) { }
126 static inline void this_cpu_enable_ftrace(void) { }
127 static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
128 static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
129 static inline void ftrace_free_init_tramp(void) { }
130 #endif /* CONFIG_PPC64 */
131 #endif /* !__ASSEMBLY__ */
133 #endif /* _ASM_POWERPC_FTRACE */