diff mbox series

[v2,04/18] boot: Respect the load_op in fit_image_load()

Message ID 20240920081309.140426-5-sjg@chromium.org
State Superseded
Delegated to: Tom Rini
Headers show
Series vbe: Series part E | expand

Commit Message

Simon Glass Sept. 20, 2024, 8:12 a.m. UTC
Some code has crept in which ignores this parameter. Fix this and add a
little debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 boot/image-fit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Simon Glass Sept. 20, 2024, 3:59 p.m. UTC | #1
On Fri, 20 Sept 2024 at 10:13, Simon Glass <sjg@chromium.org> wrote:
>
> Some code has crept in which ignores this parameter. Fix this and add a
> little debugging.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>  boot/image-fit.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>

As requested:

Fixes: b1307f884a9 ("fit: Support compression for non-kernel
components (e.g. FDT)")

Or at least that is my reading of the situation


> diff --git a/boot/image-fit.c b/boot/image-fit.c
> index 439ff51edf6..db7fb61bca9 100644
> --- a/boot/image-fit.c
> +++ b/boot/image-fit.c
> @@ -2226,6 +2226,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
>         data = map_to_sysmem(buf);
>         load = data;
>         if (load_op == FIT_LOAD_IGNORED) {
> +               log_debug("load_op: not loading\n");
>                 /* Don't load */
>         } else if (fit_image_get_load(fit, noffset, &load)) {
>                 if (load_op == FIT_LOAD_REQUIRED) {
> @@ -2262,10 +2263,13 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
>         /* Kernel images get decompressed later in bootm_load_os(). */
>         if (!fit_image_get_comp(fit, noffset, &comp) &&
>             comp != IH_COMP_NONE &&
> +           load_op != FIT_LOAD_IGNORED &&
>             !(image_type == IH_TYPE_KERNEL ||
>               image_type == IH_TYPE_KERNEL_NOLOAD ||
>               image_type == IH_TYPE_RAMDISK)) {
>                 ulong max_decomp_len = len * 20;
> +
> +               log_debug("decompressing image\n");
>                 if (load == data) {
>                         loadbuf = malloc(max_decomp_len);
>                         load = map_to_sysmem(loadbuf);
> @@ -2280,6 +2284,7 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
>                 }
>                 len = load_end - load;
>         } else if (load != data) {
> +               log_debug("copying\n");
>                 loadbuf = map_sysmem(load, len);
>                 memcpy(loadbuf, buf, len);
>         }
> @@ -2289,8 +2294,9 @@ int fit_image_load(struct bootm_headers *images, ulong addr,
>                      " please fix your .its file!\n");
>
>         /* verify that image data is a proper FDT blob */
> -       if (image_type == IH_TYPE_FLATDT && fdt_check_header(loadbuf)) {
> -               puts("Subimage data is not a FDT");
> +       if (load_op != FIT_LOAD_IGNORED && image_type == IH_TYPE_FLATDT &&
> +           fdt_check_header(loadbuf)) {
> +               puts("Subimage data is not a FDT\n");
>                 return -ENOEXEC;
>         }
>
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/boot/image-fit.c b/boot/image-fit.c
index 439ff51edf6..db7fb61bca9 100644
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2226,6 +2226,7 @@  int fit_image_load(struct bootm_headers *images, ulong addr,
 	data = map_to_sysmem(buf);
 	load = data;
 	if (load_op == FIT_LOAD_IGNORED) {
+		log_debug("load_op: not loading\n");
 		/* Don't load */
 	} else if (fit_image_get_load(fit, noffset, &load)) {
 		if (load_op == FIT_LOAD_REQUIRED) {
@@ -2262,10 +2263,13 @@  int fit_image_load(struct bootm_headers *images, ulong addr,
 	/* Kernel images get decompressed later in bootm_load_os(). */
 	if (!fit_image_get_comp(fit, noffset, &comp) &&
 	    comp != IH_COMP_NONE &&
+	    load_op != FIT_LOAD_IGNORED &&
 	    !(image_type == IH_TYPE_KERNEL ||
 	      image_type == IH_TYPE_KERNEL_NOLOAD ||
 	      image_type == IH_TYPE_RAMDISK)) {
 		ulong max_decomp_len = len * 20;
+
+		log_debug("decompressing image\n");
 		if (load == data) {
 			loadbuf = malloc(max_decomp_len);
 			load = map_to_sysmem(loadbuf);
@@ -2280,6 +2284,7 @@  int fit_image_load(struct bootm_headers *images, ulong addr,
 		}
 		len = load_end - load;
 	} else if (load != data) {
+		log_debug("copying\n");
 		loadbuf = map_sysmem(load, len);
 		memcpy(loadbuf, buf, len);
 	}
@@ -2289,8 +2294,9 @@  int fit_image_load(struct bootm_headers *images, ulong addr,
 		     " please fix your .its file!\n");
 
 	/* verify that image data is a proper FDT blob */
-	if (image_type == IH_TYPE_FLATDT && fdt_check_header(loadbuf)) {
-		puts("Subimage data is not a FDT");
+	if (load_op != FIT_LOAD_IGNORED && image_type == IH_TYPE_FLATDT &&
+	    fdt_check_header(loadbuf)) {
+		puts("Subimage data is not a FDT\n");
 		return -ENOEXEC;
 	}