]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Core: Fix incorrect memory map generated in a rare case
authorJian J Wang <jian.j.wang@intel.com>
Sat, 16 Dec 2017 09:22:35 +0000 (17:22 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 19 Dec 2017 07:19:46 +0000 (15:19 +0800)
The root cause is that mImagePropertiesPrivateData.CodeSegmentCountMax was
not updated with correct value due to the fact that SortImageRecord() called
before might change the content of current ImageRecord. This will in turn
cause incorrect memory map entries generated in SplitTable().

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c
MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c

index 75d9b14c1f87412b638b84f03b5aa8d8308b9685..a84507df95996f93389b196d97fef9eaab5d21ac 100644 (file)
@@ -1229,12 +1229,12 @@ InsertImageRecord (
   InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link);\r
   mImagePropertiesPrivateData.ImageRecordCount++;\r
 \r
-  SortImageRecord ();\r
-\r
   if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) {\r
     mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount;\r
   }\r
 \r
+  SortImageRecord ();\r
+\r
 Finish:\r
   return ;\r
 }\r
index e3c505ef18abf9b31f1f1f1b4019225525f71076..36ccf65fa362a08acb2d1282408588ba35ef3d3d 100644 (file)
@@ -1214,12 +1214,12 @@ SmmInsertImageRecord (
   InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link);\r
   mImagePropertiesPrivateData.ImageRecordCount++;\r
 \r
-  SortImageRecord ();\r
-\r
   if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) {\r
     mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount;\r
   }\r
 \r
+  SortImageRecord ();\r
+\r
 Finish:\r
   return ;\r
 }\r