diff mbox series

[edk2,RFC,6/7] ArmVirtPkg/MemoryInitPeiLib: split memory HOB based on MAX_ALLOC_ADDRESS

Message ID 20181207112304.19765-7-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:23 a.m. UTC
The current ArmVirtMemoryInitPeiLib code splits the memory region passed
via PcdSystemMemoryBase/PcdSystemMemorySize in two if the region extends
beyond the MAX_ADDRESS limit. This was introduced for 32-bit ARM, which
may support more than 4 GB of physical address space, but cannot address
all of it via a 1:1 mapping, and a single region that is not mappable
in its entirety is unusable by the PEI core.

AArch64 is in a similar situation now: platforms may support more than
256 TB of physical address space, but only 256 TB is addressable by the
CPU, and so a memory region that extends from below this limit to above
it should be split.

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

---
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.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

Laszlo Ersek Dec. 7, 2018, 12:47 p.m. UTC | #1
On 12/07/18 12:23, Ard Biesheuvel wrote:
> The current ArmVirtMemoryInitPeiLib code splits the memory region passed

> via PcdSystemMemoryBase/PcdSystemMemorySize in two if the region extends

> beyond the MAX_ADDRESS limit. This was introduced for 32-bit ARM, which

> may support more than 4 GB of physical address space, but cannot address

> all of it via a 1:1 mapping, and a single region that is not mappable

> in its entirety is unusable by the PEI core.

> 

> AArch64 is in a similar situation now: platforms may support more than

> 256 TB of physical address space, but only 256 TB is addressable by the

> CPU, and so a memory region that extends from below this limit to above

> it should be split.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

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

> ---

>  ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 8 ++++----

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

> 

> diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c

> index 05afd1282422..66925fc05ebd 100644

> --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c

> +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c

> @@ -75,18 +75,18 @@ MemoryPeim (

>    SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +

>                      PcdGet64 (PcdSystemMemorySize);

>  

> -  if (SystemMemoryTop - 1 > MAX_ADDRESS) {

> +  if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {

>      BuildResourceDescriptorHob (

>          EFI_RESOURCE_SYSTEM_MEMORY,

>          ResourceAttributes,

>          PcdGet64 (PcdSystemMemoryBase),

> -        (UINT64)MAX_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1

> +        (UINT64)MAX_ALLOC_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1

>          );

>      BuildResourceDescriptorHob (

>          EFI_RESOURCE_SYSTEM_MEMORY,

>          ResourceAttributes,

> -        (UINT64)MAX_ADDRESS + 1,

> -        SystemMemoryTop - MAX_ADDRESS - 1

> +        (UINT64)MAX_ALLOC_ADDRESS + 1,

> +        SystemMemoryTop - MAX_ALLOC_ADDRESS - 1

>          );

>    } else {

>      BuildResourceDescriptorHob (

> 


Looks correct to me.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>



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

Patch

diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 05afd1282422..66925fc05ebd 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -75,18 +75,18 @@  MemoryPeim (
   SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
                     PcdGet64 (PcdSystemMemorySize);
 
-  if (SystemMemoryTop - 1 > MAX_ADDRESS) {
+  if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
     BuildResourceDescriptorHob (
         EFI_RESOURCE_SYSTEM_MEMORY,
         ResourceAttributes,
         PcdGet64 (PcdSystemMemoryBase),
-        (UINT64)MAX_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
+        (UINT64)MAX_ALLOC_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
         );
     BuildResourceDescriptorHob (
         EFI_RESOURCE_SYSTEM_MEMORY,
         ResourceAttributes,
-        (UINT64)MAX_ADDRESS + 1,
-        SystemMemoryTop - MAX_ADDRESS - 1
+        (UINT64)MAX_ALLOC_ADDRESS + 1,
+        SystemMemoryTop - MAX_ALLOC_ADDRESS - 1
         );
   } else {
     BuildResourceDescriptorHob (