public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule
@ 2021-10-19 16:10 Bob Morgan
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Morgan @ 2021-10-19 16:10 UTC (permalink / raw)
  To: devel; +Cc: Bob Morgan, Jian J Wang, Liming Gao, Guomin Jiang

Enhance RelocateCapsuleToRam() to skip creation of the Capsule on Disk
file name capsule if PcdSupportUpdateCapsuleReset feature is not enabled.
This avoids an EFI_UNSUPPORTED return status from UpdateCapsule() when the
file name capsule is encountered and PcdSupportUpdateCapsuleReset is FALSE.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Bob Morgan <bobm@nvidia.com>
---
 .../Library/DxeCapsuleLibFmp/CapsuleOnDisk.c  | 19 ++++++++++++++++---
 .../DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
index 4c32c6cdcf..e65e335585 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
@@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
   UINT8                         *StringBuf;
   UINTN                         StringSize;
   UINTN                         TotalStringSize;
+  UINTN                         CapsulesToProcess;
 
   CapsuleOnDiskBuf = NULL;
   BlockDescriptors = NULL;
@@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
     TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
   }
 
+  // If Persist Across Reset isn't supported, skip the file name strings capsule
+  if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {
+    CapsulesToProcess = CapsuleOnDiskNum;
+    goto BuildSg;
+  }
+  CapsulesToProcess = CapsuleOnDiskNum + 1;
+
   FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
   if (FileNameCapsule == NULL) {
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name capsule.\n"));
@@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
   //
   // 3. Build Gather list for the capsules
   //
-  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum + 1, &BlockDescriptors);
+BuildSg:
+  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsulesToProcess, &BlockDescriptors);
   if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
     FreePool (CapsuleBuffer);
     FreePool (CapsuleSize);
-    FreePool (FileNameCapsule);
+    if (FileNameCapsule != NULL) {
+      FreePool (FileNameCapsule);
+    }
     return EFI_OUT_OF_RESOURCES;
   }
 
   //
   // 4. Call UpdateCapsule() service
   //
-  Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer, CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);
+  Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
+                               CapsulesToProcess,
+                               (UINTN) BlockDescriptors);
 
   return Status;
 }
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 05de4299fb..4932479d42 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -68,6 +68,9 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath                     ## SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName                    ## CONSUMES
 
