Message ID | 1378762380-13152-1-git-send-email-apinski@cavium.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Sep 9, 2013 at 2:32 PM, Andrew Pinski <pinskia@gmail.com> wrote: > Since the ILP32 ABI uses similar signal code as the LP64 ABI, it makes sense to reuse rather > than copy the same code. I just noticed that signal_template.c was not part of this patch but it is included with patch number 5. Thanks, Andrew Pinski > > > Signed-off-by: Andrew Pinski <apinski@cavium.com> > --- > arch/arm64/kernel/signal.c | 170 +------------------------------------------- > 1 files changed, 1 insertions(+), 169 deletions(-) > > diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c > index 3fbd848..d97a0c0 100644 > --- a/arch/arm64/kernel/signal.c > +++ b/arch/arm64/kernel/signal.c > @@ -95,176 +95,8 @@ static int restore_fpsimd_context(struct fpsimd_context __user *ctx) > return err ? -EFAULT : 0; > } > > -static int restore_sigframe(struct pt_regs *regs, > - struct rt_sigframe __user *sf) > -{ > - sigset_t set; > - int i, err; > - struct aux_context __user *aux = > - (struct aux_context __user *)sf->uc.uc_mcontext.__reserved; > - > - err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set)); > - if (err == 0) > - set_current_blocked(&set); > - > - for (i = 0; i < 31; i++) > - __get_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], > - err); > - __get_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); > - __get_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); > - __get_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); > - > - /* > - * Avoid sys_rt_sigreturn() restarting. > - */ > - regs->syscallno = ~0UL; > - > - err |= !valid_user_regs(®s->user_regs); > - > - if (err == 0) > - err |= restore_fpsimd_context(&aux->fpsimd); > - > - return err; > -} > - > -asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) > -{ > - struct rt_sigframe __user *frame; > - > - /* Always make any pending restarted system calls return -EINTR */ > - current_thread_info()->restart_block.fn = do_no_restart_syscall; > - > - /* > - * Since we stacked the signal on a 128-bit boundary, then 'sp' should > - * be word aligned here. > - */ > - if (regs->sp & 15) > - goto badframe; > - > - frame = (struct rt_sigframe __user *)regs->sp; > - > - if (!access_ok(VERIFY_READ, frame, sizeof (*frame))) > - goto badframe; > - > - if (restore_sigframe(regs, frame)) > - goto badframe; > - > - if (restore_altstack(&frame->uc.uc_stack)) > - goto badframe; > - > - return regs->regs[0]; > - > -badframe: > - if (show_unhandled_signals) > - pr_info_ratelimited("%s[%d]: bad frame in %s: pc=%08llx sp=%08llx\n", > - current->comm, task_pid_nr(current), __func__, > - regs->pc, regs->sp); > - force_sig(SIGSEGV, current); > - return 0; > -} > - > -static int setup_sigframe(struct rt_sigframe __user *sf, > - struct pt_regs *regs, sigset_t *set) > -{ > - int i, err = 0; > - struct aux_context __user *aux = > - (struct aux_context __user *)sf->uc.uc_mcontext.__reserved; > - > - /* set up the stack frame for unwinding */ > - __put_user_error(regs->regs[29], &sf->fp, err); > - __put_user_error(regs->regs[30], &sf->lr, err); > - > - for (i = 0; i < 31; i++) > - __put_user_error(regs->regs[i], &sf->uc.uc_mcontext.regs[i], > - err); > - __put_user_error(regs->sp, &sf->uc.uc_mcontext.sp, err); > - __put_user_error(regs->pc, &sf->uc.uc_mcontext.pc, err); > - __put_user_error(regs->pstate, &sf->uc.uc_mcontext.pstate, err); > - > - __put_user_error(current->thread.fault_address, &sf->uc.uc_mcontext.fault_address, err); > - > - err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(*set)); > - > - if (err == 0) > - err |= preserve_fpsimd_context(&aux->fpsimd); > - > - /* set the "end" magic */ > - __put_user_error(0, &aux->end.magic, err); > - __put_user_error(0, &aux->end.size, err); > +#include "signal_template.c" > > - return err; > -} > - > -static struct rt_sigframe __user *get_sigframe(struct k_sigaction *ka, > - struct pt_regs *regs) > -{ > - unsigned long sp, sp_top; > - struct rt_sigframe __user *frame; > - > - sp = sp_top = regs->sp; > - > - /* > - * This is the X/Open sanctioned signal stack switching. > - */ > - if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp)) > - sp = sp_top = current->sas_ss_sp + current->sas_ss_size; > - > - sp = (sp - sizeof(struct rt_sigframe)) & ~15; > - frame = (struct rt_sigframe __user *)sp; > - > - /* > - * Check that we can actually write to the signal frame. > - */ > - if (!access_ok(VERIFY_WRITE, frame, sp_top - sp)) > - frame = NULL; > - > - return frame; > -} > - > -static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, > - void __user *frame, int usig) > -{ > - __sigrestore_t sigtramp; > - > - regs->regs[0] = usig; > - regs->sp = (unsigned long)frame; > - regs->regs[29] = regs->sp + offsetof(struct rt_sigframe, fp); > - regs->pc = (unsigned long)ka->sa.sa_handler; > - > - if (ka->sa.sa_flags & SA_RESTORER) > - sigtramp = ka->sa.sa_restorer; > - else > - sigtramp = VDSO_SYMBOL(current->mm->context.vdso, sigtramp); > - > - regs->regs[30] = (unsigned long)sigtramp; > -} > - > -static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, > - sigset_t *set, struct pt_regs *regs) > -{ > - struct rt_sigframe __user *frame; > - int err = 0; > - > - frame = get_sigframe(ka, regs); > - if (!frame) > - return 1; > - > - __put_user_error(0, &frame->uc.uc_flags, err); > - __put_user_error(NULL, &frame->uc.uc_link, err); > - > - err |= __save_altstack(&frame->uc.uc_stack, regs->sp); > - err |= setup_sigframe(frame, regs, set); > - if (err == 0) { > - setup_return(regs, ka, frame, usig); > - if (ka->sa.sa_flags & SA_SIGINFO) { > - err |= copy_siginfo_to_user(&frame->info, info); > - regs->regs[1] = (unsigned long)&frame->info; > - regs->regs[2] = (unsigned long)&frame->uc; > - } > - } > - > - return err; > -} > > static void setup_restart_syscall(struct pt_regs *regs) > { > -- > 1.7.2.5 >
On 09/09/2013 02:38 PM, Andrew Pinski wrote: > On Mon, Sep 9, 2013 at 2:32 PM, Andrew Pinski <pinskia@gmail.com> wrote: >> Since the ILP32 ABI uses similar signal code as the LP64 ABI, it makes sense to reuse rather >> than copy the same code. > > I just noticed that signal_template.c was not part of this patch but > it is included with patch number 5. > At a minimum, the patch set should be respun so that it builds, runs and has no unusable Kconfig options at all intermediate points in the set. You could also consider splitting out cosmetic changes unrelated to the meat of a change to a separate patches. David Daney
Hi Andrew, On Mon, Sep 09, 2013 at 10:32:55PM +0100, Andrew Pinski wrote: > Right now CONFIG_COMPAT means enabling AARCH32 support in the ARM64 traget, which we want to split out so we can it to mean any 32bit ABI support instead. First, there are some coding style and patch format issues. Please pass the patches through checkpatch.pl. Also, I would like to see a cover letter giving an overview of the ABI changes needed for arm64 ILP32 and better, longer patch description. At a first look, you would think that this simply changes CONFIG_COMPAT to CONFIG_ARM64_AARCH32 but you have other changes like compat_elf_greg_t types. More comments below. > --- a/arch/arm64/include/asm/compat.h > +++ b/arch/arm64/include/asm/compat.h > @@ -279,28 +279,52 @@ struct compat_shmid64_ds { > compat_ulong_t __unused5; > }; > > -static inline int is_compat_task(void) > +#if defined(CONFIG_ARM64_AARCH32) > +static inline int is_aarch32_task(void) > { > return test_thread_flag(TIF_32BIT); > } > > -static inline int is_compat_thread(struct thread_info *thread) > +static inline int is_aarch32_thread(struct thread_info *thread) > { > return test_ti_thread_flag(thread, TIF_32BIT); > } > +#else > +static inline int is_aarch32_task(void) > +{ > + return 0; > +} > + > +static inline int is_aarch32_thread(struct thread_info *thread) > +{ > + return 0; > +} > +#endif > + > > #else /* !CONFIG_COMPAT */ Is the comment still correct here? > -static inline int is_compat_task(void) > +static inline int is_aarch32_task(void) > { > return 0; > } > > -static inline int is_compat_thread(struct thread_info *thread) > +static inline int is_aarch32_thread(struct thread_info *thread) > { > return 0; > } > > #endif /* CONFIG_COMPAT */ Same here. > diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h > index e7fa87f..0a89e94 100644 > --- a/arch/arm64/include/asm/elf.h > +++ b/arch/arm64/include/asm/elf.h > @@ -153,24 +153,33 @@ extern unsigned long arch_randomize_brk(struct mm_struct *mm); > > #define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3)) > > +#ifdef CONFIG_ARM64_AARCH32 > /* AArch32 registers. */ > #define COMPAT_ELF_NGREG 18 > -typedef unsigned int compat_elf_greg_t; > -typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; > +typedef unsigned int compat_a32_elf_greg_t; > +typedef compat_a32_elf_greg_t compat_a32_elf_gregset_t[COMPAT_ELF_NGREG]; I'm not sure we need to bother placing typedefs under #ifdef. I'll have to see how this file is modified in later patches. > > /* AArch32 EABI. */ > #define EF_ARM_EABI_MASK 0xff000000 > -#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ > +#define compat_elf_a32_check_arch(x) (((x)->e_machine == EM_ARM) && \ > ((x)->e_flags & EF_ARM_EABI_MASK)) > > -#define compat_start_thread compat_start_thread > -#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT); > +#define COMPAT_SET_A32_PERSONALITY(ex) set_thread_flag(TIF_32BIT); > #define COMPAT_ARCH_DLINFO > + > extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, > int uses_interp); > #define compat_arch_setup_additional_pages \ > aarch32_setup_vectors_page > > +typedef compat_a32_elf_greg_t compat_elf_greg_t; > +typedef compat_a32_elf_gregset_t compat_elf_gregset_t; > +#endif > + > +#define compat_elf_check_arch(x) compat_elf_a32_check_arch(x) > +#define COMPAT_SET_PERSONALITY(ex) COMPAT_SET_A32_PERSONALITY(x) > +#define compat_start_thread compat_start_thread > + > #endif /* CONFIG_COMPAT */ Mismatched comment? > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 20925bc..4a644a5 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -49,11 +49,11 @@ > > #ifdef CONFIG_COMPAT > #define TASK_SIZE_32 UL(0x100000000) > -#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ > +#define TASK_SIZE (is_compat_task() ? \ > TASK_SIZE_32 : TASK_SIZE_64) Does this file also need to include compat.h? > --- a/arch/arm64/include/asm/processor.h > +++ b/arch/arm64/include/asm/processor.h > @@ -38,7 +38,7 @@ > #define STACK_TOP_MAX TASK_SIZE_64 > #ifdef CONFIG_COMPAT > #define AARCH32_VECTORS_BASE 0xffff0000 > -#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ > +#define STACK_TOP (is_compat_task() ? \ > AARCH32_VECTORS_BASE : STACK_TOP_MAX) Same here. > --- a/arch/arm64/include/asm/ptrace.h > +++ b/arch/arm64/include/asm/ptrace.h > @@ -107,7 +107,7 @@ struct pt_regs { > > #define arch_has_single_step() (1) > > -#ifdef CONFIG_COMPAT > +#ifdef CONFIG_ARM64_AARCH32 > #define compat_thumb_mode(regs) \ > (((regs)->pstate & COMPAT_PSR_T_BIT)) Maybe for consistency it could be worth changing to compat_a32_thumb_mode(), if the aim is to use compat_ prefix for ILP32 as well (I'll see in the rest of the patches). > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -35,6 +35,7 @@ > #include <asm/system_misc.h> > #include <asm/pgtable.h> > #include <asm/tlbflush.h> > +#include <asm/compat.h> > > static const char *fault_name(unsigned int esr); > > diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c > index 8ed6cb1..29eb82a 100644 > --- a/arch/arm64/mm/mmap.c > +++ b/arch/arm64/mm/mmap.c > @@ -28,6 +28,7 @@ > #include <linux/random.h> > > #include <asm/cputype.h> > +#include <asm/compat.h> So you added these includes because one was missing in memory.h?
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index ae323a4..cc64df5 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -247,9 +247,13 @@ menu "Userspace binary formats" source "fs/Kconfig.binfmt" config COMPAT + def_bool y + depends on ARM64_AARCH32 + select COMPAT_BINFMT_ELF + +config ARM64_AARCH32 bool "Kernel support for 32-bit EL0" depends on !ARM64_64K_PAGES - select COMPAT_BINFMT_ELF select HAVE_UID16 select OLD_SIGSUSPEND3 select COMPAT_OLD_SIGACTION diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index 899af80..5ab2676 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -279,28 +279,52 @@ struct compat_shmid64_ds { compat_ulong_t __unused5; }; -static inline int is_compat_task(void) +#if defined(CONFIG_ARM64_AARCH32) +static inline int is_aarch32_task(void) { return test_thread_flag(TIF_32BIT); } -static inline int is_compat_thread(struct thread_info *thread) +static inline int is_aarch32_thread(struct thread_info *thread) { return test_ti_thread_flag(thread, TIF_32BIT); } +#else +static inline int is_aarch32_task(void) +{ + return 0; +} + +static inline int is_aarch32_thread(struct thread_info *thread) +{ + return 0; +} +#endif + #else /* !CONFIG_COMPAT */ -static inline int is_compat_task(void) +static inline int is_aarch32_task(void) { return 0; } -static inline int is_compat_thread(struct thread_info *thread) +static inline int is_aarch32_thread(struct thread_info *thread) { return 0; } #endif /* CONFIG_COMPAT */ + +static inline int is_compat_task(void) +{ + return is_aarch32_task(); +} + +static inline int is_compat_thread(struct thread_info *thread) +{ + return is_aarch32_thread(thread); +} + #endif /* __KERNEL__ */ #endif /* __ASM_COMPAT_H */ diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index e7fa87f..0a89e94 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -153,24 +153,33 @@ extern unsigned long arch_randomize_brk(struct mm_struct *mm); #define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3)) +#ifdef CONFIG_ARM64_AARCH32 /* AArch32 registers. */ #define COMPAT_ELF_NGREG 18 -typedef unsigned int compat_elf_greg_t; -typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; +typedef unsigned int compat_a32_elf_greg_t; +typedef compat_a32_elf_greg_t compat_a32_elf_gregset_t[COMPAT_ELF_NGREG]; /* AArch32 EABI. */ #define EF_ARM_EABI_MASK 0xff000000 -#define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \ +#define compat_elf_a32_check_arch(x) (((x)->e_machine == EM_ARM) && \ ((x)->e_flags & EF_ARM_EABI_MASK)) -#define compat_start_thread compat_start_thread -#define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT); +#define COMPAT_SET_A32_PERSONALITY(ex) set_thread_flag(TIF_32BIT); #define COMPAT_ARCH_DLINFO + extern int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp); #define compat_arch_setup_additional_pages \ aarch32_setup_vectors_page +typedef compat_a32_elf_greg_t compat_elf_greg_t; +typedef compat_a32_elf_gregset_t compat_elf_gregset_t; +#endif + +#define compat_elf_check_arch(x) compat_elf_a32_check_arch(x) +#define COMPAT_SET_PERSONALITY(ex) COMPAT_SET_A32_PERSONALITY(x) +#define compat_start_thread compat_start_thread + #endif /* CONFIG_COMPAT */ #endif diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index c43b4ac..1924290 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -39,7 +39,7 @@ struct fpsimd_state { }; }; -#if defined(__KERNEL__) && defined(CONFIG_COMPAT) +#if defined(__KERNEL__) && defined(CONFIG_ARM64_AARCH32) /* Masks for extracting the FPSR and FPCR from the FPSCR */ #define VFP_FPSCR_STAT_MASK 0xf800009f #define VFP_FPSCR_CTRL_MASK 0x07f79f00 diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index 6d4482f..d189728 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -37,12 +37,13 @@ * instruction set this cpu supports. */ #define ELF_HWCAP (elf_hwcap) -#define COMPAT_ELF_HWCAP (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ +#define COMPAT_ELF_A32_HWCAP (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\ COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\ COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\ COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV) extern unsigned int elf_hwcap; +#define COMPAT_ELF_HWCAP COMPAT_ELF_A32_HWCAP #endif #endif diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 20925bc..4a644a5 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -49,11 +49,11 @@ #ifdef CONFIG_COMPAT #define TASK_SIZE_32 UL(0x100000000) -#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ +#define TASK_SIZE (is_compat_task() ? \ TASK_SIZE_32 : TASK_SIZE_64) #else -#define TASK_SIZE TASK_SIZE_64 -#endif /* CONFIG_COMPAT */ +#define TASK_SIZE TASK_SIZE_64 +#endif #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 4)) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index ab239b2..9f0cbcd 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -38,7 +38,7 @@ #define STACK_TOP_MAX TASK_SIZE_64 #ifdef CONFIG_COMPAT #define AARCH32_VECTORS_BASE 0xffff0000 -#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ +#define STACK_TOP (is_compat_task() ? \ AARCH32_VECTORS_BASE : STACK_TOP_MAX) #else #define STACK_TOP STACK_TOP_MAX diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index 0dacbbf..832a4d8 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -107,7 +107,7 @@ struct pt_regs { #define arch_has_single_step() (1) -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 #define compat_thumb_mode(regs) \ (((regs)->pstate & COMPAT_PSR_T_BIT)) #else diff --git a/arch/arm64/include/asm/stat.h b/arch/arm64/include/asm/stat.h index 15e3559..989128a 100644 --- a/arch/arm64/include/asm/stat.h +++ b/arch/arm64/include/asm/stat.h @@ -18,7 +18,7 @@ #include <uapi/asm/stat.h> -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 #include <asm/compat.h> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7b4b564..e23efb7 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -11,7 +11,7 @@ arm64-obj-y := cputable.o debug-monitors.o entry.o irq.o fpsimd.o \ sys.o stacktrace.o time.o traps.o io.o vdso.o \ hyp-stub.o psci.o -arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ +arm64-obj-$(CONFIG_ARM64_AARCH32) += sys32.o kuser32.o signal32.o \ sys_compat.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_SMP) += smp.o smp_spin_table.o smp_psci.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 3881fd1..28cf5c7 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -167,7 +167,7 @@ ENTRY(vectors) ventry el0_fiq_invalid // FIQ 64-bit EL0 ventry el0_error_invalid // Error 64-bit EL0 -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 ventry el0_sync_compat // Synchronous 32-bit EL0 ventry el0_irq_compat // IRQ 32-bit EL0 ventry el0_fiq_invalid_compat // FIQ 32-bit EL0 @@ -207,7 +207,7 @@ el0_error_invalid: inv_entry 0, BAD_ERROR ENDPROC(el0_error_invalid) -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 el0_fiq_invalid_compat: inv_entry 0, BAD_FIQ, 32 ENDPROC(el0_fiq_invalid_compat) @@ -371,7 +371,7 @@ el0_sync: b.ge el0_dbg b el0_inv -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 .align 6 el0_sync_compat: kernel_entry 0, 32 diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 7090c12..ad6a33a 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -188,7 +188,7 @@ ENTRY(el2_setup) mov x0, #0x33ff msr cptr_el2, x0 // Disable copro. traps to EL2 -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 msr hstr_el2, xzr // Disable CP15 traps to EL2 #endif diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 329218c..fbaad0d 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -392,7 +392,7 @@ static int arch_build_bp_info(struct perf_event *bp) * Watchpoints can be of length 1, 2, 4 or 8 bytes. */ if (info->ctrl.type == ARM_BREAKPOINT_EXECUTE) { - if (is_compat_task()) { + if (is_aarch32_task()) { if (info->ctrl.len != ARM_BREAKPOINT_LEN_2 && info->ctrl.len != ARM_BREAKPOINT_LEN_4) return -EINVAL; @@ -449,7 +449,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp) * AArch32 tasks expect some simple alignment fixups, so emulate * that here. */ - if (is_compat_task()) { + if (is_aarch32_task()) { if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) alignment_mask = 0x7; else @@ -636,7 +636,7 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr, info = counter_arch_bp(wp); /* AArch32 watchpoints are either 4 or 8 bytes aligned. */ - if (is_compat_task()) { + if (is_aarch32_task()) { if (info->ctrl.len == ARM_BREAKPOINT_LEN_8) alignment_mask = 0x7; else diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 57fb55c..8845c2d 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -202,7 +202,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, if (likely(!(p->flags & PF_KTHREAD))) { *childregs = *current_pt_regs(); childregs->regs[0] = 0; - if (is_compat_thread(task_thread_info(p))) { + if (is_aarch32_thread(task_thread_info(p))) { if (stack_start) childregs->compat_sp = stack_start; } else { @@ -243,12 +243,12 @@ static void tls_thread_switch(struct task_struct *next) { unsigned long tpidr, tpidrro; - if (!is_compat_task()) { + if (!is_aarch32_task()) { asm("mrs %0, tpidr_el0" : "=r" (tpidr)); current->thread.tp_value = tpidr; } - if (is_compat_thread(task_thread_info(next))) { + if (is_aarch32_thread(task_thread_info(next))) { tpidr = 0; tpidrro = next->thread.tp_value; } else { diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index fecdbf7..4805581 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -69,10 +69,10 @@ static void ptrace_hbptriggered(struct perf_event *bp, .si_addr = (void __user *)(bkpt->trigger), }; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 int i; - if (!is_compat_task()) + if (!is_aarch32_task()) goto send_sig; for (i = 0; i < ARM_MAX_BRP; ++i) { @@ -609,7 +609,7 @@ static const struct user_regset_view user_aarch64_view = { .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) }; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 #include <linux/compat.h> enum compat_regset { @@ -775,8 +775,8 @@ static const struct user_regset aarch32_regsets[] = { [REGSET_COMPAT_GPR] = { .core_note_type = NT_PRSTATUS, .n = COMPAT_ELF_NGREG, - .size = sizeof(compat_elf_greg_t), - .align = sizeof(compat_elf_greg_t), + .size = sizeof(compat_a32_elf_greg_t), + .align = sizeof(compat_a32_elf_greg_t), .get = compat_gpr_get, .set = compat_gpr_set }, @@ -809,7 +809,7 @@ static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, tmp = tsk->mm->start_data; else if (off == COMPAT_PT_TEXT_END_ADDR) tmp = tsk->mm->end_code; - else if (off < sizeof(compat_elf_gregset_t)) + else if (off < sizeof(compat_a32_elf_gregset_t)) return copy_regset_to_user(tsk, &user_aarch32_view, REGSET_COMPAT_GPR, off, sizeof(compat_ulong_t), ret); @@ -829,7 +829,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off, if (off & 3 || off >= COMPAT_USER_SZ) return -EIO; - if (off >= sizeof(compat_elf_gregset_t)) + if (off >= sizeof(compat_a32_elf_gregset_t)) return 0; ret = copy_regset_from_user(tsk, &user_aarch32_view, @@ -989,7 +989,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ret = copy_regset_to_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, - 0, sizeof(compat_elf_gregset_t), + 0, sizeof(compat_a32_elf_gregset_t), datap); break; @@ -997,7 +997,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ret = copy_regset_from_user(child, &user_aarch32_view, REGSET_COMPAT_GPR, - 0, sizeof(compat_elf_gregset_t), + 0, sizeof(compat_a32_elf_gregset_t), datap); break; @@ -1045,12 +1045,12 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, return ret; } -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_ARM64_AARCH32 */ const struct user_regset_view *task_user_regset_view(struct task_struct *task) { -#ifdef CONFIG_COMPAT - if (is_compat_thread(task_thread_info(task))) +#ifdef CONFIG_ARM64_AARCH32 + if (is_aarch32_thread(task_thread_info(task))) return &user_aarch32_view; #endif return &user_aarch64_view; @@ -1069,7 +1069,7 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) if (!test_thread_flag(TIF_SYSCALL_TRACE)) return regs->syscallno; - if (is_compat_task()) { + if (is_aarch32_task()) { /* AArch32 uses ip (r12) for scratch */ saved_reg = regs->regs[12]; regs->regs[12] = dir; @@ -1087,7 +1087,7 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) else if (tracehook_report_syscall_entry(regs)) regs->syscallno = ~0UL; - if (is_compat_task()) + if (is_aarch32_task()) regs->regs[12] = saved_reg; else regs->regs[7] = saved_reg; diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 890a591..3fbd848 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -268,7 +268,7 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info, static void setup_restart_syscall(struct pt_regs *regs) { - if (is_compat_task()) + if (is_aarch32_task()) compat_setup_restart_syscall(regs); else regs->regs[8] = __NR_restart_syscall; @@ -295,7 +295,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka, /* * Set up the stack frame */ - if (is_compat_task()) { + if (is_aarch32_task()) { if (ka->sa.sa_flags & SA_SIGINFO) ret = compat_setup_rt_frame(usig, ka, info, oldset, regs); diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 7ffaddd..0bc28fa 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -285,9 +285,9 @@ long compat_arm_syscall(struct pt_regs *regs); asmlinkage long do_ni_syscall(struct pt_regs *regs) { -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 long ret; - if (is_compat_task()) { + if (is_aarch32_task()) { ret = compat_arm_syscall(regs); if (ret != -ENOSYS) return ret; diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 6a389dc..b5605ac 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -49,7 +49,7 @@ static union { } vdso_data_store __page_aligned_data; struct vdso_data *vdso_data = &vdso_data_store.data; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 /* * Create and map the vectors page for AArch32 tasks. */ @@ -99,7 +99,7 @@ int aarch32_setup_vectors_page(struct linux_binprm *bprm, int uses_interp) return ret; } -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_ARM64_AARCH32 */ static int __init vdso_init(void) { @@ -191,7 +191,7 @@ const char *arch_vma_name(struct vm_area_struct *vma) * it conflicting with the vectors base. */ if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso) { -#ifdef CONFIG_COMPAT +#ifdef CONFIG_ARM64_AARCH32 if (vma->vm_start == AARCH32_VECTORS_BASE) return "[vectors]"; #endif diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 6c8ba25..428658e 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -35,6 +35,7 @@ #include <asm/system_misc.h> #include <asm/pgtable.h> #include <asm/tlbflush.h> +#include <asm/compat.h> static const char *fault_name(unsigned int esr); diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 8ed6cb1..29eb82a 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c @@ -28,6 +28,7 @@ #include <linux/random.h> #include <asm/cputype.h> +#include <asm/compat.h> /* * Leave enough space between the mmap area and the stack to honour ulimit in