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.web08.25931.1664180726255277846 for ; Mon, 26 Sep 2022 01:25:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=caaaWJSD; 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 BD41461902; Mon, 26 Sep 2022 08:25:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 304A2C433D6; Mon, 26 Sep 2022 08:25:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664180725; bh=ne66onYwcyp7I5ms0yT4En8Lcf16oaMSC+BsswJx76E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=caaaWJSDO/PuAu/SJj21zSMqunFhXw+AnHIf/9NTuASFr0PC5FNMYF9yE+SETJUn5 Z+fL8ZFFgkCuVCaDJTvzezf2ASFhDULRak/4+hJFJ74wvcOiAcBvA3+wmBAzdd7yI4 pgYCQxzB5xqleB9UyvMGWaFJiM0W1X9IjyS1bSH75+1MrGiV6MfxMGqBYUc/63Urgd bo4cMDi82IHcYXTwUlmhNYja7UJ7sexMUefoTKShssTBi3FbEJM/LyRTj77QU6xnKy uAQWhcczLnK0qOHc8QaNnRXZLSP2TuqeWXzNKGGFT/QopHzSPkw2GwywRthJjySCyo 7uyh0NoYrL4rw== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Alexander Graf Subject: [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> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220926082511.2110797-1-ardb@kernel.org> References: <20220926082511.2110797-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