public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/2] Core: Handle multiple FV images in one FV file
@ 2018-08-29  9:37 Star Zeng
  2018-08-29  9:37 ` [PATCH 1/2] MdeModulePkg PeiCore: " Star Zeng
  2018-08-29  9:37 ` [PATCH 2/2] MdeModulePkg DxeCore: " Star Zeng
  0 siblings, 2 replies; 6+ messages in thread
From: Star Zeng @ 2018-08-29  9:37 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131

Star Zeng (2):
  MdeModulePkg PeiCore: Handle multiple FV images in one FV file
  MdeModulePkg DxeCore: Handle multiple FV images in one FV file

 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 241 ++++++++++++-----------
 MdeModulePkg/Core/Pei/FwVol/FwVol.c           | 267 ++++++++++++++------------
 MdeModulePkg/Core/Pei/PeiMain.h               |   2 +-
 3 files changed, 273 insertions(+), 237 deletions(-)

-- 
2.7.0.windows.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] MdeModulePkg PeiCore: Handle multiple FV images in one FV file
  2018-08-29  9:37 [PATCH 0/2] Core: Handle multiple FV images in one FV file Star Zeng
@ 2018-08-29  9:37 ` Star Zeng
  2018-08-30 10:02   ` Gao, Liming
  2018-08-29  9:37 ` [PATCH 2/2] MdeModulePkg DxeCore: " Star Zeng
  1 sibling, 1 reply; 6+ messages in thread
From: Star Zeng @ 2018-08-29  9:37 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao, Jiewen Yao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131

PI spec and BaseTools supports to generate multiple FV images
in one FV file.
This patch is to update PeiCore to handle the case.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Core/Pei/FwVol/FwVol.c | 267 +++++++++++++++++++-----------------
 MdeModulePkg/Core/Pei/PeiMain.h     |   2 +-
 2 files changed, 145 insertions(+), 124 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index 65c485549718..7ea503a10fb5 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -1358,7 +1358,7 @@ GetFvUsedSize (
 }
 
 /**
-  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
+  Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.
 
   @param PrivateData          PeiCore's private data structure
   @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
@@ -1391,6 +1391,7 @@ ProcessFvFile (
   UINT32                        AuthenticationStatus;
   UINT32                        FvUsedSize;
   UINT8                         EraseByte;
+  UINTN                         Index;
 
   //
   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
@@ -1412,144 +1413,164 @@ ProcessFvFile (
   ParentFvPpi    = ParentFvCoreHandle->FvPpi;
 
   //
-  // Find FvImage in FvFile
+  // Find FvImage(s) in FvFile
   //
-  AuthenticationStatus = 0;
-  if ((ParentFvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
-      (ParentFvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
-    Status = ParentFvPpi->FindSectionByType2 (
-                            ParentFvPpi,
-                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
-                            0,
-                            ParentFvFileHandle,
-                            (VOID **)&FvHeader,
-                            &AuthenticationStatus
-                            );
-  } else {
-    Status = ParentFvPpi->FindSectionByType (
-                            ParentFvPpi,
-                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
-                            ParentFvFileHandle,
-                            (VOID **)&FvHeader
-                            );
-  }
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle, AuthenticationStatus);
-  if (Status == EFI_SECURITY_VIOLATION) {
-    return Status;
-  }
-
-  //
-  // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
-  // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
-  // its initial linked location and maintain its alignment.
-  //
-  if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
-    //
-    // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
-    //
-    FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
-    if (FvAlignment < 8) {
-      FvAlignment = 8;
+  Index = 0;
+  do {
+    AuthenticationStatus = 0;
+    if ((ParentFvPpi->Signature == EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
+        (ParentFvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
+      Status = ParentFvPpi->FindSectionByType2 (
+                              ParentFvPpi,
+                              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
+                              Index,
+                              ParentFvFileHandle,
+                              (VOID **)&FvHeader,
+                              &AuthenticationStatus
+                              );
+    } else {
+      //
+      // Old FvPpi has no parameter to input SearchInstance,
+      // only one instance is supported.
+      //
+      if (Index > 0) {
+        break;
+      }
+      Status = ParentFvPpi->FindSectionByType (
+                              ParentFvPpi,
+                              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
+                              ParentFvFileHandle,
+                              (VOID **)&FvHeader
+                              );
+    }
+    if (EFI_ERROR (Status)) {
+      break;
     }
 
-    DEBUG ((
-      DEBUG_INFO,
-      "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
-      __FUNCTION__,
-      FvHeader,
-      FvAlignment
-      ));
+    Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle, AuthenticationStatus);
+    if (Status == EFI_SECURITY_VIOLATION) {
+      break;
+    }
 
     //
-    // Check FvImage alignment.
+    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
+    // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
+    // its initial linked location and maintain its alignment.
     //
-    if ((UINTN) FvHeader % FvAlignment != 0) {
-      FvLength    = ReadUnaligned64 (&FvHeader->FvLength);
-      NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);
-      if (NewFvBuffer == NULL) {
-        return EFI_OUT_OF_RESOURCES;
+    if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
+      //
+      // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+      //
+      FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
+      if (FvAlignment < 8) {
+        FvAlignment = 8;
       }
-      if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
-        //
-        // Copy the used bytes and fill the rest with the erase value.
-        //
-        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvUsedSize);
-        SetMem (
-          (UINT8 *) NewFvBuffer + FvUsedSize,
-          (UINTN) (FvLength - FvUsedSize),
-          EraseByte
-          );
-      } else {
-        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
+
+      DEBUG ((
+        DEBUG_INFO,
+        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
+        __FUNCTION__,
+        FvHeader,
+        FvAlignment
+        ));
+
+      //
+      // Check FvImage alignment.
+      //
+      if ((UINTN) FvHeader % FvAlignment != 0) {
+        FvLength    = ReadUnaligned64 (&FvHeader->FvLength);
+        NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvLength), FvAlignment);
+        if (NewFvBuffer == NULL) {
+          Status = EFI_OUT_OF_RESOURCES;
+          break;
+        }
+        if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
+          //
+          // Copy the used bytes and fill the rest with the erase value.
+          //
+          CopyMem (NewFvBuffer, FvHeader, (UINTN) FvUsedSize);
+          SetMem (
+            (UINT8 *) NewFvBuffer + FvUsedSize,
+            (UINTN) (FvLength - FvUsedSize),
+            EraseByte
+            );
+        } else {
+          CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
+        }
+        FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
       }
-      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
     }
-  }
 
-  Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);
-  ASSERT_EFI_ERROR (Status);
+    Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle, &ParentFvImageInfo);
+    ASSERT_EFI_ERROR (Status);
 
-  Status = ParentFvPpi->GetFileInfo (ParentFvPpi, ParentFvFileHandle, &FileInfo);
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Install FvInfo(2) Ppi
-  // NOTE: FvInfo2 must be installed before FvInfo so that recursive processing of encapsulated
-  // FVs inherit the proper AuthenticationStatus.
-  //
-  PeiServicesInstallFvInfo2Ppi(
-    &FvHeader->FileSystemGuid,
-    (VOID**)FvHeader,
-    (UINT32)FvHeader->FvLength,
-    &ParentFvImageInfo.FvName,
-    &FileInfo.FileName,
-    AuthenticationStatus
-    );
+    Status = ParentFvPpi->GetFileInfo (ParentFvPpi, ParentFvFileHandle, &FileInfo);
+    ASSERT_EFI_ERROR (Status);
 
-  PeiServicesInstallFvInfoPpi (
-    &FvHeader->FileSystemGuid,
-    (VOID**) FvHeader,
-    (UINT32) FvHeader->FvLength,
-    &ParentFvImageInfo.FvName,
-    &FileInfo.FileName
-    );
+    //
+    // Install FvInfo(2) Ppi
+    // NOTE: FvInfo2 must be installed before FvInfo so that recursive processing of encapsulated
+    // FVs inherit the proper AuthenticationStatus.
+    //
+    PeiServicesInstallFvInfo2Ppi(
+      &FvHeader->FileSystemGuid,
+      (VOID**)FvHeader,
+      (UINT32)FvHeader->FvLength,
+      &ParentFvImageInfo.FvName,
+      &FileInfo.FileName,
+      AuthenticationStatus
+      );
+
+    PeiServicesInstallFvInfoPpi (
+      &FvHeader->FileSystemGuid,
+      (VOID**) FvHeader,
+      (UINT32) FvHeader->FvLength,
+      &ParentFvImageInfo.FvName,
+      &FileInfo.FileName
+      );
 
-  //
-  // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase
-  //
-  BuildFvHob (
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
-    FvHeader->FvLength
-    );
+    //
+    // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase
+    //
+    BuildFvHob (
+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+      FvHeader->FvLength
+      );
 
-  //
-  // Makes the encapsulated volume show up in DXE phase to skip processing of
-  // encapsulated file again.
-  //
-  BuildFv2Hob (
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
-    FvHeader->FvLength,
-    &ParentFvImageInfo.FvName,
-    &FileInfo.FileName
-    );
+    //
+    // Makes the encapsulated volume show up in DXE phase to skip processing of
+    // encapsulated file again.
+    //
+    BuildFv2Hob (
+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+      FvHeader->FvLength,
+      &ParentFvImageInfo.FvName,
+      &FileInfo.FileName
+      );
 
-  //
-  // Build FV3 HOB with authentication status to be propagated to DXE.
-  //
-  BuildFv3Hob (
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
-    FvHeader->FvLength,
-    AuthenticationStatus,
-    TRUE,
-    &ParentFvImageInfo.FvName,
-    &FileInfo.FileName
-    );
+    //
+    // Build FV3 HOB with authentication status to be propagated to DXE.
+    //
+    BuildFv3Hob (
+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+      FvHeader->FvLength,
+      AuthenticationStatus,
+      TRUE,
+      &ParentFvImageInfo.FvName,
+      &FileInfo.FileName
+      );
+
+    Index++;
+  } while (TRUE);
 
-  return EFI_SUCCESS;
+  if (Index > 0) {
+    //
+    // At least one FvImage has been processed successfully.
+    //
+    return EFI_SUCCESS;
+  } else {
+    return Status;
+  }
 }
 
 /**
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index e2f8cd9c7758..6469436b8f79 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -1258,7 +1258,7 @@ SecurityPpiNotifyCallback (
   );
 
 /**
-  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
+  Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2, 3) hob.
 
   @param PrivateData          PeiCore's private data structure
   @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in one FV file
  2018-08-29  9:37 [PATCH 0/2] Core: Handle multiple FV images in one FV file Star Zeng
  2018-08-29  9:37 ` [PATCH 1/2] MdeModulePkg PeiCore: " Star Zeng
@ 2018-08-29  9:37 ` Star Zeng
  2018-08-30  9:54   ` Gao, Liming
  1 sibling, 1 reply; 6+ messages in thread
From: Star Zeng @ 2018-08-29  9:37 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao, Jiewen Yao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131

PI spec and BaseTools supports to generate multiple FV images
in one FV file.
This patch is to update DxeCore to handle the case.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 241 ++++++++++++++------------
 1 file changed, 128 insertions(+), 113 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index f72c47a9e54c..086a590ef4e3 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -184,14 +184,13 @@ CoreAddToDriverList (
   );
 
 /**
-  Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
+  Get Fv image(s) from the FV through file name, and produce FVB protocol for every Fv image(s).
 
   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
   @param  FvHandle              The handle which FVB protocol installed on.
   @param  DriverName            The driver guid specified.
 
   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
   @retval EFI_SUCCESS           Function successfully returned.
 
 **/
@@ -199,7 +198,7 @@ EFI_STATUS
 CoreProcessFvImageFile (
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
   IN  EFI_HANDLE                      FvHandle,
-  IN  EFI_GUID                        *DriverName
+  IN  EFI_GUID                        *FileName
   );
 
 
@@ -1004,14 +1003,13 @@ GetFvUsedSize (
 }
 
 /**
-  Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
+  Get Fv image(s) from the FV through file name, and produce FVB protocol for every Fv image(s).
 
   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
   @param  FvHandle              The handle which FVB protocol installed on.
   @param  DriverName            The driver guid specified.
 
   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
   @retval EFI_SUCCESS           Function successfully returned.
 
 **/
