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 9D108C4167B for ; Mon, 27 Nov 2023 11:10:53 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6kAOkWEcST4q9X4kfhcbLuUL75rc6O8x2Xaw7E6Op8w=; b=tSMb1DEcPIHRE1 T/6yDrBeB9Wr1zEhgpeER98pzZ38g2Cl700nkWuxp0pUZ5jSw7NSN9MzPcar9RbwwOSrMK2dQ3q0Z y1ABLG209pM5PCaBOsADre4mn1MRR6q5sDqr5PMHWwTXrBY6Gdl378RnGU4VrWTFsLKAKIQ/Xk3uQ DgEWFinOsniFtasWEdzVNqx1HnQHnHtuK5cxf0VF/YzcR0BQtI3I3ba6Mo5Myht0coLkRy0I3ZwV7 OGoyTSgkra1dSu5dZRSi4+aG4Wwi67DqRV899qmbV++xjVcWgIFJDHfMVJYasfdqGJaO+2ysFoEM0 9cWPwbWp1PngbpglpWww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7ZVT-002Arp-0m; Mon, 27 Nov 2023 11:10:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7ZVK-002App-12 for linux-arm-kernel@lists.infradead.org; Mon, 27 Nov 2023 11:10:19 +0000 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 5672F2F4; Mon, 27 Nov 2023 03:11:01 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.43.171]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A57E83F73F; Mon, 27 Nov 2023 03:10:12 -0800 (PST) Date: Mon, 27 Nov 2023 11:10:07 +0000 From: Mark Rutland To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, Ard Biesheuvel Subject: Re: [PATCH] arm64: Avoid enabling KPTI unnecessarily Message-ID: References: <20231127102141.2241123-2-ardb@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231127102141.2241123-2-ardb@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_031018_502945_D51F962B X-CRM114-Status: GOOD ( 18.95 ) 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 Hi Ard, On Mon, Nov 27, 2023 at 11:21:42AM +0100, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > Commit 42c5a3b04bf6 refactored the KPTI init code in a way that results > in the use of non-global kernel mappings even on systems that have no > need for it, and even when KPTI has been disabled explicitly via the > command line. > > Ensure that this only happens when we have decided (based on the > detected CPU features) that KPTI should be enabled. > > Fixes: 42c5a3b04bf6 ("arm64: Split kpti_install_ng_mappings()") > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kernel/cpufeature.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 646591c67e7a..4b1762b9c37c 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3352,7 +3352,8 @@ void __init setup_system_features(void) > */ > enable_cpu_capabilities(SCOPE_ALL & ~SCOPE_BOOT_CPU); > > - kpti_install_ng_mappings(); > + if (arm64_kernel_unmapped_at_el0()) > + kpti_install_ng_mappings(); My bad; I had intended that kpti_install_ng_mappings() checked everything necessary, but clearly I missed this. Modulo breakage, could we move the conditionality into kpti_install_ng_mappings()? Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel