Skip to content

Commit 772c5bb

Browse files
makubackimergify[bot]
authored andcommitted
FmpDevicePkg/FmpDxe: Update FmpDeviceCheckImageWithStatus() handling
Update the logic handling last attempt status codes from FmpDeviceCheckImageWithStatus() implementations to account for cases when the function return status code is EFI_SUCCESS (since the image was checked successfully) but the ImageUpdatable value is not valid. In addition the following sentence is removed from the LastAttemptStatus parameter definition for FmpDeviceCheckImageWithStatus() since it can lead to confusion. The expected status code value range is sufficient to implement the library API. "This value will only be checked when this function returns an error." Cc: Liming Gao <[email protected]> Cc: Michael D Kinney <[email protected]> Cc: Guomin Jiang <[email protected]> Cc: Wei6 Xu <[email protected]> Signed-off-by: Michael Kubacki <[email protected]> Reviewed-by: Guomin Jiang <[email protected]>
1 parent 5801910 commit 772c5bb

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Diff for: FmpDevicePkg/FmpDxe/FmpDxe.c

+17-6
Original file line numberDiff line numberDiff line change
@@ -1040,21 +1040,32 @@ CheckTheImageInternal (
10401040
//
10411041
Status = FmpDeviceCheckImageWithStatus ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
10421042
if (EFI_ERROR (Status)) {
1043+
// The image cannot be valid if an error occurred checking the image
1044+
if (*ImageUpdatable == IMAGE_UPDATABLE_VALID) {
1045+
*ImageUpdatable = IMAGE_UPDATABLE_INVALID;
1046+
}
1047+
10431048
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));
1049+
}
10441050

1051+
//
1052+
// Only validate the library last attempt status code if the image is not updatable.
1053+
// This specifically avoids converting LAST_ATTEMPT_STATUS_SUCCESS if it set for an updatable image.
1054+
//
1055+
if (*ImageUpdatable != IMAGE_UPDATABLE_VALID) {
10451056
//
10461057
// LastAttemptStatus returned from the device library should fall within the designated error range
10471058
// [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
10481059
//
10491060
if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||
10501061
(*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))
10511062
{
1052-
DEBUG (
1053-
(DEBUG_ERROR,
1054-
"FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
1055-
mImageIdName,
1056-
*LastAttemptStatus)
1057-
);
1063+
DEBUG ((
1064+
DEBUG_ERROR,
1065+
"FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
1066+
mImageIdName,
1067+
*LastAttemptStatus
1068+
));
10581069
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
10591070
}
10601071
}

Diff for: FmpDevicePkg/Include/Library/FmpDeviceLib.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,7 @@ FmpDeviceCheckImage (
421421
IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
422422
@param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
423423
status to report back to the ESRT table in case
424-
of error. This value will only be checked when this
425-
function returns an error.
424+
of error.
426425
427426
The return status code must fall in the range of
428427
LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to

Diff for: FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ FmpDeviceCheckImage (
434434
IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE
435435
@param[out] LastAttemptStatus A pointer to a UINT32 that holds the last attempt
436436
status to report back to the ESRT table in case
437-
of error. This value will only be checked when this
438-
function returns an error.
437+
of error.
439438
440439
The return status code must fall in the range of
441440
LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to

0 commit comments

Comments
 (0)