public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support
@ 2017-11-29 10:14 Star Zeng
  2017-11-29 10:14 ` [PATCH V2 1/4] MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions Star Zeng
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Star Zeng @ 2017-11-29 10:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao

V2:
The first version did not adjust ExtEntryList in the while loop
of [PATCH 2/4] and [PATCH 4/4], it is a bug and fixed in this V2.

The USED_SIZE FV_EXT_TYPE is introduced by PI 1.6 spec.

The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.

When the FV gets shadowed into memory you only need to copy the used
bytes into memory and fill the rest of the memory buffer with the
erase value.

Cc: Liming Gao <liming.gao@intel.com>

Star Zeng (4):
  MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions
  MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE
  MdeModulePkg DxeCore: Check FvImage alignment
  MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE

 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 115 +++++++++++++++++++++++---
 MdeModulePkg/Core/Pei/FwVol/FwVol.c           |  91 +++++++++++++++++++-
 MdePkg/Include/Pi/PiFirmwareVolume.h          |  23 +++++-
 3 files changed, 211 insertions(+), 18 deletions(-)

-- 
2.7.0.windows.1



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

* [PATCH V2 1/4] MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions
  2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
@ 2017-11-29 10:14 ` Star Zeng
  2017-11-29 10:14 ` [PATCH V2 2/4] MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Star Zeng @ 2017-11-29 10:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao

The definitions are introduced by PI 1.6 spec.

The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.

When the FV gets shadowed into memory you only need to copy the used
bytes into memory and fill the rest of the memory buffer with the
erase value.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdePkg/Include/Pi/PiFirmwareVolume.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Pi/PiFirmwareVolume.h b/MdePkg/Include/Pi/PiFirmwareVolume.h
index 79fde131902e..2482a7f96add 100644
--- a/MdePkg/Include/Pi/PiFirmwareVolume.h
+++ b/MdePkg/Include/Pi/PiFirmwareVolume.h
@@ -1,7 +1,7 @@
 /** @file
   The firmware volume related definitions in PI.
 
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -11,7 +11,7 @@
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
   @par Revision Reference:
-  PI Version 1.3
+  PI Version 1.6
 
 **/
 
@@ -231,4 +231,23 @@ typedef struct {
   ///
 } EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
 
+#define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
+
+///
+/// The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
+/// out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.
+///
+typedef struct {
+  ///
+  /// Standard extension entry, with the type EFI_FV_EXT_TYPE_USED_SIZE_TYPE.
+  ///
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY     Hdr;
+  ///
+  /// The number of bytes of the FV that are in uses. The remaining
+  /// EFI_FIRMWARE_VOLUME_HEADER FvLength minus UsedSize bytes in
+  /// the FV must contain the value implied by EFI_FVB2_ERASE_POLARITY.
+  ///
+  UINT32                            UsedSize;
+} EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;
+
 #endif
-- 
2.7.0.windows.1



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

* [PATCH V2 2/4] MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE
  2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
  2017-11-29 10:14 ` [PATCH V2 1/4] MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions Star Zeng
@ 2017-11-29 10:14 ` Star Zeng
  2017-11-29 10:14 ` [PATCH V2 3/4] MdeModulePkg DxeCore: Check FvImage alignment Star Zeng
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Star Zeng @ 2017-11-29 10:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao

The USED_SIZE FV_EXT_TYPE is introduced by PI 1.6 spec.

The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.

