Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1809725pxu; Fri, 27 Nov 2020 16:18:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw37Qvm9v+lNIjRMBbtuf5OBxAakyzqSHfl7r9rLPDwcxuoQSjVLwIIhcvWaxD2F/kzjyO/ X-Received: by 2002:aa7:d7d7:: with SMTP id e23mr10800810eds.78.1606522705542; Fri, 27 Nov 2020 16:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606522705; cv=none; d=google.com; s=arc-20160816; b=L7QIj1KOp2db/aknJcDko542mKIWY9glIfmlLuppqvqq10Go4YrQbCrozJJeqVBTdV XqGEhF+ydrbQcnCt+35jBL5JTP0PCim0qJhEZ3ERIBWweRFWTRunRYm8mozTVx3Qzb4O zjb5MzXFlGXu3y/1JYQBuwL26AZRtSaeloCRwiPeJkEva9KHvEgiAWbM6/JkuKY2851+ RogyJpXs4m99er/bdaHNtVxtBnfGbpRps8IAz8xfxIRLBI93vQRb2BdMm02QAfA6aXJa OD/EbXqhlAeVta2MKIVlQOa7pE/BU87vYcZGm+gfmwkMpvNsdpG8E4+PDZ1on/Wn9/Dq 5VGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=drI2NMaA1h0By8bzx5QzMtmQW2Z0hFOGwlex65B97ww=; b=u+81OdvhfU0X8iWV0wRb2YntagrAdM/KG1x1/SD0R1I4ZayZScNYI/6G5le/3ePEBd 1tsMtSKuli+dqEE+X7cWtXx1rnLHvBaYyKhARvYm2p8F3TMpH8rnfPsu9WnxymteFDAY eWkqsfzpevFC+b6Sk9EwFDYbIRX5uz/dPvjp7+Y2p3eW8yVhOl2Lhki3oqFcTvVxVPCw VQHglgb4giKKrIlggwM7+csYV+hw9N05uA58OZ7bOZDfTVfvKZY/VUcVLEYUtVyOPwNT Dz4EMQKZiJ+wkDO7+U/tyQPhR+0+TnLIWWA1WC/919wYvksUQbxJ3sj4TzIKge7pVyaT qpwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=baVlIfO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si7252028edr.228.2020.11.27.16.18.01; Fri, 27 Nov 2020 16:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=baVlIfO4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729274AbgK0Lud (ORCPT + 99 others); Fri, 27 Nov 2020 06:50:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:60232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725985AbgK0Luc (ORCPT ); Fri, 27 Nov 2020 06:50:32 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BCF621D46; Fri, 27 Nov 2020 11:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606477831; bh=LtVP95hrMMclG30wUBaX1D+fuXhT9e1/YraMHggZoh4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=baVlIfO4opAFzmlCelU1RQ/Ds6muHOTAl+KSi62Xbp8/MIWJqKnE0Ve3lP4Y6gy7P b+esiDjwFAuzVUsRCaxta69kKtcv3ECBwbgqVWIQJ7E16ksrQR+LQ0mwbI0qq294ts mqWKmcetdnshC1gijJOw7q0zMyvniz8Fltl0Snzk= Date: Fri, 27 Nov 2020 11:50:24 +0000 From: Will Deacon To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v4 02/14] arm64: Allow mismatched 32-bit EL0 support Message-ID: <20201127115024.GA20564@willie-the-truck> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-3-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 27, 2020 at 10:25:06AM +0000, Marc Zyngier wrote: > On 2020-11-24 15:50, Will Deacon wrote: > > When confronted with a mixture of CPUs, some of which support 32-bit > > applications and others which don't, we quite sensibly treat the system > > as 64-bit only for userspace and prevent execve() of 32-bit binaries. > > > > Unfortunately, some crazy folks have decided to build systems like this > > with the intention of running 32-bit applications, so relax our > > sanitisation logic to continue to advertise 32-bit support to userspace > > on these systems and track the real 32-bit capable cores in a cpumask > > instead. For now, the default behaviour remains but will be tied to > > a command-line option in a later patch. > > > > Signed-off-by: Will Deacon > > --- > > arch/arm64/include/asm/cpucaps.h | 2 +- > > arch/arm64/include/asm/cpufeature.h | 8 ++- > > arch/arm64/kernel/cpufeature.c | 106 ++++++++++++++++++++++++++-- > > 3 files changed, 107 insertions(+), 9 deletions(-) > > > > diff --git a/arch/arm64/include/asm/cpucaps.h > > b/arch/arm64/include/asm/cpucaps.h > > index e7d98997c09c..e6f0eb4643a0 100644 > > --- a/arch/arm64/include/asm/cpucaps.h > > +++ b/arch/arm64/include/asm/cpucaps.h > > @@ -20,7 +20,7 @@ > > #define ARM64_ALT_PAN_NOT_UAO 10 > > #define ARM64_HAS_VIRT_HOST_EXTN 11 > > #define ARM64_WORKAROUND_CAVIUM_27456 12 > > -#define ARM64_HAS_32BIT_EL0 13 > > +#define ARM64_HAS_32BIT_EL0_DO_NOT_USE 13 > > #define ARM64_HARDEN_EL2_VECTORS 14 > > #define ARM64_HAS_CNP 15 > > #define ARM64_HAS_NO_FPSIMD 16 > > diff --git a/arch/arm64/include/asm/cpufeature.h > > b/arch/arm64/include/asm/cpufeature.h > > index 97244d4feca9..f447d313a9c5 100644 > > --- a/arch/arm64/include/asm/cpufeature.h > > +++ b/arch/arm64/include/asm/cpufeature.h > > @@ -604,9 +604,15 @@ static inline bool > > cpu_supports_mixed_endian_el0(void) > > return id_aa64mmfr0_mixed_endian_el0(read_cpuid(ID_AA64MMFR0_EL1)); > > } > > > > +const struct cpumask *system_32bit_el0_cpumask(void); > > +DECLARE_STATIC_KEY_FALSE(arm64_mismatched_32bit_el0); > > + > > static inline bool system_supports_32bit_el0(void) > > { > > - return cpus_have_const_cap(ARM64_HAS_32BIT_EL0); > > + u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1); > > + > > + return id_aa64pfr0_32bit_el0(pfr0) || > > + static_branch_unlikely(&arm64_mismatched_32bit_el0); > > nit: swapping the two sides of this expression has the potential > for slightly better code, resulting in better performance on > these asymmetric systems. Not a big real, but since this lands > on the fast path on vcpu exit, I'll take every bit of optimisation. I'll swap 'em, thanks. Will