From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A37FC61DF4 for ; Fri, 24 Nov 2023 12:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=U27kMlz/XEdl6bi+QEogv/8pEsZh+Zq1KE0FCXlws+A=; b=tgS7GohLTbnYDo R0vqpexVY6FMrLAYuhUtPHGJYiibQRIXybiVHyh/2DYaMSL/nR5EcykQw8hNK5AEXSLvpWJqx4nkY PRV9sWOYp/VE6moMCAFaLBfXpdBVIpXGKfgf7TM6s464QdGUv4DGl2fXzw95cVyzWF38O5920Ypxs YCsfoLTDrdr7DdWEa/9v/GKWX5fGzMcgZ7hicVS2Mnx6BtB0ePXaGTxSkpPK20s8xkf51xW74QQdD 2tIwAh0ZulGaB1fcDYRVeyjKwLL2eUaiHDIEBMKnIDZ2cidJ2PfSxLE/e4VLcEdL+eyM5Ii7VelZK En4DqqHpCgG2Ud+H+Dxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6VRI-007DVi-2J; Fri, 24 Nov 2023 12:37:44 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r6VRF-007DVH-2z for linux-arm-kernel@lists.infradead.org; Fri, 24 Nov 2023 12:37:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 735F5621A2; Fri, 24 Nov 2023 12:37:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 220E4C433C7; Fri, 24 Nov 2023 12:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700829460; bh=q9dWaPwLsV2luvklskm2b9rTuIErEEgmA7H3uM233FQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ew75uV6fstMogDF6geE4dRKuW94FZH2VTi2rDQSHQvhYT2x7SWt8Ep1A/QQ1ZeW4u Z5JpjqIFkD1Y6pbD9tHsTRAIZ9jnbihZU7wjJF/ZmRfPlQSYTG8liWFkxtiQ+ua2H/ QL0EXeI28/UHaldO5Bf+Is887rR9vUSHfhIc2U+jEtah7WN1mQH/4Flc0N2w4xN0oQ 0wSARx2lXU1IqTexhfjA+6dDl1gq7j9GoFV4jirpVxhv/vFYDcIKTQk7iFwVjTxj+C 5i8MW9JlzpyhWG7uG+DjtBmeYBx0OX/LisgvH9tp4qNNU1JBNzbOljxtD2I5yMpiNC JYMq9EBq824qQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r6VRB-00G5yQ-Uj; Fri, 24 Nov 2023 12:37:38 +0000 Date: Fri, 24 Nov 2023 12:37:33 +0000 Message-ID: <86plzzcooi.wl-maz@kernel.org> From: Marc Zyngier To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: Re: [PATCH v5 29/39] arm64: Add helpers to probe local CPU for PAC and BTI support In-Reply-To: <20231124101840.944737-70-ardb@google.com> References: <20231124101840.944737-41-ardb@google.com> <20231124101840.944737-70-ardb@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ardb@google.com, linux-arm-kernel@lists.infradead.org, ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, ryan.roberts@arm.com, anshuman.khandual@arm.com, keescook@chromium.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231124_043742_056009_C171E746 X-CRM114-Status: GOOD ( 23.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 24 Nov 2023 10:19:09 +0000, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > Add some helpers that will be used by the early kernel mapping code to > check feature support on the local CPU. This permits the early kernel > mapping to be created with the right attributes, removing the need for > tearing it down and recreating it. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/include/asm/cpufeature.h | 44 ++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h > index 99c01417e544..301d4d2211d5 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -921,6 +921,50 @@ static inline bool kaslr_disabled_cmdline(void) > u32 get_kvm_ipa_limit(void); > void dump_cpu_features(void); > > +static inline bool cpu_has_bti(void) > +{ > + u64 pfr1; > + > + if (!IS_ENABLED(CONFIG_ARM64_BTI)) > + return false; > + > + pfr1 = read_cpuid(ID_AA64PFR1_EL1); > + pfr1 &= ~id_aa64pfr1_override.mask; > + pfr1 |= id_aa64pfr1_override.val; There is a potential gotcha here. If the override failed because a filter rejected it, val will be set to full ones for the size of the failed override field, and the corresponding mask will be set to 0 (see match_options()). A safer pattern would be: pfr1 |= id_aa64pfr1_override.val & id_aa64pfr1_override.mask; although we currently don't have such a filter for BTI nor PAC, so the code is OK for now. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel