diff mbox series

[edk2,RFC,2/7] MdeModulePkg/Dxe/Gcd: disregard memory above MAX_ALLOC_ADDRESS

Message ID 20181207112304.19765-3-ard.biesheuvel@linaro.org
State Superseded
Headers show
Series introduce MAX_ALLOC_ADDRESS to limit boot time allocations | expand

Commit Message

Ard Biesheuvel Dec. 7, 2018, 11:22 a.m. UTC
Update the GCD memory map initialization code so it disregards
memory that is not addressable by the CPU at boot time. This
only affects the first memory descriptor that is added, other
memory descriptors are permitted that describe memory ranges
that may be accessible to the CPU itself only when executing
under the OS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

-- 
2.19.2

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Wang, Jian J Dec. 12, 2018, 1:18 a.m. UTC | #1
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>


> -----Original Message-----

> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]

> Sent: Friday, December 07, 2018 7:23 PM

> To: edk2-devel@lists.01.org

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Kinney, Michael D

> <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Wang,

> Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Leif

> Lindholm <leif.lindholm@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Eric

> Auger <eric.auger@redhat.com>; Andrew Jones <drjones@redhat.com>;

> Philippe Mathieu-Daude <philmd@redhat.com>

> Subject: [RFC PATCH 2/7] MdeModulePkg/Dxe/Gcd: disregard memory above

> MAX_ALLOC_ADDRESS

> 

> Update the GCD memory map initialization code so it disregards

> memory that is not addressable by the CPU at boot time. This

> only affects the first memory descriptor that is added, other

> memory descriptors are permitted that describe memory ranges

> that may be accessible to the CPU itself only when executing

> under the OS.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 8 ++++----

>  1 file changed, 4 insertions(+), 4 deletions(-)

> 

> diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c

> b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c

> index a76d2db73c46..504e14a74e1d 100644

> --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c

> +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c

> @@ -2284,7 +2284,7 @@ CoreInitializeMemoryServices (

>      // region that is big enough to initialize the DXE core.  Always skip the PHIT

> Resource HOB.

>      // The max address must be within the physically addressible range for the

> processor.

>      //

> -    HighAddress = MAX_ADDRESS;

> +    HighAddress = MAX_ALLOC_ADDRESS;

>      for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw =

> GET_NEXT_HOB(Hob)) {

>        //

>        // Skip the Resource Descriptor HOB that contains the PHIT

> @@ -2300,7 +2300,7 @@ CoreInitializeMemoryServices (

>        }

> 

>        //

> -      // Skip Resource Descriptor HOBs that do not describe tested system

> memory below MAX_ADDRESS

> +      // Skip Resource Descriptor HOBs that do not describe tested system

> memory below MAX_ALLOC_ADDRESS

>        //

>        ResourceHob = Hob.ResourceDescriptor;

>        if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {

> @@ -2309,14 +2309,14 @@ CoreInitializeMemoryServices (

>        if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=

> TESTED_MEMORY_ATTRIBUTES) {

>          continue;

>        }

> -      if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) >

> (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS) {

> +      if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) >

> (EFI_PHYSICAL_ADDRESS)MAX_ALLOC_ADDRESS) {

>          continue;

>        }

> 

>        //

>        // Skip Resource Descriptor HOBs that are below a previously found

> Resource Descriptor HOB

>        //

> -      if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS &&

> ResourceHob->PhysicalStart <= HighAddress) {

> +      if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ALLOC_ADDRESS &&

> ResourceHob->PhysicalStart <= HighAddress) {

>          continue;

>        }

> 

> --

> 2.19.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index a76d2db73c46..504e14a74e1d 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2284,7 +2284,7 @@  CoreInitializeMemoryServices (
     // region that is big enough to initialize the DXE core.  Always skip the PHIT Resource HOB.
     // The max address must be within the physically addressible range for the processor.
     //
-    HighAddress = MAX_ADDRESS;
+    HighAddress = MAX_ALLOC_ADDRESS;
     for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
       //
       // Skip the Resource Descriptor HOB that contains the PHIT
@@ -2300,7 +2300,7 @@  CoreInitializeMemoryServices (
       }
 
       //
-      // Skip Resource Descriptor HOBs that do not describe tested system memory below MAX_ADDRESS
+      // Skip Resource Descriptor HOBs that do not describe tested system memory below MAX_ALLOC_ADDRESS
       //
       ResourceHob = Hob.ResourceDescriptor;
       if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
@@ -2309,14 +2309,14 @@  CoreInitializeMemoryServices (
       if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
         continue;
       }
-      if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS) {
+      if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > (EFI_PHYSICAL_ADDRESS)MAX_ALLOC_ADDRESS) {
         continue;
       }
 
       //
       // Skip Resource Descriptor HOBs that are below a previously found Resource Descriptor HOB
       //
-      if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ADDRESS && ResourceHob->PhysicalStart <= HighAddress) {
+      if (HighAddress != (EFI_PHYSICAL_ADDRESS)MAX_ALLOC_ADDRESS && ResourceHob->PhysicalStart <= HighAddress) {
         continue;
       }