From 39dbc4d5534790b5efcd67ce6b0f82ac23c6db6d Mon Sep 17 00:00:00 2001 From: Thomas Palmer Date: Wed, 27 Jul 2016 01:48:15 -0500 Subject: [PATCH] OvmfPkg/Sec: Support SECTION2 DXEFV types Support down-stream projects that require large DXEFV sizes greater than 16MB by handling SECTION2 common headers. These are already created by the build tools when necessary. Use IS_SECTION2 and SECTION2_SIZE macros to calculate accurate image sizes when appropriate. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Palmer Reviewed-by: Laszlo Ersek Regression-tested-by: Laszlo Ersek [lersek@redhat.com: fix NB->MB typo in commit message] Signed-off-by: Laszlo Ersek --- OvmfPkg/Sec/SecMain.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 384fa74735..464de10507 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -336,6 +336,8 @@ DecompressMemFvs ( EFI_COMMON_SECTION_HEADER *FvSection; EFI_FIRMWARE_VOLUME_HEADER *PeiMemFv; EFI_FIRMWARE_VOLUME_HEADER *DxeMemFv; + UINT32 FvHeaderSize; + UINT32 FvSectionSize; FvSection = (EFI_COMMON_SECTION_HEADER*) NULL; @@ -420,11 +422,19 @@ DecompressMemFvs ( } ASSERT (FvSection->Type == EFI_SECTION_FIRMWARE_VOLUME_IMAGE); - ASSERT (SECTION_SIZE (FvSection) == - (PcdGet32 (PcdOvmfDxeMemFvSize) + sizeof (*FvSection))); + + if (IS_SECTION2 (FvSection)) { + FvSectionSize = SECTION2_SIZE (FvSection); + FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER2); + } else { + FvSectionSize = SECTION_SIZE (FvSection); + FvHeaderSize = sizeof (EFI_COMMON_SECTION_HEADER); + } + + ASSERT (FvSectionSize == (PcdGet32 (PcdOvmfDxeMemFvSize) + FvHeaderSize)); DxeMemFv = (EFI_FIRMWARE_VOLUME_HEADER*)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase); - CopyMem (DxeMemFv, (VOID*) (FvSection + 1), PcdGet32 (PcdOvmfDxeMemFvSize)); + CopyMem (DxeMemFv, (VOID*) ((UINTN)FvSection + FvHeaderSize), PcdGet32 (PcdOvmfDxeMemFvSize)); if (DxeMemFv->Signature != EFI_FVH_SIGNATURE) { DEBUG ((EFI_D_ERROR, "Extracted FV at %p does not have FV header signature\n", DxeMemFv));