From nobody Mon Feb 9 09:33:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93233+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93233+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1662476813; cv=none; d=zohomail.com; s=zohoarc; b=m+2qPF1pWUJ7gaM/8arBAXWq5fIm23H0yu+ViobFhITDCT2nx1TkofwCNzr5ICrvpgZNeVURErVJ0GX2lmXu1JBLFBhJ721an0xNpDgV01jSI7lpiwoT29jHPpi+HMDOC3PDDCagOFpL50yVAxDVcPcSi8yYvRdvc0vZWl2pcko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662476813; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=E5kMzsQ4S0A9SKAAN9J1jRIFx7Tqla3NxV4Pi6hEO6w=; b=P+FmVOMfJGPJm4TwbeFzD8GlnvzLpaHf/8uONBR4aYtGTOPC1jNIgM9TJIvKX6xsbkmeFAS5flAgoBUc0zGUSs+4w2/W0btFOqtsNvnsoXG1ZrnAIHGVJCx4NBj8rEk7tfzAruueG7Bxd9xXGtYnkGPf1bnwx4wZCES5YPuAOKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93233+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662476813761522.727718160466; Tue, 6 Sep 2022 08:06:53 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 03GrYY1788612x1TzbmjgGh9; Tue, 06 Sep 2022 08:06:53 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web08.240.1662476812674215756 for ; Tue, 06 Sep 2022 08:06:52 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFA2061561; Tue, 6 Sep 2022 15:06:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C492C433C1; Tue, 6 Sep 2022 15:06:50 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, sami.mujawar@arm.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 3/7] ArmPkg/ArmMmuLib: permit initial configuration with MMU enabled Date: Tue, 6 Sep 2022 17:06:35 +0200 Message-Id: <20220906150639.157227-4-ardb@kernel.org> In-Reply-To: <20220906150639.157227-1-ardb@kernel.org> References: <20220906150639.157227-1-ardb@kernel.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org X-Gm-Message-State: YoLRta2bX1M5AAp5UQxxRQnvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662476813; bh=rWhcu5h2tvuH5fylkxSHmXwaxg71qlkr3HhGC2Ank/s=; h=Cc:Date:From:Reply-To:Subject:To; b=O5xOkTNjRf788RGVgC2yxs4qVkpPF4FLT2+kDyskeMhz18THH4ikIs0EJ7GvsvlNsaf Z48Nc9qFImqf3FTPM0xhN4lfZnCddMRiFk8zTolANCMgBU+/UtFRCpcF/ndrpweBascs5 kFku2hu9yYbCb6SgAK4XZwCaBC9lIgmT0uQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662476814444100009 Content-Type: text/plain; charset="utf-8" Permit the use of this library with the MMU and caches already enabled. This removes the need for any cache maintenance for coherency, and is generally better for robustness and performance, especially when running under virtualization. Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 30 +++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 747ebc533511..ebd39ab4a657 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -689,14 +689,16 @@ ArmConfigureMmu ( *TranslationTableSize =3D RootTableEntryCount * sizeof (UINT64); } =20 - // - // Make sure we are not inadvertently hitting in the caches - // when populating the page tables. - // - InvalidateDataCacheRange ( - TranslationTable, - RootTableEntryCount * sizeof (UINT64) - ); + if (!ArmMmuEnabled ()) { + // + // Make sure we are not inadvertently hitting in the caches + // when populating the page tables. + // + InvalidateDataCacheRange ( + TranslationTable, + RootTableEntryCount * sizeof (UINT64) + ); + } =20 ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64)); =20 @@ -722,12 +724,14 @@ ArmConfigureMmu ( =20 ArmSetTTBR0 (TranslationTable); =20 - ArmDisableAlignmentCheck (); - ArmEnableStackAlignmentCheck (); - ArmEnableInstructionCache (); - ArmEnableDataCache (); + if (!ArmMmuEnabled ()) { + ArmDisableAlignmentCheck (); + ArmEnableStackAlignmentCheck (); + ArmEnableInstructionCache (); + ArmEnableDataCache (); =20 - ArmEnableMmu (); + ArmEnableMmu (); + } =20 if (NumRootPages > 1) { // --=20 2.35.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93233): https://edk2.groups.io/g/devel/message/93233 Mute This Topic: https://groups.io/mt/93503039/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-