From 2a414cd3c35f09978124936f3377b073f2ce37fc Mon Sep 17 00:00:00 2001 From: Garrett Kirkendall Date: Mon, 16 Sep 2013 09:29:52 +0000 Subject: [PATCH 1/1] ArmPlatformPkg/MemoryInitPei: AARCH64 fix memory address calculations At least for AARCH64 currently, SystemMemoryTop and FdTop can overflow while adding the 32-bit PCDs together. The resulting value loses the upper 32-bits. Cast each of the values to EFI_PHYSICAL_ADDRESS size before doing the addition to prevent erroneous overflow. There is currently no 32-bit platform in EDKII open source that will overflow and this change would not fix that problem anyway. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Garrett Kirkendall Reviewed-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14675 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c index 192486ce56..d1bf394c45 100755 --- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c +++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c @@ -101,8 +101,8 @@ MemoryPeim ( PcdGet32 (PcdSystemMemorySize) ); - SystemMemoryTop = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize); - FdTop = PcdGet32(PcdFdBaseAddress) + PcdGet32(PcdFdSize); + SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdSystemMemorySize); + FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet32(PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32(PcdFdSize); // EDK2 does not have the concept of boot firmware copied into DRAM. To avoid the DXE // core to overwrite this area we must mark the region with the attribute non-present -- 2.39.2