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]>
---
 lib/efi_loader/Kconfig        | 8 ++++++++
 lib/efi_loader/efi_firmware.c | 7 +++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 483d2c6dc18..50302a03eae 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -387,6 +387,14 @@ config FWU_NUM_IMAGES_PER_BANK
          Define the number of firmware images per bank. This value
          should be the same for all the banks.
 
+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
diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c
index 290db9d27eb..09d386cdf9a 100644
--- a/lib/efi_loader/efi_firmware.c
+++ b/lib/efi_loader/efi_firmware.c
@@ -512,8 +512,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;
+               }
+
        }
 }
 
-- 
2.43.0

Reply via email to