summaryrefslogtreecommitdiff
path: root/DuetPkg
diff options
context:
space:
mode:
authorEric Dong <eric.dong@intel.com>2014-10-15 05:17:41 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2014-10-15 05:17:41 +0000
commit55501e13510038786f735a681c43a3354b363355 (patch)
treebe71c55f817ad71269ff2cc16a46291e5e36cdfc /DuetPkg
parentbf5a9493fa9d7013015ac511714d4efdca23ae34 (diff)
downloadedk2-platforms-55501e13510038786f735a681c43a3354b363355.tar.xz
Prevent EBDA area being overwritten, get the size info from the address 0x40E. If can’t get the size info, then use the default value for it.
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
Diffstat (limited to 'DuetPkg')
-rw-r--r--DuetPkg/DxeIpl/HobGeneration.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/DuetPkg/DxeIpl/HobGeneration.c b/DuetPkg/DxeIpl/HobGeneration.c
index 401d5c718d..fac74b08fd 100644
--- a/DuetPkg/DxeIpl/HobGeneration.c
+++ b/DuetPkg/DxeIpl/HobGeneration.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -25,6 +25,7 @@ Revision History:
#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000
#define CPUID_EXTENDED_ADD_SIZE 0x80000008
+#define EBDA_VALUE_ADDRESS 0x40E
HOB_TEMPLATE gHobTemplate = {
{ // Phit
@@ -602,12 +603,21 @@ Return:
--*/
{
UINTN Index;
+ UINT64 EbdaAddress;
//
// Prepare Low Memory
// 0x18 pages is 72 KB.
//
- gHob->MemoryFreeUnder1MB.ResourceLength = EFI_MEMORY_BELOW_1MB_END - EFI_MEMORY_BELOW_1MB_START;
+ EbdaAddress = ((UINT64)(*(UINT16 *)(UINTN)(EBDA_VALUE_ADDRESS))) << 4;
+ if (EbdaAddress < 0x9A000 || EbdaAddress > EFI_MEMORY_BELOW_1MB_END) {
+ //
+ // EBDA should not go below 0x9A000 in any implementation,
+ // so add check here to make sure EBDA_VALUE_ADDRESS has a valid value.
+ //
+ EbdaAddress = EFI_MEMORY_BELOW_1MB_END;
+ }
+ gHob->MemoryFreeUnder1MB.ResourceLength = EbdaAddress - EFI_MEMORY_BELOW_1MB_START;
gHob->MemoryFreeUnder1MB.PhysicalStart = EFI_MEMORY_BELOW_1MB_START;
//