From nobody Sun Feb 8 14:53:08 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+91039+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+91039+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1656957201; cv=none; d=zohomail.com; s=zohoarc; b=C89LQyORDi8m//lyttTg4lZBlYEsoS5ir5dRzRzehHZIns8N9UoHEifx6PaW+cMpcuCu5a1k2V3k8gmfcMhgCWPauJ4cMnSZftHj5pkDArTknAxAfVUc0GXt/Q2X7T5vhQNOX7MLIRTNgcBZzrijFxiHJHLNbeaxn3R80Sln/rI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656957201; 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=VpVS97aE5kkHJSq4eZgDDM22uBFiVJo1p6vf1sBV5TU=; b=bnNW9a20QZKoCRwGmNf6Io7b242CFfooT+FtO+cDjDgQ3W76baOjVFmBP/xdroCLC7+5WHIGSuFcciXHVu0M0U8K0SY5uoM7E2J4ZUHtY0ihRkfyNzFdKsEDK/qOjiCt+Vmm65fDwQdw6gjZJ6JQCS8r0ak7KZ+c7XcU8Y+u4Lw= 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+91039+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 1656957201095516.3755963619383; Mon, 4 Jul 2022 10:53:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id E7X6YY1788612x3Z79dpluWp; Mon, 04 Jul 2022 10:53:20 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.74764.1656957198560435812 for ; Mon, 04 Jul 2022 10:53:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 467EAB811EF; Mon, 4 Jul 2022 17:53:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA3DFC341CD; Mon, 4 Jul 2022 17:53:14 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, sami.mujawar@arm.com, Ard Biesheuvel , Marc Zyngier , Alexander Graf Subject: [edk2-devel] [PATCH 3/7] ArmPkg/ArmMmuLib: permit initial configuration with MMU enabled Date: Mon, 4 Jul 2022 19:52:48 +0200 Message-Id: <20220704175252.4015120-4-ardb@kernel.org> In-Reply-To: <20220704175252.4015120-1-ardb@kernel.org> References: <20220704175252.4015120-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: EXvH9DFXEx8hLqIB4nE1IPpMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1656957200; bh=DKPTwI4kvSMEX9ui+Vz1sTZzKQtBI4Ryo5z/QuQJdXs=; h=Cc:Date:From:Reply-To:Subject:To; b=ewnHuaWOlfe1I/ADG63WAkhbnGThFOJyUkznBqLEYco09BGXmZm8c1zi2Z02eMK1i0J zqR2i2RlyBLkU5KDv11g9GOifdxDbey5MiVJYW8475Ryh0VXRXOyB02sY/RFocm6aMRyy r1cN+9BbxEvEub5ToVzq9B0vO5yYirFSTkQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1656957202892100006 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 d5c19600dce8..8934ea6fd420 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -657,14 +657,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) + ); + } ZeroMem (TranslationTable, RootTableEntryCount * sizeof (UINT64)); =20 for (MemTab =3D MemoryTable; MemTab->Length !=3D 0; MemTab++) { @@ -689,12 +691,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 (#91039): https://edk2.groups.io/g/devel/message/91039 Mute This Topic: https://groups.io/mt/92170206/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-