From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 A8679223522AD for ; Tue, 13 Mar 2018 01:29:53 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 01:36:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,464,1515484800"; d="scan'208";a="36860229" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 13 Mar 2018 01:36:15 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 13 Mar 2018 01:36:15 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 13 Mar 2018 01:36:14 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.80]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.166]) with mapi id 14.03.0319.002; Tue, 13 Mar 2018 16:36:12 +0800 From: "Yao, Jiewen" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Dong, Eric" Thread-Topic: [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard Thread-Index: AQHTuqYSQ8kZJ8r19UGWnqeM+K7pd6PN1yQA Date: Tue, 13 Mar 2018 08:36:11 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AAFAA37@shsmsx102.ccr.corp.intel.com> References: <20180313083401.28180-1-jian.j.wang@intel.com> In-Reply-To: <20180313083401.28180-1-jian.j.wang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODllNjljYTItNWUyMy00NzgzLWI5Y2MtODJmNjljOGRmNDkyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJTQ3gzS25uK1o0Q1NWY211NXVJUThnWU93VUUrOFN1QkxUa3dEQWxIZ05PVTN5bVlCeWFNU3FCcUNyaUtFaHRZIn0= x-ctpclassification: CTP_NT 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/PiSmmCore: fix mem alloc issues in heap guard X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 08:29:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intelc.om > -----Original Message----- > From: Wang, Jian J > Sent: Tuesday, March 13, 2018 4:34 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Dong, Eric ; Y= ao, > Jiewen > Subject: [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap gua= rd >=20 > This patch fixes the same issues in Heap Guard in DXE core, which is fixe= d > in another patch. >=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/PiSmmCore/HeapGuard.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > index aa9c25d102..923af93de2 100644 > --- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > +++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > @@ -251,8 +251,8 @@ FindGuardedMemoryMap ( > // > // Adjust current map table depth according to the address to access > // > - while (mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH > - && > + while (AllocMapUnit && > + mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH && > RShiftU64 ( > Address, > mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel - > 1] > @@ -887,6 +887,10 @@ AdjustMemoryS ( > } >=20 > Target =3D Start + Size - SizeRequested; > + ASSERT (Target >=3D Start); > + if (Target =3D=3D 0) { > + return 0; > + } >=20 > if (!IsGuardPage (Start + Size)) { > // No Guard at tail to share. One more page is needed. > -- > 2.16.2.windows.1