Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1830787rda; Tue, 24 Oct 2023 04:56:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMLaCan0o/nnNOfpZrupnHP3zMJUjqV1ozbkbnVlYBZIAhV8Z3lfIiL5gn+A+vk3XualdI X-Received: by 2002:a17:902:7487:b0:1c7:755d:ccc8 with SMTP id h7-20020a170902748700b001c7755dccc8mr9801050pll.29.1698148589336; Tue, 24 Oct 2023 04:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148589; cv=none; d=google.com; s=arc-20160816; b=wHuxh4u/ai79J7cVs9K1ghRceArcEGS4MIy4ICPEt9jF87/i2/KYdDl86VwOmXcunK IhhwHcSE65LeKpgFwrpt6bvR+2TMQ7COeAyJkhEblYRvUS/Ngpye/VtzK7i6MH67M4IF ixC6ZgobZNSv32Ddf1dEOkvf+YMDkmO8w+DfrAFa8WEtr3+KGfu7ef8EHusLdAdeC069 s+lRVYHDUvDl63nogrr8q5WPSKBdlBITJ5QBEBXj6I2euF3IKV1Sv/dWZi9qu5uZgpFM oAgvj7PsdgW2QZAqXXfN2mln+0tN77wGPTxnSqhlNqB9tcNRzO+t+c9bfNRYFhQuWeuZ BlUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=RbmoX6nDrrYKrCSix5sN1d2wibyLBbPzpPQnHi9Qul4=; fh=YNI2K2Kr54FkX7ypFlyelPlkwNUCd8IUtijDJcLvCcM=; b=osrPXCTxu4MbI52toP0D8XUe3iqTguWZo97PDPCPuNL0lzuuCvV1uuQI0zU+OWp/cx SUPLzVS9AsoUtOHNG2uCk4wDRQa0YMWQda5BZ5GfKqSyqbBUiot8MpLQ9Dpb+mAK13bA L8YNOn0dOFFytP7yOFF7f7NaH8KevF9dFyFjgaYWpHavH3/y+tVTVjk+9gstekagB/Fe G3YQStqlwdISOU95wz0CpOdtvTt6Lqj1md6KAzS9EEB5RbO3OQL+mSlfMUpResO2ljQa sDkFsSV52p4hBPeUMdyg7J5GTUWrkIMXIUIRdZAxGykGfTpCXCYapXuCW/syO6n/RTo8 itgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u11-20020a17090282cb00b001bbb39c68b2si8204600plz.178.2023.10.24.04.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:56:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DE8808041FE8; Tue, 24 Oct 2023 04:56:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232340AbjJXL4U (ORCPT + 99 others); Tue, 24 Oct 2023 07:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbjJXL4S (ORCPT ); Tue, 24 Oct 2023 07:56:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A11BBD for ; Tue, 24 Oct 2023 04:56:16 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C653C2F4; Tue, 24 Oct 2023 04:56:56 -0700 (PDT) Received: from [10.1.196.40] (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8B70A3F64C; Tue, 24 Oct 2023 04:56:14 -0700 (PDT) Message-ID: Date: Tue, 24 Oct 2023 12:56:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] arm64: Introduce aarch32_enabled() Content-Language: en-GB To: Andrea della Porta , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nik.borisov@suse.com, arnd@arndb.de, mark.rutland@arm.com References: <1dec05cc8f54d0b85acffce69d929f13e6d81313.1698069331.git.andrea.porta@suse.com> From: Robin Murphy In-Reply-To: <1dec05cc8f54d0b85acffce69d929f13e6d81313.1698069331.git.andrea.porta@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 04:56:27 -0700 (PDT) On 23/10/2023 3:42 pm, Andrea della Porta wrote: > Aarch32 bit support on 64bit kernels depends on whether CONFIG_COMPAT > is selected or not. As it is a compile time option it doesn't > provide the flexibility to have distributions set their own policy for > Aarch32 support and give the user the flexibility to override it. > > As a first step introduce aarch32_enabled() which abstracts whether 32 > bit compat is turned on or off. Upcoming patches will implement > the ability to set Aarch32 compat state at boot time. Other than patch #3, which as previously mentioned should be unnecessary if the kernel correctly never starts an "unsupported" AArch32 process to begin with, what does this do that simply overriding ID_AA64PFR0_EL1.EL0 via the existing idreg-override mechanism wouldn't? Thanks, Robin. > Signed-off-by: Andrea della Porta > --- > arch/arm64/include/asm/cpufeature.h | 15 +++++++++++++++ > arch/arm64/kernel/entry-common.c | 2 ++ > 2 files changed, 17 insertions(+) > > diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h > index 396af9b9c857..1180d68daaff 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -657,6 +657,21 @@ static inline bool supports_clearbhb(int scope) > ID_AA64ISAR2_EL1_CLRBHB_SHIFT); > } > > +#ifdef CONFIG_COMPAT > +extern bool __aarch32_enabled; > + > +static inline bool aarch32_enabled(void) > +{ > + return __aarch32_enabled; > +} > +#else /* !CONFIG_COMPAT */ > + > +static inline bool aarch32_enabled(void) > +{ > + return false; > +} > +#endif > + > const struct cpumask *system_32bit_el0_cpumask(void); > DECLARE_STATIC_KEY_FALSE(arm64_mismatched_32bit_el0); > > diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c > index 0fc94207e69a..69ff9b8c0bde 100644 > --- a/arch/arm64/kernel/entry-common.c > +++ b/arch/arm64/kernel/entry-common.c > @@ -877,6 +877,8 @@ asmlinkage void noinstr el0t_32_error_handler(struct pt_regs *regs) > { > __el0_error_handler_common(regs); > } > + > +bool __aarch32_enabled __ro_after_init = true; > #else /* CONFIG_COMPAT */ > UNHANDLED(el0t, 32, sync) > UNHANDLED(el0t, 32, irq)