]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Prevent EBDA area being overwritten, get the size info from the address 0x40E. If...
authorEric Dong <eric.dong@intel.com>
Wed, 15 Oct 2014 05:17:41 +0000 (05:17 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 15 Oct 2014 05:17:41 +0000 (05:17 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16216 6f19259b-4bc3-4df7-8a09-765794883524

DuetPkg/DxeIpl/HobGeneration.c

index 401d5c718d8dc1e84b331ba143609ad6de1fa0d1..fac74b08fd98d47fdd0d69f23b05ea4c2009de78 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -25,6 +25,7 @@ Revision History:
 \r
 #define EFI_CPUID_EXTENDED_FUNCTION  0x80000000\r
 #define CPUID_EXTENDED_ADD_SIZE      0x80000008\r
+#define EBDA_VALUE_ADDRESS           0x40E\r
 \r
 HOB_TEMPLATE  gHobTemplate = {\r
   { // Phit\r
@@ -602,12 +603,21 @@ Return:
 --*/\r
 {\r
   UINTN                Index;\r
+  UINT64               EbdaAddress;\r
 \r
   //\r
   // Prepare Low Memory\r
   // 0x18 pages is 72 KB.\r
   //\r
-  gHob->MemoryFreeUnder1MB.ResourceLength = EFI_MEMORY_BELOW_1MB_END - EFI_MEMORY_BELOW_1MB_START;\r
+  EbdaAddress = ((UINT64)(*(UINT16 *)(UINTN)(EBDA_VALUE_ADDRESS))) << 4;\r
+  if (EbdaAddress < 0x9A000 || EbdaAddress > EFI_MEMORY_BELOW_1MB_END) {\r
+    //\r
+    // EBDA should not go below 0x9A000 in any implementation,\r
+    // so add check here to make sure EBDA_VALUE_ADDRESS has a valid value.\r
+    //\r
+    EbdaAddress = EFI_MEMORY_BELOW_1MB_END;\r
+  }\r
+  gHob->MemoryFreeUnder1MB.ResourceLength = EbdaAddress - EFI_MEMORY_BELOW_1MB_START;\r
   gHob->MemoryFreeUnder1MB.PhysicalStart  = EFI_MEMORY_BELOW_1MB_START;\r
 \r
   //\r