+[FeaturePcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ## CONSUMES
+
 [Protocols]
   gEsrtManagementProtocolGuid                   ## CONSUMES
   gEfiFirmwareManagementProtocolGuid            ## CONSUMES
-- 
2.17.1


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

* [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule
@ 2021-11-02 20:40 Bob Morgan
  2021-11-03  2:05 ` 回复: " gaoliming
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Morgan @ 2021-11-02 20:40 UTC (permalink / raw)
  To: devel; +Cc: Bob Morgan, Jian J Wang, Liming Gao, Guomin Jiang

Enhance RelocateCapsuleToRam() to skip creation of the Capsule on Disk
file name capsule if PcdSupportUpdateCapsuleReset feature is not enabled.
This avoids an EFI_UNSUPPORTED return status from UpdateCapsule() when the
file name capsule is encountered and PcdSupportUpdateCapsuleReset is FALSE.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Bob Morgan <bobm@nvidia.com>
---
 .../Library/DxeCapsuleLibFmp/CapsuleOnDisk.c  | 19 ++++++++++++++++---
 .../DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
index 4c32c6cdcf..814c5400fe 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
@@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
   UINT8                         *StringBuf;
   UINTN                         StringSize;
   UINTN                         TotalStringSize;
+  UINTN                         CapsulesToProcess;
 
   CapsuleOnDiskBuf = NULL;
   BlockDescriptors = NULL;
@@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
     TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
   }
 
+  // If Persist Across Reset isn't supported, skip the file name strings capsule
+  if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {
+    CapsulesToProcess = CapsuleOnDiskNum;
+    goto BuildGather;
+  }
+  CapsulesToProcess = CapsuleOnDiskNum + 1;
+
   FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
   if (FileNameCapsule == NULL) {
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name capsule.\n"));
@@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
   //
   // 3. Build Gather list for the capsules
   //
-  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum + 1, &BlockDescriptors);
+BuildGather:
+  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsulesToProcess, &BlockDescriptors);
   if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
     FreePool (CapsuleBuffer);
     FreePool (CapsuleSize);
-    FreePool (FileNameCapsule);
+    if (FileNameCapsule != NULL) {
+      FreePool (FileNameCapsule);
+    }
     return EFI_OUT_OF_RESOURCES;
   }
 
   //
   // 4. Call UpdateCapsule() service
   //
-  Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer, CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);
+  Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
+                               CapsulesToProcess,
+                               (UINTN) BlockDescriptors);
 
   return Status;
 }
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 05de4299fb..4932479d42 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -68,6 +68,9 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath                     ## SOMETIMES_CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName                    ## CONSUMES
 
+[FeaturePcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ## CONSUMES
+
 [Protocols]
   gEsrtManagementProtocolGuid                   ## CONSUMES
   gEfiFirmwareManagementProtocolGuid            ## CONSUMES
-- 
2.17.1


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

* 回复: [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule
  2021-11-02 20:40 [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule Bob Morgan
@ 2021-11-03  2:05 ` gaoliming
  0 siblings, 0 replies; 3+ messages in thread
From: gaoliming @ 2021-11-03  2:05 UTC (permalink / raw)
  To: 'Bob Morgan', devel; +Cc: 'Jian J Wang', 'Guomin Jiang'

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Bob Morgan <bobm@nvidia.com>
> 发送时间: 2021年11月3日 4:40
> 收件人: devel@edk2.groups.io
> 抄送: Bob Morgan <bobm@nvidia.com>; Jian J Wang
> <jian.j.wang@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Guomin
> Jiang <guomin.jiang@intel.com>
> 主题: [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file
> name capsule
> 
> Enhance RelocateCapsuleToRam() to skip creation of the Capsule on Disk
> file name capsule if PcdSupportUpdateCapsuleReset feature is not enabled.
> This avoids an EFI_UNSUPPORTED return status from UpdateCapsule() when
> the
> file name capsule is encountered and PcdSupportUpdateCapsuleReset is
> FALSE.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Guomin Jiang <guomin.jiang@intel.com>
> Signed-off-by: Bob Morgan <bobm@nvidia.com>
> ---
>  .../Library/DxeCapsuleLibFmp/CapsuleOnDisk.c  | 19
> ++++++++++++++++---
>  .../DxeCapsuleLibFmp/DxeCapsuleLib.inf        |  3 +++
>  2 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> index 4c32c6cdcf..814c5400fe 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
> @@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
>    UINT8                         *StringBuf;
>    UINTN                         StringSize;
>    UINTN                         TotalStringSize;
> +  UINTN                         CapsulesToProcess;
> 
>    CapsuleOnDiskBuf = NULL;
>    BlockDescriptors = NULL;
> @@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
>      TotalStringSize += StrSize
> (CapsuleOnDiskBuf[Index].FileInfo->FileName);
>    }
> 
> +  // If Persist Across Reset isn't supported, skip the file name strings
capsule
> +  if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {
> +    CapsulesToProcess = CapsuleOnDiskNum;
> +    goto BuildGather;
> +  }
> +  CapsulesToProcess = CapsuleOnDiskNum + 1;
> +
>    FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) +
> TotalStringSize);
>    if (FileNameCapsule == NULL) {
>      DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name
> capsule.\n"));
> @@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
>    //
>    // 3. Build Gather list for the capsules
>    //
> -  Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum
+
> 1, &BlockDescriptors);
> +BuildGather:
> +  Status = BuildGatherList (CapsuleBuffer, CapsuleSize,
CapsulesToProcess,
> &BlockDescriptors);
>    if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
>      FreePool (CapsuleBuffer);
>      FreePool (CapsuleSize);
> -    FreePool (FileNameCapsule);
> +    if (FileNameCapsule != NULL) {
> +      FreePool (FileNameCapsule);
> +    }
>      return EFI_OUT_OF_RESOURCES;
>    }
> 
>    //
>    // 4. Call UpdateCapsule() service
>    //
> -  Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer,
> CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);
> +  Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
> +                               CapsulesToProcess,
> +                               (UINTN) BlockDescriptors);
> 
>    return Status;
>  }
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index 05de4299fb..4932479d42 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -68,6 +68,9 @@
>    gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath
> ## SOMETIMES_CONSUMES
>    gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName
> ## CONSUMES
> 
> +[FeaturePcd]
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ##
> CONSUMES
> +
>  [Protocols]
>    gEsrtManagementProtocolGuid                   ## CONSUMES
>    gEfiFirmwareManagementProtocolGuid            ## CONSUMES
> --
> 2.17.1




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

end of thread, other threads:[~2021-11-03  2:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-02 20:40 [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule Bob Morgan
2021-11-03  2:05 ` 回复: " gaoliming
  -- strict thread matches above, loose matches on Subject: below --
2021-10-19 16:10 Bob Morgan

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