]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/BdsLib/Arm: Check Linux image and parameters are not overlapping
authorOlivier Martin <olivier.martin@arm.com>
Mon, 1 Sep 2014 13:24:01 +0000 (13:24 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 1 Sep 2014 13:24:01 +0000 (13:24 +0000)
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

ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c

index 3d512486da415f5d2d19edb6cbb00e94a48e6a14..42f301d9b9cd0f9158634191f265a0be40a929c4 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
@@ -17,6 +17,9 @@
 \r
 #define ALIGN32_BELOW(addr)   ALIGN_POINTER(addr - 32,32)\r
 \r
+#define IS_ADDRESS_IN_REGION(RegionStart, RegionSize, Address) \\r
+    (((UINTN)(RegionStart) <= (UINTN)(Address)) && ((UINTN)(Address) <= ((UINTN)(RegionStart) + (UINTN)(RegionSize))))\r
+\r
 STATIC\r
 EFI_STATUS\r
 PreparePlatformHardware (\r
@@ -91,7 +94,10 @@ StartLinux (
     LinuxImageSize -= 64;\r
   }\r
 \r
-  //TODO: Check there is no overlapping between kernel and Atag\r
+  // Check there is no overlapping between kernel and its parameters\r
+  // We can only assert because it is too late to fallback to UEFI (ExitBootServices has been called).\r
+  ASSERT (!IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress) &&\r
+          !IS_ADDRESS_IN_REGION(LinuxKernel, LinuxImageSize, KernelParamsAddress + KernelParamsSize));\r
 \r
   //\r
   // Switch off interrupts, caches, mmu, etc\r