From: Abdellatif El Khlifi <[email protected]>

Allow sending the payload with its FMP header

The Secure world needs the data provided by the payload
FMP header. So, let's allow the user to keep it in
case of FWU_ARM_PSA. This is controlled with
CONFIG_FWU_KEEP_FMP_HEADER.

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:

* Add CONFIG_FWU_KEEP_FMP_HEADER to control whether
  the user wants to keep the FMP header or strip it

 lib/efi_loader/efi_firmware.c | 7 +++++--
 lib/fwu_updates/Kconfig       | 8 ++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 46d500966ad..61cfa791ffa 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -510,8 +510,11 @@ static void efi_firmware_get_fw_version(const void 
**p_image,
                /* FMP header is inserted above the capsule payload */
                state->fw_version = header->fw_version;
 
-               *p_image += header->header_size;
-               *p_image_size -= header->header_size;
+               if (!IS_ENABLED(CONFIG_FWU_KEEP_FMP_HEADER)) {
+                       *p_image += header->header_size;
+                       *p_image_size -= header->header_size;
+               }
+
        }
 }
 
diff --git a/lib/fwu_updates/Kconfig b/lib/fwu_updates/Kconfig
index cdc96109f0a..29e1d441813 100644
--- a/lib/fwu_updates/Kconfig
+++ b/lib/fwu_updates/Kconfig
@@ -57,6 +57,14 @@ config FWU_ARM_PSA
          driver that supports the Arm PSA firmware update specification as
          mentioned in https://developer.arm.com/documentation/den0118/a/
 
+config FWU_KEEP_FMP_HEADER
+       bool "Allow sending the FMP header with the payload"
+       depends on FWU_ARM_PSA
+       default y
+       help
+         Select this option if you do not want to strip the FMP header
+         of the payload
+
 config FWU_BUFFER_PAGES
        int "Number of 4KB pages in the FWU shared buffer"
        depends on FWU_ARM_PSA
-- 
2.43.0

Reply via email to