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
14 extern void _mcount(void);
16 static inline unsigned long ftrace_call_adjust(unsigned long addr)
18 /* relocation of mcount call site is the same as the address */
22 unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
25 struct dyn_arch_ftrace {
29 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
34 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
36 /* We clear regs.msr in ftrace_call */
37 return fregs->regs.msr ? &fregs->regs : NULL;
40 static __always_inline void
41 ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
44 regs_set_return_ip(&fregs->regs, ip);
49 #define ftrace_graph_func ftrace_graph_func
50 void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
51 struct ftrace_ops *op, struct ftrace_regs *fregs);
53 #endif /* __ASSEMBLY__ */
55 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
56 #define ARCH_SUPPORTS_FTRACE_OPS 1
58 #endif /* CONFIG_FUNCTION_TRACER */
61 #ifdef CONFIG_FTRACE_SYSCALLS
63 * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
64 * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
67 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
68 #ifdef CONFIG_PPC64_ELF_ABI_V1
69 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
71 /* We need to skip past the initial dot, and the __se_sys alias */
72 return !strcmp(sym + 1, name) ||
73 (!strncmp(sym, ".__se_sys", 9) && !strcmp(sym + 6, name)) ||
74 (!strncmp(sym, ".ppc_", 5) && !strcmp(sym + 5, name + 4)) ||
75 (!strncmp(sym, ".ppc32_", 7) && !strcmp(sym + 7, name + 4)) ||
76 (!strncmp(sym, ".ppc64_", 7) && !strcmp(sym + 7, name + 4));
79 static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
81 return !strcmp(sym, name) ||
82 (!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
83 (!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
84 (!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
85 (!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
87 #endif /* CONFIG_PPC64_ELF_ABI_V1 */
88 #endif /* CONFIG_FTRACE_SYSCALLS */
90 #if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
93 static inline void this_cpu_disable_ftrace(void)
95 get_paca()->ftrace_enabled = 0;
98 static inline void this_cpu_enable_ftrace(void)
100 get_paca()->ftrace_enabled = 1;
103 /* Disable ftrace on this CPU if possible (may not be implemented) */
104 static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
106 get_paca()->ftrace_enabled = ftrace_enabled;
109 static inline u8 this_cpu_get_ftrace_enabled(void)
111 return get_paca()->ftrace_enabled;
114 void ftrace_free_init_tramp(void);
115 #else /* CONFIG_PPC64 */
116 static inline void this_cpu_disable_ftrace(void) { }
117 static inline void this_cpu_enable_ftrace(void) { }
118 static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
119 static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
120 static inline void ftrace_free_init_tramp(void) { }
121 #endif /* CONFIG_PPC64 */
122 #endif /* !__ASSEMBLY__ */
124 #endif /* _ASM_POWERPC_FTRACE */