From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web12.13819.1628451642474649535 for ; Sun, 08 Aug 2021 12:40:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=NuHzwmW5; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id EC248240029 for ; Sun, 8 Aug 2021 21:40:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628451641; bh=fq06HDIxAQCzNkfp/EZ+QyRrajPSthas7IrWNNHYG6c=; h=From:To:Cc:Subject:Date:From; b=NuHzwmW5SxOtc9hSfWDuvRVAREdJaAfkP4U1+nv4nKGEPOunaGG9keVY8VLCtKh0E DrpsktX1zeWSRH1ymOjIdqEOA4KLT4OePb0Q0VV2+/6IJfWBVWmbi0mhi0N4pnTeyM 33NdDduJUDGMFxCV4hfX++/f3YyoSV4fFak5gWNTppJoVIN24xClXd6g1IuOfe/0o/ e7cbesYx5RELTU19O4Lz7ZTxARvi7HUMwXJVF2H8sYhKIC6+ht/6If9uavPA7i2IDT FTauHHUe3ICh8So8kpB8WidfWo3BFX6wbpPUfBX7AiOqpgCp+wL79IJ4PF1+v8l/uH 3Noz/EoWpX0ew== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GjV1h2JN1z6tmD; Sun, 8 Aug 2021 21:40:40 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Vitaly Cheptsov Subject: [PATCH] MdeModulePkg/DxeCore: Fix DebugImageInfoTable size report Date: Sun, 8 Aug 2021 19:39:55 +0000 Message-Id: <5159497b61000dee562cd18b7e6cbc519f00fe8b.1628443860.git.mhaeuser@posteo.de> In-Reply-To: <88816e99692b15cf61f3057ffab4d54455159c7c.1628443860.git.mhaeuser@posteo.de> References: <88816e99692b15cf61f3057ffab4d54455159c7c.1628443860.git.mhaeuser@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Separate tracking the used entries from the table's self-reported size. Removing an entry from the table does not necessarily reduce the size of the table as defragmentation is not performed. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Vitaly Cheptsov Signed-off-by: Marvin H=C3=A4user --- MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c b/MdeModulePkg/Cor= e/Dxe/Misc/DebugImageInfo.c index 7bd970115111..cc22e23eb0b3 100644 --- a/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c +++ b/MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c @@ -18,6 +18,8 @@ EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = =3D { =0D UINTN mMaxTableEntries =3D 0;=0D =0D +UINTN mUsedTableEntries =3D 0;=0D +=0D EFI_SYSTEM_TABLE_POINTER *mDebugTable =3D NULL;=0D =0D #define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *))=0D @@ -178,7 +180,7 @@ CoreNewDebugImageInfoEntry ( =0D Table =3D mDebugInfoTableHeader.EfiDebugImageInfoTable;=0D =0D - if (mDebugInfoTableHeader.TableSize < mMaxTableEntries) {=0D + if (mUsedTableEntries < mMaxTableEntries) {=0D //=0D // We still have empty entires in the Table, find the first empty entr= y.=0D //=0D @@ -237,8 +239,17 @@ CoreNewDebugImageInfoEntry ( // increase the number of EFI_DEBUG_IMAGE_INFO elements.=0D //=0D mDebugInfoTableHeader.UpdateStatus |=3D EFI_DEBUG_IMAGE_INFO_TABLE_MOD= IFIED;=0D + mUsedTableEntries++;=0D Table[Index].NormalImage =3D NormalImage;=0D - mDebugInfoTableHeader.TableSize++;=0D + //=0D + // Only increase the amount of elements in the table if the new entry = did=0D + // not take the place of a previously removed entry.=0D + //=0D + if (Index =3D=3D mDebugInfoTableHeader.TableSize) {=0D + mDebugInfoTableHeader.TableSize++;=0D + }=0D +=0D + ASSERT (Index < mDebugInfoTableHeader.TableSize);=0D }=0D mDebugInfoTableHeader.UpdateStatus &=3D ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_= PROGRESS;=0D }=0D @@ -274,9 +285,10 @@ CoreRemoveDebugImageInfoEntry ( mDebugInfoTableHeader.UpdateStatus |=3D EFI_DEBUG_IMAGE_INFO_TABLE_M= ODIFIED;=0D Table[Index].NormalImage =3D NULL;=0D //=0D - // Decrease the number of EFI_DEBUG_IMAGE_INFO elements.=0D + // Do not reduce the amount of elements reported to be in the table = as=0D + // this would only work for the last element without defragmentation= .=0D //=0D - mDebugInfoTableHeader.TableSize--;=0D + mUsedTableEntries--;=0D //=0D // Free up the record.=0D //=0D --=20 2.31.1