From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com [40.92.3.40]) by mx.groups.io with SMTP id smtpd.web12.75531.1597785442791549990 for ; Tue, 18 Aug 2020 14:17:23 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=IYVkYvMB; spf=pass (domain: outlook.com, ip: 40.92.3.40, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bDMJh4erzu2jG9lDuFCtbKEzePPwLCW327WhYD0mpmPS7kOSaNZML9SyVXdV2KSuHrf3oZMCIwfRG2iEl+32anAzPzAX0gB0bI8Yc1F8B/ThEeA6j+vBjaCz+NVmH6ECW+ovXRjbIJ7KCMRegUnDU7pkO6XrxJ1izFPP2d9+TKOiFOsv41wOgL9iGpMzTsJ9boaconvlGiqEWlfSF0kJ71IqN5eaTgUEUuVdP9b2fWRBbJVNBAiGUNBmjxYzxxsn76zzXekZy746KDbIVwbQwJ2JpBHgYTDNLQPtbbmGBc0miKAB92wgXkRpPsBUn/j4wP6o54zP/BI4vGnQerMNdg== 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=j7c9rqmvZL+fvtgHATjwlAtnMMg3SE5b97/gMkEMwHA=; b=B4BWDvyh3nAiCGn2v91ChJc52+LCKLkpjAEW0UNIq/SO/UxPMqn7TzvqDtQ2rJZqDmONN7tllg+Kt+eSlPBiDd4b+zgH1RrZkE3s5H36d82CsnOLPOkX6UwpFLJjv2pgqJmDWUOmQnzqTmGSevHv5wC+pJMzVPwrYhMyrcdYtLRo+YQGaKjDKy8diJeodAbR8Ge55BfkwoaHKTwu+k2vSyWneJsDZglfiV9JLTdv3VA1ys8MFvZ+OXKtYfMMn2wB9pSCO1OZif8Ka3TN58glQAggCKJBK300hyKniTwpeD85G9ueDvOc8GfhzLYqlMb+OizzuVV7+h9L5UCqRuB8UQ== 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=j7c9rqmvZL+fvtgHATjwlAtnMMg3SE5b97/gMkEMwHA=; b=IYVkYvMBpJnIcCsRB0D9gyHFFMn4WkTBY6w2OJpj8UIvsDm2J1KaXReC4bqxgUFSO87MV3REWnfADmG3y4sW4TGkmn2NNr4BkI/F4d10ne8CMmcD3DWmJiIwS7/jHNiWtfAGysbxv7xq9qgtaOSOzBZBzPNPlYkTMH5UgYgABLMnMvnbum1dmXqRt88K1lCgWex4K6ONz9U+E0HHZBXxuDpzH858Hubb9TqzVnf1OF7h7o8AtaWNaqz3bHcMhtBLjv+6nJAXq/2bL9XwR7Uam8T3PGjHLGBNThnM9KZWC2c/0bHEkS5o2QCWamOUeXIsAaXGEuFS9whVjelyr+0iBw== Received: from SN1NAM02FT007.eop-nam02.prod.protection.outlook.com (10.152.72.58) by SN1NAM02HT012.eop-nam02.prod.protection.outlook.com (10.152.72.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Tue, 18 Aug 2020 21:17:21 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e44::4e) by SN1NAM02FT007.mail.protection.outlook.com (2a01:111:e400:7e44::88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Tue, 18 Aug 2020 21:17:21 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7E9AE9B9D3F55017A3005534106DD5738D2ED062EA4254B12E90205CCD5F75E8;UpperCasedChecksum:1CA873732FDE032CB57DB923AB505957DD0E573D34A0E7CB63054F4233536829;SizeAsReceived:7811;Count:49 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::eda9:ccc8:2ef:2471]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::eda9:ccc8:2ef:2471%7]) with mapi id 15.20.3283.027; Tue, 18 Aug 2020 21:17:21 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io CC: Liming Gao , Michael D Kinney , Guomin Jiang , Wei6 Xu Subject: [PATCH v3 6/6] FmpDevicePkg/FmpDeviceLib: Add Last Attempt Status to Check/Set API Date: Tue, 18 Aug 2020 14:16:29 -0700 Message-ID: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20200818211629.1193-1-michael.kubacki@outlook.com> References: <20200818211629.1193-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR14CA0033.namprd14.prod.outlook.com (2603:10b6:300:12b::19) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200818211629.1193-7-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:1:e4ef:ebe4:8509:47e7) by MWHPR14CA0033.namprd14.prod.outlook.com (2603:10b6:300:12b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Tue, 18 Aug 2020 21:17:20 +0000 X-Mailer: git-send-email 2.28.0.windows.1 X-Microsoft-Original-Message-ID: <20200818211629.1193-7-michael.kubacki@outlook.com> X-TMN: [0mv+pnPkwLHkVCMgOVJzOvZvPpdUN09YPGMRe4B8yA8frsL4AtJ6+Zj3prwBO9ZO] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9a0432da-79fa-428c-17f7-08d843bc1811 X-MS-TrafficTypeDiagnostic: SN1NAM02HT012: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hI63K1Kf/6CPhoa7qPXNpXqaynjZp5rF7nogrVh09hiy6HfMYhesw/KPTqLbuAfSupAqk1I0u2Dgd9GQ2oEed4pwSjdbh1z7tvlBbRS2XsCY9mL8ld7E1qoZz+WRGWnWHvmIwwgWSuU7pEe1hMlzzP5Z8O14dDp7MVeD3WJkjXvJrofjlfbfKcuwv+mpl3TB1nuXU1n5Dfhdwahr1X+71Q== 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;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: 2qZ8+nss8PbQBC+j3Nl5v5ddBQx+jtlx6p2dKj68599F0LWYkDR3h7zwEpNQvB0p92Tdp3TkmT39D5Mu369htSD5k7AnsmDFCDJEk6Y8rFzvR/r6rTKX5it76X0L5cjc31oR7OcJPV5gIUZoy5/IrNUIPu+mIZR6meDwcYWC5TrSMx6vvzGw/znWjxAkeshTn0Mv1mKkOduOVgAtNidPNQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a0432da-79fa-428c-17f7-08d843bc1811 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2020 21:17:21.2269 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT007.eop-nam02.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: SN1NAM02HT012 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 | 33 +++++++++++++- FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c | 48 ++++++++++++++--= ---- FmpDevicePkg/Include/Library/FmpDeviceLib.h | 48 ++++++++++++++--= ---- 3 files changed, 99 insertions(+), 30 deletions(-) diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 93d9a0c3c54c..53beb709e1b2 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -1019,12 +1019,28 @@ 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)); + + // + // LastAttemptStatus returned from the device library should fall with= in the designated error range + // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTE= MPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE] + // + if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR= _CODE_VALUE) || + (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_C= ODE_VALUE)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - LastAttemptStatu= s from FmpDeviceCheckImage is invalid.\n", mImageIdName)); + ASSERT (FALSE); + *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; + } } =20 cleanup: @@ -1356,10 +1372,23 @@ SetTheImage ( VendorCode, FmpDxeProgress, IncomingFwVersion, - AbortReason + AbortReason, + &LastAttemptStatus ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDevic= eLib failed. Status =3D %r.\n", mImageIdName, Status)); + + // + // LastAttemptStatus returned from the device library should fall with= in the designated error range + // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTE= MPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE] + // + if ((LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_= CODE_VALUE) || + (LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CO= DE_VALUE)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - LastAttemptStatus = from FmpDeviceSetImage is invalid.\n", mImageIdName)); + ASSERT (FALSE); + LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL; + } + goto cleanup; } =20 diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevi= cePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c index 316de12e910c..9dacb5801639 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,26 @@ 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. This value will only be checke= d when this + function returns an error. The return st= atus code + must fall in the range of + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_E= RROR_CODE_VALUE to + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_E= RROR_CODE_VALUE. + If the value falls outside this range, i= t will be converted + to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFU= L. =20 @retval EFI_SUCCESS The image was successfully checked. Addi= tional status information is returned in @@ -404,7 +413,8 @@ EFIAPI FmpDeviceCheckImage ( IN CONST VOID *Image, IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable + OUT UINT32 *ImageUpdatable, + OUT UINT32 *LastAttemptStatus ) { return EFI_SUCCESS; @@ -453,6 +463,15 @@ 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. This value will only be checked = when this + function returns an error. The return stat= us code + must fall in the range of + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERR= OR_CODE_VALUE to + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERR= OR_CODE_VALUE. + If the value falls outside this range, it = will be converted + to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL. =20 @retval EFI_SUCCESS The firmware device was successfully upda= ted with the new firmware image. @@ -470,7 +489,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..96d1b999797d 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 @@ -376,17 +376,26 @@ 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. This value will only be checke= d when this + function returns an error. The return st= atus code + must fall in the range of + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_E= RROR_CODE_VALUE to + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_E= RROR_CODE_VALUE. + If the value falls outside this range, i= t will be converted + to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFU= L. =20 @retval EFI_SUCCESS The image was successfully checked. Addi= tional status information is returned in @@ -400,7 +409,8 @@ EFIAPI FmpDeviceCheckImage ( IN CONST VOID *Image, IN UINTN ImageSize, - OUT UINT32 *ImageUpdatable + OUT UINT32 *ImageUpdatable, + OUT UINT32 *LastAttemptStatus ); =20 /** @@ -446,6 +456,15 @@ 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. This value will only be checked = when this + function returns an error. The return stat= us code + must fall in the range of + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERR= OR_CODE_VALUE to + LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERR= OR_CODE_VALUE. + If the value falls outside this range, it = will be converted + to LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL. =20 @retval EFI_SUCCESS The firmware device was successfully upda= ted with the new firmware image. @@ -463,7 +482,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