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-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2012 ARM Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifndef __ASM_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #define __ASM_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <asm/hwcap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * ELF register definitions..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * AArch64 static relocation types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /* Miscellaneous. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define R_ARM_NONE			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define R_AARCH64_NONE			256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* Data. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define R_AARCH64_ABS64			257
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define R_AARCH64_ABS32			258
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define R_AARCH64_ABS16			259
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define R_AARCH64_PREL64		260
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define R_AARCH64_PREL32		261
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define R_AARCH64_PREL16		262
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /* Instructions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define R_AARCH64_MOVW_UABS_G0		263
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define R_AARCH64_MOVW_UABS_G0_NC	264
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define R_AARCH64_MOVW_UABS_G1		265
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define R_AARCH64_MOVW_UABS_G1_NC	266
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define R_AARCH64_MOVW_UABS_G2		267
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define R_AARCH64_MOVW_UABS_G2_NC	268
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define R_AARCH64_MOVW_UABS_G3		269
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define R_AARCH64_MOVW_SABS_G0		270
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define R_AARCH64_MOVW_SABS_G1		271
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define R_AARCH64_MOVW_SABS_G2		272
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define R_AARCH64_LD_PREL_LO19		273
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define R_AARCH64_ADR_PREL_LO21		274
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define R_AARCH64_ADR_PREL_PG_HI21	275
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define R_AARCH64_ADR_PREL_PG_HI21_NC	276
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define R_AARCH64_ADD_ABS_LO12_NC	277
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define R_AARCH64_LDST8_ABS_LO12_NC	278
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define R_AARCH64_TSTBR14		279
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define R_AARCH64_CONDBR19		280
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define R_AARCH64_JUMP26		282
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define R_AARCH64_CALL26		283
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define R_AARCH64_LDST16_ABS_LO12_NC	284
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define R_AARCH64_LDST32_ABS_LO12_NC	285
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define R_AARCH64_LDST64_ABS_LO12_NC	286
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define R_AARCH64_LDST128_ABS_LO12_NC	299
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define R_AARCH64_MOVW_PREL_G0		287
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define R_AARCH64_MOVW_PREL_G0_NC	288
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define R_AARCH64_MOVW_PREL_G1		289
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define R_AARCH64_MOVW_PREL_G1_NC	290
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define R_AARCH64_MOVW_PREL_G2		291
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define R_AARCH64_MOVW_PREL_G2_NC	292
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define R_AARCH64_MOVW_PREL_G3		293
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define R_AARCH64_RELATIVE		1027
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * These are used to set parameters in the core dumps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define ELF_CLASS	ELFCLASS64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #ifdef __AARCH64EB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define ELF_DATA	ELFDATA2MSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define ELF_DATA	ELFDATA2LSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define ELF_ARCH	EM_AARCH64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * This yields a string that ld.so will use to load implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * specific libraries for optimization.  This is more specific in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * intent than poking at uname or /proc/cpuinfo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define ELF_PLATFORM_SIZE	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) #ifdef __AARCH64EB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #define ELF_PLATFORM		("aarch64_be")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define ELF_PLATFORM		("aarch64")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * This is used to ensure we don't load something for the wrong architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) #define elf_check_arch(x)		((x)->e_machine == EM_AARCH64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * An executable for which elf_read_implies_exec() returns TRUE will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * have the READ_IMPLIES_EXEC personality flag set automatically.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * The decision process for determining the results are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *                CPU*: | arm32      | arm64      |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * ELF:                 |            |            |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * ---------------------|------------|------------|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * missing PT_GNU_STACK | exec-all   | exec-none  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * PT_GNU_STACK == RWX  | exec-stack | exec-stack |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * PT_GNU_STACK == RW   | exec-none  | exec-none  |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *  exec-all  : all PROT_READ user mappings are executable, except when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  *              backed by files on a noexec-filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *  exec-none : only PROT_EXEC user mappings are executable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  *  exec-stack: only the stack and PROT_EXEC user mappings are executable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *  *all arm64 CPUs support NX, so there is no "lacks NX" column.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define compat_elf_read_implies_exec(ex, stk)	(stk == EXSTACK_DEFAULT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define CORE_DUMP_USE_REGSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define ELF_EXEC_PAGESIZE	PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  * This is the base location for PIE (ET_DYN with INTERP) loads. On
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * 64-bit, this is above 4GB to leave the entire 32-bit address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * space open for things that want to use the area for 32-bit pointers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #ifdef CONFIG_ARM64_FORCE_52BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define ELF_ET_DYN_BASE		(2 * TASK_SIZE_64 / 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define ELF_ET_DYN_BASE		(2 * DEFAULT_MAP_WINDOW_64 / 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) #endif /* CONFIG_ARM64_FORCE_52BIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #include <uapi/linux/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #include <asm/processor.h> /* for signal_minsigstksz, used by ARCH_DLINFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) typedef unsigned long elf_greg_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define ELF_CORE_COPY_REGS(dest, regs)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	*(struct user_pt_regs *)&(dest) = (regs)->user_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) typedef elf_greg_t elf_gregset_t[ELF_NGREG];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) typedef struct user_fpsimd_state elf_fpregset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * When the program starts, a1 contains a pointer to a function to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * registered with atexit, as per the SVR4 ABI.  A value of 0 means we have no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * such handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define ELF_PLAT_INIT(_r, load_addr)	(_r)->regs[0] = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define SET_PERSONALITY(ex)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) ({									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	clear_thread_flag(TIF_32BIT);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	current->personality &= ~READ_IMPLIES_EXEC;			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define ARCH_DLINFO							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	NEW_AUX_ENT(AT_SYSINFO_EHDR,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		    (elf_addr_t)current->mm->context.vdso);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	/*								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	 * Should always be nonzero unless there's a kernel bug.	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	 * If we haven't determined a sensible value to give to		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	 * userspace, omit the entry:					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	 */								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (likely(signal_minsigstksz))					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		NEW_AUX_ENT(AT_MINSIGSTKSZ, signal_minsigstksz);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	else								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		NEW_AUX_ENT(AT_IGNORE, 0);				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct linux_binprm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) extern int arch_setup_additional_pages(struct linux_binprm *bprm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				       int uses_interp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* 1GB of VA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #define STACK_RND_MASK			(test_thread_flag(TIF_32BIT) ? \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 						0x7ff >> (PAGE_SHIFT - 12) : \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 						0x3ffff >> (PAGE_SHIFT - 12))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define STACK_RND_MASK			(0x3ffff >> (PAGE_SHIFT - 12))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #ifdef __AARCH64EB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define COMPAT_ELF_PLATFORM		("v8b")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define COMPAT_ELF_PLATFORM		("v8l")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #define COMPAT_ELF_ET_DYN_BASE		0x000400000UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* AArch32 registers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #define COMPAT_ELF_NGREG		18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) typedef unsigned int			compat_elf_greg_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) typedef compat_elf_greg_t		compat_elf_gregset_t[COMPAT_ELF_NGREG];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* AArch32 EABI. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define EF_ARM_EABI_MASK		0xff000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define compat_elf_check_arch(x)	(system_supports_32bit_el0() && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 					 ((x)->e_machine == EM_ARM) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					 ((x)->e_flags & EF_ARM_EABI_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #define compat_start_thread		compat_start_thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * Unlike the native SET_PERSONALITY macro, the compat version maintains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * READ_IMPLIES_EXEC across an execve() since this is the behaviour on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  * arch/arm/.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define COMPAT_SET_PERSONALITY(ex)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ({									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	set_thread_flag(TIF_32BIT);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #ifdef CONFIG_COMPAT_VDSO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define COMPAT_ARCH_DLINFO						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	/*								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 * Note that we use Elf64_Off instead of elf_addr_t because	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	 * elf_addr_t in compat is defined as Elf32_Addr and casting	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	 * current->mm->context.vdso to it triggers a cast warning of	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	 * cast from pointer to integer of different size.		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	 */								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	NEW_AUX_ENT(AT_SYSINFO_EHDR,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			(Elf64_Off)current->mm->context.vdso);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define COMPAT_ARCH_DLINFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern int aarch32_setup_additional_pages(struct linux_binprm *bprm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 					  int uses_interp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define compat_arch_setup_additional_pages \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 					aarch32_setup_additional_pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #endif /* CONFIG_COMPAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct arch_elf_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #define ARM64_ELF_BTI		(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #define INIT_ARCH_ELF_STATE {			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	.flags = 0,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static inline int arch_parse_elf_property(u32 type, const void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 					  size_t datasz, bool compat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 					  struct arch_elf_state *arch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	/* No known properties for AArch32 yet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (IS_ENABLED(CONFIG_COMPAT) && compat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		const u32 *p = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		if (datasz != sizeof(*p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			return -ENOEXEC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		if (system_supports_bti() &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		    (*p & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			arch->flags |= ARM64_ELF_BTI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) static inline int arch_elf_pt_proc(void *ehdr, void *phdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 				   struct file *f, bool is_interp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 				   struct arch_elf_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static inline int arch_check_elf(void *ehdr, bool has_interp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				 void *interp_ehdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				 struct arch_elf_state *state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) #endif /* !__ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #endif