From nobody Sun Apr 28 19:26:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1520397649074579.60941986756; Tue, 6 Mar 2018 20:40:49 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E137722485A6A; Tue, 6 Mar 2018 20:34:32 -0800 (PST) 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 66B6B22135D47 for ; Tue, 6 Mar 2018 20:34:31 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2018 20:40:45 -0800 Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.93]) by orsmga004.jf.intel.com with ESMTP; 06 Mar 2018 20:40:44 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,434,1515484800"; d="scan'208";a="180543201" From: Jian J Wang To: edk2-devel@lists.01.org Date: Wed, 7 Mar 2018 12:40:41 +0800 Message-Id: <20180307044041.18392-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [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: , Cc: Jiewen Yao , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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. // // At least one more page needed for Guard page. // if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) { return 0; } The following code in the same function actually covers above check implicitly. So the fix is simply removing above check. Cc: Star Zeng Cc: Eric Dong Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang Reviewed-by: Jiewen.yao@intel.com --- MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 9 +-------- MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) 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 BSD = License which accompanies this distribution. The full text of the license may be = 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/Pi= SmmCore/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 BSD = License which accompanies this distribution. The full text of the license may be = 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); --=20 2.14.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel