From f1c7088597ea5a9d7172e2f0eb06348fb3beed5d Mon Sep 17 00:00:00 2001 From: Ye Li Date: Thu, 20 Jun 2019 20:09:07 -0700 Subject: [PATCH] MLK-22078 romapi: Fix issue for stream mode with secure boot enabled When download image through ROM API for stream mode (USB, eMMC fastboot). We uses tricky way to get the total image size: The spl_load_simple_fit is called but the data reading is invalid, so the image data is not really downloaded. We should not call HAB authenticate in this tricky way. Otherwise it will alway fail. This patch add a new flag SPL_FIT_BYPASS_POST_LOAD to skip the authentication only for this tricky using. Signed-off-by: Ye Li Reviewed-by: Peng Fan (cherry picked from commit 47b0cf6de06ff9b3e2b2755d5c8203210378b26a) (cherry picked from commit 3e50573a7007771586e737b343bdde4d98c21c23) (cherry picked from commit 50ea462702262c65afbd1985d831edf16e47e212) --- arch/arm/mach-imx/spl_imx_romapi.c | 4 ++++ common/spl/spl_fit.c | 2 +- include/spl.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 9f4d95982e..fd25df31b6 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -148,6 +148,10 @@ static ulong get_fit_image_size(void *fit) spl_load_info.read = spl_ram_load_read; spl_load_info.priv = &last; + /* We call load_simple_fit is just to get total size, the image is not downloaded, + * so should bypass authentication + */ + spl_image.flags = SPL_FIT_BYPASS_POST_LOAD; spl_load_simple_fit(&spl_image, &spl_load_info, (uintptr_t)fit, fit); diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 6e9c587a14..3f49945124 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -766,7 +766,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->flags |= SPL_FIT_FOUND; - if (IS_ENABLED(CONFIG_IMX_HAB)) + if (IS_ENABLED(CONFIG_IMX_HAB) && !(spl_image->flags & SPL_FIT_BYPASS_POST_LOAD)) board_spl_fit_post_load(ctx.fit); return 0; diff --git a/include/spl.h b/include/spl.h index 0d134587de..aa95637433 100644 --- a/include/spl.h +++ b/include/spl.h @@ -289,6 +289,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, #define SPL_COPY_PAYLOAD_ONLY 1 #define SPL_FIT_FOUND 2 +#define SPL_FIT_BYPASS_POST_LOAD 4 /** * spl_load_legacy_img() - Loads a legacy image from a device. -- 2.17.1