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.74762.1656957193825092966 for ; Mon, 04 Jul 2022 10:53:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0N4UJjH; 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 116EB6152C; Mon, 4 Jul 2022 17:53:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 156F6C341CE; Mon, 4 Jul 2022 17:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656957192; bh=LWtibcXswKgrnfC7/03Nw8pBcN+jQ1qeJM/q2qEZUWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0N4UJjHeYRX9iw7VDNpKBgC+FCY1JmOT9f45MmDvFN479xmQinGgRno9gV/kY7EP 3PINd4W4ABdBf9Z78FSqdCmbdo45/1iJkwAHwJnXFrLt57eXzB8Nv6LY+6sMLTkoBB z0/8pubxSnEsYj4ZOpQVGgi2ZOgdYmhSC0N0kjdz9Q94YJ0408fdIDLsb40j8MBl9H 5tTYL6CxBn0pzWuy8D6DqmtHf4ZwJW5AVciL670udgpa/doKx/DwZnbkyKkZFnpLYL AlA9eVw7QesDx3Q+yF1kvtBwA35oep0d8nKsSSWRjaJpCKwOLS0TVyAOvCV1gb0UPw IcHoECdNs89PA== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, sami.mujawar@arm.com, Ard Biesheuvel , Marc Zyngier , Alexander Graf Subject: [PATCH 1/7] ArmPkg/ArmMmuLib: don't replace table entries with block entries Date: Mon, 4 Jul 2022 19:52:46 +0200 Message-Id: <20220704175252.4015120-2-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220704175252.4015120-1-ardb@kernel.org> References: <20220704175252.4015120-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 4a0513392a75..b85ae5a30768 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