[edk2-devel] [PATCH] MdeModulePkg/DxeCore: Fix DebugImageInfoTable size report

Marvin Häuser posted 1 patch 2 years, 7 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Core/Dxe/Misc/DebugImageInfo.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
[edk2-devel] [PATCH] MdeModulePkg/DxeCore: Fix DebugImageInfoTable size report
Posted by Marvin Häuser 2 years, 7 months ago
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 <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
---
 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/Core/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 = {
 

 UINTN mMaxTableEntries = 0;

 

+UINTN mUsedTableEntries = 0;

+

 EFI_SYSTEM_TABLE_POINTER  *mDebugTable = NULL;

 

 #define EFI_DEBUG_TABLE_ENTRY_SIZE       (sizeof (VOID *))

@@ -178,7 +180,7 @@ CoreNewDebugImageInfoEntry (
 

   Table = mDebugInfoTableHeader.EfiDebugImageInfoTable;

 

-  if (mDebugInfoTableHeader.TableSize < mMaxTableEntries) {

+  if (mUsedTableEntries < mMaxTableEntries) {

     //

     // We still have empty entires in the Table, find the first empty entry.

     //

@@ -237,8 +239,17 @@ CoreNewDebugImageInfoEntry (
     // increase the number of EFI_DEBUG_IMAGE_INFO elements.

     //

     mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;

+    mUsedTableEntries++;

     Table[Index].NormalImage = 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 == mDebugInfoTableHeader.TableSize) {

+      mDebugInfoTableHeader.TableSize++;

+    }

+

+    ASSERT (Index < mDebugInfoTableHeader.TableSize);

   }

   mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;

 }

@@ -274,9 +285,10 @@ CoreRemoveDebugImageInfoEntry (
       mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;

       Table[Index].NormalImage = 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.

       //

-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-