]> git.proxmox.com Git - mirror_edk2.git/commitdiff
FmpDevicePkg/FmpDxe: Update FmpDeviceCheckImageWithStatus() handling
authorMichael Kubacki <michael.kubacki@microsoft.com>
Tue, 4 Jan 2022 20:38:24 +0000 (04:38 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 20 Jan 2022 01:41:06 +0000 (01:41 +0000)
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 <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>
FmpDevicePkg/FmpDxe/FmpDxe.c
FmpDevicePkg/Include/Library/FmpDeviceLib.h
FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c

index 197df28c8dd6c3691bb9d57eb2ea74d2b0eaece1..1e7ec4a09e1611c9bef2abe6170d1fa699664e86 100644 (file)
@@ -1040,8 +1040,19 @@ CheckTheImageInternal (
   //\r
   Status = FmpDeviceCheckImageWithStatus ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);\r
   if (EFI_ERROR (Status)) {\r
+    // The image cannot be valid if an error occurred checking the image\r
+    if (*ImageUpdatable == IMAGE_UPDATABLE_VALID) {\r
+      *ImageUpdatable = IMAGE_UPDATABLE_INVALID;\r
+    }\r
+\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));\r
+  }\r
 \r
+  //\r
+  // Only validate the library last attempt status code if the image is not updatable.\r
+  // This specifically avoids converting LAST_ATTEMPT_STATUS_SUCCESS if it set for an updatable image.\r
+  //\r
+  if (*ImageUpdatable != IMAGE_UPDATABLE_VALID) {\r
     //\r
     // LastAttemptStatus returned from the device library should fall within the designated error range\r
     // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]\r
@@ -1049,12 +1060,12 @@ CheckTheImageInternal (
     if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||\r
         (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))\r
     {\r
-      DEBUG (\r
-        (DEBUG_ERROR,\r
-         "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",\r
-         mImageIdName,\r
-         *LastAttemptStatus)\r
-        );\r
+      DEBUG ((\r
+        DEBUG_ERROR,\r
+        "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",\r
+        mImageIdName,\r
+        *LastAttemptStatus\r
+        ));\r
       *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;\r
     }\r
   }\r
index a14406abe8b5cee134f8260b7dc222c6b2500950..f82ef64503fa2d9ed6bea474f7e91387ca722371 100644 (file)
@@ -421,8 +421,7 @@ FmpDeviceCheckImage (
                                     IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r
   @param[out] LastAttemptStatus   A pointer to a UINT32 that holds the last attempt\r
                                   status to report back to the ESRT table in case\r
-                                  of error. This value will only be checked when this\r
-                                  function returns an error.\r
+                                  of error.\r
 \r
                                   The return status code must fall in the range of\r
                                   LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to\r
index 2e5c17b2b0f92ebffb9b6d4904dc01372371f233..82219e87a430e2ad9a2fdcef6a6af37339b485ac 100644 (file)
@@ -434,8 +434,7 @@ FmpDeviceCheckImage (
                                     IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE\r
   @param[out] LastAttemptStatus   A pointer to a UINT32 that holds the last attempt\r
                                   status to report back to the ESRT table in case\r
-                                  of error. This value will only be checked when this\r
-                                  function returns an error.\r
+                                  of error.\r
 \r
                                   The return status code must fall in the range of\r
                                   LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE to\r