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 CFA75C47073 for ; Thu, 4 Jan 2024 16:42:59 +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:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aEpepaEq/UnCiw6624cmgn/DfbLXz1sX2h5OVHxGl7c=; b=bcRmWIBKoS/kO4 Rm3NfaEGogF0ylnGh+WU/U1NQoQ9M+uxZ8mKCXmZuHp7TMaenWOTD9DS8p0rAUpY3M42RGIs31Sd4 A9vEylsu1z2NYFoOmXYOzzb8wlH+GDEsehIMlzuxCUSJUJiQv/5e3Ho8IY3oOEAt4dgiBhms4aHyN pWitNbpBh8FjRpTpHxvZbuRqWZlexA0rBMJ5kgwkUXJhc0AuVuqb5+YOeOjgYkUAjiD6JLbvf7UtE amWb6hrwYLfudhoBEVE/79QA//prqHoBQn7r3dh7bMnC9uTcDQapxli3HyBCHP2HdWzUWalrpAPWV Fa8low3X7rnWBgqifIXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLQnh-00Eiz5-0G; Thu, 04 Jan 2024 16:42:33 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLQne-00Eixu-1G for linux-arm-kernel@lists.infradead.org; Thu, 04 Jan 2024 16:42:31 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id BBE91B819F8; Thu, 4 Jan 2024 16:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2596C433C8; Thu, 4 Jan 2024 16:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704386548; bh=TnR23CGpf7NN8xYdZnwypKVjpHPjNqKbCrUSesLYtJ8=; h=From:To:Cc:Subject:Date:From; b=aD8vQWN8vtXKKNG5FO292zvDvXwyAlKV6gbS3I5VoOWICqFL+QodJ5SzY4d6u3QxD S3BhyDsQNaNhGPYOOOl3nd9sEav7e5zPpqU0yCA4Ja2N/QwwpUk25ARYkezk22bTOm KV50p+1DmgylF+0/xOAPl5TNs0mcEvfBL9BAtjRzwP4Cbghruk/e+/+jkxsy1qy5/q 3vJDe/KxNxP1Zt93v/ytaeFIkJsqtCVjMS7c1cFeoX+9GFVKbV+GUzkCtFNhS2KAOW cPgL5dotzIrVNbBOmX8w3UPBOvgMP0NLxonrC+Cih6NriO8A5Vzn1dzMcJxPhATAfO HAwqbf5iAC/IA== From: Will Deacon To: kvmarm@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org, maz@kernel.org, oliver.upton@linux.dev, keirf@google.com, Will Deacon , Quentin Perret Subject: [PATCH] KVM: arm64: Add missing memory barriers when switching to pKVM's hyp pgd Date: Thu, 4 Jan 2024 16:42:20 +0000 Message-Id: <20240104164220.7968-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240104_084230_587752_FF2B8656 X-CRM114-Status: GOOD ( 13.23 ) 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 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) -- 2.43.0.472.g3155946c3a-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel