summaryrefslogtreecommitdiffstats
path: root/ArmPkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-09-01 13:24:01 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2014-09-01 13:24:01 +0000
commite754c233a17e24a9da0f1841d9927179e2d748ff (patch)
treeff83ab519e7566eea98fcf3ec111a9c0de4975d3 /ArmPkg
parent5779aaafe95e5cf8d9f1b192725bba60c4b9e245 (diff)
downloadedk2-e754c233a17e24a9da0f1841d9927179e2d748ff.tar.gz
edk2-e754c233a17e24a9da0f1841d9927179e2d748ff.tar.bz2
edk2-e754c233a17e24a9da0f1841d9927179e2d748ff.zip
ArmPkg/BdsLib/Arm: Check Linux image and parameters are not overlapping
Check Linux image and parameters are not overlapping with each other. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16013 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
index 3d512486da..42f301d9b9 100644
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
+++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -17,6 +17,9 @@
#define ALIGN32_BELOW(addr) ALIGN_POINTER(addr - 32,32)
+#define IS_ADDRESS_IN_REGION(RegionStart, RegionSize, Address) \
+ (((UINTN)(RegionStart) <= (UINTN)(Address)) && ((UINTN)(Address) <= ((UINTN)(RegionStart) + (UINTN)(RegionSize))))
+
STATIC
EFI_STATUS
PreparePlatformHardware (
@@ -91,7 +94,10 @@ StartLinux (
LinuxImageSize -= 64;
}
- //TODO: Check there is no overlapping between kernel and Atag
+ // Check there is no overlapping between kernel and its parameters
+ // We can only assert because it is too late to fallback to UEFI (ExitBootServices has been called).
+ ASSERT (!IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress) &&
+ !IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress + KernelParamsSize));
//
// Switch off interrupts, caches, mmu, etc