From nobody Tue Feb 10 12:58:25 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+94327+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+94327+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1664180727; cv=none; d=zohomail.com; s=zohoarc; b=JwOqfpNjSYSqQiLBfSFULiMVRb0hNrcMWw9+m/Sn5L/eey8gUrfyc9FHn3zLVH+Cn1XV0rZO4LkjZocazdtDb7jYYtkx2bluIT46N2upj7wu2N0NnkXkfEacGvEew5+K/26pbR5QFE7WU7NdFVGgtzctCGQw+v+tsKT7Qra+FTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664180727; 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=ArZ1k+5CnR1mvdZRw/KIr7Klb2Wy+KSqXoUWkBoa/S4=; b=mrypTwcbA4lL31zoM1N9FSupebfjwLW4lDOEZ+Dh7v0ZCqf8kR3ksf68EzxJyYCFfUon2hPGvQBHkoqxZQOjhA+CjXHcEAbnRtN0m+Flv0pz7p6qPeG6z0TBjo/GaTeS9eAUDak975nh9LJhYm+cH0+vkM0PugG1V3CTDocyDzc= 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+94327+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 1664180727681262.9350689129516; Mon, 26 Sep 2022 01:25:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id O9XDYY1788612xuTvsmQzCOg; Mon, 26 Sep 2022 01:25:26 -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.25931.1664180726255277846 for ; Mon, 26 Sep 2022 01:25:26 -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 BD41461902; Mon, 26 Sep 2022 08:25:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 304A2C433D6; Mon, 26 Sep 2022 08:25:24 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [edk2-devel] [PATCH v3 05/16] ArmPkg/ArmMmuLib: don't replace table entries with block entries Date: Mon, 26 Sep 2022 10:25:00 +0200 Message-Id: <20220926082511.2110797-6-ardb@kernel.org> In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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: grZRzBO0uhReF09vXJB1ZV2Sx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664180726; bh=i6/8SNY8npaaR4bXF7NLtrzXS6jfpO6Vl+rhLmaQwIY=; h=Cc:Date:From:Reply-To:Subject:To; b=dDTDf3d4dlazL6li2WITDmpB32t3HQj5S/Oi00RtvqcbgMtS0MJTu0FdVx3QUWl3Q3l C2U3scyDMbWGTG9IgQSogbhdxbD6z1eBmgiDZuY7hVVbSCjo2toZ/KnEYOONQr3qmGXcZ pHLvJ6hxaBMm2M5K1D/8CsadFb07gpIWZk4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664180728237100016 Content-Type: text/plain; charset="utf-8" Drop the optimization that replaces table entries with block entries and frees the page tables in the subhierarchy that is being replaced. This rarely occurs in practice anyway, and will require more elaborate TLB maintenance once we switch to a different approach when running at EL1, where we no longer disable the MMU and nuke the TLB entirely every time we update a descriptor in a way that requires break-before-make (BBM). Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index e5ecc7375153..34f1031c4de3 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -197,12 +197,9 @@ UpdateRegionMappingRecursive ( // than a block, and recurse to create the block or page entries at // the next level. No block mappings are allowed at all at level 0, // so in that case, we have to recurse unconditionally. - // If we are changing a table entry and the AttributeClearMask is non-= zero, - // we cannot replace it with a block entry without potentially losing - // attribute information, so keep the table entry in that case. // if ((Level =3D=3D 0) || (((RegionStart | BlockEnd) & BlockMask) !=3D 0= ) || - (IsTableEntry (*Entry, Level) && (AttributeClearMask !=3D 0))) + IsTableEntry (*Entry, Level)) { ASSERT (Level < 3); =20 @@ -294,20 +291,7 @@ UpdateRegionMappingRecursive ( EntryValue |=3D (Level =3D=3D 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3 : TT_TYPE_BLOCK_ENTRY; =20 - if (IsTableEntry (*Entry, Level)) { - // - // We are replacing a table entry with a block entry. This is only - // possible if we are keeping none of the original attributes. - // We can free the table entry's page table, and all the ones below - // it, since we are dropping the only possible reference to it. - // - ASSERT (AttributeClearMask =3D=3D 0); - TranslationTable =3D (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOC= K_ENTRY); - ReplaceTableEntry (Entry, EntryValue, RegionStart, TRUE); - FreePageTablesRecursive (TranslationTable, Level + 1); - } else { - ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE); - } + ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE); } } =20 --=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 (#94327): https://edk2.groups.io/g/devel/message/94327 Mute This Topic: https://groups.io/mt/93922693/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-