summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2016-02-06 09:02:57 +0800
committerLiming Gao <liming.gao@intel.com>2016-02-29 16:28:56 +0800
commit609730ef9120cb4f30a85afc7f7833a7cc554312 (patch)
tree35196161563208fa3874603b3364412fb2af7572 /MdeModulePkg/Core
parent216fefa3f5f41c726d71d4d3566323043f40edd8 (diff)
downloadedk2-609730ef9120cb4f30a85afc7f7833a7cc554312.tar.gz
MdeModulePkg: Update PeiCore dispatcher to handle PEIM and PEI_CORE only
When PcdShadowPeimOnBoot is FALSE, they are not copied to memory and execute from their original locations. Here, this policy should only apply for PEIM and PEI_CORE, not for other file type, such as DXE_CORE. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Tested-by: Eugene Cohen <eugene@hp.com>
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Pei/Image/Image.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c
index 9c54192d8..c75ef35ee 100644
--- a/MdeModulePkg/Core/Pei/Image/Image.c
+++ b/MdeModulePkg/Core/Pei/Image/Image.c
@@ -1,7 +1,7 @@
/** @file
Pei Core Load Image Support
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2016, 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
@@ -358,7 +358,9 @@ LoadAndRelocatePeCoffImage (
BOOLEAN IsXipImage;
EFI_STATUS ReturnStatus;
BOOLEAN IsS3Boot;
+ BOOLEAN IsPeiModule;
BOOLEAN IsRegisterForShadow;
+ EFI_FV_FILE_INFO FileInfo;
Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
@@ -396,9 +398,25 @@ LoadAndRelocatePeCoffImage (
}
//
+ // Get file type first
+ //
+ Status = PeiServicesFfsGetFileInfo (FileHandle, &FileInfo);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Check whether the file type is PEI module.
+ //
+ IsPeiModule = FALSE;
+ if (FileInfo.FileType == EFI_FV_FILETYPE_PEI_CORE ||
+ FileInfo.FileType == EFI_FV_FILETYPE_PEIM ||
+ FileInfo.FileType == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER) {
+ IsPeiModule = TRUE;
+ }
+
+ //
// When Image has no reloc section, it can't be relocated into memory.
//
- if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && (
+ if (ImageContext.RelocationsStripped && (Private->PeiMemoryInstalled) && ((!IsPeiModule) ||
(!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) {
DEBUG ((EFI_D_INFO|EFI_D_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));
}
@@ -413,7 +431,7 @@ LoadAndRelocatePeCoffImage (
// On normal boot, PcdShadowPeimOnBoot decides whether load PEIM or PeiCore into memory.
// On S3 boot, PcdShadowPeimOnS3Boot decides whether load PEIM or PeiCore into memory.
//
- if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && (
+ if ((!ImageContext.RelocationsStripped) && (Private->PeiMemoryInstalled) && ((!IsPeiModule) ||
(!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) || (IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))) {
//
// Allocate more buffer to avoid buffer overflow.