From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.248.1662476809473562870 for ; Tue, 06 Sep 2022 08:06:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oCJG9dDW; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) 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 00FF261561; Tue, 6 Sep 2022 15:06:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AE80C433C1; Tue, 6 Sep 2022 15:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662476808; bh=ne66onYwcyp7I5ms0yT4En8Lcf16oaMSC+BsswJx76E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCJG9dDWHMdnSwnzrLBqv26Oc85RHDVRWjOHcZSPPre1EP/YoK24eE75U2lVtWPuQ sE6ylK7YD1i/h1HidkAVWk7rYWZhXUPsDeJVqkzcZhuzyHig58IwncVUn0PCbXVM1J /z+u7E19FgSvgiGqGwzRhFXzdWGxgnajz+dufqPLDHL62erf8ZP+p7LD4MbPJcakCE iGtKyGZLNhJGhCUO1Vw4T2DBRKLQiUJWLwpVbl5RrZsaxSX74M9iKfwNO5+q463/7u W4s7hf9SoKsZpxCPfCbw9BIVcoHOae9/zQI1artN4UkN4NME9eg3IFgDu6ArXhSIpl 37cgnUxk+EmmQ== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, sami.mujawar@arm.com, Ard Biesheuvel Subject: [PATCH v2 1/7] ArmPkg/ArmMmuLib: don't replace table entries with block entries Date: Tue, 6 Sep 2022 17:06:33 +0200 Message-Id: <20220906150639.157227-2-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906150639.157227-1-ardb@kernel.org> References: <20220906150639.157227-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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=0D // the next level. No block mappings are allowed at all at level 0,=0D // so in that case, we have to recurse unconditionally.=0D - // If we are changing a table entry and the AttributeClearMask is non-= zero,=0D - // we cannot replace it with a block entry without potentially losing= =0D - // attribute information, so keep the table entry in that case.=0D //=0D if ((Level =3D=3D 0) || (((RegionStart | BlockEnd) & BlockMask) !=3D 0= ) ||=0D - (IsTableEntry (*Entry, Level) && (AttributeClearMask !=3D 0)))=0D + IsTableEntry (*Entry, Level))=0D {=0D ASSERT (Level < 3);=0D =0D @@ -294,20 +291,7 @@ UpdateRegionMappingRecursive ( EntryValue |=3D (Level =3D=3D 3) ? TT_TYPE_BLOCK_ENTRY_LEVEL3=0D : TT_TYPE_BLOCK_ENTRY;=0D =0D - if (IsTableEntry (*Entry, Level)) {=0D - //=0D - // We are replacing a table entry with a block entry. This is only= =0D - // possible if we are keeping none of the original attributes.=0D - // We can free the table entry's page table, and all the ones belo= w=0D - // it, since we are dropping the only possible reference to it.=0D - //=0D - ASSERT (AttributeClearMask =3D=3D 0);=0D - TranslationTable =3D (VOID *)(UINTN)(*Entry & TT_ADDRESS_MASK_BLOC= K_ENTRY);=0D - ReplaceTableEntry (Entry, EntryValue, RegionStart, TRUE);=0D - FreePageTablesRecursive (TranslationTable, Level + 1);=0D - } else {=0D - ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE);=0D - }=0D + ReplaceTableEntry (Entry, EntryValue, RegionStart, FALSE);=0D }=0D }=0D =0D --=20 2.35.1