From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.92.42.67]) by mx.groups.io with SMTP id smtpd.web11.701.1597091328133464376 for ; Mon, 10 Aug 2020 13:28:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=Lg2F1cHI; spf=pass (domain: outlook.com, ip: 40.92.42.67, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WHEBSVSiXifnC3WnpyOmCh33IbXmSz4QfaODlVMjqnXb3ZwDcfmNOxeCb1q0CqSFlemkc0AQqQLJjKcOczisq23KrAz1HQlSFBqZQhuYpTzNcEDCbj4ihJeB3aAxlliFufL07BNOEkVyEIfxOkQ9NP+GdJ7qVJaVjuy4JiUGRq7ysTBuTtd91ZVC5FAXEOxOlQUyZyOdQydiX77Jelz/BLG+CqTii/sCZrUN3YO7gnAZyvKcNUVmrSFik12N9gBThmH7Ifq86GuX5PGOi8cBS4Ix1LQhXEnlMEF3Y0hrruwdCu5/oguPW2dm8+9uyiJUUrtXUnWBRo5xkZ1LBh53oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vbgi7Mi15WLl79xfsh6XJC/FhE9F/lB9SnFSrhdcaHU=; b=iGPRRhJi5FUEbHezN+mDFW1ETGpHTRxaY18zS3y51IQo3H5dDsv0lCuGC7AukZUvZu5W+fkMfAtKrncd7qi3mzPKEeBqGOB1uT2JvEO8IcnoyiQUDtsehkftG+pZmtoJDRLB6+HeTlE8ktMYEuSZeVV0ddJ+E67aGISbhVfZvDj7jZkrz4JV4fYeAbLjxUUj2wih7jTMn6zrOZ1XVcbft8WLxJXpDapV8WLUOKR+v7OLzFDOsKZPRKSFOmUx1a7qwIQCRx89m6K41TSUsIagxwdHtig53p/lccnbiWCd4Q3nwNT9/eM1Zz8zVFqC/mIUEyB7DPCQHeyhsCfBjOEDrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vbgi7Mi15WLl79xfsh6XJC/FhE9F/lB9SnFSrhdcaHU=; b=Lg2F1cHIJOj8eE2XGHJlcpJ3B6ks2iNIaInXxViZl3MXT5Jl/3Ai1I5kZuXev3sBuDbdYr+JZvEujEZfSFdqrjifYM2w7G5mqHHaHHZhp6tK2Y/473IA4X+GmxdgBR8bDCTiUtIpTD8f1BEJ0dHC8CSz9i8iY4ry/I6a7ruMYxZjrZb0DNyeoi5qpMOjvbxKLdHe1QlzpGFw16NjhAKvn+jkyfXEFK7tAshumPhNPqRoN+TS58vKzflgdi5CqGD5Ck8jQUwA8QNrGlvabnhm+gLAjvZGLMGx3PNPMMzlBgoHSYM4qkOqQoJ7slfg3AZeq3+eHnB4RnJp7Gdcvf8SBg== Received: from MW2NAM10FT048.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::4a) by MW2NAM10HT032.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Mon, 10 Aug 2020 20:28:46 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e87::44) by MW2NAM10FT048.mail.protection.outlook.com (2a01:111:e400:7e87::98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16 via Frontend Transport; Mon, 10 Aug 2020 20:28:46 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0265551368D48FDD2C746F0F644D6F18EB03B93B5A496C2C00596938EEF99964;UpperCasedChecksum:BC44615B55508539AEF61B3B052643AD7AE8F822373C59DEFEB193E6C90D094D;SizeAsReceived:7807;Count:49 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::9856:570e:1735:974e]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::9856:570e:1735:974e%7]) with mapi id 15.20.3261.024; Mon, 10 Aug 2020 20:28:46 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io CC: Liming Gao , Michael D Kinney , Guomin Jiang , Wei6 Xu Subject: [PATCH v2 6/6] FmpDevicePkg/FmpDeviceLib: Add Last Attempt Status to Check/Set API Date: Mon, 10 Aug 2020 13:27:53 -0700 Message-ID: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20200810202753.1318-1-michael.kubacki@outlook.com> References: <20200810202753.1318-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR13CA0008.namprd13.prod.outlook.com (2603:10b6:300:16::18) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200810202753.1318-7-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:1:cc6:648f:7db1:5bf9) by MWHPR13CA0008.namprd13.prod.outlook.com (2603:10b6:300:16::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.10 via Frontend Transport; Mon, 10 Aug 2020 20:28:46 +0000 X-Mailer: git-send-email 2.28.0.windows.1 X-Microsoft-Original-Message-ID: <20200810202753.1318-7-michael.kubacki@outlook.com> X-TMN: [F6mAf9zqzXQODKVYF7LC9PH2ydONnwKSoFmTSD1V/qcHEvgteZ4PgwCfYuNhU/il] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 57ee32e1-44d1-4a63-d7e2-08d83d6bfb94 X-MS-TrafficTypeDiagnostic: MW2NAM10HT032: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6DOaMwMXzqHnK5sBUczumcDPx0kD8CfhM/M5o8p6bM7KejROH+urf4r9SPgvUkVOWgqUaHy1OS98vtWVJb6rzSVD4LPVv7HvSsSKge56GdBy0phXAj1S9BSJP3OaZFP9YKAQOmhf6TVw5iq52bvhCuQrqqfcD1/cmOqspRU7uQ84ujlEyXE7oeBDR7ywT4oO0Aeqmi6b2c2LGm62cIb7kQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: xpm++UOwoW8EsOnmOZNChIxFk+PY7BCYSgaUrP+azedMPVx0FyjMSYrhzrJw6nHG0724xQmf76hUH3QXW++5EZs7R6OMnK5DfOVv679tOko0PfuWWgqDcpf8aAlBUM3Yfu60y19kG9zI/4Yx4wApVK+obWDtT3lUrv6rCXLq3qgyvgpVjHiED1MnJrcovqMN5NTdbBmvxaC4/7dyKQ1OBQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57ee32e1-44d1-4a63-d7e2-08d83d6bfb94 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2020 20:28:46.7774 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT048.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM10HT032 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Michael Kubacki Provides the ability for a given FMP device library instance to return a Last Attempt Status code during FmpDeviceCheckImage() and FmpDeviceSetImage(). Cc: Liming Gao Cc: Michael D Kinney Cc: Guomin Jiang Cc: Wei6 Xu Signed-off-by: Michael Kubacki --- FmpDevicePkg/FmpDxe/FmpDxe.c | 36 +++++++++++++++- FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c | 42 ++++++++++++----= --- FmpDevicePkg/Include/Library/FmpDeviceLib.h | 44 +++++++++++++---= ---- 3 files changed, 92 insertions(+), 30 deletions(-) diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 84a8e15cfc17..9f55e6ba5f5d 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -1020,14 +1020,32 @@ CheckTheImageInternal ( } RawSize =3D ImageSize - AllHeaderSize; =20 + // + // Set LastAttemptStatus to successful prior to getting any potential er= ror codes from FmpDeviceLib + // + *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_SUCCESS; + // // FmpDeviceLib CheckImage function to do any specific checks // - Status =3D FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawS= ize, ImageUpdatable); + Status =3D FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawS= ize, ImageUpdatable, LastAttemptStatus); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib Check= Image failed. Status =3D %r\n", mImageIdName, Status)); } =20 + // + // LastAttemptStatus returned from the device library should either be a= generic UEFI Specification defined value or + // fall within the designated LAST_ATTEMPT_STATUS_LIBRARY_ERROR range + // + if ( + (*LastAttemptStatus < LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_CO= DE && + *LastAttemptStatus >=3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VEN= DOR_RANGE_MIN) || + (*LastAttemptStatus > LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_CO= DE)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - LastAttemptStatus = from FmpDeviceCheckImage is invalid.\n", mImageIdName)); + ASSERT (FALSE); + *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; + } + cleanup: return Status; } @@ -1356,8 +1374,22 @@ SetTheImage ( VendorCode, FmpDxeProgress, IncomingFwVersion, - AbortReason + AbortReason, + &LastAttemptStatus ); + // + // LastAttemptStatus returned from the device library should either be a= generic UEFI Specification defined value or + // fall within the designated LAST_ATTEMPT_STATUS_LIBRARY_ERROR range + // + if ( + (LastAttemptStatus < LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERROR_COD= E && + LastAttemptStatus >=3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VEND= OR_RANGE_MIN) || + (LastAttemptStatus > LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERROR_COD= E)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - LastAttemptStatus fr= om FmpDeviceSetImage is invalid.\n", mImageIdName)); + ASSERT (FALSE); + LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; + } + if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDevic= eLib failed. Status =3D %r.\n", mImageIdName, Status)); goto cleanup; diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevi= cePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c index 316de12e910c..d08b5b82d42f 100644 --- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c @@ -2,7 +2,7 @@ Provides firmware device specific services to support updates of a firmw= are image stored in a firmware device. =20 - Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation.
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -380,17 +380,22 @@ FmpDeviceGetImage ( function allows firmware update operation to validate the firmware image before FmpDeviceSetImage() is called. =20 - @param[in] Image Points to a new firmware image. - @param[in] ImageSize Size, in bytes, of a new firmware image. - @param[out] ImageUpdatable Indicates if a new firmware image is valid f= or - a firmware update to the firmware device. T= he - following values from the Firmware Managemen= t - Protocol are supported: - IMAGE_UPDATABLE_VALID - IMAGE_UPDATABLE_INVALID - IMAGE_UPDATABLE_INVALID_TYPE - IMAGE_UPDATABLE_INVALID_OLD - IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE + @param[in] Image Points to a new firmware image. + @param[in] ImageSize Size, in bytes, of a new firmware image. + @param[out] ImageUpdatable Indicates if a new firmware image is val= id for + a firmware update to the firmware device= . The + following values from the Firmware Manag= ement + Protocol are supported: + IMAGE_UPDATABLE_VALID + IMAGE_UPDATABLE_INVALID + IMAGE_UPDATABLE_INVALID_TYPE + IMAGE_UPDATABLE_INVALID_OLD + IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE + @param[out] LastAttemptStatus A pointer to a UINT32 that holds the las= t attempt + status to report back to the ESRT table = in case + of error. The return status code must fa= ll in the range of + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ER= ROR_CODE to + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ER= ROR_CODE. =20 @retval EFI_SUCCESS The image was successfully checked. Addi= tional status information is returned in @@ -404,7 +409,8 @@ EFIAPI FmpDeviceCheckImage ( IN CONST VOID *Image, IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable + OUT UINT32 *ImageUpdatable, + OUT UINT32 *LastAttemptStatus ) { return EFI_SUCCESS; @@ -453,6 +459,13 @@ FmpDeviceCheckImage ( EFI_BOOT_SERVICES.AllocatePool(). It is t= he caller's responsibility to free this buffe= r with EFI_BOOT_SERVICES.FreePool(). + @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last = attempt + status to report back to the ESRT table in= case + of error. Will only be checked when this f= untions + returns error. Returned status code falls = outside of + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERRO= R_CODE and + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERRO= R_CODE + will be converted to LAST_ATTEMPT_STATUS_E= RROR_UNSUCCESSFUL =20 @retval EFI_SUCCESS The firmware device was successfully upda= ted with the new firmware image. @@ -470,7 +483,8 @@ FmpDeviceSetImage ( IN CONST VOID *VendorCode, OP= TIONAL IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OP= TIONAL IN UINT32 CapsuleFwVersion, - OUT CHAR16 **AbortReason + OUT CHAR16 **AbortReason, + OUT UINT32 *LastAttemptStatus ) { return EFI_UNSUPPORTED; diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Inc= lude/Library/FmpDeviceLib.h index 9a89f5c2eec5..163714654d60 100644 --- a/FmpDevicePkg/Include/Library/FmpDeviceLib.h +++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h @@ -2,7 +2,7 @@ Provides firmware device specific services to support updates of a firmw= are image stored in a firmware device. =20 - Copyright (c) 2016, Microsoft Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation.
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -12,6 +12,8 @@ #ifndef __FMP_DEVICE_LIB__ #define __FMP_DEVICE_LIB__ =20 +#include +#include #include =20 /** @@ -376,17 +378,22 @@ FmpDeviceGetImage ( function allows firmware update operation to validate the firmware image before FmpDeviceSetImage() is called. =20 - @param[in] Image Points to a new firmware image. - @param[in] ImageSize Size, in bytes, of a new firmware image. - @param[out] ImageUpdatable Indicates if a new firmware image is valid f= or - a firmware update to the firmware device. T= he - following values from the Firmware Managemen= t - Protocol are supported: - IMAGE_UPDATABLE_VALID - IMAGE_UPDATABLE_INVALID - IMAGE_UPDATABLE_INVALID_TYPE - IMAGE_UPDATABLE_INVALID_OLD - IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE + @param[in] Image Points to a new firmware image. + @param[in] ImageSize Size, in bytes, of a new firmware image. + @param[out] ImageUpdatable Indicates if a new firmware image is val= id for + a firmware update to the firmware device= . The + following values from the Firmware Manag= ement + Protocol are supported: + IMAGE_UPDATABLE_VALID + IMAGE_UPDATABLE_INVALID + IMAGE_UPDATABLE_INVALID_TYPE + IMAGE_UPDATABLE_INVALID_OLD + IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE + @param[out] LastAttemptStatus A pointer to a UINT32 that holds the las= t attempt + status to report back to the ESRT table = in case + of error. The return status code must fa= ll in the range of + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ER= ROR_CODE to + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ER= ROR_CODE. =20 @retval EFI_SUCCESS The image was successfully checked. Addi= tional status information is returned in @@ -400,7 +407,8 @@ EFIAPI FmpDeviceCheckImage ( IN CONST VOID *Image, IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable + OUT UINT32 *ImageUpdatable, + OUT UINT32 *LastAttemptStatus ); =20 /** @@ -446,6 +454,13 @@ FmpDeviceCheckImage ( EFI_BOOT_SERVICES.AllocatePool(). It is t= he caller's responsibility to free this buffe= r with EFI_BOOT_SERVICES.FreePool(). + @param[out] LastAttemptStatus A pointer to a UINT32 that holds the last = attempt + status to report back to the ESRT table in= case + of error. Will only be checked when this f= untions + returns error. Returned status code falls = outside of + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MIN_ERRO= R_CODE and + LAST_ATTEMPT_STATUS_LIBRARY_ERROR_MAX_ERRO= R_CODE + will be converted to LAST_ATTEMPT_STATUS_E= RROR_UNSUCCESSFUL =20 @retval EFI_SUCCESS The firmware device was successfully upda= ted with the new firmware image. @@ -463,7 +478,8 @@ FmpDeviceSetImage ( IN CONST VOID *VendorCode, OP= TIONAL IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OP= TIONAL IN UINT32 CapsuleFwVersion, - OUT CHAR16 **AbortReason + OUT CHAR16 **AbortReason, + OUT UINT32 *LastAttemptStatus ); =20 /** --=20 2.28.0.windows.1