From: Abdellatif El Khlifi <abdellatif.elkhl...@arm.com>

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 <abdellatif.elkhl...@arm.com>
Cc: Heinrich Schuchardt <xypron.g...@gmx.de>
Cc: Sughosh Ganu <sughosh.g...@linaro.org>
Cc: Tom Rini <tr...@konsulko.com>
Cc: Ilias Apalodimas <ilias.apalodi...@linaro.org>
Cc: Simon Glass <s...@chromium.org>
Cc: Michal Simek <michal.si...@amd.com>
Cc: Marek Vasut <marek.vasut+rene...@mailbox.org>
Cc: Casey Connolly <casey.conno...@linaro.org>
Cc: Adriano Cordova <adria...@gmail.com>
---
 lib/efi_loader/efi_capsule.c | 23 +++++++++++++----------
 lib/fwu_updates/fwu.c        | 21 +++++++++++++++++++++
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 234e3c1b3c0..1dac691d24d 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -696,17 +696,20 @@ static efi_status_t efi_capsule_update_firmware(
                                status = fwu_clear_accept_image(image_type_id,
                                                                update_index);
                        }
-                       ret = fwu_to_efi_error(status);
-                       if (ret != EFI_SUCCESS) {
-                               log_err("Unable to %s the accept bit for the 
image %pUs\n",
-                                       fw_accept_os ? "clear" : "set",
-                                       image_type_id);
-                               goto out;
-                       }
 
-                       log_debug("%s the accepted bit for Image %pUs\n",
-                                 fw_accept_os ? "Cleared" : "Set",
-                                 image_type_id);
+                       if (!IS_ENABLED(CONFIG_FWU_ARM_PSA)) {
+                               ret = fwu_to_efi_error(status);
+                               if (ret != EFI_SUCCESS) {
+                                       log_err("Unable to %s the accept bit 
for the image %pUs\n",
+                                               fw_accept_os ? "clear" : "set",
+                                               image_type_id);
+                                       goto out;
+                               }
+
+                               log_debug("%s the accepted bit for Image 
%pUs\n",
+                                         fw_accept_os ? "Cleared" : "Set",
+                                         image_type_id);
+                       }
                }
 
        }
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index 7f085a0211f..46b6f9356a7 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -1,6 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2022, Linaro Limited
+ *
+ * Copyright 2025 Arm Limited and/or its affiliates 
<open-source-off...@arm.com>
+ *
+ * Author:
+ *   Abdellatif El Khlifi <abdellatif.elkhl...@arm.com>
  */
 
 #include <dm.h>
@@ -586,6 +591,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 +619,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.25.1

Reply via email to