Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
ccbfac29 SR |
2 | #ifndef _ASM_POWERPC_FTRACE |
3 | #define _ASM_POWERPC_FTRACE | |
4 | ||
f55d9665 ME |
5 | #include <asm/types.h> |
6 | ||
606576ce | 7 | #ifdef CONFIG_FUNCTION_TRACER |
c93bf928 | 8 | #define MCOUNT_ADDR ((unsigned long)(_mcount)) |
395a59d0 AS |
9 | #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ |
10 | ||
370011a2 NR |
11 | #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR |
12 | ||
bf528a3a SR |
13 | #ifdef __ASSEMBLY__ |
14 | ||
15 | /* Based off of objdump optput from glibc */ | |
16 | ||
17 | #define MCOUNT_SAVE_FRAME \ | |
18 | stwu r1,-48(r1); \ | |
19 | stw r3, 12(r1); \ | |
20 | stw r4, 16(r1); \ | |
21 | stw r5, 20(r1); \ | |
22 | stw r6, 24(r1); \ | |
23 | mflr r3; \ | |
24 | lwz r4, 52(r1); \ | |
25 | mfcr r5; \ | |
26 | stw r7, 28(r1); \ | |
27 | stw r8, 32(r1); \ | |
28 | stw r9, 36(r1); \ | |
29 | stw r10,40(r1); \ | |
30 | stw r3, 44(r1); \ | |
31 | stw r5, 8(r1) | |
32 | ||
33 | #define MCOUNT_RESTORE_FRAME \ | |
34 | lwz r6, 8(r1); \ | |
35 | lwz r0, 44(r1); \ | |
36 | lwz r3, 12(r1); \ | |
37 | mtctr r0; \ | |
38 | lwz r4, 16(r1); \ | |
39 | mtcr r6; \ | |
40 | lwz r5, 20(r1); \ | |
41 | lwz r6, 24(r1); \ | |
42 | lwz r0, 52(r1); \ | |
43 | lwz r7, 28(r1); \ | |
44 | lwz r8, 32(r1); \ | |
45 | mtlr r0; \ | |
46 | lwz r9, 36(r1); \ | |
47 | lwz r10,40(r1); \ | |
48 | addi r1, r1, 48 | |
49 | ||
50 | #else /* !__ASSEMBLY__ */ | |
ccbfac29 | 51 | extern void _mcount(void); |
8fd6e5a8 | 52 | |
8fd6e5a8 SR |
53 | static inline unsigned long ftrace_call_adjust(unsigned long addr) |
54 | { | |
55 | /* reloction of mcount call site is the same as the address */ | |
56 | return addr; | |
57 | } | |
58 | ||
59 | struct dyn_arch_ftrace { | |
f48cb8b4 | 60 | struct module *mod; |
8fd6e5a8 | 61 | }; |
8fd6e5a8 | 62 | #endif /* __ASSEMBLY__ */ |
ccbfac29 | 63 | |
15308664 TD |
64 | #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS |
65 | #define ARCH_SUPPORTS_FTRACE_OPS 1 | |
66 | #endif | |
0c0c5230 | 67 | #endif /* CONFIG_FUNCTION_TRACER */ |
395a59d0 | 68 | |
c3e59d77 | 69 | #ifndef __ASSEMBLY__ |
f1079d3a | 70 | #ifdef CONFIG_FTRACE_SYSCALLS |
edf6a2df NR |
71 | /* |
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 | |
74 | * those. | |
75 | */ | |
02424d89 | 76 | #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME |
edf6a2df | 77 | #ifdef PPC64_ELF_ABI_v1 |
02424d89 IM |
78 | static inline bool arch_syscall_match_sym_name(const char *sym, const char *name) |
79 | { | |
0b7758aa NR |
80 | /* We need to skip past the initial dot, and the __se_sys alias */ |
81 | return !strcmp(sym + 1, name) || | |
edf6a2df NR |
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)); | |
02424d89 | 86 | } |
edf6a2df NR |
87 | #else |
88 | static inline bool arch_syscall_match_sym_name(const char *sym, const char *name) | |
89 | { | |
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)); | |
02424d89 | 95 | } |
f1079d3a ME |
96 | #endif /* PPC64_ELF_ABI_v1 */ |
97 | #endif /* CONFIG_FTRACE_SYSCALLS */ | |
acd55b10 NR |
98 | |
99 | #ifdef CONFIG_PPC64 | |
100 | #include <asm/paca.h> | |
101 | ||
102 | static inline void this_cpu_disable_ftrace(void) | |
103 | { | |
104 | get_paca()->ftrace_enabled = 0; | |
105 | } | |
106 | ||
107 | static inline void this_cpu_enable_ftrace(void) | |
108 | { | |
109 | get_paca()->ftrace_enabled = 1; | |
110 | } | |
111 | #else /* CONFIG_PPC64 */ | |
112 | static inline void this_cpu_disable_ftrace(void) { } | |
113 | static inline void this_cpu_enable_ftrace(void) { } | |
114 | #endif /* CONFIG_PPC64 */ | |
c3e59d77 | 115 | #endif /* !__ASSEMBLY__ */ |
02424d89 | 116 | |
395a59d0 | 117 | #endif /* _ASM_POWERPC_FTRACE */ |