]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/Core: fix too many available pages between BS_Data
authorJian J Wang <jian.j.wang@intel.com>
Wed, 7 Mar 2018 03:26:32 +0000 (11:26 +0800)
committerStar Zeng <star.zeng@intel.com>
Thu, 8 Mar 2018 04:37:28 +0000 (12:37 +0800)
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 <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
MdeModulePkg/Core/PiSmmCore/HeapGuard.c

index d7906e08c53c4f795aaf05fe5b0207eb1b1d84e7..19245049c28b847c66665c5ea08a4a967632dd0b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Heap Guard functions.\r
 \r
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -905,13 +905,6 @@ AdjustMemoryS (
 \r
   Target = Start + Size - SizeRequested;\r
 \r
-  //\r
-  // At least one more page needed for Guard page.\r
-  //\r
-  if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) {\r
-    return 0;\r
-  }\r
-\r
   if (!IsGuardPage (Start + Size)) {\r
     // No Guard at tail to share. One more page is needed.\r
     Target -= EFI_PAGES_TO_SIZE (1);\r
index c5ffb263420e0a3d37e1de9d9825c96ce87f1a17..aa9c25d1021d144d5ae3299c5a1aed44911e4f38 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Heap Guard functions.\r
 \r
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -888,13 +888,6 @@ AdjustMemoryS (
 \r
   Target = Start + Size - SizeRequested;\r
 \r
-  //\r
-  // At least one more page needed for Guard page.\r
-  //\r
-  if (Size < (SizeRequested + EFI_PAGES_TO_SIZE (1))) {\r
-    return 0;\r
-  }\r
-\r
   if (!IsGuardPage (Start + Size)) {\r
     // No Guard at tail to share. One more page is needed.\r
     Target -= EFI_PAGES_TO_SIZE (1);\r