The booti command does not use the CONFIG_SYS_BOOTM_LEN value and instead sets a maximum decompression-buffer size of 10x the size of the compressed data.
Add this as an option in bootm_load_os() so that booting without the command-line works in the same way as the 'booti' command. Link: https://lore.kernel.org/u-boot/2ad3b1c5-b6e7-47e2-b225-834b821cc...@kwiboo.se/ Signed-off-by: Simon Glass <s...@chromium.org> Reported-by: Jonas Karlman <jo...@kwiboo.se> Fixes: b13408021d3 ("boot: pxe: Use bootm_...() functions where possible") --- boot/bootm.c | 13 +++++++++---- cmd/booti.c | 1 + include/bootm.h | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 7be5ec796fc..dae09060f0f 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -669,8 +669,9 @@ static bool booti_is_supported(struct image_info *os) return os->arch == IH_ARCH_ARM64 || os->arch == IH_ARCH_RISCV; } -static int bootm_load_os(struct bootm_headers *images, int boot_progress) +static int bootm_load_os(struct bootm_info *bmi, int boot_progress) { + struct bootm_headers *images = bmi->images; struct image_info os = images->os; ulong load = os.load; ulong load_end; @@ -681,6 +682,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) ulong flush_start = ALIGN_DOWN(load, ARCH_DMA_MINALIGN); bool no_overlap; void *load_buf, *image_buf; + ulong decomp_len; int err; /* @@ -706,11 +708,12 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) load_buf = map_sysmem(load, 0); image_buf = map_sysmem(os.image_start, image_len); + decomp_len = bmi->ignore_bootm_len ? image_len * 10 : bootm_len(); err = image_decomp(os.comp, load, os.image_start, os.type, - load_buf, image_buf, image_len, bootm_len(), + load_buf, image_buf, image_len, decomp_len, &load_end); if (err) { - err = handle_decomp_error(os.comp, load_end - load, bootm_len(), + err = handle_decomp_error(os.comp, load_end - load, decomp_len, err); bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); return err; @@ -1073,7 +1076,7 @@ int bootm_run_states(struct bootm_info *bmi, int states) if (!ret && (states & BOOTM_STATE_LOADOS)) { iflag = bootm_disable_interrupts(); board_fixup_os(&images->os); - ret = bootm_load_os(images, 0); + ret = bootm_load_os(bmi, 0); if (ret && ret != BOOTM_ERR_OVERLAP) goto err; else if (ret == BOOTM_ERR_OVERLAP) @@ -1237,6 +1240,8 @@ int bootz_run(struct bootm_info *bmi) int booti_run(struct bootm_info *bmi) { + bmi->ignore_bootm_len = true; + return boot_run(bmi, "booti", BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS); diff --git a/cmd/booti.c b/cmd/booti.c index 43e79e87201..f4f782da056 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -118,6 +118,7 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bmi.conf_fdt = argv[2]; bmi.boot_progress = true; bmi.cmd_name = "booti"; + bmi.ignore_bootm_len = true; /* do not set up argc and argv[] since nothing uses them */ if (booti_start(&bmi)) diff --git a/include/bootm.h b/include/bootm.h index 82ab8e0e565..97f77bc1ded 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -44,6 +44,8 @@ struct cmd_tbl; * @argc: Number of arguments to the command (excluding the actual command). * This is 0 if there are no arguments * @argv: NULL-terminated list of arguments, or NULL if there are no arguments + * @ignore_bootm_len: Ignore the value CONFIG_SYS_BOOTM_LEN and use 10x the + * compressed length as the maximum uncompressed size * * For zboot: * @bzimage_addr: Address of the bzImage to boot, or 0 if the image has already @@ -69,6 +71,7 @@ struct bootm_info { const char *cmd_name; int argc; char *const *argv; + bool ignore_bootm_len; /* zboot items */ #ifdef CONFIG_X86 -- 2.43.0