From: Abdellatif El Khlifi <[email protected]>

Do not update the acceptance metadata bit after updating an image

The update agent (secure world) is responsible of setting the acceptance
bit in the metadata.

Signed-off-by: Abdellatif El Khlifi <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Sughosh Ganu <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Casey Connolly <[email protected]>
Cc: Adriano Cordova <[email protected]>

---

Changelog of changes:
===========================

v5:

* As suggested by Ilias: Make PSA handling simpler for the acceptance logic
  (less ifs)

 lib/efi_loader/efi_capsule.c |  5 +++--
 lib/fwu_updates/fwu.c        | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 234e3c1b3c0..06b502e2c25 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -704,8 +704,9 @@ static efi_status_t efi_capsule_update_firmware(
                                goto out;
                        }
 
-                       log_debug("%s the accepted bit for Image %pUs\n",
-                                 fw_accept_os ? "Cleared" : "Set",
+                       log_debug("%s %s the accepted bit for Image %pUs\n",
+                                 IS_ENABLED(CONFIG_FWU_ARM_PSA) ? "PSA will" : 
"",
+                                 fw_accept_os ? "clear" : "set",
                                  image_type_id);
                }
 
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index 7f085a0211f..bfbb98c16d7 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -586,6 +586,14 @@ out:
  */
 int fwu_accept_image(efi_guid_t *img_type_id, u32 bank)
 {
+       /*
+        * In case of Arm PSA accepting images is either
+        * at ExitBootServices() or in the OS. So, let's skip setting the
+        * acceptance bit (not used in Arm PSA)
+        */
+       if (IS_ENABLED(CONFIG_FWU_ARM_PSA))
+               return EFI_SUCCESS;
+
        return fwu_clrset_image_accept(img_type_id, bank,
                                       IMAGE_ACCEPT_SET);
 }
@@ -606,6 +614,14 @@ int fwu_accept_image(efi_guid_t *img_type_id, u32 bank)
  */
 int fwu_clear_accept_image(efi_guid_t *img_type_id, u32 bank)
 {
+       /*
+        * In case of Arm PSA accepting images is either
+        * at ExitBootServices() or in the OS. So, let's skip clearing the
+        * acceptance bit (not used in Arm PSA)
+        */
+       if (IS_ENABLED(CONFIG_FWU_ARM_PSA))
+               return EFI_SUCCESS;
+
        return fwu_clrset_image_accept(img_type_id, bank,
                                       IMAGE_ACCEPT_CLEAR);
 }
-- 
2.43.0

Reply via email to