From 3e50573a7007771586e737b343bdde4d98c21c23 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) --- common/spl/spl_fit.c | 3 ++- common/spl/spl_imx_romapi.c | 4 ++++ include/spl.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 9246c7e708..6d196cf5f3 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -558,7 +558,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->flags |= SPL_FIT_FOUND; #ifdef CONFIG_SECURE_BOOT - board_spl_fit_post_load((ulong)fit, size); + if (!(spl_image->flags & SPL_FIT_BYPASS_POST_LOAD)) + board_spl_fit_post_load((ulong)fit, size); #endif return 0; diff --git a/common/spl/spl_imx_romapi.c b/common/spl/spl_imx_romapi.c index 84c222e628..b924c85d1a 100644 --- a/common/spl/spl_imx_romapi.c +++ b/common/spl/spl_imx_romapi.c @@ -160,6 +160,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); return last - (ulong)fit; } diff --git a/include/spl.h b/include/spl.h index f09909e189..d3a82af534 100644 --- a/include/spl.h +++ b/include/spl.h @@ -124,6 +124,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 common functions */ void preloader_console_init(void); -- 2.17.1