From nobody Mon Apr 29 08:31:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+78897+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78897+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=posteo.de ARC-Seal: i=1; a=rsa-sha256; t=1628451644; cv=none; d=zohomail.com; s=zohoarc; b=LvlcuALpxaryK6foW4zttYWRXSB/GEtK9fp1v+7l69sqP7zgV6ESw6U/k0fSXhN2Pe4FVSkcTmeYFBmDO2fQTqFYD1Ml64Qd007T27WGyAzGaN00M7kqG6l23aqSu/DVZ9RfItCcJH1edXfflyinAorReMeexXsAVk/0++ejNLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628451644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=os0G4nx9D64Jsp0a60H1Um0dgH/7EOXHBoqgbrfpC48=; b=fCe9d+RxcdiqbLKdFKA0eTLGl+P+Xl2O9rsvnHFBrGpQrBdgKbQDATDWu/i9QFYidwJlZuCtS8yfzqfUFlz0AahyXvqYAogWALrHqQPM55L77i9ZiRCuIF3ZWVf1qE5sO/H6yuyFqFLd2t/Fw7feMuBqx1mALcwX73ogHwl+/Iw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78897+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1628451644134316.88336549869405; Sun, 8 Aug 2021 12:40:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id W9V7YY1788612xpQzwlQELp1; Sun, 08 Aug 2021 12:40:43 -0700 X-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 X-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) X-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: [edk2-devel] [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 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mhaeuser@posteo.de X-Gm-Message-State: njBk4X4steOENB4o3nAMmyfux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628451643; bh=pzQe2e1EJRJPZfhFWW7A5AtUo8rTI29VV5QGV0a11HY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=cEDQPu/eTKa1aVfc9VttKfwoEf6sAnHlLVehsTAiECeaGbL0tM0xOSuZ5qzF3dxLj/b Ou09xYEV3zWs9ecHvjPV6qKdzLR24KP+dwee5q4bZ0u/JqBmZ+tSLhYiF6abELQ4Lijtl sSc28j3viTOUo+Z40Cp1j3X0ZbIt6FscHyQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628451645995100086 Content-Type: text/plain; charset="utf-8" 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 { =20 UINTN mMaxTableEntries =3D 0; =20 +UINTN mUsedTableEntries =3D 0; + EFI_SYSTEM_TABLE_POINTER *mDebugTable =3D NULL; =20 #define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *)) @@ -178,7 +180,7 @@ CoreNewDebugImageInfoEntry ( =20 Table =3D mDebugInfoTableHeader.EfiDebugImageInfoTable; =20 - if (mDebugInfoTableHeader.TableSize < mMaxTableEntries) { + if (mUsedTableEntries < mMaxTableEntries) { // // We still have empty entires in the Table, find the first empty entr= y. // @@ -237,8 +239,17 @@ CoreNewDebugImageInfoEntry ( // increase the number of EFI_DEBUG_IMAGE_INFO elements. // mDebugInfoTableHeader.UpdateStatus |=3D EFI_DEBUG_IMAGE_INFO_TABLE_MOD= IFIED; + mUsedTableEntries++; Table[Index].NormalImage =3D NormalImage; - mDebugInfoTableHeader.TableSize++; + // + // Only increase the amount of elements in the table if the new entry = did + // not take the place of a previously removed entry. + // + if (Index =3D=3D mDebugInfoTableHeader.TableSize) { + mDebugInfoTableHeader.TableSize++; + } + + ASSERT (Index < mDebugInfoTableHeader.TableSize); } mDebugInfoTableHeader.UpdateStatus &=3D ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_= PROGRESS; } @@ -274,9 +285,10 @@ CoreRemoveDebugImageInfoEntry ( mDebugInfoTableHeader.UpdateStatus |=3D EFI_DEBUG_IMAGE_INFO_TABLE_M= ODIFIED; Table[Index].NormalImage =3D NULL; // - // Decrease the number of EFI_DEBUG_IMAGE_INFO elements. + // Do not reduce the amount of elements reported to be in the table = as + // this would only work for the last element without defragmentation. // - mDebugInfoTableHeader.TableSize--; + mUsedTableEntries--; // // Free up the record. // --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78897): https://edk2.groups.io/g/devel/message/78897 Mute This Topic: https://groups.io/mt/84754072/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-