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

Xu, Wei6 posted 2 patches 8 weeks ago

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

Posted by Xu, Wei6 8 weeks ago
From: Oleksiy Yakovlev <oleksiyy@ami.com>

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>
Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
---
 .../RecoveryModuleLoadPei/RecoveryModuleLoadPei.c       | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
index 53b821c2bb..af8e5cb84c 100644
--- a/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
+++ b/SignedCapsulePkg/Universal/RecoveryModuleLoadPei/RecoveryModuleLoadPei.c
@@ -326,12 +326,18 @@ ValidateFmpCapsule (
     if ((ImageHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) ||
         (ImageHeader->Version < 1)) {
       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) {
+    ///
+    /// Current Init ImageHeader version is 3. UpdateHardwareInstance field was added in version 2
+    /// and ImageCapsuleSupport field was added in version 3
+    ///
+    if (ImageHeader->Version == 1) {
       FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+    } else if (ImageHeader->Version == 2){
+      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));
@@ -637,13 +643,18 @@ ProcessFmpCapsuleImage (
     if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
       Image = (UINT8 *)(ImageHeader + 1);
     } 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);
     if (EFI_ERROR(Status)) {
       return Status;
-- 
2.16.2.windows.1


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

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

Re: [edk2-devel] [PATCH 2/2] SignedCapsulePkg: Add FMP Capsule Image Header extension

Posted by Oleksiy Yakovlev 8 weeks ago
Reviewed-by: Oleksiy Yakovlev <oleksiyy@ami.com>

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

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