Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _ASM_POWERPC_FTRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _ASM_POWERPC_FTRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <asm/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifdef CONFIG_FUNCTION_TRACER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define MCOUNT_ADDR		((unsigned long)(_mcount))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #ifdef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* Based off of objdump optput from glibc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define MCOUNT_SAVE_FRAME			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	stwu	r1,-48(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	stw	r3, 12(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	stw	r4, 16(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	stw	r5, 20(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	stw	r6, 24(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	mflr	r3;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	lwz	r4, 52(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	mfcr	r5;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	stw	r7, 28(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	stw	r8, 32(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	stw	r9, 36(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	stw	r10,40(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	stw	r3, 44(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	stw	r5, 8(r1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define MCOUNT_RESTORE_FRAME			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	lwz	r6, 8(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	lwz	r0, 44(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	lwz	r3, 12(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	mtctr	r0;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	lwz	r4, 16(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	mtcr	r6;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	lwz	r5, 20(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	lwz	r6, 24(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	lwz	r0, 52(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	lwz	r7, 28(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	lwz	r8, 32(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	mtlr	r0;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	lwz	r9, 36(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	lwz	r10,40(r1);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	addi	r1, r1, 48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #else /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) extern void _mcount(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static inline unsigned long ftrace_call_adjust(unsigned long addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)        /* reloction of mcount call site is the same as the address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)        return addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) struct dyn_arch_ftrace {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct module *mod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define ARCH_SUPPORTS_FTRACE_OPS 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #endif /* CONFIG_FUNCTION_TRACER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #ifdef CONFIG_FTRACE_SYSCALLS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * Some syscall entry functions on powerpc start with "ppc_" (fork and clone,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * for instance) or ppc32_/ppc64_. We should also match the sys_ variant with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * those.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #ifdef PPC64_ELF_ABI_v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* We need to skip past the initial dot, and the __se_sys alias */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return !strcmp(sym + 1, name) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		(!strncmp(sym, ".__se_sys", 9) && !strcmp(sym + 6, name)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		(!strncmp(sym, ".ppc_", 5) && !strcmp(sym + 5, name + 4)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		(!strncmp(sym, ".ppc32_", 7) && !strcmp(sym + 7, name + 4)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		(!strncmp(sym, ".ppc64_", 7) && !strcmp(sym + 7, name + 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return !strcmp(sym, name) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		(!strncmp(sym, "__se_sys", 8) && !strcmp(sym + 5, name)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		(!strncmp(sym, "ppc_", 4) && !strcmp(sym + 4, name + 4)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		(!strncmp(sym, "ppc32_", 6) && !strcmp(sym + 6, name + 4)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		(!strncmp(sym, "ppc64_", 6) && !strcmp(sym + 6, name + 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #endif /* PPC64_ELF_ABI_v1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #endif /* CONFIG_FTRACE_SYSCALLS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #include <asm/paca.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static inline void this_cpu_disable_ftrace(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	get_paca()->ftrace_enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline void this_cpu_enable_ftrace(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	get_paca()->ftrace_enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* Disable ftrace on this CPU if possible (may not be implemented) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	get_paca()->ftrace_enabled = ftrace_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline u8 this_cpu_get_ftrace_enabled(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return get_paca()->ftrace_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #else /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static inline void this_cpu_disable_ftrace(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static inline void this_cpu_enable_ftrace(void) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif /* CONFIG_PPC64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #endif /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #endif /* _ASM_POWERPC_FTRACE */