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 71ABAC4345F for ; Mon, 15 Apr 2024 08:22:55 +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=dUmd7YPZVVCJtDdaajxSwqhaNzYT1SzTnwJOY3QNTZk=; b=HLf5iEUcHREEH4 ZYlg43wp3cxiBc/h47r4eJxWFjSYhNLHc7sKmVsp/f92jcSvv2hrQ3jJRorGA0hieM3x+8qHIJCrc Y60kMUCKSQwnJd1cUibGg5rw3SyPv+fT4WsaIQA18cNGOwTw4+nji6qOU3gAk8brX4ZYfyx3t/cHA pclM2NosFbdGtYAE2WC5WsxYtR+/vFfBEgEVcMCJ60afCTSXX0zs+d1l3OZQRsUPEgFyNNClI2xaS NhOfsTLoYyloCDf7ujE9luU/RyX+cItZIsXhLCyso9V3UyEgOJkzZFm6n8e6yfmu0TVOya/z7jkzH DGudQsllUQC6WIeZJl/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwHbz-00000007Wjp-21Sl; Mon, 15 Apr 2024 08:22:47 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwHbw-00000007Wi2-3UeC for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 08:22:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id BFC5ACE09E9; Mon, 15 Apr 2024 08:22:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F27F9C2BD11; Mon, 15 Apr 2024 08:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713169362; bh=buS9AjZGGcnTbrQJlROQFxz3eaoA30Cl91+5ey1GQDQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cb7+TQ3q8Oj1Fo9vqCErJnPaz8d8ODj3pruszfmhqwUMRL8HeoE6SX4+DIsqpybAk FRUz+u7WHFvjxYTSS47PX2XuVnaIOcgmIr42w2KFNUelmWZfXB67eZ1DZfQr/Mlr1A lfuD6Wy1GfDU+vBG/ZSppsfQ50jv0djEzzr3XoRwozMsEYN2C3dZUxfZK4DVRWnNwL MRCp3NeYlBVlrrPm2iksHMYEl8Zhqis6oI6wQZ20u6wuaqiM9zRj0wQscnFDy2JWxz P8/p+q+ZKH8xADkxHGRfkefM2q8gLKWM31DNGwvqgL+Uf4RrSJtqgPgTvrPDA/77Mu lpg6fe7I1zjIA== 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 1rwHbr-004XfT-SO; Mon, 15 Apr 2024 09:22:39 +0100 Date: Mon, 15 Apr 2024 09:22:39 +0100 Message-ID: <868r1frq5s.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 Subject: Re: [PATCH 2/2] arm64/head: Disable MMU at EL2 before clearing HCR_EL2.E2H In-Reply-To: <20240415075412.2347624-6-ardb+git@google.com> References: <20240415075412.2347624-4-ardb+git@google.com> <20240415075412.2347624-6-ardb+git@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.2 (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+git@google.com, linux-arm-kernel@lists.infradead.org, ardb@kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.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-20240415_012245_254999_B83F9D7B X-CRM114-Status: GOOD ( 26.35 ) 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 Mon, 15 Apr 2024 08:54:15 +0100, Ard Biesheuvel wrote: > > From: Ard Biesheuvel > > Even though the boot protocol stipulates otherwise, an exception has > been made for the EFI stub, and entering the core kernel with the MMU > enabled is permitted. This allows a substantial amount of cache > maintenance to be elided, wich is significant when fast boot times are > critical (e.g., for booting micro-VMs) > > Once the initial ID map has been populated, the MMU is disabled as part > of the logic sequence that puts all system registers into a known state. > Any code that needs to execute within the window where the MMU is off is > cleaned to the PoC explicitly, which includes all of HYP text when > entering at EL2. > > However, the current sequence of initializing the EL2 system registers > is not safe: HCR_EL2 is set to its nVHE initial state before SCTLR_EL2 > is reprogrammed, and this means that a VHE-to-nVHE switch may occur > while the MMU is enabled. This switch causes some system registers as > well as page table descriptors to be interpreted in a different way, > potentially resulting in spurious exceptions relating to MMU > translation. > > So disable the MMU explicitly first when entering in EL2 with the MMU > and caches enabled. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kernel/head.S | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S > index b8bbd72cb194..cb68adcabe07 100644 > --- a/arch/arm64/kernel/head.S > +++ b/arch/arm64/kernel/head.S > @@ -289,6 +289,11 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL) > adr_l x1, __hyp_text_end > adr_l x2, dcache_clean_poc > blr x2 > + > + mov_q x0, INIT_SCTLR_EL2_MMU_OFF > + pre_disable_mmu_workaround > + msr sctlr_el2, x0 > + isb > 0: > mov_q x0, HCR_HOST_NVHE_FLAGS > Acked-by: Marc Zyngier 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