@@ -1019,7 +1017,7 @@ EFI_STATUS
 CoreProcessFvImageFile (
   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
   IN  EFI_HANDLE                      FvHandle,
-  IN  EFI_GUID                        *DriverName
+  IN  EFI_GUID                        *FileName
   )
 {
   EFI_STATUS                          Status;
@@ -1033,141 +1031,158 @@ CoreProcessFvImageFile (
   EFI_DEVICE_PATH_PROTOCOL            *FvFileDevicePath;
   UINT32                              FvUsedSize;
   UINT8                               EraseByte;
+  UINTN                               Index;
 
   //
-  // Read the first (and only the first) firmware volume section
+  // Read firmware volume section(s)
   //
   SectionType   = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
-  FvHeader      = NULL;
-  FvAlignment   = 0;
-  Buffer        = NULL;
-  BufferSize    = 0;
-  AlignedBuffer = NULL;
-  Status = Fv->ReadSection (
-                 Fv,
-                 DriverName,
-                 SectionType,
-                 0,
-                 &Buffer,
-                 &BufferSize,
-                 &AuthenticationStatus
-                 );
-  if (!EFI_ERROR (Status)) {
-     //
-    // Evaluate the authentication status of the Firmware Volume through
-    // Security Architectural Protocol
-    //
-    if (gSecurity != NULL) {
-      FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
-      Status = gSecurity->FileAuthenticationState (
-                            gSecurity,
-                            AuthenticationStatus,
-                            FvFileDevicePath
-                            );
-      if (FvFileDevicePath != NULL) {
-        FreePool (FvFileDevicePath);
-      }
 
-      if (Status != EFI_SUCCESS) {
-        //
-        // Security check failed. The firmware volume should not be used for any purpose.
-        //
-        if (Buffer != NULL) {
-          FreePool (Buffer);
+  Index = 0;
+  do {
+    FvHeader      = NULL;
+    FvAlignment   = 0;
+    Buffer        = NULL;
+    BufferSize    = 0;
+    AlignedBuffer = NULL;
+    Status = Fv->ReadSection (
+                   Fv,
+                   FileName,
+                   SectionType,
+                   Index,
+                   &Buffer,
+                   &BufferSize,
+                   &AuthenticationStatus
+                   );
+    if (!EFI_ERROR (Status)) {
+       //
+      // Evaluate the authentication status of the Firmware Volume through
+      // Security Architectural Protocol
+      //
+      if (gSecurity != NULL) {
+        FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, FileName);
+        Status = gSecurity->FileAuthenticationState (
+                              gSecurity,
+                              AuthenticationStatus,
+                              FvFileDevicePath
+                              );
+        if (FvFileDevicePath != NULL) {
+          FreePool (FvFileDevicePath);
+        }
+
+        if (Status != EFI_SUCCESS) {
+          //
+          // Security check failed. The firmware volume should not be used for any purpose.
+          //
+          if (Buffer != NULL) {
+            FreePool (Buffer);
+          }
+          break;
         }
-        return Status;
       }
-    }
 
-    //
-    // FvImage should be at its required alignment.
-    //
-    FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
-    //
-    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
-    // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
-    // its initial linked location and maintain its alignment.
-    //
-    if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
       //
-      // Get FvHeader alignment
+      // FvImage should be at its required alignment.
       //
-      FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
       //
-      // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+      // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
+      // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
+      // its initial linked location and maintain its alignment.
       //
-      if (FvAlignment < 8) {
-        FvAlignment = 8;
-      }
+      if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
+        //
+        // Get FvHeader alignment
+        //
+        FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ALIGNMENT) >> 16);
+        //
+        // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
+        //
+        if (FvAlignment < 8) {
+          FvAlignment = 8;
+        }
 
-      DEBUG ((
-        DEBUG_INFO,
-        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
-        __FUNCTION__,
-        FvHeader,
-        FvAlignment
-        ));
+        DEBUG ((
+          DEBUG_INFO,
+          "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
+          __FUNCTION__,
+          FvHeader,
+          FvAlignment
+          ));
 
-      //
-      // Check FvImage alignment.
-      //
-      if ((UINTN) FvHeader % FvAlignment != 0) {
         //
-        // Allocate the aligned buffer for the FvImage.
+        // Check FvImage alignment.
         //
-        AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
-        if (AlignedBuffer == NULL) {
-          FreePool (Buffer);
-          return EFI_OUT_OF_RESOURCES;
-        } else {
+        if ((UINTN) FvHeader % FvAlignment != 0) {
           //
-          // Move FvImage into the aligned buffer and release the original buffer.
+          // Allocate the aligned buffer for the FvImage.
           //
-          if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
+          AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
+          if (AlignedBuffer == NULL) {
+            FreePool (Buffer);
+            Status = EFI_OUT_OF_RESOURCES;
+            break;
+          } else {
             //
-            // Copy the used bytes and fill the rest with the erase value.
+            // Move FvImage into the aligned buffer and release the original buffer.
             //
-            CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
-            SetMem (
-              (UINT8 *) AlignedBuffer + FvUsedSize,
-              (UINTN) (BufferSize - FvUsedSize),
-              EraseByte
-              );
-          } else {
-            CopyMem (AlignedBuffer, Buffer, BufferSize);
+            if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
+              //
+              // Copy the used bytes and fill the rest with the erase value.
+              //
+              CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
+              SetMem (
+                (UINT8 *) AlignedBuffer + FvUsedSize,
+                (UINTN) (BufferSize - FvUsedSize),
+                EraseByte
+                );
+            } else {
+              CopyMem (AlignedBuffer, Buffer, BufferSize);
+            }
+            FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
+            FreePool (Buffer);
+            Buffer = NULL;
           }
-          FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
-          CoreFreePool (Buffer);
-          Buffer = NULL;
         }
       }
+      //
+      // Produce a FVB protocol for the file
+      //
+      Status = ProduceFVBProtocolOnBuffer (
+                (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+                (UINT64)BufferSize,
+                FvHandle,
+                AuthenticationStatus,
+                NULL
+                );
     }
-    //
-    // Produce a FVB protocol for the file
-    //
-    Status = ProduceFVBProtocolOnBuffer (
-              (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
-              (UINT64)BufferSize,
-              FvHandle,
-              AuthenticationStatus,
-              NULL
-              );
-  }
 
-  if (EFI_ERROR (Status)) {
-    //
-    // ReadSection or Produce FVB failed, Free data buffer
-    //
-    if (Buffer != NULL) {
-      FreePool (Buffer);
-    }
+    if (EFI_ERROR (Status)) {
+      //
+      // ReadSection or Produce FVB failed, Free data buffer
+      //
+      if (Buffer != NULL) {
+        FreePool (Buffer);
+      }
+
+      if (AlignedBuffer != NULL) {
+        FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
+      }
 
-    if (AlignedBuffer != NULL) {
-      FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
+      break;
+    } else {
+      Index++;
     }
-  }
+  } while (TRUE);
 
-  return Status;
+  if (Index > 0) {
+    //
+    // At least one FvImage has been processed successfully.
+    //
+    return EFI_SUCCESS;
+  } else {
+    return Status;
+  }
 }
 
 
-- 
2.7.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in one FV file
  2018-08-29  9:37 ` [PATCH 2/2] MdeModulePkg DxeCore: " Star Zeng
@ 2018-08-30  9:54   ` Gao, Liming
  2018-08-30  9:59     ` Zeng, Star
  0 siblings, 1 reply; 6+ messages in thread
From: Gao, Liming @ 2018-08-30  9:54 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen

Star:
  You change the parameter name in the function. Please also update the function description to match the function implementation. 

Thanks
Liming
>-----Original Message-----
>From: Zeng, Star
>Sent: Wednesday, August 29, 2018 5:38 PM
>To: edk2-devel@lists.01.org
>Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>;
>Yao, Jiewen <jiewen.yao@intel.com>
>Subject: [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in
>one FV file
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131
>
>PI spec and BaseTools supports to generate multiple FV images
>in one FV file.
>This patch is to update DxeCore to handle the case.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Jiewen Yao <jiewen.yao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Star Zeng <star.zeng@intel.com>
>---
> MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 241 ++++++++++++++-
>-----------
> 1 file changed, 128 insertions(+), 113 deletions(-)
>
>diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>index f72c47a9e54c..086a590ef4e3 100644
>--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>@@ -184,14 +184,13 @@ CoreAddToDriverList (
>   );
>
> /**
>-  Get the driver from the FV through driver name, and produce a FVB
>protocol on FvHandle.
>+  Get Fv image(s) from the FV through file name, and produce FVB protocol
>for every Fv image(s).
>
>   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
>   @param  FvHandle              The handle which FVB protocol installed on.
>   @param  DriverName            The driver guid specified.
>
>   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
>-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
>   @retval EFI_SUCCESS           Function successfully returned.
>
> **/
>@@ -199,7 +198,7 @@ EFI_STATUS
> CoreProcessFvImageFile (
>   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
>   IN  EFI_HANDLE                      FvHandle,
>-  IN  EFI_GUID                        *DriverName
>+  IN  EFI_GUID                        *FileName
>   );
>
>
>@@ -1004,14 +1003,13 @@ GetFvUsedSize (
> }
>
> /**
>-  Get the driver from the FV through driver name, and produce a FVB
>protocol on FvHandle.
>+  Get Fv image(s) from the FV through file name, and produce FVB protocol
>for every Fv image(s).
>
>   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
>   @param  FvHandle              The handle which FVB protocol installed on.
>   @param  DriverName            The driver guid specified.
>
>   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
>-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
>   @retval EFI_SUCCESS           Function successfully returned.
>
> **/
>@@ -1019,7 +1017,7 @@ EFI_STATUS
> CoreProcessFvImageFile (
>   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
>   IN  EFI_HANDLE                      FvHandle,
>-  IN  EFI_GUID                        *DriverName
>+  IN  EFI_GUID                        *FileName
>   )
> {
>   EFI_STATUS                          Status;
>@@ -1033,141 +1031,158 @@ CoreProcessFvImageFile (
>   EFI_DEVICE_PATH_PROTOCOL            *FvFileDevicePath;
>   UINT32                              FvUsedSize;
>   UINT8                               EraseByte;
>+  UINTN                               Index;
>
>   //
>-  // Read the first (and only the first) firmware volume section
>+  // Read firmware volume section(s)
>   //
>   SectionType   = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
>-  FvHeader      = NULL;
>-  FvAlignment   = 0;
>-  Buffer        = NULL;
>-  BufferSize    = 0;
>-  AlignedBuffer = NULL;
>-  Status = Fv->ReadSection (
>-                 Fv,
>-                 DriverName,
>-                 SectionType,
>-                 0,
>-                 &Buffer,
>-                 &BufferSize,
>-                 &AuthenticationStatus
>-                 );
>-  if (!EFI_ERROR (Status)) {
>-     //
>-    // Evaluate the authentication status of the Firmware Volume through
>-    // Security Architectural Protocol
>-    //
>-    if (gSecurity != NULL) {
>-      FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
>-      Status = gSecurity->FileAuthenticationState (
>-                            gSecurity,
>-                            AuthenticationStatus,
>-                            FvFileDevicePath
>-                            );
>-      if (FvFileDevicePath != NULL) {
>-        FreePool (FvFileDevicePath);
>-      }
>
>-      if (Status != EFI_SUCCESS) {
>-        //
>-        // Security check failed. The firmware volume should not be used for any
>purpose.
>-        //
>-        if (Buffer != NULL) {
>-          FreePool (Buffer);
>+  Index = 0;
>+  do {
>+    FvHeader      = NULL;
>+    FvAlignment   = 0;
>+    Buffer        = NULL;
>+    BufferSize    = 0;
>+    AlignedBuffer = NULL;
>+    Status = Fv->ReadSection (
>+                   Fv,
>+                   FileName,
>+                   SectionType,
>+                   Index,
>+                   &Buffer,
>+                   &BufferSize,
>+                   &AuthenticationStatus
>+                   );
>+    if (!EFI_ERROR (Status)) {
>+       //
>+      // Evaluate the authentication status of the Firmware Volume through
>+      // Security Architectural Protocol
>+      //
>+      if (gSecurity != NULL) {
>+        FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, FileName);
>+        Status = gSecurity->FileAuthenticationState (
>+                              gSecurity,
>+                              AuthenticationStatus,
>+                              FvFileDevicePath
>+                              );
>+        if (FvFileDevicePath != NULL) {
>+          FreePool (FvFileDevicePath);
>+        }
>+
>+        if (Status != EFI_SUCCESS) {
>+          //
>+          // Security check failed. The firmware volume should not be used for
>any purpose.
>+          //
>+          if (Buffer != NULL) {
>+            FreePool (Buffer);
>+          }
>+          break;
>         }
>-        return Status;
>       }
>-    }
>
>-    //
>-    // FvImage should be at its required alignment.
>-    //
>-    FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
>-    //
>-    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the
>first byte of the volume
>-    // can be aligned on any power-of-two boundary. A weakly aligned volume
>can not be moved from
>-    // its initial linked location and maintain its alignment.
>-    //
>-    if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>       //
>-      // Get FvHeader alignment
>+      // FvImage should be at its required alignment.
>       //
>-      FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
>       //
>-      // FvAlignment must be greater than or equal to 8 bytes of the minimum
>FFS alignment value.
>+      // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the
>first byte of the volume
>+      // can be aligned on any power-of-two boundary. A weakly aligned
>volume can not be moved from
>+      // its initial linked location and maintain its alignment.
>       //
>-      if (FvAlignment < 8) {
>-        FvAlignment = 8;
>-      }
>+      if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>+        //
>+        // Get FvHeader alignment
>+        //
>+        FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>+        //
>+        // FvAlignment must be greater than or equal to 8 bytes of the minimum
>FFS alignment value.
>+        //
>+        if (FvAlignment < 8) {
>+          FvAlignment = 8;
>+        }
>
>-      DEBUG ((
>-        DEBUG_INFO,
>-        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>-        __FUNCTION__,
>-        FvHeader,
>-        FvAlignment
>-        ));
>+        DEBUG ((
>+          DEBUG_INFO,
>+          "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>+          __FUNCTION__,
>+          FvHeader,
>+          FvAlignment
>+          ));
>
>-      //
>-      // Check FvImage alignment.
>-      //
>-      if ((UINTN) FvHeader % FvAlignment != 0) {
>         //
>-        // Allocate the aligned buffer for the FvImage.
>+        // Check FvImage alignment.
>         //
>-        AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize),
>(UINTN) FvAlignment);
>-        if (AlignedBuffer == NULL) {
>-          FreePool (Buffer);
>-          return EFI_OUT_OF_RESOURCES;
>-        } else {
>+        if ((UINTN) FvHeader % FvAlignment != 0) {
>           //
>-          // Move FvImage into the aligned buffer and release the original buffer.
>+          // Allocate the aligned buffer for the FvImage.
>           //
>-          if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>+          AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES
>(BufferSize), (UINTN) FvAlignment);
>+          if (AlignedBuffer == NULL) {
>+            FreePool (Buffer);
>+            Status = EFI_OUT_OF_RESOURCES;
>+            break;
>+          } else {
>             //
>-            // Copy the used bytes and fill the rest with the erase value.
>+            // Move FvImage into the aligned buffer and release the original
>buffer.
>             //
>-            CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
>-            SetMem (
>-              (UINT8 *) AlignedBuffer + FvUsedSize,
>-              (UINTN) (BufferSize - FvUsedSize),
>-              EraseByte
>-              );
>-          } else {
>-            CopyMem (AlignedBuffer, Buffer, BufferSize);
>+            if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>+              //
>+              // Copy the used bytes and fill the rest with the erase value.
>+              //
>+              CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
>+              SetMem (
>+                (UINT8 *) AlignedBuffer + FvUsedSize,
>+                (UINTN) (BufferSize - FvUsedSize),
>+                EraseByte
>+                );
>+            } else {
>+              CopyMem (AlignedBuffer, Buffer, BufferSize);
>+            }
>+            FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
>+            FreePool (Buffer);
>+            Buffer = NULL;
>           }
>-          FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
>-          CoreFreePool (Buffer);
>-          Buffer = NULL;
>         }
>       }
>+      //
>+      // Produce a FVB protocol for the file
>+      //
>+      Status = ProduceFVBProtocolOnBuffer (
>+                (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>+                (UINT64)BufferSize,
>+                FvHandle,
>+                AuthenticationStatus,
>+                NULL
>+                );
>     }
>-    //
>-    // Produce a FVB protocol for the file
>-    //
>-    Status = ProduceFVBProtocolOnBuffer (
>-              (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>-              (UINT64)BufferSize,
>-              FvHandle,
>-              AuthenticationStatus,
>-              NULL
>-              );
>-  }
>
>-  if (EFI_ERROR (Status)) {
>-    //
>-    // ReadSection or Produce FVB failed, Free data buffer
>-    //
>-    if (Buffer != NULL) {
>-      FreePool (Buffer);
>-    }
>+    if (EFI_ERROR (Status)) {
>+      //
>+      // ReadSection or Produce FVB failed, Free data buffer
>+      //
>+      if (Buffer != NULL) {
>+        FreePool (Buffer);
>+      }
>+
>+      if (AlignedBuffer != NULL) {
>+        FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
>+      }
>
>-    if (AlignedBuffer != NULL) {
>-      FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
>+      break;
>+    } else {
>+      Index++;
>     }
>-  }
>+  } while (TRUE);
>
>-  return Status;
>+  if (Index > 0) {
>+    //
>+    // At least one FvImage has been processed successfully.
>+    //
>+    return EFI_SUCCESS;
>+  } else {
>+    return Status;
>+  }
> }
>
>
>--
>2.7.0.windows.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in one FV file
  2018-08-30  9:54   ` Gao, Liming
@ 2018-08-30  9:59     ` Zeng, Star
  0 siblings, 0 replies; 6+ messages in thread
From: Zeng, Star @ 2018-08-30  9:59 UTC (permalink / raw)
  To: Gao, Liming, edk2-devel@lists.01.org; +Cc: Yao, Jiewen, Zeng, Star

Oh, yes, agree. I should update description.

Thanks,
Star
-----Original Message-----
From: Gao, Liming 
Sent: Thursday, August 30, 2018 5:55 PM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Yao, Jiewen <jiewen.yao@intel.com>
Subject: RE: [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in one FV file

Star:
  You change the parameter name in the function. Please also update the function description to match the function implementation. 

Thanks
Liming
>-----Original Message-----
>From: Zeng, Star
>Sent: Wednesday, August 29, 2018 5:38 PM
>To: edk2-devel@lists.01.org
>Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming 
><liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
>Subject: [PATCH 2/2] MdeModulePkg DxeCore: Handle multiple FV images in 
>one FV file
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131
>
>PI spec and BaseTools supports to generate multiple FV images in one FV 
>file.
>This patch is to update DxeCore to handle the case.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Jiewen Yao <jiewen.yao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Star Zeng <star.zeng@intel.com>
>---
> MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 241 ++++++++++++++-
>-----------
> 1 file changed, 128 insertions(+), 113 deletions(-)
>
>diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>index f72c47a9e54c..086a590ef4e3 100644
>--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
>@@ -184,14 +184,13 @@ CoreAddToDriverList (
>   );
>
> /**
>-  Get the driver from the FV through driver name, and produce a FVB 
>protocol on FvHandle.
>+  Get Fv image(s) from the FV through file name, and produce FVB 
>+ protocol
>for every Fv image(s).
>
>   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
>   @param  FvHandle              The handle which FVB protocol installed on.
>   @param  DriverName            The driver guid specified.
>
>   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
>-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
>   @retval EFI_SUCCESS           Function successfully returned.
>
> **/
>@@ -199,7 +198,7 @@ EFI_STATUS
> CoreProcessFvImageFile (
>   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
>   IN  EFI_HANDLE                      FvHandle,
>-  IN  EFI_GUID                        *DriverName
>+  IN  EFI_GUID                        *FileName
>   );
>
>
>@@ -1004,14 +1003,13 @@ GetFvUsedSize (  }
>
> /**
>-  Get the driver from the FV through driver name, and produce a FVB 
>protocol on FvHandle.
>+  Get Fv image(s) from the FV through file name, and produce FVB 
>+ protocol
>for every Fv image(s).
>
>   @param  Fv                    The FIRMWARE_VOLUME protocol installed on the FV.
>   @param  FvHandle              The handle which FVB protocol installed on.
>   @param  DriverName            The driver guid specified.
>
>   @retval EFI_OUT_OF_RESOURCES  No enough memory or other resource.
>-  @retval EFI_VOLUME_CORRUPTED  Corrupted volume.
>   @retval EFI_SUCCESS           Function successfully returned.
>
> **/
>@@ -1019,7 +1017,7 @@ EFI_STATUS
> CoreProcessFvImageFile (
>   IN  EFI_FIRMWARE_VOLUME2_PROTOCOL   *Fv,
>   IN  EFI_HANDLE                      FvHandle,
>-  IN  EFI_GUID                        *DriverName
>+  IN  EFI_GUID                        *FileName
>   )
> {
>   EFI_STATUS                          Status;
>@@ -1033,141 +1031,158 @@ CoreProcessFvImageFile (
>   EFI_DEVICE_PATH_PROTOCOL            *FvFileDevicePath;
>   UINT32                              FvUsedSize;
>   UINT8                               EraseByte;
>+  UINTN                               Index;
>
>   //
>-  // Read the first (and only the first) firmware volume section
>+  // Read firmware volume section(s)
>   //
>   SectionType   = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
>-  FvHeader      = NULL;
>-  FvAlignment   = 0;
>-  Buffer        = NULL;
>-  BufferSize    = 0;
>-  AlignedBuffer = NULL;
>-  Status = Fv->ReadSection (
>-                 Fv,
>-                 DriverName,
>-                 SectionType,
>-                 0,
>-                 &Buffer,
>-                 &BufferSize,
>-                 &AuthenticationStatus
>-                 );
>-  if (!EFI_ERROR (Status)) {
>-     //
>-    // Evaluate the authentication status of the Firmware Volume through
>-    // Security Architectural Protocol
>-    //
>-    if (gSecurity != NULL) {
>-      FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
>-      Status = gSecurity->FileAuthenticationState (
>-                            gSecurity,
>-                            AuthenticationStatus,
>-                            FvFileDevicePath
>-                            );
>-      if (FvFileDevicePath != NULL) {
>-        FreePool (FvFileDevicePath);
>-      }
>
>-      if (Status != EFI_SUCCESS) {
>-        //
>-        // Security check failed. The firmware volume should not be used for any
>purpose.
>-        //
>-        if (Buffer != NULL) {
>-          FreePool (Buffer);
>+  Index = 0;
>+  do {
>+    FvHeader      = NULL;
>+    FvAlignment   = 0;
>+    Buffer        = NULL;
>+    BufferSize    = 0;
>+    AlignedBuffer = NULL;
>+    Status = Fv->ReadSection (
>+                   Fv,
>+                   FileName,
>+                   SectionType,
>+                   Index,
>+                   &Buffer,
>+                   &BufferSize,
>+                   &AuthenticationStatus
>+                   );
>+    if (!EFI_ERROR (Status)) {
>+       //
>+      // Evaluate the authentication status of the Firmware Volume through
>+      // Security Architectural Protocol
>+      //
>+      if (gSecurity != NULL) {
>+        FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, FileName);
>+        Status = gSecurity->FileAuthenticationState (
>+                              gSecurity,
>+                              AuthenticationStatus,
>+                              FvFileDevicePath
>+                              );
>+        if (FvFileDevicePath != NULL) {
>+          FreePool (FvFileDevicePath);
>+        }
>+
>+        if (Status != EFI_SUCCESS) {
>+          //
>+          // Security check failed. The firmware volume should not be 
>+ used for
>any purpose.
>+          //
>+          if (Buffer != NULL) {
>+            FreePool (Buffer);
>+          }
>+          break;
>         }
>-        return Status;
>       }
>-    }
>
>-    //
>-    // FvImage should be at its required alignment.
>-    //
>-    FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
>-    //
>-    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the
>first byte of the volume
>-    // can be aligned on any power-of-two boundary. A weakly aligned volume
>can not be moved from
>-    // its initial linked location and maintain its alignment.
>-    //
>-    if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>       //
>-      // Get FvHeader alignment
>+      // FvImage should be at its required alignment.
>       //
>-      FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>+      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;
>       //
>-      // FvAlignment must be greater than or equal to 8 bytes of the minimum
>FFS alignment value.
>+      // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then 
>+ the
>first byte of the volume
>+      // can be aligned on any power-of-two boundary. A weakly aligned
>volume can not be moved from
>+      // its initial linked location and maintain its alignment.
>       //
>-      if (FvAlignment < 8) {
>-        FvAlignment = 8;
>-      }
>+      if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>+        //
>+        // Get FvHeader alignment
>+        //
>+        FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>+        //
>+        // FvAlignment must be greater than or equal to 8 bytes of the 
>+ minimum
>FFS alignment value.
>+        //
>+        if (FvAlignment < 8) {
>+          FvAlignment = 8;
>+        }
>
>-      DEBUG ((
>-        DEBUG_INFO,
>-        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>-        __FUNCTION__,
>-        FvHeader,
>-        FvAlignment
>-        ));
>+        DEBUG ((
>+          DEBUG_INFO,
>+          "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>+          __FUNCTION__,
>+          FvHeader,
>+          FvAlignment
>+          ));
>
>-      //
>-      // Check FvImage alignment.
>-      //
>-      if ((UINTN) FvHeader % FvAlignment != 0) {
>         //
>-        // Allocate the aligned buffer for the FvImage.
>+        // Check FvImage alignment.
>         //
>-        AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize),
>(UINTN) FvAlignment);
>-        if (AlignedBuffer == NULL) {
>-          FreePool (Buffer);
>-          return EFI_OUT_OF_RESOURCES;
>-        } else {
>+        if ((UINTN) FvHeader % FvAlignment != 0) {
>           //
>-          // Move FvImage into the aligned buffer and release the original buffer.
>+          // Allocate the aligned buffer for the FvImage.
>           //
>-          if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>+          AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES
>(BufferSize), (UINTN) FvAlignment);
>+          if (AlignedBuffer == NULL) {
>+            FreePool (Buffer);
>+            Status = EFI_OUT_OF_RESOURCES;
>+            break;
>+          } else {
>             //
>-            // Copy the used bytes and fill the rest with the erase value.
>+            // Move FvImage into the aligned buffer and release the 
>+ original
>buffer.
>             //
>-            CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
>-            SetMem (
>-              (UINT8 *) AlignedBuffer + FvUsedSize,
>-              (UINTN) (BufferSize - FvUsedSize),
>-              EraseByte
>-              );
>-          } else {
>-            CopyMem (AlignedBuffer, Buffer, BufferSize);
>+            if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>+              //
>+              // Copy the used bytes and fill the rest with the erase value.
>+              //
>+              CopyMem (AlignedBuffer, FvHeader, (UINTN) FvUsedSize);
>+              SetMem (
>+                (UINT8 *) AlignedBuffer + FvUsedSize,
>+                (UINTN) (BufferSize - FvUsedSize),
>+                EraseByte
>+                );
>+            } else {
>+              CopyMem (AlignedBuffer, Buffer, BufferSize);
>+            }
>+            FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
>+            FreePool (Buffer);
>+            Buffer = NULL;
>           }
>-          FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
>-          CoreFreePool (Buffer);
>-          Buffer = NULL;
>         }
>       }
>+      //
>+      // Produce a FVB protocol for the file
>+      //
>+      Status = ProduceFVBProtocolOnBuffer (
>+                (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>+                (UINT64)BufferSize,
>+                FvHandle,
>+                AuthenticationStatus,
>+                NULL
>+                );
>     }
>-    //
>-    // Produce a FVB protocol for the file
>-    //
>-    Status = ProduceFVBProtocolOnBuffer (
>-              (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>-              (UINT64)BufferSize,
>-              FvHandle,
>-              AuthenticationStatus,
>-              NULL
>-              );
>-  }
>
>-  if (EFI_ERROR (Status)) {
>-    //
>-    // ReadSection or Produce FVB failed, Free data buffer
>-    //
>-    if (Buffer != NULL) {
>-      FreePool (Buffer);
>-    }
>+    if (EFI_ERROR (Status)) {
>+      //
>+      // ReadSection or Produce FVB failed, Free data buffer
>+      //
>+      if (Buffer != NULL) {
>+        FreePool (Buffer);
>+      }
>+
>+      if (AlignedBuffer != NULL) {
>+        FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
>+      }
>
>-    if (AlignedBuffer != NULL) {
>-      FreeAlignedPages (AlignedBuffer, EFI_SIZE_TO_PAGES (BufferSize));
>+      break;
>+    } else {
>+      Index++;
>     }
>-  }
>+  } while (TRUE);
>
>-  return Status;
>+  if (Index > 0) {
>+    //
>+    // At least one FvImage has been processed successfully.
>+    //
>+    return EFI_SUCCESS;
>+  } else {
>+    return Status;
>+  }
> }
>
>
>--
>2.7.0.windows.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] MdeModulePkg PeiCore: Handle multiple FV images in one FV file
  2018-08-29  9:37 ` [PATCH 1/2] MdeModulePkg PeiCore: " Star Zeng
@ 2018-08-30 10:02   ` Gao, Liming
  0 siblings, 0 replies; 6+ messages in thread
From: Gao, Liming @ 2018-08-30 10:02 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Yao, Jiewen

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Zeng, Star
>Sent: Wednesday, August 29, 2018 5:38 PM
>To: edk2-devel@lists.01.org
>Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>;
>Yao, Jiewen <jiewen.yao@intel.com>
>Subject: [PATCH 1/2] MdeModulePkg PeiCore: Handle multiple FV images in
>one FV file
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1131
>
>PI spec and BaseTools supports to generate multiple FV images
>in one FV file.
>This patch is to update PeiCore to handle the case.
>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Jiewen Yao <jiewen.yao@intel.com>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Star Zeng <star.zeng@intel.com>
>---
> MdeModulePkg/Core/Pei/FwVol/FwVol.c | 267 +++++++++++++++++++-----
>------------
> MdeModulePkg/Core/Pei/PeiMain.h     |   2 +-
> 2 files changed, 145 insertions(+), 124 deletions(-)
>
>diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
>b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
>index 65c485549718..7ea503a10fb5 100644
>--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
>+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
>@@ -1358,7 +1358,7 @@ GetFvUsedSize (
> }
>
> /**
>-  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
>+  Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2,
>3) hob.
>
>   @param PrivateData          PeiCore's private data structure
>   @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent
>Fv image that contain this Fv image.
>@@ -1391,6 +1391,7 @@ ProcessFvFile (
>   UINT32                        AuthenticationStatus;
>   UINT32                        FvUsedSize;
>   UINT8                         EraseByte;
>+  UINTN                         Index;
>
>   //
>   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has
>already
>@@ -1412,144 +1413,164 @@ ProcessFvFile (
>   ParentFvPpi    = ParentFvCoreHandle->FvPpi;
>
>   //
>-  // Find FvImage in FvFile
>+  // Find FvImage(s) in FvFile
>   //
>-  AuthenticationStatus = 0;
>-  if ((ParentFvPpi->Signature ==
>EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
>-      (ParentFvPpi->Revision == EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION))
>{
>-    Status = ParentFvPpi->FindSectionByType2 (
>-                            ParentFvPpi,
>-                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
>-                            0,
>-                            ParentFvFileHandle,
>-                            (VOID **)&FvHeader,
>-                            &AuthenticationStatus
>-                            );
>-  } else {
>-    Status = ParentFvPpi->FindSectionByType (
>-                            ParentFvPpi,
>-                            EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
>-                            ParentFvFileHandle,
>-                            (VOID **)&FvHeader
>-                            );
>-  }
>-  if (EFI_ERROR (Status)) {
>-    return Status;
>-  }
>-
>-  Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle,
>AuthenticationStatus);
>-  if (Status == EFI_SECURITY_VIOLATION) {
>-    return Status;
>-  }
>-
>-  //
>-  // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first
>byte of the volume
>-  // can be aligned on any power-of-two boundary. A weakly aligned volume
>can not be moved from
>-  // its initial linked location and maintain its alignment.
>-  //
>-  if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>-    //
>-    // FvAlignment must be greater than or equal to 8 bytes of the minimum
>FFS alignment value.
>-    //
>-    FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>-    if (FvAlignment < 8) {
>-      FvAlignment = 8;
>+  Index = 0;
>+  do {
>+    AuthenticationStatus = 0;
>+    if ((ParentFvPpi->Signature ==
>EFI_PEI_FIRMWARE_VOLUME_PPI_SIGNATURE) &&
>+        (ParentFvPpi->Revision ==
>EFI_PEI_FIRMWARE_VOLUME_PPI_REVISION)) {
>+      Status = ParentFvPpi->FindSectionByType2 (
>+                              ParentFvPpi,
>+                              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
>+                              Index,
>+                              ParentFvFileHandle,
>+                              (VOID **)&FvHeader,
>+                              &AuthenticationStatus
>+                              );
>+    } else {
>+      //
>+      // Old FvPpi has no parameter to input SearchInstance,
>+      // only one instance is supported.
>+      //
>+      if (Index > 0) {
>+        break;
>+      }
>+      Status = ParentFvPpi->FindSectionByType (
>+                              ParentFvPpi,
>+                              EFI_SECTION_FIRMWARE_VOLUME_IMAGE,
>+                              ParentFvFileHandle,
>+                              (VOID **)&FvHeader
>+                              );
>+    }
>+    if (EFI_ERROR (Status)) {
>+      break;
>     }
>
>-    DEBUG ((
>-      DEBUG_INFO,
>-      "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>-      __FUNCTION__,
>-      FvHeader,
>-      FvAlignment
>-      ));
>+    Status = VerifyPeim (PrivateData, ParentFvHandle, ParentFvFileHandle,
>AuthenticationStatus);
>+    if (Status == EFI_SECURITY_VIOLATION) {
>+      break;
>+    }
>
>     //
>-    // Check FvImage alignment.
>+    // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the
>first byte of the volume
>+    // can be aligned on any power-of-two boundary. A weakly aligned volume
>can not be moved from
>+    // its initial linked location and maintain its alignment.
>     //
>-    if ((UINTN) FvHeader % FvAlignment != 0) {
>-      FvLength    = ReadUnaligned64 (&FvHeader->FvLength);
>-      NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32)
>FvLength), FvAlignment);
>-      if (NewFvBuffer == NULL) {
>-        return EFI_OUT_OF_RESOURCES;
>+    if ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
>+      //
>+      // FvAlignment must be greater than or equal to 8 bytes of the minimum
>FFS alignment value.
>+      //
>+      FvAlignment = 1 << ((ReadUnaligned32 (&FvHeader->Attributes) &
>EFI_FVB2_ALIGNMENT) >> 16);
>+      if (FvAlignment < 8) {
>+        FvAlignment = 8;
>       }
>-      if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>-        //
>-        // Copy the used bytes and fill the rest with the erase value.
>-        //
>-        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvUsedSize);
>-        SetMem (
>-          (UINT8 *) NewFvBuffer + FvUsedSize,
>-          (UINTN) (FvLength - FvUsedSize),
>-          EraseByte
>-          );
>-      } else {
>-        CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
>+
>+      DEBUG ((
>+        DEBUG_INFO,
>+        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
>+        __FUNCTION__,
>+        FvHeader,
>+        FvAlignment
>+        ));
>+
>+      //
>+      // Check FvImage alignment.
>+      //
>+      if ((UINTN) FvHeader % FvAlignment != 0) {
>+        FvLength    = ReadUnaligned64 (&FvHeader->FvLength);
>+        NewFvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32)
>FvLength), FvAlignment);
>+        if (NewFvBuffer == NULL) {
>+          Status = EFI_OUT_OF_RESOURCES;
>+          break;
>+        }
>+        if (GetFvUsedSize (FvHeader, &FvUsedSize, &EraseByte)) {
>+          //
>+          // Copy the used bytes and fill the rest with the erase value.
>+          //
>+          CopyMem (NewFvBuffer, FvHeader, (UINTN) FvUsedSize);
>+          SetMem (
>+            (UINT8 *) NewFvBuffer + FvUsedSize,
>+            (UINTN) (FvLength - FvUsedSize),
>+            EraseByte
>+            );
>+        } else {
>+          CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
>+        }
>+        FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
>       }
>-      FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*) NewFvBuffer;
>     }
>-  }
>
>-  Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle,
>&ParentFvImageInfo);
>-  ASSERT_EFI_ERROR (Status);
>+    Status = ParentFvPpi->GetVolumeInfo (ParentFvPpi, ParentFvHandle,
>&ParentFvImageInfo);
>+    ASSERT_EFI_ERROR (Status);
>
>-  Status = ParentFvPpi->GetFileInfo (ParentFvPpi, ParentFvFileHandle,
>&FileInfo);
>-  ASSERT_EFI_ERROR (Status);
>-
>-  //
>-  // Install FvInfo(2) Ppi
>-  // NOTE: FvInfo2 must be installed before FvInfo so that recursive
>processing of encapsulated
>-  // FVs inherit the proper AuthenticationStatus.
>-  //
>-  PeiServicesInstallFvInfo2Ppi(
>-    &FvHeader->FileSystemGuid,
>-    (VOID**)FvHeader,
>-    (UINT32)FvHeader->FvLength,
>-    &ParentFvImageInfo.FvName,
>-    &FileInfo.FileName,
>-    AuthenticationStatus
>-    );
>+    Status = ParentFvPpi->GetFileInfo (ParentFvPpi, ParentFvFileHandle,
>&FileInfo);
>+    ASSERT_EFI_ERROR (Status);
>
>-  PeiServicesInstallFvInfoPpi (
>-    &FvHeader->FileSystemGuid,
>-    (VOID**) FvHeader,
>-    (UINT32) FvHeader->FvLength,
>-    &ParentFvImageInfo.FvName,
>-    &FileInfo.FileName
>-    );
>+    //
>+    // Install FvInfo(2) Ppi
>+    // NOTE: FvInfo2 must be installed before FvInfo so that recursive
>processing of encapsulated
>+    // FVs inherit the proper AuthenticationStatus.
>+    //
>+    PeiServicesInstallFvInfo2Ppi(
>+      &FvHeader->FileSystemGuid,
>+      (VOID**)FvHeader,
>+      (UINT32)FvHeader->FvLength,
>+      &ParentFvImageInfo.FvName,
>+      &FileInfo.FileName,
>+      AuthenticationStatus
>+      );
>+
>+    PeiServicesInstallFvInfoPpi (
>+      &FvHeader->FileSystemGuid,
>+      (VOID**) FvHeader,
>+      (UINT32) FvHeader->FvLength,
>+      &ParentFvImageInfo.FvName,
>+      &FileInfo.FileName
>+      );
>
>-  //
>-  // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase
>-  //
>-  BuildFvHob (
>-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>-    FvHeader->FvLength
>-    );
>+    //
>+    // Inform the extracted FvImage to Fv HOB consumer phase, i.e. DXE
>phase
>+    //
>+    BuildFvHob (
>+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>+      FvHeader->FvLength
>+      );
>
>-  //
>-  // Makes the encapsulated volume show up in DXE phase to skip processing
>of
>-  // encapsulated file again.
>-  //
>-  BuildFv2Hob (
>-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>-    FvHeader->FvLength,
>-    &ParentFvImageInfo.FvName,
>-    &FileInfo.FileName
>-    );
>+    //
>+    // Makes the encapsulated volume show up in DXE phase to skip
>processing of
>+    // encapsulated file again.
>+    //
>+    BuildFv2Hob (
>+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>+      FvHeader->FvLength,
>+      &ParentFvImageInfo.FvName,
>+      &FileInfo.FileName
>+      );
>
>-  //
>-  // Build FV3 HOB with authentication status to be propagated to DXE.
>-  //
>-  BuildFv3Hob (
>-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>-    FvHeader->FvLength,
>-    AuthenticationStatus,
>-    TRUE,
>-    &ParentFvImageInfo.FvName,
>-    &FileInfo.FileName
>-    );
>+    //
>+    // Build FV3 HOB with authentication status to be propagated to DXE.
>+    //
>+    BuildFv3Hob (
>+      (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
>+      FvHeader->FvLength,
>+      AuthenticationStatus,
>+      TRUE,
>+      &ParentFvImageInfo.FvName,
>+      &FileInfo.FileName
>+      );
>+
>+    Index++;
>+  } while (TRUE);
>
>-  return EFI_SUCCESS;
>+  if (Index > 0) {
>+    //
>+    // At least one FvImage has been processed successfully.
>+    //
>+    return EFI_SUCCESS;
>+  } else {
>+    return Status;
>+  }
> }
>
> /**
>diff --git a/MdeModulePkg/Core/Pei/PeiMain.h
>b/MdeModulePkg/Core/Pei/PeiMain.h
>index e2f8cd9c7758..6469436b8f79 100644
>--- a/MdeModulePkg/Core/Pei/PeiMain.h
>+++ b/MdeModulePkg/Core/Pei/PeiMain.h
>@@ -1258,7 +1258,7 @@ SecurityPpiNotifyCallback (
>   );
>
> /**
>-  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
>+  Get Fv image(s) from the FV type file, then install FV INFO(2) ppi, Build FV(2,
>3) hob.
>
>   @param PrivateData          PeiCore's private data structure
>   @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent
>Fv image that contain this Fv image.
>--
>2.7.0.windows.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-30 10:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-29  9:37 [PATCH 0/2] Core: Handle multiple FV images in one FV file Star Zeng
2018-08-29  9:37 ` [PATCH 1/2] MdeModulePkg PeiCore: " Star Zeng
2018-08-30 10:02   ` Gao, Liming
2018-08-29  9:37 ` [PATCH 2/2] MdeModulePkg DxeCore: " Star Zeng
2018-08-30  9:54   ` Gao, Liming
2018-08-30  9:59     ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox