From b36f701d4f925172516cfdee72915e3217c92551 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 21 Jan 2014 19:39:13 +0000 Subject: [PATCH] OvmfPkg: Split MAINFV into a separate PEI and DXE FVs By splitting the PEI and DXE phases into separate FVs, we can only reserve the PEI FV for ACPI S3 support. This should save about 7MB. Unfortunately, this all has to happen in a single commit. DEC: * Remove PcdOvmfMemFv(Base|Size) * Add PcdOvmfPeiMemFv(Base|Size) * Add PcdOvmfDxeMemFv(Base|Size) FDF: * Add new PEIFV. Move PEI modules here. * Remove MAINFV * Add PEIFV and DXEFV into FVMAIN_COMPACT - They are added as 2 sections of a file, and compressed together so they should retain good compression * PcdOvmf(Pei|Dxe)MemFv(Base|Size) are set SEC: * Find both the PEI and DXE FVs after decompression. - Copy them separately to their memory locations. Platform PEI driver: * Fv.c: Publish both FVs as appropriate * MemDetect.c: PcdOvmfMemFv(Base|Size) => PcdOvmfDxeMemFv(Base|Size) OVMF.fd before: Non-volatile data storage FVMAIN_COMPACT uncompressed FV FFS file LZMA compressed MAINFV uncompressed individual PEI modules uncompressed FV FFS file compressed with PI_NONE DXEFV uncompressed individual DXE modules uncompressed SECFV uncompressed OVMF.fd after: Non-volatile data storage FVMAIN_COMPACT uncompressed FV FFS file LZMA compressed PEIFV uncompressed individual PEI modules uncompressed DXEFV uncompressed individual DXE modules uncompressed SECFV uncompressed Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen Reviewed-by: Laszlo Ersek git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15151 6f19259b-4bc3-4df7-8a09-765794883524 --- OvmfPkg/OvmfPkg.dec | 6 ++- OvmfPkg/OvmfPkgIa32.fdf | 37 ++++++++--------- OvmfPkg/OvmfPkgIa32X64.fdf | 37 ++++++++--------- OvmfPkg/OvmfPkgX64.fdf | 37 ++++++++--------- OvmfPkg/PlatformPei/Fv.c | 46 ++++++++++++++------- OvmfPkg/PlatformPei/MemDetect.c | 4 +- OvmfPkg/PlatformPei/PlatformPei.inf | 8 ++-- OvmfPkg/Sec/SecMain.c | 62 +++++++++++++++++++++-------- OvmfPkg/Sec/SecMain.inf | 8 ++-- 9 files changed, 141 insertions(+), 104 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 0e33b3b69c..034ccd8ef7 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -48,8 +48,10 @@ gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}} [PcdsFixedAtBuild] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|0x0|UINT32|0 - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize|0x0|UINT32|1 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize|0x0|UINT32|1 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|0x0|UINT32|0x15 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize|0x0|UINT32|0x16 ## This flag is used to control the destination port for PlatformDebugLibIoPort gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort|0x402|UINT16|4 diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf index 210abdedeb..7c4e6cda62 100644 --- a/OvmfPkg/OvmfPkgIa32.fdf +++ b/OvmfPkg/OvmfPkgIa32.fdf @@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P 0x010000|0x008000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize -0x020000|0x7E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize -FV = MAINFV +0x020000|0x0E0000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize +FV = PEIFV + +0x100000|0x700000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize +FV = DXEFV ################################################################################ @@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE # SEC Phase modules # # The code in this FV handles the initial firmware startup, and -# decompresses the MAINFV which handles the majority of the boot sequence. +# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. # INF OvmfPkg/Sec/SecMain.inf INF RuleOverride=RESET_VECTOR UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf ################################################################################ -[FV.MAINFV] +[FV.PEIFV] BlockSize = 0x10000 FvAlignment = 16 ERASE_POLARITY = 1 @@ -196,15 +200,6 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE -# -# Files to be placed in MAIN FV -# -# This firmware volume will have files placed in it uncompressed, -# and then then entire firmware volume will be compressed in a -# single compression operation in order to achieve better -# overall compression. -# - APRIORI PEI { INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf } @@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C { - SECTION COMPRESS PI_NONE { - SECTION FV_IMAGE = DXEFV - } -} - ################################################################################ [FV.DXEFV] @@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - SECTION FV_IMAGE = MAINFV + # + # These firmware volumes will have files placed in them uncompressed, + # and then both firmware volumes will be compressed in a single + # compression operation in order to achieve better overall compression. + # + SECTION FV_IMAGE = PEIFV + SECTION FV_IMAGE = DXEFV } } diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 90f44a6237..3cb49de30a 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P 0x010000|0x008000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize -0x020000|0x7E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize -FV = MAINFV +0x020000|0x0E0000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize +FV = PEIFV + +0x100000|0x700000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize +FV = DXEFV ################################################################################ @@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE # SEC Phase modules # # The code in this FV handles the initial firmware startup, and -# decompresses the MAINFV which handles the majority of the boot sequence. +# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. # INF OvmfPkg/Sec/SecMain.inf INF RuleOverride=RESET_VECTOR USE = IA32 UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf ################################################################################ -[FV.MAINFV] +[FV.PEIFV] BlockSize = 0x10000 FvAlignment = 16 ERASE_POLARITY = 1 @@ -196,15 +200,6 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE -# -# Files to be placed in MAIN FV -# -# This firmware volume will have files placed in it uncompressed, -# and then then entire firmware volume will be compressed in a -# single compression operation in order to achieve better -# overall compression. -# - APRIORI PEI { INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf } @@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C { - SECTION COMPRESS PI_NONE { - SECTION FV_IMAGE = DXEFV - } -} - ################################################################################ [FV.DXEFV] @@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - SECTION FV_IMAGE = MAINFV + # + # These firmware volumes will have files placed in them uncompressed, + # and then both firmware volumes will be compressed in a single + # compression operation in order to achieve better overall compression. + # + SECTION FV_IMAGE = PEIFV + SECTION FV_IMAGE = DXEFV } } diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 67c7415fda..bd1dc1bc5d 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -141,9 +141,13 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P 0x010000|0x008000 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize -0x020000|0x7E0000 -gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize -FV = MAINFV +0x020000|0x0E0000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize +FV = PEIFV + +0x100000|0x700000 +gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize +FV = DXEFV ################################################################################ @@ -170,14 +174,14 @@ READ_LOCK_STATUS = TRUE # SEC Phase modules # # The code in this FV handles the initial firmware startup, and -# decompresses the MAINFV which handles the majority of the boot sequence. +# decompresses the PEI and DXE FVs which handles the rest of the boot sequence. # INF OvmfPkg/Sec/SecMain.inf INF RuleOverride=RESET_VECTOR OvmfPkg/ResetVector/Bin/ResetVector.inf ################################################################################ -[FV.MAINFV] +[FV.PEIFV] BlockSize = 0x10000 FvAlignment = 16 ERASE_POLARITY = 1 @@ -196,15 +200,6 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE -# -# Files to be placed in MAIN FV -# -# This firmware volume will have files placed in it uncompressed, -# and then then entire firmware volume will be compressed in a -# single compression operation in order to achieve better -# overall compression. -# - APRIORI PEI { INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf } @@ -218,12 +213,6 @@ INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf INF OvmfPkg/PlatformPei/PlatformPei.inf INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf -FILE FV_IMAGE = A4EF5A93-3F1B-4232-A1C4-F0910E6D1D9C { - SECTION COMPRESS PI_NONE { - SECTION FV_IMAGE = DXEFV - } -} - ################################################################################ [FV.DXEFV] @@ -400,7 +389,13 @@ READ_LOCK_STATUS = TRUE FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 { SECTION GUIDED EE4E5898-3914-4259-9D6E-DC7BD79403CF PROCESSING_REQUIRED = TRUE { - SECTION FV_IMAGE = MAINFV + # + # These firmware volumes will have files placed in them uncompressed, + # and then both firmware volumes will be compressed in a single + # compression operation in order to achieve better overall compression. + # + SECTION FV_IMAGE = PEIFV + SECTION FV_IMAGE = DXEFV } } diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Fv.c index f389e277c9..fbdb597043 100644 --- a/OvmfPkg/PlatformPei/Fv.c +++ b/OvmfPkg/PlatformPei/Fv.c @@ -1,7 +1,7 @@ /** @file Build FV related hobs for platform. - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
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 @@ -20,10 +20,8 @@ /** - Perform a call-back into the SEC simulator to get address of the Firmware Hub - - @param FfsHeader Ffs Header availible to every PEIM - @param PeiServices General purpose services available to every PEIM. + Publish PEI & DXE (Decompressed) Memory based FVs to let PEI + and DXE know about them. @retval EFI_SUCCESS Platform PEI FVs were initialized successfully. @@ -33,26 +31,44 @@ PeiFvInitialization ( VOID ) { - DEBUG ((EFI_D_ERROR, "Platform PEI Firmware Volume Initialization\n")); + DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n")); - DEBUG ( - (EFI_D_ERROR, "Firmware Volume HOB: 0x%x 0x%x\n", - PcdGet32 (PcdOvmfMemFvBase), - PcdGet32 (PcdOvmfMemFvSize) - ) + // + // Create a memory allocation HOB for the PEI FV. + // + // This is marked as ACPI NVS so it will still be available on S3 resume. + // + BuildMemoryAllocationHob ( + PcdGet32 (PcdOvmfPeiMemFvBase), + PcdGet32 (PcdOvmfPeiMemFvSize), + EfiACPIMemoryNVS ); - BuildFvHob (PcdGet32 (PcdOvmfMemFvBase), PcdGet32 (PcdOvmfMemFvSize)); + // + // Let DXE know about the DXE FV + // + BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize)); // - // Create a memory allocation HOB. + // Create a memory allocation HOB for the DXE FV. // BuildMemoryAllocationHob ( - PcdGet32 (PcdOvmfMemFvBase), - PcdGet32 (PcdOvmfMemFvSize), + PcdGet32 (PcdOvmfDxeMemFvBase), + PcdGet32 (PcdOvmfDxeMemFvSize), EfiBootServicesData ); + // + // Let PEI know about the DXE FV so it can find the DXE Core + // + PeiServicesInstallFvInfoPpi ( + NULL, + (VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase), + PcdGet32 (PcdOvmfDxeMemFvSize), + NULL, + NULL + ); + return EFI_SUCCESS; } diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index a1de762681..bd57b7792e 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -1,7 +1,7 @@ /**@file Memory Detection for Virtual Machines. - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
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 @@ -104,7 +104,7 @@ PublishPeiMemory ( // // Determine the range of memory to use during PEI // - MemoryBase = PcdGet32 (PcdOvmfMemFvBase) + PcdGet32 (PcdOvmfMemFvSize); + MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize); MemorySize = LowerMemorySize - MemoryBase; if (MemorySize > SIZE_64MB) { MemoryBase = LowerMemorySize - SIZE_64MB; diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 7fe9d471cb..7c646ab8a0 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -2,7 +2,7 @@ # Platform PEI driver # # This module provides platform specific function to detect boot mode. -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -58,8 +58,10 @@ PcdLib [Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize 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.
+# Copyright (c) 2008 - 2013, Intel Corporation. All rights reserved.
# # 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 -- 2.39.2