From nobody Sun Feb 8 12:39:17 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+99802+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+99802+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1675879107; cv=none; d=zohomail.com; s=zohoarc; b=S5yJ3pihOhAedfM4cMp/s6da/FRGy+Vg9Snx+brUwaEa4qCZF2taGbDOf/bgZigFphERS4Blt2OiudgHQxGIozYr7zexQ7Dtkrlx8iT9TMNL8/WsjuLppVbDWU6EsqFTdiVt2gL0YApBXVTDufl4jobRck2joydTHvLE2vwrRjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675879107; 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=t81ksS4gErY2ijheHXcAtT3pgGh7PhsG7psg2O7cbLo=; b=OEhmTP4wOih/pPM/MCF5yZJsIrwKR1I7Qdcg44rhriR3++rwZUJBOgmzX3na4PXWzzvkb1s7KMtGK/q4uGvnJVMf+G1tb2CtD9YNwa4c0+5T3sw4bbTHZ7UqoNsuPbTiWJe528F5Nds56uXMopteKwv47INS2cGUmplu03xKJZU= 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+99802+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 167587910716115.731567477933822; Wed, 8 Feb 2023 09:58:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uTN6YY1788612xfm48cKvQFy; Wed, 08 Feb 2023 09:58:26 -0800 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.5341.1675879105782325376 for ; Wed, 08 Feb 2023 09:58:25 -0800 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 2F6FF6171A; Wed, 8 Feb 2023 17:58:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C355C4339B; Wed, 8 Feb 2023 17:58:22 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe , =?UTF-8?q?Marvin=20H=C3=A4user?= Subject: [edk2-devel] [PATCH 1/3] ArmPkg/ArmMmuLib: Avoid splitting block entries if possible Date: Wed, 8 Feb 2023 18:58:10 +0100 Message-Id: <20230208175812.700129-2-ardb@kernel.org> In-Reply-To: <20230208175812.700129-1-ardb@kernel.org> References: <20230208175812.700129-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: EsfRxBxM95pybuK58PHnbk0ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1675879106; bh=vTs1/irI0+JfFmVNcY/qjNeJW5Xz2aeP3BrHyR0p+jo=; h=Cc:Date:From:Reply-To:Subject:To; b=UZe6RGU4hOskSsppLs3LMZ4tfyipy+rUoRgF2lUY7p9uffeDpD6pEX4+sRNfJO4HhyE 365E0GniVK9GVu0dLHqw810cpoVAxLgDFOXNPV+dQw04SWSlsCo4ObOsxKCO+LQN8X/WO l+uotN3LDuE7HaZDAaNLhvZsUGB3jfoakPU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675879109086100007 Content-Type: text/plain; charset="utf-8" Currently, the AArch64 MMU page table logic will break down any block entry that overlaps with the region being mapped, even if the block entry in question is using the same attributes as the new region. This means that creating a non-executable mapping inside a region that is already mapped non-executable at a coarser granularity may trigger a call to AllocatePages (), which may recurse back into the page table code to update the attributes on the newly allocated page tables. Let's avoid this, by preserving the block entry if it already covers the region being mapped with the correct attributes. Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 1cf8dc090012..28191938aeb1 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -251,6 +251,15 @@ UpdateRegionMappingRecursive ( ASSERT (Level < 3); =20 if (!IsTableEntry (*Entry, Level)) { + // + // If the region we are trying to map is already covered by a block + // entry with the right attributes, don't bother splitting it up. + // + if (IsBlockEntry (*Entry, Level) && + ((*Entry & TT_ATTRIBUTES_MASK & ~AttributeClearMask) =3D=3D At= tributeSetMask)) { + continue; + } + // // No table entry exists yet, so we need to allocate a page table // for the next level. --=20 2.39.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 (#99802): https://edk2.groups.io/g/devel/message/99802 Mute This Topic: https://groups.io/mt/96835913/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-