When the FV gets shadowed into memory you only need to copy the used
bytes into memory and fill the rest of the memory buffer with the
erase value.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Core/Pei/FwVol/FwVol.c | 90 +++++++++++++++++++++++++++++++++++--
 1 file changed, 87 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index 3da90f95312d..7cb295c2c679 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -1295,6 +1295,68 @@ PeiFfsGetVolumeInfo (
 }
 
 /**
+  Find USED_SIZE FV_EXT_TYPE entry in FV extension header and get the FV used size.
+
+  @param[in]  FvHeader      Pointer to FV header.
+  @param[out] FvUsedSize    Pointer to FV used size returned,
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.
+  @param[out] EraseByte     Pointer to erase byte returned,
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.
+
+  @retval TRUE              USED_SIZE FV_EXT_TYPE entry is found,
+                            FV used size and erase byte are returned.
+  @retval FALSE             No USED_SIZE FV_EXT_TYPE entry found.
+
+**/
+BOOLEAN
+GetFvUsedSize (
+  IN EFI_FIRMWARE_VOLUME_HEADER     *FvHeader,
+  OUT UINT32                        *FvUsedSize,
+  OUT UINT8                         *EraseByte
+  )
+{
+  UINT16                                        ExtHeaderOffset;
+  EFI_FIRMWARE_VOLUME_EXT_HEADER                *ExtHeader;
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY                 *ExtEntryList;
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE  *ExtEntryUsedSize;
+
+  ExtHeaderOffset = ReadUnaligned16 (&FvHeader->ExtHeaderOffset);
+  if (ExtHeaderOffset != 0) {
+    ExtHeader    = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FvHeader + ExtHeaderOffset);
+    ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *) (ExtHeader + 1);
+    while ((UINTN) ExtEntryList < ((UINTN) ExtHeader + ReadUnaligned32 (&ExtHeader->ExtHeaderSize))) {
+      if (ReadUnaligned16 (&ExtEntryList->ExtEntryType) == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {
+        //
+        // USED_SIZE FV_EXT_TYPE entry is found.
+        //
+        ExtEntryUsedSize = (EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *) ExtEntryList;
+        *FvUsedSize = ReadUnaligned32 (&ExtEntryUsedSize->UsedSize);
+        if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ERASE_POLARITY) != 0) {
+          *EraseByte = 0xFF;
+        } else {
+          *EraseByte = 0;
+        }
+        DEBUG ((
+          DEBUG_INFO,
+          "FV at 0x%x has 0x%x used size, and erase byte is 0x%02x\n",
+          FvHeader,
+          *FvUsedSize,
+          *EraseByte
+          ));
+        return TRUE;
+      }
+      ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *)
+                     ((UINT8 *) ExtEntryList + ReadUnaligned16 (&ExtEntryList->ExtEntrySize));
+    }
+  }
+
+  //
+  // No USED_SIZE FV_EXT_TYPE entry found.
+  //
+  return FALSE;
+}
+
+/**
   Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.
 
   @param PrivateData          PeiCore's private data structure
@@ -1326,7 +1388,9 @@ ProcessFvFile (
   EFI_FV_FILE_INFO              FileInfo;
   UINT64                        FvLength;
   UINT32                        AuthenticationStatus;
-  
+  UINT32                        FvUsedSize;
+  UINT8                         EraseByte;
+
   //
   // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
   // been extracted.
@@ -1391,8 +1455,16 @@ ProcessFvFile (
       FvAlignment = 8;
     }
 
+    DEBUG ((
+      DEBUG_INFO,
+      "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
+      __FUNCTION__,
+      FvHeader,
+      FvAlignment
+      ));
+
     //
-    // Check FvImage
+    // Check FvImage alignment.
     //
     if ((UINTN) FvHeader % FvAlignment != 0) {
       FvLength    = ReadUnaligned64 (&FvHeader->FvLength);
@@ -1400,7 +1472,19 @@ ProcessFvFile (
       if (NewFvBuffer == NULL) {
         return EFI_OUT_OF_RESOURCES;
       }
-      CopyMem (NewFvBuffer, FvHeader, (UINTN) FvLength);
+      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;
     }
   }
-- 
2.7.0.windows.1



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

* [PATCH V2 3/4] MdeModulePkg DxeCore: Check FvImage alignment
  2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
  2017-11-29 10:14 ` [PATCH V2 1/4] MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions Star Zeng
  2017-11-29 10:14 ` [PATCH V2 2/4] MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
@ 2017-11-29 10:14 ` Star Zeng
  2017-11-29 10:14 ` [PATCH V2 4/4] MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
  2017-11-30 11:09 ` [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Gao, Liming
  4 siblings, 0 replies; 6+ messages in thread
From: Star Zeng @ 2017-11-29 10:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao

No need to allocate aligned buffer if FvImage has been
at required alignment.

Then the code logic will be aligned with ProcessFvFile() in
MdeModulePkg/Core/Pei/FwVol/FwVol.c.

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

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index 5eee71bb2cd3..c7b9224c0e33 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -1023,32 +1023,38 @@ CoreProcessFvImageFile (
     // 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 ((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
+    if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) {
       //
       // Get FvHeader alignment
       //
-      FvAlignment = 1 << ((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
+      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;
       }
+
       //
-      // 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.
         //
-        CopyMem (AlignedBuffer, Buffer, BufferSize);
-        FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
-        CoreFreePool (Buffer);
-        Buffer = NULL;
+        AlignedBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES (BufferSize), (UINTN) FvAlignment);
+        if (AlignedBuffer == NULL) {
+          FreePool (Buffer);
+          return EFI_OUT_OF_RESOURCES;
+        } else {
+          //
+          // Move FvImage into the aligned buffer and release the original buffer.
+          //
+          CopyMem (AlignedBuffer, Buffer, BufferSize);
+          FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) AlignedBuffer;
+          CoreFreePool (Buffer);
+          Buffer = NULL;
+        }
       }
     }
     //
-- 
2.7.0.windows.1



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

* [PATCH V2 4/4] MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE
  2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
                   ` (2 preceding siblings ...)
  2017-11-29 10:14 ` [PATCH V2 3/4] MdeModulePkg DxeCore: Check FvImage alignment Star Zeng
@ 2017-11-29 10:14 ` Star Zeng
  2017-11-30 11:09 ` [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Gao, Liming
  4 siblings, 0 replies; 6+ messages in thread
From: Star Zeng @ 2017-11-29 10:14 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Liming Gao

The USED_SIZE FV_EXT_TYPE is introduced by PI 1.6 spec.

The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.

When the FV gets shadowed into memory you only need to copy the used
bytes into memory and fill the rest of the memory buffer with the
erase value.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 84 ++++++++++++++++++++++++++-
 1 file changed, 83 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
index c7b9224c0e33..088cd8106313 100644
--- a/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c
@@ -938,7 +938,67 @@ FvFoundInHobFv2 (
   return FALSE;
 }
 
+/**
+  Find USED_SIZE FV_EXT_TYPE entry in FV extension header and get the FV used size.
+
+  @param[in]  FvHeader      Pointer to FV header.
+  @param[out] FvUsedSize    Pointer to FV used size returned,
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.
+  @param[out] EraseByte     Pointer to erase byte returned,
+                            only valid if USED_SIZE FV_EXT_TYPE entry is found.
 
+  @retval TRUE              USED_SIZE FV_EXT_TYPE entry is found,
+                            FV used size and erase byte are returned.
+  @retval FALSE             No USED_SIZE FV_EXT_TYPE entry found.
+
+**/
+BOOLEAN
+GetFvUsedSize (
+  IN EFI_FIRMWARE_VOLUME_HEADER     *FvHeader,
+  OUT UINT32                        *FvUsedSize,
+  OUT UINT8                         *EraseByte
+  )
+{
+  UINT16                                        ExtHeaderOffset;
+  EFI_FIRMWARE_VOLUME_EXT_HEADER                *ExtHeader;
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY                 *ExtEntryList;
+  EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE  *ExtEntryUsedSize;
+
+  ExtHeaderOffset = ReadUnaligned16 (&FvHeader->ExtHeaderOffset);
+  if (ExtHeaderOffset != 0) {
+    ExtHeader    = (EFI_FIRMWARE_VOLUME_EXT_HEADER *) ((UINT8 *) FvHeader + ExtHeaderOffset);
+    ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *) (ExtHeader + 1);
+    while ((UINTN) ExtEntryList < ((UINTN) ExtHeader + ReadUnaligned32 (&ExtHeader->ExtHeaderSize))) {
+      if (ReadUnaligned16 (&ExtEntryList->ExtEntryType) == EFI_FV_EXT_TYPE_USED_SIZE_TYPE) {
+        //
+        // USED_SIZE FV_EXT_TYPE entry is found.
+        //
+        ExtEntryUsedSize = (EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE *) ExtEntryList;
+        *FvUsedSize = ReadUnaligned32 (&ExtEntryUsedSize->UsedSize);
+        if ((ReadUnaligned32 (&FvHeader->Attributes) & EFI_FVB2_ERASE_POLARITY) != 0) {
+          *EraseByte = 0xFF;
+        } else {
+          *EraseByte = 0;
+        }
+        DEBUG ((
+          DEBUG_INFO,
+          "FV at 0x%x has 0x%x used size, and erase byte is 0x%02x\n",
+          FvHeader,
+          *FvUsedSize,
+          *EraseByte
+          ));
+        return TRUE;
+      }
+      ExtEntryList = (EFI_FIRMWARE_VOLUME_EXT_ENTRY *)
+                     ((UINT8 *) ExtEntryList + ReadUnaligned16 (&ExtEntryList->ExtEntrySize));
+    }
+  }
+
+  //
+  // No USED_SIZE FV_EXT_TYPE entry found.
+  //
+  return FALSE;
+}
 
 /**
   Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
@@ -968,6 +1028,8 @@ CoreProcessFvImageFile (
   EFI_FIRMWARE_VOLUME_HEADER          *FvHeader;
   UINT32                              FvAlignment;
   EFI_DEVICE_PATH_PROTOCOL            *FvFileDevicePath;
+  UINT32                              FvUsedSize;
+  UINT8                               EraseByte;
 
   //
   // Read the first (and only the first) firmware volume section
@@ -1035,6 +1097,14 @@ CoreProcessFvImageFile (
         FvAlignment = 8;
       }
 
+      DEBUG ((
+        DEBUG_INFO,
+        "%a() FV at 0x%x, FvAlignment required is 0x%x\n",
+        __FUNCTION__,
+        FvHeader,
+        FvAlignment
+        ));
+
       //
       // Check FvImage alignment.
       //
@@ -1050,7 +1120,19 @@ CoreProcessFvImageFile (
           //
           // Move FvImage into the aligned buffer and release the original buffer.
           //
-          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;
           CoreFreePool (Buffer);
           Buffer = NULL;
-- 
2.7.0.windows.1



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

* Re: [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support
  2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
                   ` (3 preceding siblings ...)
  2017-11-29 10:14 ` [PATCH V2 4/4] MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
@ 2017-11-30 11:09 ` Gao, Liming
  4 siblings, 0 replies; 6+ messages in thread
From: Gao, Liming @ 2017-11-30 11:09 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org

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

> -----Original Message-----
> From: Zeng, Star
> Sent: Wednesday, November 29, 2017 6:15 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support
> 
> V2:
> The first version did not adjust ExtEntryList in the while loop
> of [PATCH 2/4] and [PATCH 4/4], it is a bug and fixed in this V2.
> 
> The USED_SIZE FV_EXT_TYPE is introduced by PI 1.6 spec.
> 
> The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
> out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.
> 
> When the FV gets shadowed into memory you only need to copy the used
> bytes into memory and fill the rest of the memory buffer with the
> erase value.
> 
> Cc: Liming Gao <liming.gao@intel.com>
> 
> Star Zeng (4):
>   MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions
>   MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE
>   MdeModulePkg DxeCore: Check FvImage alignment
>   MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE
> 
>  MdeModulePkg/Core/Dxe/Dispatcher/Dispatcher.c | 115 +++++++++++++++++++++++---
>  MdeModulePkg/Core/Pei/FwVol/FwVol.c           |  91 +++++++++++++++++++-
>  MdePkg/Include/Pi/PiFirmwareVolume.h          |  23 +++++-
>  3 files changed, 211 insertions(+), 18 deletions(-)
> 
> --
> 2.7.0.windows.1



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

end of thread, other threads:[~2017-11-30 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29 10:14 [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Star Zeng
2017-11-29 10:14 ` [PATCH V2 1/4] MdePkg PiFirmwareVolume.h: Add USED_SIZE FV_EXT_TYPE definitions Star Zeng
2017-11-29 10:14 ` [PATCH V2 2/4] MdeModulePkg PeiCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
2017-11-29 10:14 ` [PATCH V2 3/4] MdeModulePkg DxeCore: Check FvImage alignment Star Zeng
2017-11-29 10:14 ` [PATCH V2 4/4] MdeModulePkg DxeCore: Support USED_SIZE FV_EXT_TYPE Star Zeng
2017-11-30 11:09 ` [PATCH 0/4] Add USED_SIZE FV_EXT_TYPE support Gao, Liming

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