Skip to content

Commit

Permalink
FmpDevicePkg/FmpDxe: Improve set image path Last Attempt Status granu…
Browse files Browse the repository at this point in the history
…larity

Increases the level of granularity for Last Attempt Status codes
returned from SetTheImage() in FmpDxe. This allows better
identification of the error that occurred in the set image
operation using Last Attempt Status codes.

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]>
Acked-by: Liming Gao <[email protected]>
Reviewed-by: Wei6 Xu <[email protected]>
Reviewed-by: Michael D Kinney <[email protected]>
  • Loading branch information
makubacki authored and mergify[bot] committed Oct 28, 2020
1 parent 5550f4d commit 004ce0a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions FmpDevicePkg/FmpDxe/FmpDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ SetTheImage (
if (This == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - This is NULL.\n", mImageIdName));
Status = EFI_INVALID_PARAMETER;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
goto cleanup;
}

Expand All @@ -1163,19 +1164,17 @@ SetTheImage (
//
if (Private->FmpDeviceLocked) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Device is already locked. Can't update.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED;
Status = EFI_UNSUPPORTED;
goto cleanup;
}

//
// Call check image to verify the image
//
Status = CheckTheImage (This, ImageIndex, Image, ImageSize, &Updateable);
Status = CheckTheImageInternal (This, ImageIndex, Image, ImageSize, &Updateable, &LastAttemptStatus);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Check The Image failed with %r.\n", mImageIdName, Status));
if (Status == EFI_SECURITY_VIOLATION) {
LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR;
}
goto cleanup;
}

Expand All @@ -1191,6 +1190,7 @@ SetTheImage (
FmpHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize );
if (FmpHeader == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER;
Status = EFI_ABORTED;
goto cleanup;
}
Expand Down Expand Up @@ -1218,6 +1218,7 @@ SetTheImage (

if (Progress == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Invalid progress callback\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR;
Status = EFI_INVALID_PARAMETER;
goto cleanup;
}
Expand All @@ -1238,6 +1239,7 @@ SetTheImage (
Status = CheckSystemPower (&BooleanValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemPower - API call failed %r.\n", mImageIdName, Status));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API;
goto cleanup;
}
if (!BooleanValue) {
Expand All @@ -1258,10 +1260,12 @@ SetTheImage (
Status = CheckSystemThermal (&BooleanValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemThermal - API call failed %r.\n", mImageIdName, Status));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API;
goto cleanup;
}
if (!BooleanValue) {
Status = EFI_ABORTED;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL;
DEBUG (
(DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n", mImageIdName)
Expand All @@ -1277,10 +1281,12 @@ SetTheImage (
Status = CheckSystemEnvironment (&BooleanValue);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", mImageIdName, Status));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API;
goto cleanup;
}
if (!BooleanValue) {
Status = EFI_ABORTED;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV;
DEBUG (
(DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n", mImageIdName)
Expand All @@ -1302,12 +1308,14 @@ SetTheImage (
Status = GetFmpPayloadHeaderSize (FmpHeader, FmpPayloadSize, &FmpHeaderSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", mImageIdName, Status));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
goto cleanup;
}

AllHeaderSize = GetAllHeaderSize ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);
if (AllHeaderSize == 0) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
Status = EFI_ABORTED;
goto cleanup;
}
Expand Down Expand Up @@ -1372,6 +1380,7 @@ SetTheImage (
mProgressFunc = NULL;

if (Private != NULL) {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): SetTheImage() LastAttemptStatus: %u.\n", mImageIdName, LastAttemptStatus));
SetLastAttemptStatusInVariable (Private, LastAttemptStatus);
}

Expand Down

0 comments on commit 004ce0a

Please sign in to comment.