From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 2BE0D221C1927 for ; Mon, 18 Dec 2017 19:47:25 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2017 19:52:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,424,1508828400"; d="scan'208";a="13472145" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 18 Dec 2017 19:52:09 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 18 Dec 2017 19:51:27 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 18 Dec 2017 19:51:25 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Tue, 19 Dec 2017 11:50:38 +0800 From: "Yao, Jiewen" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Dong, Eric" Thread-Topic: [PATCH] MdeModulePkg/Core: Fix incorrect memory map generated in a rare case Thread-Index: AQHTd9vOx1iddSI9uU6CFp3ueOd1EqNKCU2Q Date: Tue, 19 Dec 2017 03:50:38 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AA4C632@shsmsx102.ccr.corp.intel.com> References: <20171218083946.19292-1-jian.j.wang@intel.com> In-Reply-To: <20171218083946.19292-1-jian.j.wang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDU5ZWNlNjAtZjRkMC00MDUzLTg0ZDQtNTQ2M2ExNjhmNmEwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJVUUhnc3I3eWtKUW8zYU1aRHhVVUZENmZ3cCs5YUcrQTRZekJlZGVhUCtXYjFhZTJhclwvcjJ5Z25FckQrQkpDMSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Tue, 19 Dec 2017 03:47:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Wang, Jian J > Sent: Monday, December 18, 2017 4:40 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Dong, Eric ; Y= ao, > Jiewen > Subject: [PATCH] MdeModulePkg/Core: Fix incorrect memory map generated in > a rare case >=20 > The root cause is that mImagePropertiesPrivateData.CodeSegmentCountMax > was > not updated with correct value due to the fact that SortImageRecord() cal= led > before might change the content of current ImageRecord. This will in turn > cause incorrect memory map entries generated in SplitTable(). >=20 > 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(-) >=20 > 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++; >=20 > - SortImageRecord (); > - > if (mImagePropertiesPrivateData.CodeSegmentCountMax < > ImageRecord->CodeSegmentCount) { > mImagePropertiesPrivateData.CodeSegmentCountMax =3D > ImageRecord->CodeSegmentCount; > } >=20 > + 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++; >=20 > - SortImageRecord (); > - > if (mImagePropertiesPrivateData.CodeSegmentCountMax < > ImageRecord->CodeSegmentCount) { > mImagePropertiesPrivateData.CodeSegmentCountMax =3D > ImageRecord->CodeSegmentCount; > } >=20 > + SortImageRecord (); > + > Finish: > return ; > } > -- > 2.15.1.windows.2