]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SmmCorePerformanceLib: Update mPerformanceLength
authorDandan Bi <dandan.bi@intel.com>
Mon, 2 Jul 2018 05:29:52 +0000 (13:29 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 4 Jul 2018 02:42:36 +0000 (10:42 +0800)
In mSmmBootPerformanceTable there are two parts,
one is the FPDT table header and the other is FPDT records.
Currently:
mPerformanceLength: The length of existing FPDT records.
mMaxPerformanceLength: The maximum length allocated for
mSmmBootPerformanceTable(including FPDT table header length
and existing FPDT records length)
But when compare mPerformanceLength with mMaxPerformanceLength
to check whether need to allocate new buffer for new FPDT
record, we miss to add mPerformanceLength with header length,
which will cause pool allocation behavior is not correct.

Now update the mPerformanceLength to fix this issue:
updated mPerformanceLength = FPDT table header length
+ existing FPDT records length.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c

index f18c3fb60df55e930597cd6f7a9f62aafc263c67..e03d41ed37bccb0ca66bc109333a94c536713832 100644 (file)
@@ -45,7 +45,7 @@ typedef struct {
 HANDLE_GUID_MAP      mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];\r
 UINTN                mCachePairCount = 0;\r
 \r
 HANDLE_GUID_MAP      mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];\r
 UINTN                mCachePairCount = 0;\r
 \r
-UINT32               mPerformanceLength    = 0;\r
+UINT32               mPerformanceLength    = sizeof (SMM_BOOT_PERFORMANCE_TABLE);\r
 UINT32               mMaxPerformanceLength = 0;\r
 UINT32               mLoadImageCount       = 0;\r
 BOOLEAN              mFpdtDataIsReported   = FALSE;\r
 UINT32               mMaxPerformanceLength = 0;\r
 UINT32               mLoadImageCount       = 0;\r
 BOOLEAN              mFpdtDataIsReported   = FALSE;\r
@@ -100,15 +100,15 @@ GetFpdtRecordPtr (
     if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {\r
       mSmmBootPerformanceTable = ReallocatePool (\r
                                    mPerformanceLength,\r
     if (mPerformanceLength + RecordSize > mMaxPerformanceLength) {\r
       mSmmBootPerformanceTable = ReallocatePool (\r
                                    mPerformanceLength,\r
-                                   mPerformanceLength + sizeof (SMM_BOOT_PERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER,\r
+                                   mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER,\r
                                    mSmmBootPerformanceTable\r
                               );\r
 \r
       if (mSmmBootPerformanceTable == NULL) {\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
                                    mSmmBootPerformanceTable\r
                               );\r
 \r
       if (mSmmBootPerformanceTable == NULL) {\r
         return EFI_OUT_OF_RESOURCES;\r
       }\r
-      mSmmBootPerformanceTable->Header.Length = sizeof (SMM_BOOT_PERFORMANCE_TABLE) + mPerformanceLength;\r
-      mMaxPerformanceLength = mPerformanceLength + sizeof (SMM_BOOT_PERFORMANCE_TABLE) + RecordSize + FIRMWARE_RECORD_BUFFER;\r
+      mSmmBootPerformanceTable->Header.Length = mPerformanceLength;\r
+      mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;\r
     }\r
     //\r
     // Covert buffer to FPDT Ptr Union type.\r
     }\r
     //\r
     // Covert buffer to FPDT Ptr Union type.\r