[edk2,v2,5/6] ArmPlatformPkg/MemoryInitPeim: take MAX_ALLOC_ADDRESS into account

Message ID 20181219205640.4704-6-ard.biesheuvel@linaro.org
State Accepted
Commit 6bd42402f70ba0db9161fc59301b60ee82ba1c09
Headers show
Series
  • introduce MAX_ALLOC_ADDRESS to limit boot time allocations
Related show

Commit Message

Ard Biesheuvel Dec. 19, 2018, 8:56 p.m.
Limit the PEI memory region so it will not extend beyond what we can
address architecturally when running with 4 KB pages.

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

---
 ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.19.2

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

Comments

Leif Lindholm Dec. 19, 2018, 9:15 p.m. | #1
On Wed, Dec 19, 2018 at 09:56:39PM +0100, Ard Biesheuvel wrote:
> Limit the PEI memory region so it will not extend beyond what we can

> address architecturally when running with 4 KB pages.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

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


Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>


> ---

>  ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c | 6 +++---

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

> 

> diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c

> index 389a2e6f1abd..010f93add76b 100644

> --- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c

> +++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c

> @@ -105,12 +105,12 @@ InitializeMemory (

>  

>    // Ensure PcdSystemMemorySize has been set

>    ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);

> -  ASSERT (PcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ADDRESS);

> +  ASSERT (PcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS);

>  

>    SystemMemoryBase = (UINTN)PcdGet64 (PcdSystemMemoryBase);

>    SystemMemoryTop = SystemMemoryBase + PcdGet64 (PcdSystemMemorySize);

> -  if (SystemMemoryTop - 1 > MAX_ADDRESS) {

> -    SystemMemoryTop = (UINT64)MAX_ADDRESS + 1;

> +  if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {

> +    SystemMemoryTop = (UINT64)MAX_ALLOC_ADDRESS + 1;

>    }

>    FdBase = (UINTN)PcdGet64 (PcdFdBaseAddress);

>    FdTop = FdBase + (UINTN)PcdGet32 (PcdFdSize);

> -- 

> 2.19.2

> 

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

Patch

diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
index 389a2e6f1abd..010f93add76b 100644
--- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
+++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
@@ -105,12 +105,12 @@  InitializeMemory (
 
   // Ensure PcdSystemMemorySize has been set
   ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
-  ASSERT (PcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ADDRESS);
+  ASSERT (PcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS);
 
   SystemMemoryBase = (UINTN)PcdGet64 (PcdSystemMemoryBase);
   SystemMemoryTop = SystemMemoryBase + PcdGet64 (PcdSystemMemorySize);
-  if (SystemMemoryTop - 1 > MAX_ADDRESS) {
-    SystemMemoryTop = (UINT64)MAX_ADDRESS + 1;
+  if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
+    SystemMemoryTop = (UINT64)MAX_ALLOC_ADDRESS + 1;
   }
   FdBase = (UINTN)PcdGet64 (PcdFdBaseAddress);
   FdTop = FdBase + (UINTN)PcdGet32 (PcdFdSize);