Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _ASM_POWERPC_FTRACE
  3#define _ASM_POWERPC_FTRACE
  4
  5#include <asm/types.h>
  6
  7#ifdef CONFIG_FUNCTION_TRACER
  8#define MCOUNT_ADDR		((unsigned long)(_mcount))
  9#define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
 10
 11#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
 12
 13/* Ignore unused weak functions which will have larger offsets */
 14#if defined(CONFIG_MPROFILE_KERNEL) || defined(CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY)
 15#define FTRACE_MCOUNT_MAX_OFFSET	16
 16#elif defined(CONFIG_PPC32)
 17#define FTRACE_MCOUNT_MAX_OFFSET	8
 18#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 19
 20#ifndef __ASSEMBLY__
 21extern void _mcount(void);
 22
 23unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip,
 24				    unsigned long sp);
 
 
 
 
 
 
 25
 26struct module;
 27struct dyn_ftrace;
 28struct dyn_arch_ftrace {
 29	struct module *mod;
 30};
 31
 32#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
 33#define ftrace_need_init_nop()	(true)
 34int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
 35#define ftrace_init_nop ftrace_init_nop
 36
 37struct ftrace_regs {
 38	struct pt_regs regs;
 39};
 40
 41static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
 42{
 43	/* We clear regs.msr in ftrace_call */
 44	return fregs->regs.msr ? &fregs->regs : NULL;
 45}
 46
 47static __always_inline void
 48ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
 49				    unsigned long ip)
 50{
 51	regs_set_return_ip(&fregs->regs, ip);
 52}
 53
 54static __always_inline unsigned long
 55ftrace_regs_get_instruction_pointer(struct ftrace_regs *fregs)
 56{
 57	return instruction_pointer(&fregs->regs);
 58}
 59
 60#define ftrace_regs_get_argument(fregs, n) \
 61	regs_get_kernel_argument(&(fregs)->regs, n)
 62#define ftrace_regs_get_stack_pointer(fregs) \
 63	kernel_stack_pointer(&(fregs)->regs)
 64#define ftrace_regs_return_value(fregs) \
 65	regs_return_value(&(fregs)->regs)
 66#define ftrace_regs_set_return_value(fregs, ret) \
 67	regs_set_return_value(&(fregs)->regs, ret)
 68#define ftrace_override_function_with_return(fregs) \
 69	override_function_with_return(&(fregs)->regs)
 70#define ftrace_regs_query_register_offset(name) \
 71	regs_query_register_offset(name)
 72
 73struct ftrace_ops;
 74
 75#define ftrace_graph_func ftrace_graph_func
 76void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
 77		       struct ftrace_ops *op, struct ftrace_regs *fregs);
 78#endif
 79#endif /* __ASSEMBLY__ */
 80
 81#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
 82#define ARCH_SUPPORTS_FTRACE_OPS 1
 83#endif
 84#endif /* CONFIG_FUNCTION_TRACER */
 85
 86#ifndef __ASSEMBLY__
 87#ifdef CONFIG_FTRACE_SYSCALLS
 88/*
 89 * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
 90 * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
 91 * those.
 92 */
 93#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
 94static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
 95{
 96	return !strcmp(sym, name) ||
 97		(!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
 98		(!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
 99		(!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
100		(!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
101}
102#endif /* CONFIG_FTRACE_SYSCALLS */
103
104#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
105#include <asm/paca.h>
106
107static inline void this_cpu_disable_ftrace(void)
108{
109	get_paca()->ftrace_enabled = 0;
110}
111
112static inline void this_cpu_enable_ftrace(void)
113{
114	get_paca()->ftrace_enabled = 1;
115}
116
117/* Disable ftrace on this CPU if possible (may not be implemented) */
118static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
119{
120	get_paca()->ftrace_enabled = ftrace_enabled;
121}
122
123static inline u8 this_cpu_get_ftrace_enabled(void)
124{
125	return get_paca()->ftrace_enabled;
126}
127#else /* CONFIG_PPC64 */
128static inline void this_cpu_disable_ftrace(void) { }
129static inline void this_cpu_enable_ftrace(void) { }
130static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
131static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
132#endif /* CONFIG_PPC64 */
133
134#ifdef CONFIG_FUNCTION_TRACER
135extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
136void ftrace_free_init_tramp(void);
137unsigned long ftrace_call_adjust(unsigned long addr);
138#else
139static inline void ftrace_free_init_tramp(void) { }
140static inline unsigned long ftrace_call_adjust(unsigned long addr) { return addr; }
141#endif
142#endif /* !__ASSEMBLY__ */
143
144#endif /* _ASM_POWERPC_FTRACE */
v4.10.11
 
 1#ifndef _ASM_POWERPC_FTRACE
 2#define _ASM_POWERPC_FTRACE
 3
 4#include <asm/types.h>
 5
 6#ifdef CONFIG_FUNCTION_TRACER
 7#define MCOUNT_ADDR		((unsigned long)(_mcount))
 8#define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
 9
10#ifdef __ASSEMBLY__
11
12/* Based off of objdump optput from glibc */
13
14#define MCOUNT_SAVE_FRAME			\
15	stwu	r1,-48(r1);			\
16	stw	r3, 12(r1);			\
17	stw	r4, 16(r1);			\
18	stw	r5, 20(r1);			\
19	stw	r6, 24(r1);			\
20	mflr	r3;				\
21	lwz	r4, 52(r1);			\
22	mfcr	r5;				\
23	stw	r7, 28(r1);			\
24	stw	r8, 32(r1);			\
25	stw	r9, 36(r1);			\
26	stw	r10,40(r1);			\
27	stw	r3, 44(r1);			\
28	stw	r5, 8(r1)
29
30#define MCOUNT_RESTORE_FRAME			\
31	lwz	r6, 8(r1);			\
32	lwz	r0, 44(r1);			\
33	lwz	r3, 12(r1);			\
34	mtctr	r0;				\
35	lwz	r4, 16(r1);			\
36	mtcr	r6;				\
37	lwz	r5, 20(r1);			\
38	lwz	r6, 24(r1);			\
39	lwz	r0, 52(r1);			\
40	lwz	r7, 28(r1);			\
41	lwz	r8, 32(r1);			\
42	mtlr	r0;				\
43	lwz	r9, 36(r1);			\
44	lwz	r10,40(r1);			\
45	addi	r1, r1, 48
46
47#else /* !__ASSEMBLY__ */
48extern void _mcount(void);
49
50#ifdef CONFIG_DYNAMIC_FTRACE
51# define FTRACE_ADDR ((unsigned long)ftrace_caller)
52# define FTRACE_REGS_ADDR FTRACE_ADDR
53static 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
 
 
59struct dyn_arch_ftrace {
60	struct module *mod;
61};
62#endif /*  CONFIG_DYNAMIC_FTRACE */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63#endif /* __ASSEMBLY__ */
64
65#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
66#define ARCH_SUPPORTS_FTRACE_OPS 1
67#endif
68#endif
69
70#if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
71#ifdef PPC64_ELF_ABI_v1
 
 
 
 
 
72#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
73static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
74{
75	/*
76	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
77	 * prefix from the symbol name and the sys prefix from the system call name and
78	 * just match the rest. This is only needed on ppc64 since symbol names on
79	 * 32bit do not start with a period so the generic function will work.
80	 */
81	return !strcmp(sym + 4, name + 3);
 
 
 
 
 
 
 
 
 
 
 
 
82}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83#endif
84#endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
85
86#endif /* _ASM_POWERPC_FTRACE */