Skip to contentSkip to conversation

pxe: Add debugging for booting

PATCH In review Simon Glass 3 participants 8 messages Jun 19, 2024 – Jul 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 pxe: Add debugging for booting

Show which boot protocol is being used.

---

 boot/pxe_utils.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
boot/pxe_utils.c +11 -4
index 4b22bb6f525..53ddb16be73 100644
@@ -4,6 +4,8 @@
  * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
  */
 
+#define LOG_CATEGORY	LOGC_BOOT
+
 #include <command.h>
 #include <dm.h>
 #include <env.h>
@@ -762,17 +764,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 
 	/* Try bootm for legacy and FIT format image */
 	if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID &&
-            IS_ENABLED(CONFIG_CMD_BOOTM))
+	    IS_ENABLED(CONFIG_CMD_BOOTM)) {
+		log_debug("using bootm\n");
 		do_bootm(ctx->cmdtp, 0, bootm_argc, bootm_argv);
 	/* Try booting an AArch64 Linux kernel image */
-	else if (IS_ENABLED(CONFIG_CMD_BOOTI))
+	} else if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
+		log_debug("using booti\n");
 		do_booti(ctx->cmdtp, 0, bootm_argc, bootm_argv);
 	/* Try booting a Image */
-	else if (IS_ENABLED(CONFIG_CMD_BOOTZ))
+	} else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) {
+		log_debug("using bootz\n");
 		do_bootz(ctx->cmdtp, 0, bootm_argc, bootm_argv);
 	/* Try booting an x86_64 Linux kernel image */
-	else if (IS_ENABLED(CONFIG_CMD_ZBOOT))
+	} else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) {
+		log_debug("using zboot\n");
 		do_zboot_parent(ctx->cmdtp, 0, zboot_argc, zboot_argv, NULL);
+	}
 
 	unmap_sysmem(buf);
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/3 zboot: Add debugging for booting

Show the boot arguments and the state mask, to aid debugging.

---

 cmd/x86/zboot.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
cmd/x86/zboot.c +10 -1
index addf28cb4aa..c14219f19e9 100644
@@ -5,6 +5,8 @@
  * Daniel Engström, Omicron Ceti AB, <[email protected]>
  */
 
+#define LOG_CATEGORY	LOGC_BOOT
+
 #include <command.h>
 #include <mapmem.h>
 #include <vsprintf.h>
@@ -14,8 +16,14 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
 			  char *const argv[])
 {
 	ulong bzimage_addr = 0, bzimage_size, initrd_addr, initrd_size;
-	ulong base_addr;
 	const char *s, *cmdline;
+	ulong base_addr;
+	int i;
+
+	log_debug("argc %d:", argc);
+	for (i = 0; i < argc; i++)
+		log_debug(" %s", argv[i]);
+	log_debug("\n");
 
 	/* argv[1] holds the address of the bzImage */
 	s = cmd_arg1(argc, argv) ? : env_get("fileaddr");
@@ -116,6 +124,7 @@ int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	int ret;
 
+	log_debug("state_mask %x\n", state_mask);
 	if (flag & ZBOOT_STATE_START)
 		ret = do_zboot_start(cmdtp, flag, argc, argv);
 	if (!ret && (flag & ZBOOT_STATE_LOAD))
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/3 zboot: Correct use of state_mask argument

In reply to Simon Glass

There is confusion in this function between the flag and state_mask parameters, which prevents the boot from actually happening. Correct this by using state_mask instead of flag for deciding which states to go through.

This fixes booting of some 32-bit Debian kernels.

Note: Some sort of CI for this is in the works.

Fixes 228c6722d44 ("x86: zboot: Avoid iteration in do_zboot_states()")

---

 cmd/x86/zboot.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
cmd/x86/zboot.c +6 -6
index c14219f19e9..94e602b8a5b 100644
@@ -122,18 +122,18 @@ U_BOOT_SUBCMDS(zboot,
 int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc,
 		    char *const argv[], int state_mask)
 {
-	int ret;
+	int ret = 0;
 
 	log_debug("state_mask %x\n", state_mask);
-	if (flag & ZBOOT_STATE_START)
+	if (state_mask & ZBOOT_STATE_START)
 		ret = do_zboot_start(cmdtp, flag, argc, argv);
-	if (!ret && (flag & ZBOOT_STATE_LOAD))
+	if (!ret && (state_mask & ZBOOT_STATE_LOAD))
 		ret = do_zboot_load(cmdtp, flag, argc, argv);
-	if (!ret && (flag & ZBOOT_STATE_SETUP))
+	if (!ret && (state_mask & ZBOOT_STATE_SETUP))
 		ret = do_zboot_setup(cmdtp, flag, argc, argv);
-	if (!ret && (flag & ZBOOT_STATE_INFO))
+	if (!ret && (state_mask & ZBOOT_STATE_INFO))
 		ret = do_zboot_info(cmdtp, flag, argc, argv);
-	if (!ret && (flag & ZBOOT_STATE_GO))
+	if (!ret && (state_mask & ZBOOT_STATE_GO))
 		ret = do_zboot_go(cmdtp, flag, argc, argv);
 	if (ret)
 		return ret;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/3
#3 lore raw
In reply to Simon Glass

Hi

Quoted 50 lines · Simon Glass

Show which boot protocol is being used.

---

 boot/pxe_utils.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
boot/pxe_utils.c +11 -5
index 4b22bb6f525..53ddb16be73 100644
@@ -4,6 +4,8 @@
  * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
  */
 
+#define LOG_CATEGORY   LOGC_BOOT
+
 #include <command.h>
 #include <dm.h>
 #include <env.h>
@@ -762,17 +764,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 
        /* Try bootm for legacy and FIT format image */
        if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID &&
-            IS_ENABLED(CONFIG_CMD_BOOTM))
+           IS_ENABLED(CONFIG_CMD_BOOTM)) {
+               log_debug("using bootm\n");
                do_bootm(ctx->cmdtp, 0, bootm_argc, bootm_argv);
        /* Try booting an AArch64 Linux kernel image */
-       else if (IS_ENABLED(CONFIG_CMD_BOOTI))
+       } else if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
+               log_debug("using booti\n");
                do_booti(ctx->cmdtp, 0, bootm_argc, bootm_argv);
        /* Try booting a Image */
-       else if (IS_ENABLED(CONFIG_CMD_BOOTZ))
+       } else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) {
+               log_debug("using bootz\n");
                do_bootz(ctx->cmdtp, 0, bootm_argc, bootm_argv);
        /* Try booting an x86_64 Linux kernel image */
-       else if (IS_ENABLED(CONFIG_CMD_ZBOOT))
+       } else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) {
+               log_debug("using zboot\n");
                do_zboot_parent(ctx->cmdtp, 0, zboot_argc, zboot_argv, NULL);
+       }
 
        unmap_sysmem(buf);
 
--
Quoted 2 lines

2.34.1

#6 lore raw
Quoted 10 lines · Simon Glass

Hi Tom,

Quoted 7 lines · Tom Rini
Quoted 3 lines · Simon Glass

Show which boot protocol is being used.

Quoted 5 lines
Quoted 1 line

Applied to u-boot/next, thanks!

I wonder if this could go to -master since it is an important bugfix?

https://patchwork.ozlabs.org/project/uboot/list/?series=411595&state=*

It doesn't apply to master and v2024.04 was also seemingly broken. I think it's clear enough that it can be cherry-picked in places as needed.

Signature · 1 line
Tom
#7 lore raw

Hi Tom,

Quoted 14 lines · Tom Rini
Quoted 12 lines · Simon Glass

Hi Tom,

Quoted 8 lines · Tom Rini
Quoted 3 lines · Simon Glass

Show which boot protocol is being used.

Applied to u-boot/next, thanks!

Quoted 7 lines
Quoted 3 lines

I wonder if this could go to -master since it is an important bugfix?

https://patchwork.ozlabs.org/project/uboot/list/?series=411595&state=*

It doesn't apply to master and v2024.04 was also seemingly broken. I think it's clear enough that it can be cherry-picked in places as needed.

OK, yes it was broken in the last release too. I'd be happy to rebase it if you do want it in.

Regards,
Simon