From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web10.20760.1628502713758238150 for ; Mon, 09 Aug 2021 02:51:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=kAChIZit; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 0DBAF240101 for ; Mon, 9 Aug 2021 11:51:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1628502712; bh=fq06HDIxAQCzNkfp/EZ+QyRrajPSthas7IrWNNHYG6c=; h=From:To:Cc:Subject:Date:From; b=kAChIZitWJjZq6lOPFx5y0CzZB3ZoabEteL6tBZipyyIq2uh0kxIM24xEaxYw8dM9 J8Q9q+bv22Jh6EC5OBXFdBZQO3xywnT1g/aepEJO6VKub28ICQ2GPFcggR4V4xqwCH gJ5Ou1LnhEWKjI8VSa0MXekEC/A3o3WSC6NlN7uqsvPLZ9mgks4r73ewTYa3TrWEiQ qlbFVZIfzIJdnwpanHjr1PF8wP/B02m1s48cqJt8Hiyzn2yPSoQ0kvuhz9dX6+6M/t 0QhnYml1eypv7I+O6tlCGdYgG5Hps0YwX6N0sgq6CMVqJXlTbtteli4W4abgOJqlOS +isLa76wY1Ihw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Gjrvq3dM9z6tmF; Mon, 9 Aug 2021 11:51:51 +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 v2 2/7] MdeModulePkg/DxeCore: Fix DebugImageInfoTable size report Date: Mon, 9 Aug 2021 09:51:25 +0000 Message-Id: <5159497b61000dee562cd18b7e6cbc519f00fe8b.1628502345.git.mhaeuser@posteo.de> In-Reply-To: References: 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