From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com []) by mx.groups.io with SMTP id smtpd.web12.8912.1589528334338023248 for ; Fri, 15 May 2020 00:38:59 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: wei6.xu@intel.com) IronPort-SDR: XsdXppF8gkUTG3fF5X9Ujg0iPdojj/Y68gI/d3uvLcrobBZrm1ewfm43UHLN/A2xY9n3O8uGpI XRQCqaBV5PbA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2020 00:38:59 -0700 IronPort-SDR: jv2qha5L+ZCrKr4eD6VyU4CQiC8zsvo594LT8di4FTgyugyi7dFG6nizWixWh+h7EzEGm5VWwl wVzoSKE6WPxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208";a="410389860" Received: from shwdeopenpsi174.ccr.corp.intel.com ([10.239.157.39]) by orsmga004.jf.intel.com with ESMTP; 15 May 2020 00:38:58 -0700 From: "Xu, Wei6" To: devel@edk2.groups.io Cc: Oleksiy Yakovlev Subject: [edk2-devel] [PATCH 2/2] SignedCapsulePkg: Add FMP Capsule Image Header extension Date: Fri, 15 May 2020 15:38:48 +0800 Message-Id: <20200515073848.13920-3-wei6.xu@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200515073848.13920-1-wei6.xu@intel.com> References: <20200515073848.13920-1-wei6.xu@intel.com> From: Oleksiy Yakovlev 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 Signed-off-by: Wei6 Xu Reviewed-by: Chao Zhang Reviewed-by: Liming Gao --- .../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