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 DCA7BC47073 for ; Thu, 4 Jan 2024 18:21:08 +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=D0BgrDkxBvXHVmOdA93QNqA34btf/xHNNA/Ia3/hqPU=; b=aV3RmeQVjGUsIg 8bwKC2LDeDms8djgBXBw9NV4syYcO2nEKz80gs9n5fED3rv1wcnZURnb0yZqvZC14tI0FpSWZV5QP /DS037aFCchESw8XqJ/H872R+JredYZd5vBkEMMiVml0vGPL4o1kN90EP36lpRDkc1XRA1fBP9y5t 9zCqK3E+HqTieY3Zakoa3POtz0qaeKqczHZnX4WmikUZ/9s4V5EQGCX1z3Gl1yF4R8/XXE3ydmjpc TBinFaEXH4kbWrsr2AXbKNip7VcOTuugTO+5w4yzalSv9wEEihorzC/T03H1+OwrsO5U/3v/3lgh8 g4aGgyORCflygEJqRPvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLSKf-00EwhV-32; Thu, 04 Jan 2024 18:20:41 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLSKc-00EwhA-37 for linux-arm-kernel@lists.infradead.org; Thu, 04 Jan 2024 18:20:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 42CC7617E2; Thu, 4 Jan 2024 18:20:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0845C433C7; Thu, 4 Jan 2024 18:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704392437; bh=hUHPmvIxdQzT4lTOMflKeDh3RMXPM4EXAP3QWKhd9k0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WnMA1qJhIaFGrq2nrpR9A1UfLP7aCYcAypx1B0t/S1qbW24SlXiADaNMx9eGK/YO9 fLRpH/G6oqKldWYb50Orvpqaa8dcfa3HwZhKcrgQFxHfiobHQ6fOSjWMn0ZCpyQr0v d559YR9pymmFBYPFimsP8EZRMZS+oa82QNYPcSiHdL3B6usxxUygpaiBD7yT4Jh/ST sDlFDTCMN/vbmmmk/QhYJKIPy6wmxnDKEmAZDMv+ghW76IRHzgDr5E+rOh+i55oH8N HIMPvym1StaJvB7SsssF0vBed7m8j6p4ZhOG2BmTKdo8w5RAFC69Vrd2zOJQ5o78Jl Uan1NvVBmS/aA== 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 1rLSKZ-008tMN-BK; Thu, 04 Jan 2024 18:20:35 +0000 Date: Thu, 04 Jan 2024 18:20:34 +0000 Message-ID: <86frzd9czx.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, keirf@google.com, Quentin Perret Subject: Re: [PATCH] KVM: arm64: Add missing memory barriers when switching to pKVM's hyp pgd In-Reply-To: <20240104164220.7968-1-will@kernel.org> References: <20240104164220.7968-1-will@kernel.org> 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: will@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, keirf@google.com, qperret@google.com 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-20240104_102039_089530_D1A9BDF1 X-CRM114-Status: GOOD ( 26.96 ) 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 Thu, 04 Jan 2024 16:42:20 +0000, Will Deacon wrote: > > In commit f320bc742bc23 ("KVM: arm64: Prepare the creation of s1 > mappings at EL2"), pKVM switches from a temporary host-provided > page-table to its own page-table at EL2. Since there is only a single > TTBR for the nVHE hypervisor, this involves disabling and re-enabling > the MMU in __pkvm_init_switch_pgd(). > > Unfortunately, the memory barriers here are not quite correct. > Specifically: > > - A DSB is required to complete the TLB invalidation executed while > the MMU is disabled. > > - An ISB is required to make the new TTBR value visible to the > page-table walker before the MMU is enabled in the SCTLR. > > An earlier version of the patch actually got this correct: > > https://lore.kernel.org/lkml/20210304184717.GB21795@willie-the-truck/ > > but thanks to some badly worded review comments from yours truly, these > were dropped for the version that was eventually merged. > > Bring back the barriers and fix the potential issue (but note that this > was found by code inspection). > > Cc: Quentin Perret > Fixes: f320bc742bc23 ("KVM: arm64: Prepare the creation of s1 mappings at EL2") > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S > index 1cc06e6797bd..9205e95f8529 100644 > --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S > @@ -292,6 +292,8 @@ alternative_else_nop_endif > mov sp, x0 > > /* And turn the MMU back on! */ > + dsb nsh > + isb > set_sctlr_el2 x2 > ret x1 > SYM_FUNC_END(__pkvm_init_switch_pgd) I'm happy to take the patch as is, but maybe we consider moving these barriers into the set_sctlr helper as a future cleanup? 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