summaryrefslogtreecommitdiff
path: root/OvmfPkg/Sec
diff options
context:
space:
mode:
Diffstat (limited to 'OvmfPkg/Sec')
-rw-r--r--OvmfPkg/Sec/SecMain.c62
-rw-r--r--OvmfPkg/Sec/SecMain.inf8
2 files changed, 51 insertions, 19 deletions
diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 6e238fe337..0edc4f9af3 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -311,7 +311,7 @@ FindFfsFileAndSection (
Locates the compressed main firmware volume and decompresses it.
@param[in,out] Fv On input, the firmware volume to search
- On output, the decompressed main FV
+ On output, the decompressed BOOT/PEI FV
@retval EFI_SUCCESS The file and section was found
@retval EFI_NOT_FOUND The file and section was not found
@@ -319,7 +319,7 @@ FindFfsFileAndSection (
**/
EFI_STATUS
-DecompressGuidedFv (
+DecompressMemFvs (
IN OUT EFI_FIRMWARE_VOLUME_HEADER **Fv
)
{
@@ -331,10 +331,11 @@ DecompressGuidedFv (
UINT32 AuthenticationStatus;
VOID *OutputBuffer;
VOID *ScratchBuffer;
- EFI_FIRMWARE_VOLUME_IMAGE_SECTION *NewFvSection;
- EFI_FIRMWARE_VOLUME_HEADER *NewFv;
+ EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FvSection;
+ EFI_FIRMWARE_VOLUME_HEADER *PeiMemFv;
+ EFI_FIRMWARE_VOLUME_HEADER *DxeMemFv;
- NewFvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) NULL;
+ FvSection = (EFI_FIRMWARE_VOLUME_IMAGE_SECTION*) NULL;
Status = FindFfsFileAndSection (
*Fv,
@@ -358,8 +359,7 @@ DecompressGuidedFv (
return Status;
}
- //PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize)
- OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfMemFvBase) + SIZE_1MB);
+ OutputBuffer = (VOID*) ((UINT8*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase) + SIZE_1MB);
ScratchBuffer = ALIGN_POINTER ((UINT8*) OutputBuffer + OutputBufferSize, SIZE_1MB);
Status = ExtractGuidedSectionDecode (
Section,
@@ -372,27 +372,57 @@ DecompressGuidedFv (
return Status;
}
- Status = FindFfsSectionInSections (
+ Status = FindFfsSectionInstance (
OutputBuffer,
OutputBufferSize,
EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
- (EFI_COMMON_SECTION_HEADER**) &NewFvSection
+ 0,
+ (EFI_COMMON_SECTION_HEADER**) &FvSection
);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Unable to find FV image in extracted data\n"));
+ DEBUG ((EFI_D_ERROR, "Unable to find PEI FV section\n"));
return Status;
}
- NewFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfMemFvBase);
- CopyMem (NewFv, (VOID*) (NewFvSection + 1), PcdGet32 (PcdOvmfMemFvSize));
+ ASSERT (SECTION_SIZE (FvSection) ==
+ (PcdGet32 (PcdOvmfPeiMemFvSize) + sizeof (*FvSection)));
+ ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE);
- if (NewFv->Signature != EFI_FVH_SIGNATURE) {
- DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", NewFv));
+ PeiMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfPeiMemFvBase);
+ CopyMem (PeiMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfPeiMemFvSize));
+
+ if (PeiMemFv->Signature != EFI_FVH_SIGNATURE) {
+ DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", PeiMemFv));
+ CpuDeadLoop ();
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ Status = FindFfsSectionInstance (
+ OutputBuffer,
+ OutputBufferSize,
+ EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
+ 1,
+ (EFI_COMMON_SECTION_HEADER**) &FvSection
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "Unable to find DXE FV section\n"));
+ return Status;
+ }
+
+ ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE);
+ ASSERT (SECTION_SIZE (FvSection) ==
+ (PcdGet32 (PcdOvmfDxeMemFvSize) + sizeof (*FvSection)));
+
+ DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase);
+ CopyMem (DxeMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfDxeMemFvSize));
+
+ if (DxeMemFv->Signature != EFI_FVH_SIGNATURE) {
+ DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", DxeMemFv));
CpuDeadLoop ();
return EFI_VOLUME_CORRUPTED;
}
- *Fv = NewFv;
+ *Fv = PeiMemFv;
return EFI_SUCCESS;
}
@@ -460,7 +490,7 @@ FindPeiCoreImageBase (
FindMainFv (BootFv);
- DecompressGuidedFv (BootFv);
+ DecompressMemFvs (BootFv);
FindPeiCoreImageBaseInFv (*BootFv, PeiCoreImageBase);
}
diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 0b1cda83df..107f60afc2 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -1,7 +1,7 @@
## @file
# SEC Driver
#
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2013, 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
@@ -64,8 +64,10 @@
gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED
[Pcd]
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase
- gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize