Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751436AbbLURJ7 (ORCPT ); Mon, 21 Dec 2015 12:09:59 -0500 Received: from foss.arm.com ([217.140.101.70]:49879 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbbLURJ4 (ORCPT ); Mon, 21 Dec 2015 12:09:56 -0500 Date: Mon, 21 Dec 2015 17:09:51 +0000 From: Catalin Marinas To: Yury Norov Cc: mark.rutland@arm.com, Suzuki.Poulose@arm.com, ard.biesheuvel@linaro.org, will.deacon@arm.com, linux-kernel@vger.kernel.org, klimov.linux@gmail.com, ddaney.cavm@gmail.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5] arm64: run-time detection for aarch32 support Message-ID: <20151221170951.GA24894@e104818-lin.cambridge.arm.com> References: <1450673050-12101-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450673050-12101-1-git-send-email-ynorov@caviumnetworks.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2111 Lines: 55 On Mon, Dec 21, 2015 at 07:44:10AM +0300, 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. > > v4: use new CPU Feature API. > v5: use cpuid_feature_extract_field. > > Signed-off-by: Yury Norov > --- > arch/arm64/include/asm/cpufeature.h | 7 +++++++ > arch/arm64/include/asm/elf.h | 6 ++++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h > index 8f271b8..bcb0dbe 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -184,6 +184,13 @@ static inline bool system_supports_mixed_endian_el0(void) > return id_aa64mmfr0_mixed_endian_el0(read_system_reg(SYS_ID_AA64MMFR0_EL1)); > } > > +static inline bool system_supports_aarch32_el0(void) > +{ > + u64 pfr0 = read_system_reg(SYS_ID_AA64PFR0_EL1); > + return cpuid_feature_extract_field(pfr0, ID_AA64PFR0_EL0_SHIFT) > + != ID_AA64PFR0_EL0_64BIT_ONLY; > +} Suzuki already suggested to hook this into the existing arm64_features[] array: http://lkml.kernel.org/g/56748437.2040905@arm.com > +#define compat_elf_check_arch(x) (system_supports_aarch32_el0() \ > + && ((x)->e_machine == EM_ARM) \ > + && ((x)->e_flags & EF_ARM_EABI_MASK)) And here use something like cpus_have_cap(ARM64_HAS_32BIT_EL0). And a nitpick: please use the same convention for placing the "&&" operator like in the rest of the file, i.e. on the previous line (similarly for "!=" etc.) -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/