VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   35 Branches   59 Tags
2522fe45a186e (Thomas Gleixner         2019-05-28 09:57:20 -0700   1) // SPDX-License-Identifier: GPL-2.0-only
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   2) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   3)  * 32-bit compatibility support for ELF format executables and core dumps.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   4)  *
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   5)  * Copyright (C) 2007 Red Hat, Inc.  All rights reserved.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   6)  *
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   7)  * Red Hat Author: Roland McGrath.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   8)  *
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100   9)  * This file is used in a 64-bit kernel that wants to support 32-bit ELF.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  10)  * asm/elf.h is responsible for defining the compat_* and COMPAT_* macros
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  11)  * used below, with definitions appropriate for 32-bit ABI compatibility.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  12)  *
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  13)  * We use macros to rename the ABI types and machine-dependent
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  14)  * functions used in binfmt_elf.c to compat versions.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  15)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  16) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  17) #include <linux/elfcore-compat.h>
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  18) #include <linux/time.h>
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  19) 
00e19ceec80b0 (Dave Martin             2020-03-16 16:50:44 +0000  20) #define ELF_COMPAT	1
00e19ceec80b0 (Dave Martin             2020-03-16 16:50:44 +0000  21) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  22) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  23)  * Rename the basic ELF layout types to refer to the 32-bit class of files.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  24)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  25) #undef	ELF_CLASS
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  26) #define ELF_CLASS	ELFCLASS32
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  27) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  28) #undef	elfhdr
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  29) #undef	elf_phdr
1fcccbac89f5b (Daisuke HATAYAMA        2010-03-05 13:44:07 -0800  30) #undef	elf_shdr
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  31) #undef	elf_note
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  32) #undef	elf_addr_t
00e19ceec80b0 (Dave Martin             2020-03-16 16:50:44 +0000  33) #undef	ELF_GNU_PROPERTY_ALIGN
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  34) #define elfhdr		elf32_hdr
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  35) #define elf_phdr	elf32_phdr
1fcccbac89f5b (Daisuke HATAYAMA        2010-03-05 13:44:07 -0800  36) #define elf_shdr	elf32_shdr
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  37) #define elf_note	elf32_note
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  38) #define elf_addr_t	Elf32_Addr
00e19ceec80b0 (Dave Martin             2020-03-16 16:50:44 +0000  39) #define ELF_GNU_PROPERTY_ALIGN	ELF32_GNU_PROPERTY_ALIGN
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  40) 
49ae4d4b113be (Denys Vlasenko          2012-10-04 17:15:35 -0700  41) /*
49ae4d4b113be (Denys Vlasenko          2012-10-04 17:15:35 -0700  42)  * Some data types as stored in coredump.
49ae4d4b113be (Denys Vlasenko          2012-10-04 17:15:35 -0700  43)  */
2aa362c49c314 (Denys Vlasenko          2012-10-04 17:15:36 -0700  44) #define user_long_t		compat_long_t
49ae4d4b113be (Denys Vlasenko          2012-10-04 17:15:35 -0700  45) #define user_siginfo_t		compat_siginfo_t
fa4751f454e6b (Eric W. Biederman       2020-05-05 12:12:54 +0200  46) #define copy_siginfo_to_external	copy_siginfo_to_external32
49ae4d4b113be (Denys Vlasenko          2012-10-04 17:15:35 -0700  47) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  48) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  49)  * The machine-dependent core note format types are defined in elfcore-compat.h,
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  50)  * which requires asm/elf.h to define compat_elf_gregset_t et al.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  51)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  52) #define elf_prstatus	compat_elf_prstatus
f2485a2dc9f0f (Al Viro                 2020-06-13 00:08:44 -0400  53) #define elf_prstatus_common	compat_elf_prstatus_common
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  54) #define elf_prpsinfo	compat_elf_prpsinfo
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  55) 
e2bb80d55d75c (Arnd Bergmann           2017-11-23 13:46:33 +0100  56) #undef ns_to_kernel_old_timeval
e2bb80d55d75c (Arnd Bergmann           2017-11-23 13:46:33 +0100  57) #define ns_to_kernel_old_timeval ns_to_old_timeval32
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  58) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  59) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  60)  * To use this file, asm/elf.h must define compat_elf_check_arch.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  61)  * The other following macros can be defined if the compat versions
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  62)  * differ from the native ones, or omitted when they match.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  63)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  64) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  65) #undef	elf_check_arch
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  66) #define	elf_check_arch	compat_elf_check_arch
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  67) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  68) #ifdef	COMPAT_ELF_PLATFORM
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  69) #undef	ELF_PLATFORM
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  70) #define	ELF_PLATFORM		COMPAT_ELF_PLATFORM
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  71) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  72) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  73) #ifdef	COMPAT_ELF_HWCAP
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  74) #undef	ELF_HWCAP
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  75) #define	ELF_HWCAP		COMPAT_ELF_HWCAP
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  76) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  77) 
66d6e3b385778 (Ard Biesheuvel          2014-03-03 07:34:44 +0000  78) #ifdef	COMPAT_ELF_HWCAP2
66d6e3b385778 (Ard Biesheuvel          2014-03-03 07:34:44 +0000  79) #undef	ELF_HWCAP2
66d6e3b385778 (Ard Biesheuvel          2014-03-03 07:34:44 +0000  80) #define	ELF_HWCAP2		COMPAT_ELF_HWCAP2
66d6e3b385778 (Ard Biesheuvel          2014-03-03 07:34:44 +0000  81) #endif
66d6e3b385778 (Ard Biesheuvel          2014-03-03 07:34:44 +0000  82) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  83) #ifdef	COMPAT_ARCH_DLINFO
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  84) #undef	ARCH_DLINFO
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  85) #define	ARCH_DLINFO		COMPAT_ARCH_DLINFO
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  86) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  87) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  88) #ifdef	COMPAT_ELF_ET_DYN_BASE
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  89) #undef	ELF_ET_DYN_BASE
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  90) #define	ELF_ET_DYN_BASE		COMPAT_ELF_ET_DYN_BASE
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  91) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  92) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  93) #ifdef	COMPAT_ELF_PLAT_INIT
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  94) #undef	ELF_PLAT_INIT
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  95) #define	ELF_PLAT_INIT		COMPAT_ELF_PLAT_INIT
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  96) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  97) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  98) #ifdef	COMPAT_SET_PERSONALITY
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100  99) #undef	SET_PERSONALITY
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 100) #define	SET_PERSONALITY		COMPAT_SET_PERSONALITY
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 101) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 102) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 103) #ifdef	compat_start_thread
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 104) #define COMPAT_START_THREAD(ex, regs, new_ip, new_sp)	\
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 105) 	compat_start_thread(regs, new_ip, new_sp)
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 106) #endif
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 107) 
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 108) #ifdef	COMPAT_START_THREAD
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 109) #undef	START_THREAD
bc3d7bf61a9ea (Gabriel Krisman Bertazi 2020-10-03 23:25:31 -0400 110) #define START_THREAD		COMPAT_START_THREAD
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 111) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 112) 
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 113) #ifdef compat_arch_setup_additional_pages
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 114) #define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 115) 	compat_arch_setup_additional_pages(bprm, interpreter)
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 116) #endif
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 117) 
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 118) #ifdef	COMPAT_ARCH_SETUP_ADDITIONAL_PAGES
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 119) #undef	ARCH_HAS_SETUP_ADDITIONAL_PAGES
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 120) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 121) #undef	ARCH_SETUP_ADDITIONAL_PAGES
9a29a671902c2 (Gabriel Krisman Bertazi 2020-10-03 23:25:33 -0400 122) #define	ARCH_SETUP_ADDITIONAL_PAGES COMPAT_ARCH_SETUP_ADDITIONAL_PAGES
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 123) #endif
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 124) 
6e0d6ac5f3d9d (Kees Cook               2020-03-26 23:48:20 -0700 125) #ifdef	compat_elf_read_implies_exec
6e0d6ac5f3d9d (Kees Cook               2020-03-26 23:48:20 -0700 126) #undef	elf_read_implies_exec
6e0d6ac5f3d9d (Kees Cook               2020-03-26 23:48:20 -0700 127) #define	elf_read_implies_exec compat_elf_read_implies_exec
6e0d6ac5f3d9d (Kees Cook               2020-03-26 23:48:20 -0700 128) #endif
6e0d6ac5f3d9d (Kees Cook               2020-03-26 23:48:20 -0700 129) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 130) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 131)  * Rename a few of the symbols that binfmt_elf.c will define.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 132)  * These are all local so the names don't really matter, but it
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 133)  * might make some debugging less confusing not to duplicate them.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 134)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 135) #define elf_format		compat_elf_format
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 136) #define init_elf_binfmt		init_compat_elf_binfmt
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 137) #define exit_elf_binfmt		exit_compat_elf_binfmt
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 138) 
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 139) /*
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 140)  * We share all the actual code with the native (64-bit) version.
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 141)  */
2f79e48ae2651 (Roland McGrath          2008-01-30 13:31:46 +0100 142) #include "binfmt_elf.c"