Skip to content

Commit 643d703

Browse files
Suzuki K Poulosewildea01
authored andcommitted
arm64: compat: Check for AArch32 state
Make sure we have AArch32 state available for running COMPAT binaries and also for switching the personality to PER_LINUX32. Signed-off-by: Yury Norov <ynorov@caviumnetworks.com> [ Added cap bit, checks for HWCAP, personality ] Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Tested-by: Yury Norov <ynorov@caviumnetworks.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 042446a commit 643d703

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

arch/arm64/include/asm/elf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
177177

178178
/* AArch32 EABI. */
179179
#define EF_ARM_EABI_MASK 0xff000000
180-
#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
180+
#define compat_elf_check_arch(x) (system_supports_32bit_el0() && \
181+
((x)->e_machine == EM_ARM) && \
181182
((x)->e_flags & EF_ARM_EABI_MASK))
182183

183184
#define compat_start_thread compat_start_thread

arch/arm64/kernel/cpufeature.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,8 @@ void verify_local_cpu_capabilities(void)
987987

988988
verify_local_cpu_features(arm64_features);
989989
verify_local_elf_hwcaps(arm64_elf_hwcaps);
990-
verify_local_elf_hwcaps(compat_elf_hwcaps);
990+
if (system_supports_32bit_el0())
991+
verify_local_elf_hwcaps(compat_elf_hwcaps);
991992
}
992993

993994
static void __init setup_feature_capabilities(void)
@@ -1004,7 +1005,9 @@ void __init setup_cpu_features(void)
10041005
/* Set the CPU feature capabilies */
10051006
setup_feature_capabilities();
10061007
setup_elf_hwcaps(arm64_elf_hwcaps);
1007-
setup_elf_hwcaps(compat_elf_hwcaps);
1008+
1009+
if (system_supports_32bit_el0())
1010+
setup_elf_hwcaps(compat_elf_hwcaps);
10081011

10091012
/* Advertise that we have computed the system capabilities */
10101013
set_sys_caps_initialised();

arch/arm64/kernel/sys.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/sched.h>
2626
#include <linux/slab.h>
2727
#include <linux/syscalls.h>
28+
#include <asm/cpufeature.h>
2829

2930
asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
3031
unsigned long prot, unsigned long flags,
@@ -36,11 +37,20 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
3637
return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
3738
}
3839

40+
SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
41+
{
42+
if (personality(personality) == PER_LINUX32 &&
43+
!system_supports_32bit_el0())
44+
return -EINVAL;
45+
return sys_personality(personality);
46+
}
47+
3948
/*
4049
* Wrappers to pass the pt_regs argument.
4150
*/
4251
asmlinkage long sys_rt_sigreturn_wrapper(void);
4352
#define sys_rt_sigreturn sys_rt_sigreturn_wrapper
53+
#define sys_personality sys_arm64_personality
4454

4555
#undef __SYSCALL
4656
#define __SYSCALL(nr, sym) [nr] = sym,

0 commit comments

Comments
 (0)