* [PATCH] MdeModulePkg/Core: fix too many available pages between BS_Data
@ 2018-03-07 4:40 Jian J Wang
2018-03-07 7:42 ` Yao, Jiewen
0 siblings, 1 reply; 2+ messages in thread
From: Jian J Wang @ 2018-03-07 4:40 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng, Eric Dong, Jiewen Yao
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>
---
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.
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>
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 (
Target = Start + Size - SizeRequested;
- //
- // 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 -= 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.
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>
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 (
Target = Start + Size - SizeRequested;
- //
- // 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 -= EFI_PAGES_TO_SIZE (1);
--
2.14.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MdeModulePkg/Core: fix too many available pages between BS_Data
2018-03-07 4:40 [PATCH] MdeModulePkg/Core: fix too many available pages between BS_Data Jian J Wang
@ 2018-03-07 7:42 ` Yao, Jiewen
0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2018-03-07 7:42 UTC (permalink / raw)
To: Wang, Jian J, edk2-devel@lists.01.org; +Cc: Zeng, Star, Dong, Eric
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 <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Yao,
> Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdeModulePkg/Core: fix too many available pages between
> BS_Data
>
> 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>
> ---
> 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.
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>
> 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 (
>
> Target = Start + Size - SizeRequested;
>
> - //
> - // 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 -= 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.
>
> -Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2017-2018, Intel Corporation. All rights reserved.<BR>
> 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 (
>
> Target = Start + Size - SizeRequested;
>
> - //
> - // 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 -= EFI_PAGES_TO_SIZE (1);
> --
> 2.14.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-07 7:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-07 4:40 [PATCH] MdeModulePkg/Core: fix too many available pages between BS_Data Jian J Wang
2018-03-07 7:42 ` Yao, Jiewen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox