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-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * ELF register definitions..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifndef _ASM_POWERPC_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #define _ASM_POWERPC_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/sched.h>	/* for task_struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <uapi/asm/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * This is used to ensure we don't load something for the wrong architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define compat_elf_check_arch(x)	((x)->e_machine == EM_PPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define CORE_DUMP_USE_REGSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define ELF_EXEC_PAGESIZE	PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * This is the base location for PIE (ET_DYN with INTERP) loads. On
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * 64-bit, this is raised to 4GB to leave the entire 32-bit address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * space open for things that want to use the area for 32-bit pointers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define ELF_ET_DYN_BASE		(is_32bit_task() ? 0x000400000UL : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 						   0x100000000UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define ELF_CORE_EFLAGS (is_elf2_task() ? 2 : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * Our registers are always unsigned longs, whether we're a 32 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * process or 64 bit, on either a 64 bit or 32 bit kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * This macro relies on elf_regs[i] having the right type to truncate to,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * either u32 or u64.  It defines the body of the elf_core_copy_regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * function, either the native one with elf_gregset_t elf_regs or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * the 32-bit one with elf_gregset_t32 elf_regs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define PPC_ELF_CORE_COPY_REGS(elf_regs, regs) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int i, nregs = min(sizeof(*regs) / sizeof(unsigned long), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			   (size_t)ELF_NGREG);			  \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	for (i = 0; i < nregs; i++) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		elf_regs[i] = ((unsigned long *) regs)[i]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	memset(&elf_regs[i], 0, (ELF_NGREG - i) * sizeof(elf_regs[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) /* Common routine for both 32-bit and 64-bit native processes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 					  struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	PPC_ELF_CORE_COPY_REGS(elf_regs, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) /* ELF_HWCAP yields a mask that user programs can use to figure out what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)    instruction set this cpu supports.  This could be done in userspace,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)    but it's not easy, and we've already done it here.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) # define ELF_HWCAP	(cur_cpu_spec->cpu_user_features)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) # define ELF_HWCAP2	(cur_cpu_spec->cpu_user_features2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* This yields a string that ld.so will use to load implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)    specific libraries for optimization.  This is more specific in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)    intent than poking at uname or /proc/cpuinfo.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define ELF_PLATFORM	(cur_cpu_spec->platform)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* While ELF_PLATFORM indicates the ISA supported by the platform, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * may not accurately reflect the underlying behavior of the hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * (as in the case of running in Power5+ compatibility mode on a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * Power6 machine).  ELF_BASE_PLATFORM allows ld.so to load libraries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * that are tuned for the real hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define ELF_BASE_PLATFORM (powerpc_base_platform)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #ifdef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) # define ELF_PLAT_INIT(_r, load_addr)	do {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	_r->gpr[2] = load_addr; 		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #endif /* __powerpc64__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #ifdef __powerpc64__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) # define SET_PERSONALITY(ex)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) do {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	if (((ex).e_flags & 0x3) == 2)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		set_thread_flag(TIF_ELF2ABI);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	else							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		clear_thread_flag(TIF_ELF2ABI);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if ((ex).e_ident[EI_CLASS] == ELFCLASS32)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		set_thread_flag(TIF_32BIT);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	else							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		clear_thread_flag(TIF_32BIT);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (personality(current->personality) != PER_LINUX32)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		set_personality(PER_LINUX |			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			(current->personality & (~PER_MASK)));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * An executable for which elf_read_implies_exec() returns TRUE will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * have the READ_IMPLIES_EXEC personality flag set automatically. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * is only required to work around bugs in old 32bit toolchains. Since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * the 64bit ABI has never had these issues dont enable the workaround
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * even if we have an executable stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) # define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		(exec_stk == EXSTACK_DEFAULT) : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #else 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) # define elf_read_implies_exec(ex, exec_stk) (exec_stk == EXSTACK_DEFAULT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #endif /* __powerpc64__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) extern int dcache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) extern int icache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) extern int ucache_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /* vDSO has arch_setup_additional_pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct linux_binprm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) extern int arch_setup_additional_pages(struct linux_binprm *bprm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 				       int uses_interp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* 1GB for 64bit, 8MB for 32bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define STACK_RND_MASK (is_32bit_task() ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	(0x7ff >> (PAGE_SHIFT - 12)) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	(0x3ffff >> (PAGE_SHIFT - 12)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #ifdef CONFIG_SPU_BASE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #define NT_SPU		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define ARCH_HAVE_EXTRA_ELF_NOTES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #endif /* CONFIG_SPU_BASE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #ifdef CONFIG_PPC64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define get_cache_geometry(level) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	(ppc64_caches.level.assoc << 16 | ppc64_caches.level.line_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define ARCH_DLINFO_CACHE_GEOMETRY					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	NEW_AUX_ENT(AT_L1I_CACHESIZE, ppc64_caches.l1i.size);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, get_cache_geometry(l1i));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	NEW_AUX_ENT(AT_L1D_CACHESIZE, ppc64_caches.l1d.size);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, get_cache_geometry(l1d));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	NEW_AUX_ENT(AT_L2_CACHESIZE, ppc64_caches.l2.size);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, get_cache_geometry(l2));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	NEW_AUX_ENT(AT_L3_CACHESIZE, ppc64_caches.l3.size);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	NEW_AUX_ENT(AT_L3_CACHEGEOMETRY, get_cache_geometry(l3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #define ARCH_DLINFO_CACHE_GEOMETRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * The requirements here are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * - keep the final alignment of sp (sp & 0xf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * - make sure the 32-bit value at the first 16 byte aligned position of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  *   AUXV is greater than 16 for glibc compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  *   AT_IGNOREPPC is used for that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  *   even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define ARCH_DLINFO							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	/* Handle glibc compatibility. */				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/* Cache size items */						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso_base);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	ARCH_DLINFO_CACHE_GEOMETRY;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* Relocate the kernel image to @final_address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) void relocate(unsigned long final_address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #endif /* _ASM_POWERPC_ELF_H */