From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: eric.jin@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Thu, 01 Aug 2019 01:45:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 01:45:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,333,1559545200"; d="scan'208";a="372534839" Received: from jjin9-mobl.ccr.corp.intel.com ([10.239.192.65]) by fmsmga006.fm.intel.com with ESMTP; 01 Aug 2019 01:45:57 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Michael Turner , Bret Barkelew , Liming Gao , Michael D Kinney Subject: [PATCH 08/14] FmpDevicePkg/FmpDxe: Add PcdFmpDeviceImageTypeIdGuid Date: Thu, 1 Aug 2019 16:45:52 +0800 Message-Id: <20190801084552.17528-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 Add PCD PcdFmpDeviceImageTypeIdGuid that contains an Image Type ID GUID value that is used if one is not provided by FmpDeviceLib. If this PCD is not a valid GUID value, then gEfiCallerIdGuid is used. Update FmpDevicePkg DSC to use PcdFmpDeviceImageTypeIdGuid as a PatchableInModule PCD. This content is based on the following commit. https://github.com/microsoft/mu_tiano_plus/commit/a2c7da88d3a73dbe9b6b75952d6866179c905f28#diff-025d4889f6d3a482b49638a25e432d6d Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Liming Gao Signed-off-by: Michael D Kinney Reviewed-by: Eric Jin --- FmpDevicePkg/FmpDevicePkg.dec | 5 +++++ FmpDevicePkg/FmpDevicePkg.dsc | 25 +++++++++++++++++++++++++ FmpDevicePkg/FmpDevicePkg.uni | 6 +++++- FmpDevicePkg/FmpDxe/FmpDxe.c | 20 +++++++++++++++----- FmpDevicePkg/FmpDxe/FmpDxe.inf | 1 + FmpDevicePkg/FmpDxe/FmpDxeLib.inf | 1 + 6 files changed, 52 insertions(+), 6 deletions(-) diff --git a/FmpDevicePkg/FmpDevicePkg.dec b/FmpDevicePkg/FmpDevicePkg.dec index c68dbb7153..56ed5fbb4a 100644 --- a/FmpDevicePkg/FmpDevicePkg.dec +++ b/FmpDevicePkg/FmpDevicePkg.dec @@ -96,6 +96,11 @@ # @Prompt Firmware Device Watchdog Time in Seconds. gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds|0x0|UINT8|0x4000000D + ## The Image Type ID to use if one is not provided by FmpDeviceLib. If this + # PCD is not a valid GUID value, then gEfiCallerIdGuid is used. + # @Prompt Firmware Device Image Type ID + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{0}|VOID*|0x40000010 + [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] ## One or more PKCS7 certificates used to verify a firmware device capsule # update image. Encoded using the Variable-Length Opaque Data format of RFC diff --git a/FmpDevicePkg/FmpDevicePkg.dsc b/FmpDevicePkg/FmpDevicePkg.dsc index 3356571fff..4e2bd8de3d 100644 --- a/FmpDevicePkg/FmpDevicePkg.dsc +++ b/FmpDevicePkg/FmpDevicePkg.dsc @@ -66,6 +66,9 @@ [LibraryClasses.ARM] ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf +[PcdsPatchableInModule] + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{0} + [Components] # # Libraries @@ -89,6 +92,17 @@ # FILE_GUID is used as ESRT GUID # FILE_GUID = $(SYSTEM_FMP_ESRT_GUID) + + # + # Unicode name string that is used to populate FMP Image Descriptor for this capsule update module + # + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"Sample Firmware Device" + # + # Certificates used to authenticate capsule update image + # + !include BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer.gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr.inc + + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{GUID("$(SYSTEM_FMP_ESRT_GUID)")} # # Use CapsuleUpdatePolicyLib that calls the Capsule Update Policy Protocol. @@ -104,6 +118,17 @@ # FILE_GUID is used as ESRT GUID # FILE_GUID = $(DEVICE_FMP_ESRT_GUID) + + # + # Unicode name string that is used to populate FMP Image Descriptor for this capsule update module + # + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"Sample Firmware Device" + # + # Certificates used to authenticate capsule update image + # + !include BaseTools/Source/Python/Pkcs7Sign/TestRoot.cer.gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr.inc + + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid|{GUID("$(DEVICE_FMP_ESRT_GUID)")} # # Directly use a platform specific CapsuleUpdatePolicyLib instance. diff --git a/FmpDevicePkg/FmpDevicePkg.uni b/FmpDevicePkg/FmpDevicePkg.uni index cf27ed5316..b7fe643186 100644 --- a/FmpDevicePkg/FmpDevicePkg.uni +++ b/FmpDevicePkg/FmpDevicePkg.uni @@ -6,7 +6,7 @@ // Capsules. The behavior of the Firmware Management Protocol instance is // customized using libraries and PCDs. // -// Copyright (c) 2018, Intel Corporation. All rights reserved.
+// Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
// // SPDX-License-Identifier: BSD-2-Clause-Patent // @@ -53,6 +53,10 @@ "value of 0 disables the watchdog timer. The default value is 0 (watchdog" "disabled)." +#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageTypeIdGuid_PROMPT #language en-US "Firmware Device Image Type ID." +#string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDeviceImageTypeIdGuid_HELP #language en-US "The Image Type ID to use if one is not provided by FmpDeviceLib. If this" + "PCD is not a valid GUID value, then gEfiCallerIdGuid is used." + #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_PROMPT #language en-US "One or more XDR encoded PKCS7 certificates used to verify firmware device capsule update images" #string STR_gFmpDevicePkgTokenSpaceGuid_PcdFmpDevicePkcs7CertBufferXdr_HELP #language en-US "Provides one or more PKCS7 certificates used to verify a firmware device" "capsule update image. This PCD is encoded using the Variable-Length Opaque" diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 4f41543194..85b9ddee3f 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -147,7 +147,9 @@ FmpDxeProgress ( /** Returns a pointer to the ImageTypeId GUID value. An attempt is made to get the GUID value from the FmpDeviceLib. If the FmpDeviceLib does not provide - a GUID value, then gEfiCallerIdGuid is returned. + a GUID value, then PcdFmpDeviceImageTypeIdGuid is used. If the size of + PcdFmpDeviceImageTypeIdGuid is not the size of EFI_GUID, then gEfiCallerIdGuid + is returned. @return The ImageTypeId GUID @@ -159,6 +161,7 @@ GetImageTypeIdGuid ( { EFI_STATUS Status; EFI_GUID *FmpDeviceLibGuid; + UINTN ImageTypeIdGuidSize; FmpDeviceLibGuid = NULL; Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid); @@ -166,11 +169,18 @@ GetImageTypeIdGuid ( if (Status != EFI_UNSUPPORTED) { DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", mImageIdName, Status)); } - return &gEfiCallerIdGuid; - } - if (FmpDeviceLibGuid == NULL) { + } else if (FmpDeviceLibGuid == NULL) { DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n", mImageIdName)); - return &gEfiCallerIdGuid; + Status = EFI_NOT_FOUND; + } + if (EFI_ERROR (Status)) { + ImageTypeIdGuidSize = PcdGetSize (PcdFmpDeviceImageTypeIdGuid); + if (ImageTypeIdGuidSize == sizeof (EFI_GUID)) { + FmpDeviceLibGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceImageTypeIdGuid); + } else { + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Fall back to ImageTypeIdGuid of gEfiCallerIdGuid\n", mImageIdName)); + FmpDeviceLibGuid = &gEfiCallerIdGuid; + } } return FmpDeviceLibGuid; } diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf index 3b9cc628c9..21fa7e1b14 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.inf +++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf @@ -67,6 +67,7 @@ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor ## CONSUMES gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr ## CONSUMES gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## SOMETIMES_PRODUCES [Depex] diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf index a4a1daab36..d951ba7dd2 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf +++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf @@ -67,6 +67,7 @@ gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor ## CONSUMES gFmpDevicePkgTokenSpaceGuid.PcdFmpDevicePkcs7CertBufferXdr ## CONSUMES gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceTestKeySha256Digest ## CONSUMES + gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageTypeIdGuid ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## SOMETIMES_PRODUCES [Depex] -- 2.20.1.windows.1