[edk2-devel] [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension

Oleksiy Yakovlev posted 6 patches 5 years, 9 months ago
There is a newer version of this series
[edk2-devel] [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension
Posted by Oleksiy Yakovlev 5 years, 9 months ago
Add bitmask to structure which gives a binary-inspectable mechanism to
determine if a capsule contains an authentication section or depex section.
(UEFI 2.8 errata a, mantis 2026)

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>

Reviewed-by: Wei6 Xu <wei6.xu@intel.com>
---
 .../RecoveryModuleLoadPei/RecoveryModuleLoadPei.c          | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
index 53b821c..307060b 100644
--- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
+++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
@@ -328,10 +328,11 @@ ValidateFmpCapsule (
       DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
       return EFI_INVALID_PARAMETER;
     }
-    if (ImageHeader->Version < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
+    if (ImageHeader->Version == 1) {
       FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+    } else {
+      FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
     }
-
     // No overflow
     if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader->UpdateVendorCodeSize) {
       DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
@@ -639,9 +640,14 @@ ProcessFmpCapsuleImage (
     } else {
       //
       // If the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER is version 1, only match ImageTypeId.
-      // Header should exclude UpdateHardwareInstance field
+      // Header should exclude UpdateHardwareInstance field.
+      // If version is 2 Header should exclude ImageCapsuleSupport field.
       //
-      Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+      if (ImageHeader->Version == 1) {
+        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+      } else {
+        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
+      }
     }
 
     Status = ProcessRecoveryImage (Image, ImageHeader->UpdateImageSize);
-- 
2.9.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI).  This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited.  Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59476): https://edk2.groups.io/g/devel/message/59476
Mute This Topic: https://groups.io/mt/74193810/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension
Posted by Zhang, Chao B 5 years, 9 months ago
Hi Yakov:
  Please add comment for V1 and V2 check.  With that change reviewed-by: Chao Zhang <chao.b.zhang@intel.com>

-----Original Message-----
From: Oleksiy Yakovlev <oleksiyy@ami.com> 
Sent: Thursday, May 14, 2020 6:40 AM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Felixp@ami.com; oleksiyy@ami.com
Subject: [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension

Add bitmask to structure which gives a binary-inspectable mechanism to determine if a capsule contains an authentication section or depex section.
(UEFI 2.8 errata a, mantis 2026)

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>

Reviewed-by: Wei6 Xu <wei6.xu@intel.com>
---
 .../RecoveryModuleLoadPei/RecoveryModuleLoadPei.c          | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
index 53b821c..307060b 100644
--- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
+++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoa
+++ dPei.c
@@ -328,10 +328,11 @@ ValidateFmpCapsule (
       DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
       return EFI_INVALID_PARAMETER;
     }
-    if (ImageHeader->Version < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
+    if (ImageHeader->Version == 1) {
       FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+    } else {
+      FmpImageHeaderSize = 
+ OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, 
+ ImageCapsuleSupport);
     }
-
     // No overflow
     if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader->UpdateVendorCodeSize) {
       DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
@@ -639,9 +640,14 @@ ProcessFmpCapsuleImage (
     } else {
       //
       // If the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER is version 1, only match ImageTypeId.
-      // Header should exclude UpdateHardwareInstance field
+      // Header should exclude UpdateHardwareInstance field.
+      // If version is 2 Header should exclude ImageCapsuleSupport field.
       //
-      Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+      if (ImageHeader->Version == 1) {
+        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+      } else {
+        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
+      }
     }
 
     Status = ProcessRecoveryImage (Image, ImageHeader->UpdateImageSize);
--
2.9.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary to American Megatrends (AMI).  This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited.  Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59486): https://edk2.groups.io/g/devel/message/59486
Mute This Topic: https://groups.io/mt/74193810/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension
Posted by Liming Gao 5 years, 9 months ago
Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Oleksiy Yakovlev <oleksiyy@ami.com>
> Sent: Thursday, May 14, 2020 6:40 AM
> To: devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu,
> Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>; Felixp@ami.com;
> oleksiyy@ami.com
> Subject: [PATCH V6 6/6] SignedCapsulePkg: Add FMP Capsule Image Header extension
> 
> Add bitmask to structure which gives a binary-inspectable mechanism to
> determine if a capsule contains an authentication section or depex section.
> (UEFI 2.8 errata a, mantis 2026)
> 
> Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>
> 
> Reviewed-by: Wei6 Xu <wei6.xu@intel.com>
> ---
>  .../RecoveryModuleLoadPei/RecoveryModuleLoadPei.c          | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
> b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
> index 53b821c..307060b 100644
> --- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
> +++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
> @@ -328,10 +328,11 @@ ValidateFmpCapsule (
>        DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
>        return EFI_INVALID_PARAMETER;
>      }
> -    if (ImageHeader->Version < EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
> +    if (ImageHeader->Version == 1) {
>        FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
> +    } else {
> +      FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
>      }
> -
>      // No overflow
>      if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader-
> >UpdateVendorCodeSize) {
>        DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n",
> FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
> @@ -639,9 +640,14 @@ ProcessFmpCapsuleImage (
>      } else {
>        //
>        // If the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER is version 1, only match ImageTypeId.
> -      // Header should exclude UpdateHardwareInstance field
> +      // Header should exclude UpdateHardwareInstance field.
> +      // If version is 2 Header should exclude ImageCapsuleSupport field.
>        //
> -      Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER,
> UpdateHardwareInstance);
> +      if (ImageHeader->Version == 1) {
> +        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER,
> UpdateHardwareInstance);
> +      } else {
> +        Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
> +      }
>      }
> 
>      Status = ProcessRecoveryImage (Image, ImageHeader->UpdateImageSize);
> --
> 2.9.0.windows.1
> 
> 
> Please consider the environment before printing this email.
> 
> The information contained in this message may be confidential and proprietary to American Megatrends (AMI).  This communication
> is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is
> not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited.  Please
> promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59501): https://edk2.groups.io/g/devel/message/59501
Mute This Topic: https://groups.io/mt/74193810/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-