diff mbox series

[v3,44/46] boot: Detect booti format properly in pxe_utils

Message ID 20241206023626.2456858-45-sjg@chromium.org
State New
Delegated to: Tom Rini
Headers show
Series pxe: Support read_all() for extlinux and PXE | expand

Commit Message

Simon Glass Dec. 6, 2024, 2:36 a.m. UTC
Rather than assuming that a file can be booted with bootm, check that
the format is correct first. Do the same for booti.

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

Changes in v3:
- Add new patch to detect booti format properly in pxe_utils

 boot/pxe_utils.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Simon Glass Dec. 20, 2024, 4:04 a.m. UTC | #1
Rather than assuming that a file can be booted with bootm, check that
the format is correct first. Do the same for booti.

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

Changes in v3:
- Add new patch to detect booti format properly in pxe_utils

 boot/pxe_utils.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Applied to sjg/master, thanks!
diff mbox series

Patch

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index 1468a8e8498..71347b19119 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -591,6 +591,7 @@  static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label,
 	ulong kernel_addr_r;
 	int ret = 0;
 	void *buf;
+	enum image_fmt_t  fmt;
 
 	bootm_init(&bmi);
 
@@ -608,13 +609,18 @@  static int label_run_boot(struct pxe_context *ctx, struct pxe_label *label,
 	kernel_addr_r = genimg_get_kernel_addr(kernel_addr);
 	buf = map_sysmem(kernel_addr_r, 0);
 
-	/* Try bootm for legacy and FIT format image */
-	if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID &&
-	    IS_ENABLED(CONFIG_CMD_BOOTM)) {
+	/*
+	 * Try bootm for legacy and FIT format image, assume booti if
+	 * compressed
+	 */
+	fmt = genimg_get_format_comp(buf);
+
+	if (IS_ENABLED(CONFIG_CMD_BOOTM) && (fmt == IMAGE_FORMAT_FIT ||
+	    fmt == IMAGE_FORMAT_LEGACY)) {
 		log_debug("using bootm\n");
 		ret = bootm_run(&bmi);
 	/* Try booting an AArch64 Linux kernel image */
-	} else if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
+	} else if (IS_ENABLED(CONFIG_CMD_BOOTI) && fmt == IMAGE_FORMAT_BOOTI) {
 		log_debug("using booti\n");
 		ret = booti_run(&bmi);
 	/* Try booting a Image */