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.151; helo=mga17.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 CADB52228350C for ; Tue, 6 Mar 2018 23:36:12 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 23:42:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,434,1515484800"; d="scan'208";a="22392226" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 06 Mar 2018 23:42:27 -0800 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 6 Mar 2018 23:42:26 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 6 Mar 2018 23:42:26 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.253]) with mapi id 14.03.0319.002; Wed, 7 Mar 2018 15:42:24 +0800 From: "Yao, Jiewen" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Zeng, Star" , "Dong, Eric" Thread-Topic: [PATCH] MdeModulePkg/Core: fix too many available pages between BS_Data Thread-Index: AQHTtc5677iAGW+WjEe7KXrx7olFOaPEZAAQ Date: Wed, 7 Mar 2018 07:42:23 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AADFAC4@shsmsx102.ccr.corp.intel.com> References: <20180307044041.18392-1-jian.j.wang@intel.com> In-Reply-To: <20180307044041.18392-1-jian.j.wang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzVhZmY4ODItYTFiYi00YjBlLWEyNDItNzZmMGIzZDA5Njg1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJVbXVMQk03a1FGU09FUFBKUFwvdWdGWmVDRUhHRDZTUDhkaEhScHVoNHVrS3VYV1dyUnhOYkRsTTd1OVB0Tmk5TSJ9 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/Core: fix too many available pages between BS_Data 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: Wed, 07 Mar 2018 07:36:13 -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: Wednesday, March 7, 2018 12:41 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Dong, Eric ; Y= ao, > Jiewen > Subject: [PATCH] MdeModulePkg/Core: fix too many available pages between > BS_Data >=20 > The root cause is an unnecessary check to Size parameter in function > AdjustMemoryS(). It will cause one standalone free page (happen to have > Guard page around) in the free memory list cannot be allocated, even if > the requested memory size is less than a page. >=20 > // > // At least one more page needed for Guard page. > // > if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) { > return 0; > } >=20 > The following code in the same function actually covers above check > implicitly. So the fix is simply removing above check. >=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/Mem/HeapGuard.c | 9 +-------- > MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 9 +-------- > 2 files changed, 2 insertions(+), 16 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c > b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c > index d7906e08c5..19245049c2 100644 > --- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c > +++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c > @@ -1,7 +1,7 @@ > /** @file > UEFI Heap Guard functions. >=20 > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017-2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -905,13 +905,6 @@ AdjustMemoryS ( >=20 > Target =3D Start + Size - SizeRequested; >=20 > - // > - // At least one more page needed for Guard page. > - // > - if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) { > - return 0; > - } > - > if (!IsGuardPage (Start + Size)) { > // No Guard at tail to share. One more page is needed. > Target -=3D EFI_PAGES_TO_SIZE (1); > diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > index c5ffb26342..aa9c25d102 100644 > --- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > +++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c > @@ -1,7 +1,7 @@ > /** @file > UEFI Heap Guard functions. >=20 > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2017-2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -888,13 +888,6 @@ AdjustMemoryS ( >=20 > Target =3D Start + Size - SizeRequested; >=20 > - // > - // At least one more page needed for Guard page. > - // > - if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) { > - return 0; > - } > - > if (!IsGuardPage (Start + Size)) { > // No Guard at tail to share. One more page is needed. > Target -=3D EFI_PAGES_TO_SIZE (1); > -- > 2.14.1.windows.1