^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) * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2012 Regents of the University of California
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _ASM_RISCV_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _ASM_RISCV_ELF_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^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) #include <asm/auxvec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/cacheinfo.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) * These are used to set parameters in the core dumps.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define ELF_ARCH EM_RISCV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #ifdef CONFIG_64BIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define ELF_CLASS ELFCLASS64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define ELF_CLASS ELFCLASS32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define ELF_DATA ELFDATA2LSB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * This is used to ensure we don't load something for the wrong architecture.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define elf_check_arch(x) ((x)->e_machine == EM_RISCV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define CORE_DUMP_USE_REGSET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define ELF_EXEC_PAGESIZE (PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * This is the location that an ET_DYN program is loaded if exec'ed. Typical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * use of this is to invoke "./ld.so someprog" to test out a new version of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * the loader. We need to make sure that it is out of the way of the program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * that it will "exec", and that there is sufficient room for the brk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define ELF_ET_DYN_BASE ((TASK_SIZE / 3) * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * This yields a mask that user programs can use to figure out what
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * instruction set this CPU supports. This could be done in user space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * but it's not easy, and we've already done it here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define ELF_HWCAP (elf_hwcap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern unsigned long elf_hwcap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * This yields a string that ld.so will use to load implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * specific libraries for optimization. This is more specific in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * intent than poking at uname or /proc/cpuinfo.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define ELF_PLATFORM (NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #ifdef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define ARCH_DLINFO \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) NEW_AUX_ENT(AT_SYSINFO_EHDR, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) (elf_addr_t)current->mm->context.vdso); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) NEW_AUX_ENT(AT_L1I_CACHESIZE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) get_cache_size(1, CACHE_TYPE_INST)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) get_cache_geometry(1, CACHE_TYPE_INST)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) NEW_AUX_ENT(AT_L1D_CACHESIZE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) get_cache_size(1, CACHE_TYPE_DATA)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) get_cache_geometry(1, CACHE_TYPE_DATA)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) NEW_AUX_ENT(AT_L2_CACHESIZE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) get_cache_size(2, CACHE_TYPE_UNIFIED)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) get_cache_geometry(2, CACHE_TYPE_UNIFIED)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct linux_binprm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern int arch_setup_additional_pages(struct linux_binprm *bprm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int uses_interp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #endif /* CONFIG_MMU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif /* _ASM_RISCV_ELF_H */