Skip to contentSkip to conversation

bootm: fdt: Use panic() instead of hang() when presented with a bad image

PATCH New Alex Kiernan 3 participants 4 messages Sep 18, 2018 – Sep 21, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bootm: fdt: Use panic() instead of hang() when presented with a bad image

When the image which bootm is given can't be booted, call panic with the error message rather than printf/hang so that we can recover from broken images via a bootcount mechanism. If hang on failure is still required then CONFIG_PANIC_HANG can still be enabled.

---

 arch/arm/lib/bootm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/lib/bootm.c +2 -4
index c3c1d2fdfa..a5ed12df74 100644
@@ -230,8 +230,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 #ifdef CONFIG_OF_LIBFDT
 		debug("using: FDT\n");
 		if (image_setup_linux(images)) {
-			printf("FDT creation failed! hanging...");
-			hang();
+			panic("FDT creation failed!\n");
 		}
 #endif
 	} else if (BOOTM_ENABLE_TAGS) {
@@ -264,8 +263,7 @@ static void boot_prep_linux(bootm_headers_t *images)
 		setup_board_tags(&params);
 		setup_end_tag(gd->bd);
 	} else {
-		printf("FDT and ATAGS support not compiled in - hanging\n");
-		hang();
+		panic("FDT and ATAGS support not compiled in\n");
 	}
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 bootm: fdt: Use panic() instead of hang() when presented with a bad image

Quoted 4 lines · Alex Kiernan

When the image which bootm is given can't be booted, call panic with the error message rather than printf/hang so that we can recover from broken images via a bootcount mechanism. If hang on failure is still required then CONFIG_PANIC_HANG can still be enabled.

This sounds plausible to me, but I think you'll want to send this patch To/Cc someone who owns that file. At least Tom Rini (now CC'd hence quoting the entire patch for context).

Quoted 29 lines

---

  arch/arm/lib/bootm.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/lib/bootm.c +2 -4
index c3c1d2fdfa..a5ed12df74 100644
@@ -230,8 +230,7 @@ static void boot_prep_linux(bootm_headers_t *images)
  #ifdef CONFIG_OF_LIBFDT
  		debug("using: FDT\n");
  		if (image_setup_linux(images)) {
-			printf("FDT creation failed! hanging...");
-			hang();
+			panic("FDT creation failed!\n");
  		}
  #endif
  	} else if (BOOTM_ENABLE_TAGS) {
@@ -264,8 +263,7 @@ static void boot_prep_linux(bootm_headers_t *images)
  		setup_board_tags(&params);
  		setup_end_tag(gd->bd);
  	} else {
-		printf("FDT and ATAGS support not compiled in - hanging\n");
-		hang();
+		panic("FDT and ATAGS support not compiled in\n");
  	}
  }
#2 lore raw

PATCH 1/1 bootm: fdt: Use panic() instead of hang() when presented with a bad image

In reply to Alex Kiernan

Dear Alex,

Quoted 4 lines · In message <[email protected]> you wrote:

When the image which bootm is given can't be booted, call panic with the error message rather than printf/hang so that we can recover from broken images via a bootcount mechanism. If hang on failure is still required then CONFIG_PANIC_HANG can still be enabled.

I wonder if the failing of the FDT creation is a reason to panic / reboot at all? The point of no return is architecture dependent - for example, on Power architecture it is usuallywhen the kernel image gests decompressed/written to RAM, as then the exception vectors get overwritten, so no return to U-Boot is possible.

But the FDT is always (I think ?) just written to an area of RAM that is not critical for the execution of U-Boot itself - so when this fails, why can we not simply return to U-Boot with an eroor indication?

I feel we should use panic/hang only as a last resort, when no other recovery is possible?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Have you lived in this village all your life?"        "No, not yet."
#3 lore raw

PATCH 1/1 bootm: fdt: Use panic() instead of hang() when presented with a bad image

Quoted 15 lines · Wolfgang Denk

Dear Alex,

Quoted 4 lines · In message <[email protected]> you wrote:

When the image which bootm is given can't be booted, call panic with the error message rather than printf/hang so that we can recover from broken images via a bootcount mechanism. If hang on failure is still required then CONFIG_PANIC_HANG can still be enabled.

I wonder if the failing of the FDT creation is a reason to panic / reboot at all? The point of no return is architecture dependent - for example, on Power architecture it is usuallywhen the kernel image gests decompressed/written to RAM, as then the exception vectors get overwritten, so no return to U-Boot is possible.

Quoted 8 lines

But the FDT is always (I think ?) just written to an area of RAM that is not critical for the execution of U-Boot itself - so when this fails, why can we not simply return to U-Boot with an eroor indication?

I feel we should use panic/hang only as a last resort, when no other recovery is possible?

Thinking it through, that sounds reasonable to me... the reason I ended up looking at this code was because I deployed a broken FIT image, then got stuck here. But if bootm had returned with a failure I could have done useful recovery actions without needing a reboot.

Signature · 1 line
Alex Kiernan