Commit 643d703d authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Will Deacon

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: default avatarYury Norov <ynorov@caviumnetworks.com>
[ Added cap bit, checks for HWCAP, personality ]
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: default avatarYury Norov <ynorov@caviumnetworks.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 042446a3
...@@ -177,7 +177,8 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; ...@@ -177,7 +177,8 @@ typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
/* AArch32 EABI. */ /* AArch32 EABI. */
#define EF_ARM_EABI_MASK 0xff000000 #define EF_ARM_EABI_MASK 0xff000000
#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ #define compat_elf_check_arch(x) (system_supports_32bit_el0() && \
((x)->e_machine == EM_ARM) && \
((x)->e_flags & EF_ARM_EABI_MASK)) ((x)->e_flags & EF_ARM_EABI_MASK))
#define compat_start_thread compat_start_thread #define compat_start_thread compat_start_thread
......
...@@ -987,7 +987,8 @@ void verify_local_cpu_capabilities(void) ...@@ -987,7 +987,8 @@ void verify_local_cpu_capabilities(void)
verify_local_cpu_features(arm64_features); verify_local_cpu_features(arm64_features);
verify_local_elf_hwcaps(arm64_elf_hwcaps); verify_local_elf_hwcaps(arm64_elf_hwcaps);
verify_local_elf_hwcaps(compat_elf_hwcaps); if (system_supports_32bit_el0())
verify_local_elf_hwcaps(compat_elf_hwcaps);
} }
static void __init setup_feature_capabilities(void) static void __init setup_feature_capabilities(void)
...@@ -1004,7 +1005,9 @@ void __init setup_cpu_features(void) ...@@ -1004,7 +1005,9 @@ void __init setup_cpu_features(void)
/* Set the CPU feature capabilies */ /* Set the CPU feature capabilies */
setup_feature_capabilities(); setup_feature_capabilities();
setup_elf_hwcaps(arm64_elf_hwcaps); setup_elf_hwcaps(arm64_elf_hwcaps);
setup_elf_hwcaps(compat_elf_hwcaps);
if (system_supports_32bit_el0())
setup_elf_hwcaps(compat_elf_hwcaps);
/* Advertise that we have computed the system capabilities */ /* Advertise that we have computed the system capabilities */
set_sys_caps_initialised(); set_sys_caps_initialised();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <asm/cpufeature.h>
asmlinkage long sys_mmap(unsigned long addr, unsigned long len, asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
unsigned long prot, unsigned long flags, unsigned long prot, unsigned long flags,
...@@ -36,11 +37,20 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len, ...@@ -36,11 +37,20 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT); return sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
} }
SYSCALL_DEFINE1(arm64_personality, unsigned int, personality)
{
if (personality(personality) == PER_LINUX32 &&
!system_supports_32bit_el0())
return -EINVAL;
return sys_personality(personality);
}
/* /*
* Wrappers to pass the pt_regs argument. * Wrappers to pass the pt_regs argument.
*/ */
asmlinkage long sys_rt_sigreturn_wrapper(void); asmlinkage long sys_rt_sigreturn_wrapper(void);
#define sys_rt_sigreturn sys_rt_sigreturn_wrapper #define sys_rt_sigreturn sys_rt_sigreturn_wrapper
#define sys_personality sys_arm64_personality
#undef __SYSCALL #undef __SYSCALL
#define __SYSCALL(nr, sym) [nr] = sym, #define __SYSCALL(nr, sym) [nr] = sym,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment