]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/FwVol/FwVol.c
MdeModulePkg PeiCore: Check error status when processing boot FV
[mirror_edk2.git] / MdeModulePkg / Core / Pei / FwVol / FwVol.c
index b2575c97982102a765c536a893eb41b43319b6f4..4150b338b211847a17cf2d2968a11b11e1e46976 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Pei Core Firmware File System service routines.\r
   \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 HP Development Company, L.P.\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -14,10 +15,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "FwVol.h"\r
 \r
-EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = {\r
-  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
-  &gEfiPeiFirmwareVolumeInfoPpiGuid,\r
-  FirmwareVolmeInfoPpiNotifyCallback \r
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList[] = {\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r
+    &gEfiPeiFirmwareVolumeInfoPpiGuid,\r
+    FirmwareVolmeInfoPpiNotifyCallback \r
+  },\r
+  {\r
+    (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+    &gEfiPeiFirmwareVolumeInfo2PpiGuid,\r
+    FirmwareVolmeInfoPpiNotifyCallback \r
+  }\r
 };\r
 \r
 PEI_FW_VOL_INSTANCE mPeiFfs2FwVol = {\r
@@ -29,7 +37,11 @@ PEI_FW_VOL_INSTANCE mPeiFfs2FwVol = {
     PeiFfsFvPpiFindFileByName,\r
     PeiFfsFvPpiGetFileInfo,\r
     PeiFfsFvPpiGetVolumeInfo,\r
-    PeiFfsFvPpiFindSectionByType\r
+    PeiFfsFvPpiFindSectionByType,\r
+    PeiFfsFvPpiGetFileInfo2,\r
+    PeiFfsFvPpiFindSectionByType2,\r
+    EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,\r
+    EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION\r
   }\r
 };\r
 \r
@@ -42,7 +54,11 @@ PEI_FW_VOL_INSTANCE mPeiFfs3FwVol = {
     PeiFfsFvPpiFindFileByName,\r
     PeiFfsFvPpiGetFileInfo,\r
     PeiFfsFvPpiGetVolumeInfo,\r
-    PeiFfsFvPpiFindSectionByType\r
+    PeiFfsFvPpiFindSectionByType,\r
+    PeiFfsFvPpiGetFileInfo2,\r
+    PeiFfsFvPpiFindSectionByType2,\r
+    EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE,\r
+    EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION\r
   }\r
 };\r
             \r
@@ -57,7 +73,62 @@ EFI_PEI_PPI_DESCRIPTOR  mPeiFfs3FvPpiList = {
   &gEfiFirmwareFileSystem3Guid,\r
   &mPeiFfs3FwVol.Fv\r
 };\r
\r
+\r
+/**\r
+Required Alignment   Alignment Value in FFS   FFS_ATTRIB_DATA_ALIGNMENT2   Alignment Value in\r
+(bytes)              Attributes Field         in FFS Attributes Field      Firmware Volume Interfaces\r
+1                               0                          0                            0\r
+16                              1                          0                            4\r
+128                             2                          0                            7\r
+512                             3                          0                            9\r
+1 KB                            4                          0                            10\r
+4 KB                            5                          0                            12\r
+32 KB                           6                          0                            15\r
+64 KB                           7                          0                            16\r
+128 KB                          0                          1                            17\r
+256 KB                          1                          1                            18\r
+512 KB                          2                          1                            19\r
+1 MB                            3                          1                            20\r
+2 MB                            4                          1                            21\r
+4 MB                            5                          1                            22\r
+8 MB                            6                          1                            23\r
+16 MB                           7                          1                            24\r
+**/\r
+UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};\r
+UINT8 mFvAttributes2[] = {17, 18, 19, 20, 21, 22, 23, 24};\r
+\r
+/**\r
+  Convert the FFS File Attributes to FV File Attributes\r
+\r
+  @param  FfsAttributes              The attributes of UINT8 type.\r
+\r
+  @return The attributes of EFI_FV_FILE_ATTRIBUTES\r
+\r
+**/\r
+EFI_FV_FILE_ATTRIBUTES\r
+FfsAttributes2FvFileAttributes (\r
+  IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes\r
+  )\r
+{\r
+  UINT8                     DataAlignment;\r
+  EFI_FV_FILE_ATTRIBUTES    FileAttribute;\r
+\r
+  DataAlignment = (UINT8) ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);\r
+  ASSERT (DataAlignment < 8);\r
+\r
+  if ((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT_2) != 0) {\r
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes2[DataAlignment];\r
+  } else {\r
+    FileAttribute = (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[DataAlignment];\r
+  }\r
+\r
+  if ((FfsAttributes & FFS_ATTRIB_FIXED) == FFS_ATTRIB_FIXED) {\r
+    FileAttribute |= EFI_FV_FILE_ATTRIB_FIXED;\r
+  }\r
+\r
+  return FileAttribute;\r
+}\r
+\r
 /**\r
   Returns the file state set by the highest zero bit in the State field\r
 \r
@@ -146,16 +217,34 @@ FileHandleToVolume (
   UINTN                       Index;\r
   PEI_CORE_INSTANCE           *PrivateData;\r
   EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
+  UINTN                       BestIndex;\r
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r
+  BestIndex   = PrivateData->FvCount;\r
   \r
+  //\r
+  // Find the best matched FV image that includes this FileHandle.\r
+  // FV may include the child FV, and they are in the same continuous space. \r
+  // If FileHandle is from the child FV, the updated logic can find its matched FV.\r
+  //\r
   for (Index = 0; Index < PrivateData->FvCount; Index++) {\r
     FwVolHeader = PrivateData->Fv[Index].FvHeader;\r
     if (((UINT64) (UINTN) FileHandle > (UINT64) (UINTN) FwVolHeader ) &&   \\r
         ((UINT64) (UINTN) FileHandle <= ((UINT64) (UINTN) FwVolHeader + FwVolHeader->FvLength - 1))) {\r
-      return &PrivateData->Fv[Index];\r
+      if (BestIndex == PrivateData->FvCount) {\r
+        BestIndex = Index;\r
+      } else {\r
+        if ((UINT64) (UINTN) PrivateData->Fv[BestIndex].FvHeader < (UINT64) (UINTN) FwVolHeader) {\r
+          BestIndex = Index;\r
+        }\r
+      }\r
     }\r
   }\r
+\r
+  if (BestIndex < PrivateData->FvCount) {\r
+    return &PrivateData->Fv[BestIndex];\r
+  }\r
+\r
   return NULL;\r
 }\r
 \r
@@ -184,10 +273,11 @@ FindFileEx (
   IN  CONST EFI_GUID                 *FileName,   OPTIONAL\r
   IN        EFI_FV_FILETYPE          SearchType,\r
   IN OUT    EFI_PEI_FILE_HANDLE      *FileHandle,\r
-  IN OUT    EFI_PEI_FV_HANDLE        *AprioriFile  OPTIONAL\r
+  IN OUT    EFI_PEI_FILE_HANDLE      *AprioriFile  OPTIONAL\r
   )\r
 {\r
-  EFI_FIRMWARE_VOLUME_HEADER           *FwVolHeader;\r
+  EFI_FIRMWARE_VOLUME_HEADER            *FwVolHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER        *FwVolExtHeader;\r
   EFI_FFS_FILE_HEADER                   **FileHeader;\r
   EFI_FFS_FILE_HEADER                   *FfsFileHeader;\r
   UINT32                                FileLength;\r
@@ -220,7 +310,16 @@ FindFileEx (
   // start from the FileHeader.\r
   //\r
   if ((*FileHeader == NULL) || (FileName != NULL)) {\r
-    FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);\r
+    if (FwVolHeader->ExtHeaderOffset != 0) {\r
+      //\r
+      // Searching for files starts on an 8 byte aligned boundary after the end of the Extended Header if it exists.\r
+      //\r
+      FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->ExtHeaderOffset);\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolExtHeader + FwVolExtHeader->ExtHeaderSize);\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *) ALIGN_POINTER (FfsFileHeader, 8);\r
+    } else {\r
+      FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);\r
+    }\r
   } else {\r
     if (IS_FFS_FILE2 (*FileHeader)) {\r
       if (!IsFfs3Fv) {\r
@@ -396,12 +495,13 @@ PeiInitializeFv (
   //\r
   // Get handle of BFV\r
   //\r
-  FvPpi->ProcessVolume (\r
-           FvPpi, \r
-           SecCoreData->BootFirmwareVolumeBase,\r
-           (UINTN)BfvHeader->FvLength,\r
-           &FvHandle\r
-           );\r
+  Status = FvPpi->ProcessVolume (\r
+                    FvPpi,\r
+                    SecCoreData->BootFirmwareVolumeBase,\r
+                    (UINTN)BfvHeader->FvLength,\r
+                    &FvHandle\r
+                    );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Update internal PEI_CORE_FV array.\r
@@ -409,29 +509,30 @@ PeiInitializeFv (
   PrivateData->Fv[PrivateData->FvCount].FvHeader = BfvHeader;\r
   PrivateData->Fv[PrivateData->FvCount].FvPpi    = FvPpi;\r
   PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+  PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = 0;\r
   DEBUG ((\r
     EFI_D_INFO, \r
     "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
     (UINT32) PrivateData->FvCount, \r
     (VOID *) BfvHeader, \r
-    BfvHeader->FvLength,\r
+    (UINT32) BfvHeader->FvLength,\r
     FvHandle\r
     ));    \r
   PrivateData->FvCount ++;\r
                             \r
   //\r
-  // Post a call-back for the FvInfoPPI services to expose\r
+  // Post a call-back for the FvInfoPPI and FvInfo2PPI services to expose\r
   // additional Fvs to PeiCore.\r
   //\r
-  Status = PeiServicesNotifyPpi (&mNotifyOnFvInfoList);\r
+  Status = PeiServicesNotifyPpi (mNotifyOnFvInfoList);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
 }\r
   \r
 /**\r
-  Process Firmware Volum Information once FvInfoPPI install.\r
+  Process Firmware Volum Information once FvInfoPPI or FvInfo2PPI install.\r
   The FV Info will be registered into PeiCore private data structure.\r
-  And search the inside FV image, if found, the new FV INFO PPI will be installed.\r
+  And search the inside FV image, if found, the new FV INFO(2) PPI will be installed.\r
 \r
   @param PeiServices       An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param NotifyDescriptor  Address of the notification descriptor data structure.\r
@@ -449,7 +550,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
   IN VOID                          *Ppi\r
   )\r
 {\r
-  EFI_PEI_FIRMWARE_VOLUME_INFO_PPI      *FvInfoPpi;\r
+  EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI     FvInfo2Ppi;\r
   EFI_PEI_FIRMWARE_VOLUME_PPI           *FvPpi;\r
   PEI_CORE_INSTANCE                     *PrivateData;\r
   EFI_STATUS                            Status;\r
@@ -457,24 +558,47 @@ FirmwareVolmeInfoPpiNotifyCallback (
   UINTN                                 FvIndex;\r
   EFI_PEI_FILE_HANDLE                   FileHandle;\r
   VOID                                  *DepexData;\r
-  \r
+  BOOLEAN                               IsFvInfo2;\r
+  UINTN                                 CurFvCount;\r
+\r
   Status       = EFI_SUCCESS;\r
   PrivateData  = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
 \r
-  if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-    DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, FixedPcdGet32 (PcdPeiCoreMaxFvSupported)));\r
-    DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));\r
-    ASSERT (FALSE);\r
+  if (CompareGuid (NotifyDescriptor->Guid, &gEfiPeiFirmwareVolumeInfo2PpiGuid)) {\r
+    //\r
+    // It is FvInfo2PPI.\r
+    //\r
+    CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI));\r
+    IsFvInfo2 = TRUE;\r
+  } else {\r
+    //\r
+    // It is FvInfoPPI.\r
+    //\r
+    CopyMem (&FvInfo2Ppi, Ppi, sizeof (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI));\r
+    FvInfo2Ppi.AuthenticationStatus = 0;\r
+    IsFvInfo2 = FALSE;\r
   }\r
 \r
-  FvInfoPpi = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi;\r
+  if (CompareGuid (&FvInfo2Ppi.FvFormat, &gEfiFirmwareFileSystem2Guid)) {\r
+    //\r
+    // gEfiFirmwareFileSystem2Guid is specified for FvFormat, then here to check the\r
+    // FileSystemGuid pointed by FvInfo against gEfiFirmwareFileSystem2Guid to make sure\r
+    // FvInfo has the firmware file system 2 format.\r
+    //\r
+    // If the ASSERT really appears, FvFormat needs to be specified correctly, for example,\r
+    // gEfiFirmwareFileSystem3Guid can be used for firmware file system 3 format, or\r
+    // ((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo)->FileSystemGuid can be just used for both\r
+    // firmware file system 2 and 3 format.\r
+    //\r
+    ASSERT (CompareGuid (&(((EFI_FIRMWARE_VOLUME_HEADER *) FvInfo2Ppi.FvInfo)->FileSystemGuid), &gEfiFirmwareFileSystem2Guid));\r
+  }\r
 \r
   //\r
   // Locate the corresponding FV_PPI according to founded FV's format guid\r
   //\r
   Status = PeiServicesLocatePpi (\r
-             &FvInfoPpi->FvFormat, \r
-             0, \r
+             &FvInfo2Ppi.FvFormat,\r
+             0,\r
              NULL,\r
              (VOID**)&FvPpi\r
              );\r
@@ -482,7 +606,7 @@ FirmwareVolmeInfoPpiNotifyCallback (
     //\r
     // Process new found FV and get FV handle.\r
     //\r
-    Status = FvPpi->ProcessVolume (FvPpi, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize, &FvHandle);\r
+    Status = FvPpi->ProcessVolume (FvPpi, FvInfo2Ppi.FvInfo, FvInfo2Ppi.FvInfoSize, &FvHandle);\r
     if (EFI_ERROR (Status)) {\r
       DEBUG ((EFI_D_ERROR, "Fail to process new found FV, FV may be corrupted!\n"));\r
       return Status;\r
@@ -493,23 +617,35 @@ FirmwareVolmeInfoPpiNotifyCallback (
     //\r
     for (FvIndex = 0; FvIndex < PrivateData->FvCount; FvIndex ++) {\r
       if (PrivateData->Fv[FvIndex].FvHandle == FvHandle) {\r
-        DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfoPpi->FvInfo));\r
+        if (IsFvInfo2 && (FvInfo2Ppi.AuthenticationStatus != PrivateData->Fv[FvIndex].AuthenticationStatus)) {\r
+          PrivateData->Fv[FvIndex].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus;\r
+          DEBUG ((EFI_D_INFO, "Update AuthenticationStatus of the %dth FV to 0x%x!\n", FvIndex, FvInfo2Ppi.AuthenticationStatus));          \r
+        }\r
+        DEBUG ((EFI_D_INFO, "The Fv %p has already been processed!\n", FvInfo2Ppi.FvInfo));\r
         return EFI_SUCCESS;\r
       }\r
     }\r
 \r
+    if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
+      DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));\r
+      DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));\r
+      ASSERT (FALSE);\r
+    }\r
+\r
     //\r
     // Update internal PEI_CORE_FV array.\r
     //\r
-    PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfoPpi->FvInfo;\r
+    PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfo2Ppi.FvInfo;\r
     PrivateData->Fv[PrivateData->FvCount].FvPpi    = FvPpi;\r
     PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+    PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = FvInfo2Ppi.AuthenticationStatus;\r
+    CurFvCount = PrivateData->FvCount;\r
     DEBUG ((\r
       EFI_D_INFO, \r
       "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
-      (UINT32) PrivateData->FvCount, \r
-      (VOID *) FvInfoPpi->FvInfo, \r
-      FvInfoPpi->FvInfoSize,\r
+      (UINT32) CurFvCount,\r
+      (VOID *) FvInfo2Ppi.FvInfo, \r
+      FvInfo2Ppi.FvInfoSize,\r
       FvHandle\r
       ));    \r
     PrivateData->FvCount ++;\r
@@ -541,19 +677,68 @@ FirmwareVolmeInfoPpiNotifyCallback (
           }\r
         }\r
         \r
-        DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, PrivateData->FvCount - 1, FvHandle));\r
-        ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);\r
+        DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle));\r
+        ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle);\r
       }\r
     } while (FileHandle != NULL);\r
   } else {\r
-    DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfoPpi->FvInfo));\r
+    DEBUG ((EFI_D_ERROR, "Fail to process FV %p because no corresponding EFI_FIRMWARE_VOLUME_PPI is found!\n", FvInfo2Ppi.FvInfo));\r
     \r
-    AddUnknownFormatFvInfo (PrivateData, &FvInfoPpi->FvFormat, FvInfoPpi->FvInfo, FvInfoPpi->FvInfoSize);\r
+    AddUnknownFormatFvInfo (PrivateData, &FvInfo2Ppi);\r
   }\r
   \r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Verify the Guided Section GUID by checking if there is the Guided Section GUID HOB recorded the GUID itself.\r
+\r
+  @param GuidedSectionGuid          The Guided Section GUID.\r
+  @param GuidedSectionExtraction    A pointer to the pointer to the supported Guided Section Extraction Ppi\r
+                                    for the Guided Section.\r
+\r
+  @return TRUE      The GuidedSectionGuid could be identified, and the pointer to\r
+                    the Guided Section Extraction Ppi will be returned to *GuidedSectionExtraction.\r
+  @return FALSE     The GuidedSectionGuid could not be identified, or \r
+                    the Guided Section Extraction Ppi has not been installed yet.\r
+\r
+**/\r
+BOOLEAN\r
+VerifyGuidedSectionGuid (\r
+  IN  EFI_GUID                                  *GuidedSectionGuid,\r
+  OUT EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI     **GuidedSectionExtraction\r
+  )\r
+{\r
+  EFI_PEI_HOB_POINTERS  Hob;\r
+  EFI_GUID              *GuidRecorded;\r
+  VOID                  *Interface;\r
+  EFI_STATUS            Status;\r
+\r
+  //\r
+  // Check if there is the Guided Section GUID HOB recorded the GUID itself.\r
+  //\r
+  Hob.Raw = GetFirstGuidHob (GuidedSectionGuid);\r
+  if (Hob.Raw != NULL) {\r
+    GuidRecorded = (EFI_GUID *) GET_GUID_HOB_DATA (Hob);\r
+    if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {\r
+      //\r
+      // Found the recorded GuidedSectionGuid.\r
+      //\r
+      Status = PeiServicesLocatePpi (GuidedSectionGuid, 0, NULL, (VOID **) &Interface);\r
+      if (!EFI_ERROR (Status) && Interface != NULL) {\r
+        //\r
+        // Found the supported Guided Section Extraction Ppi for the Guided Section.\r
+        //\r
+        *GuidedSectionExtraction = (EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *) Interface;\r
+        return TRUE;\r
+      }\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Go through the file to search SectionType section. \r
   Search within encapsulation sections (compression and GUIDed) recursively, \r
@@ -561,10 +746,12 @@ FirmwareVolmeInfoPpiNotifyCallback (
   \r
   @param PeiServices       An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SectionType       Filter to find only section of this type.\r
+  @param SectionInstance   Pointer to the filter to find the specific instance of section.\r
   @param Section           From where to search.\r
   @param SectionSize       The file size to search.\r
   @param OutputBuffer      A pointer to the discovered section, if successful.\r
                            NULL if section not found\r
+  @param AuthenticationStatus Updated upon return to point to the authentication status for this section.\r
   @param IsFfs3Fv          Indicates the FV format.\r
 \r
   @return EFI_NOT_FOUND    The match section is not found.\r
@@ -575,9 +762,11 @@ EFI_STATUS
 ProcessSection (\r
   IN CONST EFI_PEI_SERVICES     **PeiServices,\r
   IN EFI_SECTION_TYPE           SectionType,\r
+  IN OUT UINTN                  *SectionInstance,\r
   IN EFI_COMMON_SECTION_HEADER  *Section,\r
   IN UINTN                      SectionSize,\r
   OUT VOID                      **OutputBuffer,\r
+  OUT UINT32                    *AuthenticationStatus,\r
   IN BOOLEAN                    IsFfs3Fv\r
   )\r
 {\r
@@ -591,6 +780,11 @@ ProcessSection (
   UINTN                                   Index;\r
   UINT32                                  Authentication;\r
   PEI_CORE_INSTANCE                       *PrivateData;\r
+  EFI_GUID                                *SectionDefinitionGuid;\r
+  BOOLEAN                                 SectionCached;\r
+  VOID                                    *TempOutputBuffer;\r
+  UINT32                                  TempAuthenticationStatus;\r
+  UINT16                                  GuidedSectionAttributes;\r
 \r
   PrivateData   = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
   *OutputBuffer = NULL;\r
@@ -619,92 +813,151 @@ ProcessSection (
     }\r
 \r
     if (Section->Type == SectionType) {\r
-      if (IS_SECTION2 (Section)) {\r
-        *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));\r
+      //\r
+      // The type matches, so check the instance count to see if it's the one we want.\r
+      //\r
+      (*SectionInstance)--;\r
+      if (*SectionInstance == 0) {\r
+        //\r
+        // Got it!\r
+        //\r
+        if (IS_SECTION2 (Section)) {\r
+          *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));\r
+        } else {\r
+          *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+        }\r
+        return EFI_SUCCESS;\r
       } else {\r
-        *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));\r
+        if (IS_SECTION2 (Section)) {\r
+          SectionLength = SECTION2_SIZE (Section);\r
+        } else {\r
+          SectionLength = SECTION_SIZE (Section);\r
+        }\r
+        //\r
+        // SectionLength is adjusted it is 4 byte aligned.\r
+        // Go to the next section\r
+        //\r
+        SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);\r
+        ASSERT (SectionLength != 0);\r
+        ParsedLength += SectionLength;\r
+        Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);\r
+        continue;\r
       }\r
-      return EFI_SUCCESS;\r
     } else if ((Section->Type == EFI_SECTION_GUID_DEFINED) || (Section->Type == EFI_SECTION_COMPRESSION)) {\r
       //\r
       // Check the encapsulated section is extracted into the cache data.\r
       //\r
+      SectionCached = FALSE;\r
       for (Index = 0; Index < PrivateData->CacheSection.AllSectionCount; Index ++) {\r
         if (Section == PrivateData->CacheSection.Section[Index]) {\r
+          SectionCached = TRUE;\r
           PpiOutput     = PrivateData->CacheSection.SectionData[Index];\r
           PpiOutputSize = PrivateData->CacheSection.SectionSize[Index];\r
+          Authentication = PrivateData->CacheSection.AuthenticationStatus[Index];\r
           //\r
           // Search section directly from the cache data.\r
           //\r
-          return ProcessSection (\r
-                   PeiServices,\r
-                   SectionType, \r
-                   PpiOutput, \r
-                   PpiOutputSize, \r
-                   OutputBuffer,\r
-                   IsFfs3Fv\r
+          TempAuthenticationStatus = 0;\r
+          Status = ProcessSection (\r
+                     PeiServices,\r
+                     SectionType,\r
+                     SectionInstance,\r
+                     PpiOutput, \r
+                     PpiOutputSize, \r
+                     &TempOutputBuffer,\r
+                     &TempAuthenticationStatus,\r
+                     IsFfs3Fv\r
                    );\r
+          if (!EFI_ERROR (Status)) {\r
+            *OutputBuffer = TempOutputBuffer;\r
+            *AuthenticationStatus = TempAuthenticationStatus | Authentication;\r
+            return EFI_SUCCESS;\r
+          }\r
         }\r
       }\r
-      \r
-      Status = EFI_NOT_FOUND;\r
-      if (Section->Type == EFI_SECTION_GUID_DEFINED) {\r
-        if (IS_SECTION2 (Section)) {\r
-          Status = PeiServicesLocatePpi (\r
-                     &((EFI_GUID_DEFINED_SECTION2 *)Section)->SectionDefinitionGuid, \r
-                     0, \r
-                     NULL, \r
-                     (VOID **) &GuidSectionPpi\r
-                     );\r
-        } else {\r
-          Status = PeiServicesLocatePpi (\r
-                     &((EFI_GUID_DEFINED_SECTION *)Section)->SectionDefinitionGuid, \r
-                     0, \r
-                     NULL, \r
-                     (VOID **) &GuidSectionPpi\r
-                     );\r
-        }\r
-        if (!EFI_ERROR (Status)) {\r
-          Status = GuidSectionPpi->ExtractSection (\r
-                                     GuidSectionPpi,\r
-                                     Section,\r
-                                     &PpiOutput,\r
-                                     &PpiOutputSize,\r
-                                     &Authentication\r
-                                     );\r
+\r
+      //\r
+      // If SectionCached is TRUE, the section data has been cached and scanned.\r
+      //\r
+      if (!SectionCached) {\r
+        Status = EFI_NOT_FOUND;\r
+        Authentication = 0;\r
+        if (Section->Type == EFI_SECTION_GUID_DEFINED) {\r
+          if (IS_SECTION2 (Section)) {\r
+            SectionDefinitionGuid   = &((EFI_GUID_DEFINED_SECTION2 *)Section)->SectionDefinitionGuid;\r
+            GuidedSectionAttributes = ((EFI_GUID_DEFINED_SECTION2 *)Section)->Attributes;\r
+          } else {\r
+            SectionDefinitionGuid   = &((EFI_GUID_DEFINED_SECTION *)Section)->SectionDefinitionGuid;\r
+            GuidedSectionAttributes = ((EFI_GUID_DEFINED_SECTION *)Section)->Attributes;\r
+          }\r
+          if (VerifyGuidedSectionGuid (SectionDefinitionGuid, &GuidSectionPpi)) {\r
+            Status = GuidSectionPpi->ExtractSection (\r
+                                       GuidSectionPpi,\r
+                                       Section,\r
+                                       &PpiOutput,\r
+                                       &PpiOutputSize,\r
+                                       &Authentication\r
+                                       );\r
+          } else if ((GuidedSectionAttributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {\r
+            //\r
+            // Figure out the proper authentication status for GUIDED section without processing required\r
+            //\r
+            Status = EFI_SUCCESS;\r
+            if ((GuidedSectionAttributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) == EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {\r
+              Authentication |= EFI_AUTH_STATUS_IMAGE_SIGNED | EFI_AUTH_STATUS_NOT_TESTED;\r
+            }\r
+            if (IS_SECTION2 (Section)) {\r
+              PpiOutputSize = SECTION2_SIZE (Section) - ((EFI_GUID_DEFINED_SECTION2 *) Section)->DataOffset;\r
+              PpiOutput     = (UINT8 *) Section + ((EFI_GUID_DEFINED_SECTION2 *) Section)->DataOffset;\r
+            } else {\r
+              PpiOutputSize = SECTION_SIZE (Section) - ((EFI_GUID_DEFINED_SECTION *) Section)->DataOffset;\r
+              PpiOutput     = (UINT8 *) Section + ((EFI_GUID_DEFINED_SECTION *) Section)->DataOffset;\r
+            }\r
+          }\r
+        } else if (Section->Type == EFI_SECTION_COMPRESSION) {\r
+          Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);\r
+          if (!EFI_ERROR (Status)) {\r
+            Status = DecompressPpi->Decompress (\r
+                                      DecompressPpi,\r
+                                      (CONST EFI_COMPRESSION_SECTION*) Section,\r
+                                      &PpiOutput,\r
+                                      &PpiOutputSize\r
+                                      );\r
+          }\r
         }\r
-      } else if (Section->Type == EFI_SECTION_COMPRESSION) {\r
-        Status = PeiServicesLocatePpi (&gEfiPeiDecompressPpiGuid, 0, NULL, (VOID **) &DecompressPpi);\r
+\r
         if (!EFI_ERROR (Status)) {\r
-          Status = DecompressPpi->Decompress (\r
-                                    DecompressPpi,\r
-                                    (CONST EFI_COMPRESSION_SECTION*) Section,\r
-                                    &PpiOutput,\r
-                                    &PpiOutputSize\r
-                                    );\r
-        }\r
-      }\r
-      \r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Update cache section data.\r
-        //\r
-        if (PrivateData->CacheSection.AllSectionCount < CACHE_SETION_MAX_NUMBER) {\r
-          PrivateData->CacheSection.AllSectionCount ++;\r
+          if ((Authentication & EFI_AUTH_STATUS_NOT_TESTED) == 0) {\r
+            //\r
+            // Update cache section data.\r
+            //\r
+            if (PrivateData->CacheSection.AllSectionCount < CACHE_SETION_MAX_NUMBER) {\r
+              PrivateData->CacheSection.AllSectionCount ++;\r
+            }\r
+            PrivateData->CacheSection.Section [PrivateData->CacheSection.SectionIndex]     = Section;\r
+            PrivateData->CacheSection.SectionData [PrivateData->CacheSection.SectionIndex] = PpiOutput;\r
+            PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;\r
+            PrivateData->CacheSection.AuthenticationStatus [PrivateData->CacheSection.SectionIndex] = Authentication;\r
+            PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;\r
+          }\r
+\r
+          TempAuthenticationStatus = 0;\r
+          Status = ProcessSection (\r
+                     PeiServices,\r
+                     SectionType,\r
+                     SectionInstance,\r
+                     PpiOutput, \r
+                     PpiOutputSize, \r
+                     &TempOutputBuffer,\r
+                     &TempAuthenticationStatus,\r
+                     IsFfs3Fv\r
+                   );\r
+          if (!EFI_ERROR (Status)) {\r
+            *OutputBuffer = TempOutputBuffer;\r
+            *AuthenticationStatus = TempAuthenticationStatus | Authentication;\r
+            return EFI_SUCCESS;\r
+          }\r
         }\r
-        PrivateData->CacheSection.Section [PrivateData->CacheSection.SectionIndex]     = Section;\r
-        PrivateData->CacheSection.SectionData [PrivateData->CacheSection.SectionIndex] = PpiOutput;\r
-        PrivateData->CacheSection.SectionSize [PrivateData->CacheSection.SectionIndex] = PpiOutputSize;\r
-        PrivateData->CacheSection.SectionIndex = (PrivateData->CacheSection.SectionIndex + 1)%CACHE_SETION_MAX_NUMBER;\r
-        \r
-        return ProcessSection (\r
-                 PeiServices,\r
-                 SectionType, \r
-                 PpiOutput, \r
-                 PpiOutputSize, \r
-                 OutputBuffer,\r
-                 IsFfs3Fv\r
-                 );\r
       }\r
     }\r
 \r
@@ -759,6 +1012,49 @@ PeiFfsFindSectionData (
   return CoreFvHandle->FvPpi->FindSectionByType (CoreFvHandle->FvPpi, SectionType, FileHandle, SectionData);\r
 }\r
 \r
+/**\r
+  Searches for the next matching section within the specified file.\r
+\r
+  @param  PeiServices           An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  SectionType           The value of the section type to find.\r
+  @param  SectionInstance       Section instance to find.\r
+  @param  FileHandle            Handle of the firmware file to search.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+  @param  AuthenticationStatus  A pointer to the authentication status for this section.\r
+\r
+  @retval EFI_SUCCESS      The section was found.\r
+  @retval EFI_NOT_FOUND    The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFindSectionData3 (\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN     EFI_SECTION_TYPE      SectionType,\r
+  IN     UINTN                 SectionInstance,\r
+  IN     EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT VOID                     **SectionData,\r
+  OUT UINT32                   *AuthenticationStatus\r
+  )\r
+{\r
+  PEI_CORE_FV_HANDLE           *CoreFvHandle;\r
+  \r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if ((CoreFvHandle->FvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&\r
+      (CoreFvHandle->FvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {\r
+    return CoreFvHandle->FvPpi->FindSectionByType2 (CoreFvHandle->FvPpi, SectionType, SectionInstance, FileHandle, SectionData, AuthenticationStatus);\r
+  }\r
+  //\r
+  // The old FvPpi doesn't support to find section by section instance\r
+  // and return authentication status, so return EFI_UNSUPPORTED.\r
+  //\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
 /**\r
   Searches for the next matching file in the firmware volume.\r
 \r
@@ -917,6 +1213,48 @@ PeiFfsGetFileInfo (
   return CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, FileHandle, FileInfo);\r
 }\r
 \r
+/**\r
+  Returns information about a specific file.\r
+\r
+  @param FileHandle       Handle of the file.\r
+  @param FileInfo         Upon exit, points to the file's information.\r
+\r
+  @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
+  @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
+  @retval EFI_SUCCESS           File information returned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+PeiFfsGetFileInfo2 (\r
+  IN EFI_PEI_FILE_HANDLE  FileHandle,\r
+  OUT EFI_FV_FILE_INFO2   *FileInfo\r
+  )\r
+{\r
+  PEI_CORE_FV_HANDLE          *CoreFvHandle;\r
+  \r
+  if ((FileHandle == NULL) || (FileInfo == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Retrieve the FirmwareVolume which the file resides in.\r
+  //\r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if ((CoreFvHandle == NULL) || (CoreFvHandle->FvPpi == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if ((CoreFvHandle->FvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&\r
+      (CoreFvHandle->FvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {\r
+    return CoreFvHandle->FvPpi->GetFileInfo2 (CoreFvHandle->FvPpi, FileHandle, FileInfo);\r
+  }\r
+  //\r
+  // The old FvPpi doesn't support to return file info with authentication status,\r
+  // so return EFI_UNSUPPORTED.\r
+  //\r
+  return EFI_UNSUPPORTED;\r
+}\r
 \r
 /**\r
   Returns information about the specified volume.\r
@@ -958,19 +1296,84 @@ PeiFfsGetVolumeInfo (
 }\r
 \r
 /**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+  Find USED_SIZE FV_EXT_TYPE entry in FV extension header and get the FV used size.\r
+\r
+  @param[in]  FvHeader      Pointer to FV header.\r
+  @param[out] FvUsedSize    Pointer to FV used size returned,\r
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.\r
+  @param[out] EraseByte     Pointer to erase byte returned,\r
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.\r
+\r
+  @retval TRUE              USED_SIZE FV_EXT_TYPE entry is found,\r
+                            FV used size and erase byte are returned.\r
+  @retval FALSE             No USED_SIZE FV_EXT_TYPE entry found.\r
+\r
+**/\r
+BOOLEAN\r
+GetFvUsedSize (\r
+  IN EFI_FIRMWARE_VOLUME_HEADER     *FvHeader,\r
+  OUT UINT32                        *FvUsedSize,\r
+  OUT UINT8                         *EraseByte\r
+  )\r
+{\r
+  UINT16                                        ExtHeaderOffset;\r
+  EFI_FIRMWARE_VOLUME_EXT_HEADER                *ExtHeader;\r
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY                 *ExtEntryList;\r
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE  *ExtEntryUsedSize;\r
+\r
+  ExtHeaderOffset = ReadUnaligned16 (&FvHeader->ExtHeaderOffset);\r
+  if (ExtHeaderOffset != 0) {\r
+    ExtHeader    = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FvHeader + ExtHeaderOffset);\r
+    ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *) (ExtHeader + 1);\r
+    while ((UINTN) ExtEntryList < ((UINTN) ExtHeader + ReadUnaligned32 (&ExtHeader->ExtHeaderSize))) {\r
+      if (ReadUnaligned16 (&ExtEntryList->ExtEntryType) == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {\r
+        //\r
+        // USED_SIZE FV_EXT_TYPE entry is found.\r
+        //\r
+        ExtEntryUsedSize = (EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *) ExtEntryList;\r
+        *FvUsedSize = ReadUnaligned32 (&ExtEntryUsedSize->UsedSize);\r
+        if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ERASE_POLARITY) != 0) {\r
+          *EraseByte = 0xFF;\r
+        } else {\r
+          *EraseByte = 0;\r
+        }\r
+        DEBUG ((\r
+          DEBUG_INFO,\r
+          "FV at 0x%x has 0x%x used size, and erase byte is 0x%02x\n",\r
+          FvHeader,\r
+          *FvUsedSize,\r
+          *EraseByte\r
+          ));\r
+        return TRUE;\r
+      }\r
+      ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *)\r
+                     ((UINT8 *) ExtEntryList + ReadUnaligned16 (&ExtEntryList->ExtEntrySize));\r
+    }\r
+  }\r
+\r
+  //\r
+  // No USED_SIZE FV_EXT_TYPE entry found.\r
+  //\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.\r
 \r
+  @param PrivateData          PeiCore's private data structure\r
   @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
   @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
 \r
   @retval EFI_NOT_FOUND         FV image can't be found.\r
   @retval EFI_SUCCESS           Successfully to process it.\r
   @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
+  @retval EFI_SECURITY_VIOLATION Image is illegal\r
   @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
   \r
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
+  IN  PEI_CORE_INSTANCE           *PrivateData,\r
   IN  PEI_CORE_FV_HANDLE          *ParentFvCoreHandle,\r
   IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle\r
   )\r
@@ -985,7 +1388,10 @@ ProcessFvFile (
   EFI_FIRMWARE_VOLUME_HEADER    *FvHeader;\r
   EFI_FV_FILE_INFO              FileInfo;\r
   UINT64                        FvLength;\r
-  \r
+  UINT32                        AuthenticationStatus;\r
+  UINT32                        FvUsedSize;\r
+  UINT8                         EraseByte;\r
+\r
   //\r
   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r
   // been extracted.\r
@@ -1008,38 +1414,82 @@ ProcessFvFile (
   //\r
   // Find FvImage in FvFile\r
   //\r
-  Status = ParentFvPpi->FindSectionByType (\r
-                          ParentFvPpi,\r
-                          EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
-                          ParentFvFileHandle,\r
-                          (VOID **)&FvHeader\r
-                          );\r
-             \r
+  AuthenticationStatus = 0;\r
+  if ((ParentFvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&\r
+      (ParentFvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {\r
+    Status = ParentFvPpi->FindSectionByType2 (\r
+                            ParentFvPpi,\r
+                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
+                            0,\r
+                            ParentFvFileHandle,\r
+                            (VOID **)&FvHeader,\r
+                            &AuthenticationStatus\r
+                            );\r
+  } else {\r
+    Status = ParentFvPpi->FindSectionByType (\r
+                            ParentFvPpi,\r
+                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
+                            ParentFvFileHandle,\r
+                            (VOID **)&FvHeader\r
+                            );\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  //\r
-  // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
-  //\r
-  FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);\r
-  if (FvAlignment < 8) {\r
-    FvAlignment = 8;\r
+  Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle, AuthenticationStatus);\r
+  if (Status == EFI_SECURITY_VIOLATION) {\r
+    return Status;\r
   }\r
-  \r
+\r
   //\r
-  // Check FvImage\r
+  // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume\r
+  // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from\r
+  // its initial linked location and maintain its alignment.\r
   //\r
-  if ((UINTN) FvHeader % FvAlignment != 0) {\r
-    FvLength    = ReadUnaligned64 (&FvHeader->FvLength);\r
-    NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);\r
-    if (NewFvBuffer == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
+  if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {\r
+    //\r
+    // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.\r
+    //\r
+    FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);\r
+    if (FvAlignment < 8) {\r
+      FvAlignment = 8;\r
+    }\r
+\r
+    DEBUG ((\r
+      DEBUG_INFO,\r
+      "%a() FV at 0x%x, FvAlignment required is 0x%x\n",\r
+      __FUNCTION__,\r
+      FvHeader,\r
+      FvAlignment\r
+      ));\r
+\r
+    //\r
+    // Check FvImage alignment.\r
+    //\r
+    if ((UINTN) FvHeader % FvAlignment != 0) {\r
+      FvLength    = ReadUnaligned64 (&FvHeader->FvLength);\r
+      NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);\r
+      if (NewFvBuffer == NULL) {\r
+        return EFI_OUT_OF_RESOURCES;\r
+      }\r
+      if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {\r
+        //\r
+        // Copy the used bytes and fill the rest with the erase value.\r
+        //\r
+        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvUsedSize);\r
+        SetMem (\r
+          (UINT8 *) NewFvBuffer + FvUsedSize,\r
+          (UINTN) (FvLength - FvUsedSize),\r
+          EraseByte\r
+          );\r
+      } else {\r
+        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);\r
+      }\r
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;\r
     }\r
-    CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);\r
-    FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;\r
   }\r
-  \r
+\r
   Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);\r
   ASSERT_EFI_ERROR (Status);\r
   \r
@@ -1047,8 +1497,19 @@ ProcessFvFile (
   ASSERT_EFI_ERROR (Status);\r
   \r
   //\r
-  // Install FvPpi and Build FvHob\r
+  // Install FvInfo(2) Ppi\r
+  // NOTE: FvInfo2 must be installed before FvInfo so that recursive processing of encapsulated\r
+  // FVs inherit the proper AuthenticationStatus.\r
   //\r
+  PeiServicesInstallFvInfo2Ppi(\r
+    &FvHeader->FileSystemGuid,\r
+    (VOID**)FvHeader,\r
+    (UINT32)FvHeader->FvLength,\r
+    &ParentFvImageInfo.FvName,\r
+    &FileInfo.FileName,\r
+    AuthenticationStatus\r
+    );\r
+\r
   PeiServicesInstallFvInfoPpi (\r
     &FvHeader->FileSystemGuid,\r
     (VOID**) FvHeader,\r
@@ -1076,6 +1537,18 @@ ProcessFvFile (
     &FileInfo.FileName\r
     );\r
 \r
+  //\r
+  // Build FV3 HOB with authentication status to be propagated to DXE.\r
+  //\r
+  BuildFv3Hob (\r
+    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,\r
+    FvHeader->FvLength,\r
+    AuthenticationStatus,\r
+    TRUE,\r
+    &ParentFvImageInfo.FvName,\r
+    &FileInfo.FileName\r
+    );\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -1310,9 +1783,6 @@ PeiFfsFvPpiGetFileInfo (
     }\r
 \r
   FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;\r
-  CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));\r
-  FileInfo->FileType = FileHeader->Type;\r
-  FileInfo->FileAttributes = FileHeader->Attributes;\r
   if (IS_FFS_FILE2 (FileHeader)) {\r
     ASSERT (FFS_FILE2_SIZE (FileHeader) > 0x00FFFFFF);\r
     if (!FwVolInstance->IsFfs3Fv) {\r
@@ -1325,9 +1795,65 @@ PeiFfsFvPpiGetFileInfo (
     FileInfo->BufferSize = FFS_FILE_SIZE (FileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
     FileInfo->Buffer = (UINT8 *) FileHeader + sizeof (EFI_FFS_FILE_HEADER);\r
   }\r
-  return EFI_SUCCESS;  \r
-}  \r
-  \r
+  CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));\r
+  FileInfo->FileType = FileHeader->Type;\r
+  FileInfo->FileAttributes = FfsAttributes2FvFileAttributes (FileHeader->Attributes);\r
+  if ((CoreFvHandle->FvHeader->Attributes & EFI_FVB2_MEMORY_MAPPED) == EFI_FVB2_MEMORY_MAPPED) {\r
+    FileInfo->FileAttributes |= EFI_FV_FILE_ATTRIB_MEMORY_MAPPED;\r
+  }\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Returns information about a specific file.\r
+\r
+  This function returns information about a specific\r
+  file, including its file name, type, attributes, starting\r
+  address, size and authentication status.\r
+\r
+  @param This                     Points to this instance of the\r
+                                  EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param FileHandle               Handle of the file.\r
+  @param FileInfo                 Upon exit, points to the file's\r
+                                  information.\r
+\r
+  @retval EFI_SUCCESS             File information returned.\r
+  @retval EFI_INVALID_PARAMETER   If FileHandle does not\r
+                                  represent a valid file.\r
+  @retval EFI_INVALID_PARAMETER   If FileInfo is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFvPpiGetFileInfo2 (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI   *This, \r
+  IN        EFI_PEI_FILE_HANDLE           FileHandle, \r
+  OUT       EFI_FV_FILE_INFO2             *FileInfo\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  PEI_CORE_FV_HANDLE          *CoreFvHandle;\r
+\r
+  if ((FileHandle == NULL) || (FileInfo == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Retrieve the FirmwareVolume which the file resides in.\r
+  //\r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if (CoreFvHandle == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = PeiFfsFvPpiGetFileInfo (This, FileHandle, (EFI_FV_FILE_INFO *) FileInfo);\r
+  if (!EFI_ERROR (Status)) {\r
+    FileInfo->AuthenticationStatus = CoreFvHandle->AuthenticationStatus;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   This function returns information about the firmware volume.\r
   \r
@@ -1413,13 +1939,67 @@ PeiFfsFvPpiFindSectionByType (
   OUT VOID                                 **SectionData\r
   )\r
 {\r
+  UINT32 AuthenticationStatus;\r
+  return PeiFfsFvPpiFindSectionByType2 (This, SearchType, 0, FileHandle, SectionData, &AuthenticationStatus);\r
+}\r
+\r
+/**\r
+  Find the next matching section in the firmware file.\r
+\r
+  This service enables PEI modules to discover sections\r
+  of a given instance and type within a valid file.\r
+\r
+  @param This                   Points to this instance of the\r
+                                EFI_PEI_FIRMWARE_VOLUME_PPI.\r
+  @param SearchType             A filter to find only sections of this\r
+                                type.\r
+  @param SearchInstance         A filter to find the specific instance\r
+                                of sections.\r
+  @param FileHandle             Handle of firmware file in which to\r
+                                search.\r
+  @param SectionData            Updated upon return to point to the\r
+                                section found.\r
+  @param AuthenticationStatus   Updated upon return to point to the\r
+                                authentication status for this section.\r
+\r
+  @retval EFI_SUCCESS     Section was found.\r
+  @retval EFI_NOT_FOUND   Section of the specified type was not\r
+                          found. SectionData contains NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFvPpiFindSectionByType2 (\r
+  IN  CONST EFI_PEI_FIRMWARE_VOLUME_PPI    *This,\r
+  IN        EFI_SECTION_TYPE               SearchType,\r
+  IN        UINTN                          SearchInstance,\r
+  IN        EFI_PEI_FILE_HANDLE            FileHandle,\r
+  OUT VOID                                 **SectionData,\r
+  OUT UINT32                               *AuthenticationStatus\r
+  )\r
+{\r
+  EFI_STATUS                              Status;\r
   EFI_FFS_FILE_HEADER                     *FfsFileHeader;\r
   UINT32                                  FileSize;\r
   EFI_COMMON_SECTION_HEADER               *Section;\r
   PEI_FW_VOL_INSTANCE                     *FwVolInstance;\r
+  PEI_CORE_FV_HANDLE                      *CoreFvHandle;\r
+  UINTN                                   Instance;\r
+  UINT32                                  ExtractedAuthenticationStatus;\r
+\r
+  if (SectionData == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   FwVolInstance = PEI_FW_VOL_INSTANCE_FROM_FV_THIS (This);\r
 \r
+  //\r
+  // Retrieve the FirmwareVolume which the file resides in.\r
+  //\r
+  CoreFvHandle = FileHandleToVolume (FileHandle);\r
+  if (CoreFvHandle == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);\r
 \r
   if (IS_FFS_FILE2 (FfsFileHeader)) {\r
@@ -1435,15 +2015,26 @@ PeiFfsFvPpiFindSectionByType (
     FileSize = FFS_FILE_SIZE (FfsFileHeader) - sizeof (EFI_FFS_FILE_HEADER);\r
   }\r
 \r
-  return ProcessSection (\r
-           GetPeiServicesTablePointer (),\r
-           SearchType, \r
-           Section, \r
-           FileSize, \r
-           SectionData,\r
-           FwVolInstance->IsFfs3Fv\r
-           );  \r
-}  \r
+  Instance = SearchInstance + 1;\r
+  ExtractedAuthenticationStatus = 0;\r
+  Status = ProcessSection (\r
+             GetPeiServicesTablePointer (),\r
+             SearchType,\r
+             &Instance,\r
+             Section, \r
+             FileSize, \r
+             SectionData,\r
+             &ExtractedAuthenticationStatus,\r
+             FwVolInstance->IsFfs3Fv\r
+             );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Inherit the authentication status.\r
+    //\r
+    *AuthenticationStatus = ExtractedAuthenticationStatus | CoreFvHandle->AuthenticationStatus;\r
+  }\r
+  return Status;\r
+}\r
 \r
 /**\r
   Convert the handle of FV to pointer of corresponding PEI_CORE_FV_HANDLE.\r
@@ -1543,7 +2134,7 @@ FindNextCoreFvHandle (
     }\r
   }\r
 \r
-  ASSERT (Private->FvCount <= FixedPcdGet32 (PcdPeiCoreMaxFvSupported));\r
+  ASSERT (Private->FvCount <= PcdGet32 (PcdPeiCoreMaxFvSupported));\r
   if (Instance >= Private->FvCount) {\r
     return NULL;\r
   }\r
@@ -1554,7 +2145,7 @@ FindNextCoreFvHandle (
 /**\r
   After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
   be re-installed with the instance in permanent memory and all cached FvPpi pointers in \r
-  PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant\r
+  PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent\r
   memory.\r
   \r
   @param PrivateData   Pointer to PEI_CORE_INSTANCE.\r
@@ -1591,7 +2182,7 @@ PeiReinitializeFv (
   //\r
   // Fixup all FvPpi pointers for the implementation in flash to permanent memory.\r
   //\r
-  for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
+  for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
     if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {\r
       PrivateData->Fv[Index].FvPpi = &mPeiFfs2FwVol.Fv;\r
     }\r
@@ -1619,7 +2210,7 @@ PeiReinitializeFv (
   //\r
   // Fixup all FvPpi pointers for the implementation in flash to permanent memory.\r
   //\r
-  for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
+  for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r
     if (PrivateData->Fv[Index].FvPpi == OldFfsFvPpi) {\r
       PrivateData->Fv[Index].FvPpi = &mPeiFfs3FwVol.Fv;\r
     }\r
@@ -1630,40 +2221,37 @@ PeiReinitializeFv (
   Report the information for a new discoveried FV in unknown third-party format.\r
   \r
   If the EFI_PEI_FIRMWARE_VOLUME_PPI has not been installed for third-party FV format, but\r
-  the FV in this format has been discoveried, then this FV's information will be cached into \r
+  the FV in this format has been discoveried, then this FV's information will be cached into\r
   PEI_CORE_INSTANCE's UnknownFvInfo array.\r
   Also a notification would be installed for unknown third-party FV format guid, if EFI_PEI_FIRMWARE_VOLUME_PPI\r
   is installed later by platform's PEIM, the original unknown third-party FV will be processed by\r
   using new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
   \r
   @param PrivateData  Point to instance of PEI_CORE_INSTANCE\r
-  @param Format       Point to the unknown third-party format guid.\r
-  @param FvInfo       Point to FvInfo buffer.\r
-  @param FvInfoSize   The size of FvInfo buffer.\r
+  @param FvInfo2Ppi   Point to FvInfo2 PPI.\r
   \r
   @retval EFI_OUT_OF_RESOURCES  The FV info array in PEI_CORE_INSTANCE has no more spaces.\r
   @retval EFI_SUCCESS           Success to add the information for unknown FV.\r
 **/\r
 EFI_STATUS\r
 AddUnknownFormatFvInfo (\r
-  IN PEI_CORE_INSTANCE *PrivateData,\r
-  IN EFI_GUID          *Format,\r
-  IN VOID              *FvInfo,\r
-  IN UINT32            FvInfoSize\r
+  IN PEI_CORE_INSTANCE                  *PrivateData,\r
+  IN EFI_PEI_FIRMWARE_VOLUME_INFO2_PPI  *FvInfo2Ppi\r
   )\r
 {\r
   PEI_CORE_UNKNOW_FORMAT_FV_INFO    *NewUnknownFv;\r
   \r
-  if (PrivateData->UnknownFvInfoCount + 1 >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
+  if (PrivateData->UnknownFvInfoCount + 1 >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   \r
   NewUnknownFv = &PrivateData->UnknownFvInfo[PrivateData->UnknownFvInfoCount];\r
   PrivateData->UnknownFvInfoCount ++;\r
   \r
-  CopyGuid (&NewUnknownFv->FvFormat, Format);\r
-  NewUnknownFv->FvInfo     = FvInfo;\r
-  NewUnknownFv->FvInfoSize = FvInfoSize;\r
+  CopyGuid (&NewUnknownFv->FvFormat, &FvInfo2Ppi->FvFormat);\r
+  NewUnknownFv->FvInfo     = FvInfo2Ppi->FvInfo;\r
+  NewUnknownFv->FvInfoSize = FvInfo2Ppi->FvInfoSize;\r
+  NewUnknownFv->AuthenticationStatus = FvInfo2Ppi->AuthenticationStatus;\r
   NewUnknownFv->NotifyDescriptor.Flags  = (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);\r
   NewUnknownFv->NotifyDescriptor.Guid   = &NewUnknownFv->FvFormat;\r
   NewUnknownFv->NotifyDescriptor.Notify = ThirdPartyFvPpiNotifyCallback;\r
@@ -1682,6 +2270,7 @@ AddUnknownFormatFvInfo (
   @param Format           Point to given FV format guid\r
   @param FvInfo           On return, the pointer of FV information buffer\r
   @param FvInfoSize       On return, the size of FV information buffer.\r
+  @param AuthenticationStatus On return, the authentication status of FV information buffer.\r
   \r
   @retval EFI_NOT_FOUND  The FV is not found for new installed EFI_PEI_FIRMWARE_VOLUME_PPI\r
   @retval EFI_SUCCESS    Success to find a FV which could be processed by new installed EFI_PEI_FIRMWARE_VOLUME_PPI.\r
@@ -1691,7 +2280,8 @@ FindUnknownFormatFvInfo (
   IN  PEI_CORE_INSTANCE *PrivateData,\r
   IN  EFI_GUID          *Format,\r
   OUT VOID              **FvInfo,\r
-  OUT UINT32            *FvInfoSize\r
+  OUT UINT32            *FvInfoSize,\r
+  OUT UINT32            *AuthenticationStatus\r
   )\r
 {\r
   UINTN Index;\r
@@ -1710,6 +2300,7 @@ FindUnknownFormatFvInfo (
   \r
   *FvInfo     = PrivateData->UnknownFvInfo[Index].FvInfo;\r
   *FvInfoSize = PrivateData->UnknownFvInfo[Index].FvInfoSize;\r
+  *AuthenticationStatus = PrivateData->UnknownFvInfo[Index].AuthenticationStatus;\r
   \r
   //\r
   // Remove an entry from UnknownFvInfo array.\r
@@ -1746,18 +2337,20 @@ ThirdPartyFvPpiNotifyCallback (
   EFI_PEI_FIRMWARE_VOLUME_PPI  *FvPpi;\r
   VOID                         *FvInfo;\r
   UINT32                       FvInfoSize;\r
+  UINT32                       AuthenticationStatus;\r
   EFI_STATUS                   Status;\r
   EFI_PEI_FV_HANDLE            FvHandle;\r
   BOOLEAN                      IsProcessed;\r
   UINTN                        FvIndex;\r
   EFI_PEI_FILE_HANDLE          FileHandle;\r
   VOID                         *DepexData;  \r
-  \r
+  UINTN                        CurFvCount;\r
+\r
   PrivateData  = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
   FvPpi = (EFI_PEI_FIRMWARE_VOLUME_PPI*) Ppi;\r
   \r
   do {\r
-    Status = FindUnknownFormatFvInfo (PrivateData, NotifyDescriptor->Guid, &FvInfo, &FvInfoSize);\r
+    Status = FindUnknownFormatFvInfo (PrivateData, NotifyDescriptor->Guid, &FvInfo, &FvInfoSize, &AuthenticationStatus);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_SUCCESS;\r
     }\r
@@ -1787,8 +2380,8 @@ ThirdPartyFvPpiNotifyCallback (
       continue;\r
     }\r
     \r
-    if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
-      DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, FixedPcdGet32 (PcdPeiCoreMaxFvSupported)));\r
+    if (PrivateData->FvCount >= PcdGet32 (PcdPeiCoreMaxFvSupported)) {\r
+      DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, PcdGet32 (PcdPeiCoreMaxFvSupported)));\r
       DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC"));\r
       ASSERT (FALSE);\r
     }\r
@@ -1799,10 +2392,12 @@ ThirdPartyFvPpiNotifyCallback (
     PrivateData->Fv[PrivateData->FvCount].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) FvInfo;\r
     PrivateData->Fv[PrivateData->FvCount].FvPpi    = FvPpi;\r
     PrivateData->Fv[PrivateData->FvCount].FvHandle = FvHandle;\r
+    PrivateData->Fv[PrivateData->FvCount].AuthenticationStatus = AuthenticationStatus;\r
+    CurFvCount = PrivateData->FvCount;\r
     DEBUG ((\r
       EFI_D_INFO, \r
       "The %dth FV start address is 0x%11p, size is 0x%08x, handle is 0x%p\n", \r
-      (UINT32) PrivateData->FvCount, \r
+      (UINT32) CurFvCount,\r
       (VOID *) FvInfo, \r
       FvInfoSize,\r
       FvHandle\r
@@ -1836,8 +2431,8 @@ ThirdPartyFvPpiNotifyCallback (
           }\r
         }\r
         \r
-        DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, PrivateData->FvCount - 1, FvHandle));\r
-        ProcessFvFile (&PrivateData->Fv[PrivateData->FvCount - 1], FileHandle);\r
+        DEBUG ((EFI_D_INFO, "Found firmware volume Image File %p in FV[%d] %p\n", FileHandle, CurFvCount, FvHandle));\r
+        ProcessFvFile (PrivateData, &PrivateData->Fv[CurFvCount], FileHandle);\r
       }\r
     } while (FileHandle != NULL);\r
   } while (TRUE);\r