From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754864AbbIARlj (ORCPT ); Tue, 1 Sep 2015 13:41:39 -0400 Received: from eu-smtp-delivery-143.mimecast.com ([146.101.78.143]:37861 "EHLO eu-smtp-delivery-143.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754149AbbIARlc convert rfc822-to-8bit (ORCPT ); Tue, 1 Sep 2015 13:41:32 -0400 Message-ID: <55E5E349.4080802@arm.com> Date: Tue, 01 Sep 2015 18:41:29 +0100 From: "Suzuki K. Poulose" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Mark Rutland , Yury Norov CC: Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "ddaney@caviumnetworks.com" Subject: Re: [PATCH 2/2] arm64: don't load 32-bit binaries if platform has no aarch32_el0 References: <1441118472-3513-1-git-send-email-ynorov@caviumnetworks.com> <1441118472-3513-3-git-send-email-ynorov@caviumnetworks.com> <20150901160426.GB16430@leverpostej> In-Reply-To: <20150901160426.GB16430@leverpostej> X-OriginalArrivalTime: 01 Sep 2015 17:41:29.0824 (UTC) FILETIME=[6F32A600:01D0E4DD] X-MC-Unique: j1UnfQX9RSmSnZFlf0PDUw-1 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/09/15 17:04, Mark Rutland wrote: > On Tue, Sep 01, 2015 at 03:41:12PM +0100, Yury Norov wrote: >> Kernel option COMPAT defines the ability of executing aarch32 binaries. >> Some platforms does not support aarch32 mode, and so cannot execute that >> binaries. But we cannot just disable COMPAT for them because the same >> kernel binary may be used by multiple platforms. >> >> In this patch, system_supports_aarch32_el0() is introduced to detect >> aarch32 support at run-time. >> >> Signed-off-by: Yury Norov >> --- >> arch/arm64/include/asm/cpufeature.h | 1 + >> arch/arm64/include/asm/elf.h | 6 ++++-- >> arch/arm64/kernel/cpuinfo.c | 9 +++++++++ >> 3 files changed, 14 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h >> index 20cdc26..d24ea15 100644 >> --- a/arch/arm64/include/asm/cpufeature.h >> +++ b/arch/arm64/include/asm/cpufeature.h >> @@ -81,6 +81,7 @@ void check_local_cpu_errata(void); >> void check_local_cpu_features(void); >> bool cpu_supports_mixed_endian_el0(void); >> bool system_supports_mixed_endian_el0(void); >> +bool system_supports_aarch32_el0(void); >> >> #endif /* __ASSEMBLY__ */ >> >> diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h >> index faad6df..461897b 100644 >> --- a/arch/arm64/include/asm/elf.h >> +++ b/arch/arm64/include/asm/elf.h >> @@ -21,6 +21,7 @@ >> /* >> * ELF register definitions.. >> */ >> +#include >> #include >> #include >> >> @@ -173,8 +174,9 @@ typedef compat_elf_greg_t compat_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) && \ >> - ((x)->e_flags & EF_ARM_EABI_MASK)) >> +#define compat_elf_check_arch(x) (system_supports_aarch32_el0() \ >> + && ((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); >> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c >> index 75d5a86..95d953f 100644 >> --- a/arch/arm64/kernel/cpuinfo.c >> +++ b/arch/arm64/kernel/cpuinfo.c >> @@ -79,6 +79,15 @@ bool system_supports_mixed_endian_el0(void) >> return mixed_endian_el0; >> } >> >> +#define AARCH64 1 >> +#define AARCH32_64 2 > > These should be better namespaced. Perhaps ID_AA64PFR0_EL1_EL0_64 and > ID_AA64PFR0_EL1_EL0_6432 ? > >> +bool system_supports_aarch32_el0(void) >> +{ >> + struct cpuinfo_arm64 *info = this_cpu_ptr(&cpu_data); >> + u64 arm64_el0 = info->reg_id_aa64pfr0 & 0xf; >> + return arm64_el0 == AARCH32_64; >> +} > > We should handle this the same way as we do for endianness support and > check that all CPUs support AArch32, and set a global flag, rather than > assuming that all CPUs are symmetric. Likewise for any other feature we > have to dynamically detect. Correct. With my series, which I will post after the merge window, we should be able to define this as a CPU capability and check that bit instead, which would give us a system wide value. Suzuki > > Thanks, > Mark. >