From 92059bf40727b11d62eb943929b85cabf920fabf Mon Sep 17 00:00:00 2001 From: Jinjie Ruan Date: Tue, 2 Jan 2024 11:16:44 +0800 Subject: [PATCH] arm64: Fix compilation error with ILP32 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8S6IA ------------------------------------------------- This patch fix the following compilation errors with ILP32 support using openeuler_defcofig. When ILP32 support is enabled, compilation on ARM64 would complain about an undeclared __NR_compat_syscalls, since commit b16c8a680a2b ("arm64: ilp32: introduce syscall table for ILP32") changes the config that __NR_compat_syscalls depends on but commit dbece8b041f3 ("arm64: rename COMPAT to AARCH32_EL0") ignores it for __NR_compat_syscalls. Modify the config for SECCOMP_ARCH_COMPAT_NR accordingly. And commit dbece8b041f3 ("arm64: rename COMPAT to AARCH32_EL0") ignores ARM64_ERRATU_1742098 which only depends on AARCH32_EL0 but not ARM64_ILP32. compat_elf_gregset_t is used in elfcore-compat.h but only defined in binfmt_ilp32.c which depends on ARM64_ILP32, so move it to elf.h. Commit 7de3ab4c3dd9 ("arm64: introduce binfmt_elf32.c") rename COMPAT to AARCH32_EL0 for compat_elf_check_arch(), but compat_binfmt_elf.c also uses it with ILP32 support, so changes it back. And make EF_ARM_EABI_MASK and compat_elf_check_arch() function declaration to be common for ARM64_ILP32 and AARCH32_EL0. ./arch/arm64/include/asm/seccomp.h:57:33: error: ‘__NR_compat_syscalls’ undeclared here (not in a function); did you mean ‘in_compat_syscall’? 57 | # define SECCOMP_ARCH_COMPAT_NR __NR_compat_syscalls ./arch/arm64/kernel/cpufeature.c:2200:17: error: ‘a32_elf_hwcap2’ undeclared (first use in this function); did you mean ‘elf_hwcap’? 2200 | a32_elf_hwcap2 &= ~COMPAT_HWCAP2_AES; | ^~~~~~~~~~~~~~ | elf_hwcap ./include/linux/elfcore-compat.h:62:9: error: unknown type name ‘compat_elf_gregset_t’ 62 | compat_elf_gregset_t pr_reg; | ^~~~~~~~~~~~~~~~~~~~ ./fs/compat_binfmt_elf.c:66:25: error: implicit declaration of function ‘compat_elf_check_arch’; did you mean ‘elf_check_arch’? [-Werror=implicit-function-declaration] 66 | #define elf_check_arch compat_elf_check_arch | ^~~~~~~~~~~~~~~~~~~~~ Fixes: dbece8b041f3 ("arm64: rename COMPAT to AARCH32_EL0") Fixes: 7de3ab4c3dd9 ("arm64: introduce binfmt_elf32.c") Signed-off-by: Jinjie Ruan --- arch/arm64/Kconfig | 2 +- arch/arm64/include/asm/elf.h | 8 ++++++-- arch/arm64/include/asm/seccomp.h | 4 ++-- arch/arm64/kernel/binfmt_ilp32.c | 3 --- arch/arm64/kernel/process.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 42079bfdf40a..42f31d37ce23 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -568,7 +568,7 @@ config ARM64_ERRATUM_834220 config ARM64_ERRATUM_1742098 bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence" - depends on COMPAT + depends on AARCH32_EL0 default y help This option removes the AES hwcap for aarch32 user-space to diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index de3ad90894ec..27415d5464cb 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -203,6 +203,8 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #endif #ifdef CONFIG_COMPAT +#define EF_ARM_EABI_MASK 0xff000000 +int compat_elf_check_arch(const struct elf32_hdr *); /* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */ #define COMPAT_ELF_ET_DYN_BASE 0x000400000UL @@ -215,8 +217,6 @@ typedef unsigned int compat_elf_greg_t; typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; /* AArch32 EABI. */ -#define EF_ARM_EABI_MASK 0xff000000 -int compat_elf_check_arch(const struct elf32_hdr *); #define compat_start_thread compat_start_thread #ifdef CONFIG_COMPAT_VDSO @@ -239,6 +239,10 @@ extern int aarch32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp); #endif /* CONFIG_AARCH32_EL0 */ +#ifdef CONFIG_ARM64_ILP32 +#define compat_elf_gregset_t elf_gregset_t +#endif + struct arch_elf_state { int flags; }; diff --git a/arch/arm64/include/asm/seccomp.h b/arch/arm64/include/asm/seccomp.h index a6be48b9225a..bc3ab2468f03 100644 --- a/arch/arm64/include/asm/seccomp.h +++ b/arch/arm64/include/asm/seccomp.h @@ -52,10 +52,10 @@ static inline const int *get_compat_mode1_syscalls(void) #define SECCOMP_ARCH_NATIVE AUDIT_ARCH_AARCH64 #define SECCOMP_ARCH_NATIVE_NR NR_syscalls #define SECCOMP_ARCH_NATIVE_NAME "aarch64" -#ifdef CONFIG_COMPAT +#ifdef CONFIG_AARCH32_EL0 # define SECCOMP_ARCH_COMPAT AUDIT_ARCH_ARM # define SECCOMP_ARCH_COMPAT_NR __NR_compat_syscalls # define SECCOMP_ARCH_COMPAT_NAME "arm" -#endif +#endif /* CONFIG_AARCH32_EL0 */ #endif /* _ASM_SECCOMP_H */ diff --git a/arch/arm64/kernel/binfmt_ilp32.c b/arch/arm64/kernel/binfmt_ilp32.c index 17784c7f1163..c5ce83dc0746 100644 --- a/arch/arm64/kernel/binfmt_ilp32.c +++ b/arch/arm64/kernel/binfmt_ilp32.c @@ -3,9 +3,6 @@ /* * Support for ILP32 Linux/aarch64 ELF binaries. */ -#undef CONFIG_AARCH32_EL0 -#define compat_elf_gregset_t elf_gregset_t - #include #include #include diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 489810e3a7a1..1c87f990e7af 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -597,7 +597,7 @@ unsigned long arch_align_stack(unsigned long sp) return sp & ~0xf; } -#ifdef CONFIG_AARCH32_EL0 +#ifdef CONFIG_COMPAT int compat_elf_check_arch(const struct elf32_hdr *hdr) { if (!system_supports_32bit_el0()) -- Gitee