From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DB9AB2035B2C4 for ; Mon, 18 Dec 2017 00:35:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2017 00:39:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,421,1508828400"; d="scan'208";a="187926420" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.47]) by fmsmga006.fm.intel.com with ESMTP; 18 Dec 2017 00:39:50 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Cc: Star Zeng , Eric Dong , Jiewen Yao Date: Mon, 18 Dec 2017 16:39:46 +0800 Message-Id: <20171218083946.19292-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [PATCH] MdeModulePkg/Core: Fix incorrect memory map generated in a rare case X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Dec 2017 08:35:07 -0000 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 Cc: Eric Dong Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang --- MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 4 ++-- MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c index 75d9b14c1f..a84507df95 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -1229,12 +1229,12 @@ InsertImageRecord ( InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link); mImagePropertiesPrivateData.ImageRecordCount++; - SortImageRecord (); - if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) { mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount; } + SortImageRecord (); + Finish: return ; } diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c index e3c505ef18..36ccf65fa3 100644 --- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c @@ -1214,12 +1214,12 @@ SmmInsertImageRecord ( InsertTailList (&mImagePropertiesPrivateData.ImageRecordList, &ImageRecord->Link); mImagePropertiesPrivateData.ImageRecordCount++; - SortImageRecord (); - if (mImagePropertiesPrivateData.CodeSegmentCountMax < ImageRecord->CodeSegmentCount) { mImagePropertiesPrivateData.CodeSegmentCountMax = ImageRecord->CodeSegmentCount; } + SortImageRecord (); + Finish: return ; } -- 2.15.1.windows.2