mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] common: prefix panic with PANIC:
@ 2025-08-06 12:47 Ahmad Fatoum
  2025-08-06 12:47 ` [PATCH 2/2] ARM: interrupts: unify panic output on unhandled exception Ahmad Fatoum
  2025-08-07  6:06 ` [PATCH 1/2] common: prefix panic with PANIC: Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-08-06 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

This makes it easier to match against in the test suite.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 common/misc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/misc.c b/common/misc.c
index ce1fbc284f48..af22579af16f 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -289,6 +289,8 @@ BAREBOX_MAGICVAR(global.of.kernel.add_machine_compatible, "Extra machine/board c
 
 static void __noreturn do_panic(bool stacktrace, const char *fmt, va_list ap)
 {
+	if (*fmt)
+		eprintf("PANIC: ");
 	veprintf(fmt, ap);
 	eputchar('\n');
 
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ARM: interrupts: unify panic output on unhandled exception
  2025-08-06 12:47 [PATCH 1/2] common: prefix panic with PANIC: Ahmad Fatoum
@ 2025-08-06 12:47 ` Ahmad Fatoum
  2025-08-07  6:06 ` [PATCH 1/2] common: prefix panic with PANIC: Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-08-06 12:47 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

ARM32 and ARM64 exceptions look slightly different making it cumbersome
to match against in the test suite. Let's unify them to a common scheme.

For example, on ARM64 instead of:

  NULL pointer dereference: DABT (current EL) exception \
    (ESR 0x9600004b) at 0x0000000000000800

We now have:

  PANIC: unable to handle NULL pointer dereference at address $addr
  DABT (current EL) (ESR 0x9600004b)

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/cpu/interrupts_32.c | 24 +++++++++-----------
 arch/arm/cpu/interrupts_64.c | 44 +++++++++++++++++++-----------------
 2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/interrupts_32.c b/arch/arm/cpu/interrupts_32.c
index b8b9210197ea..185646e38195 100644
--- a/arch/arm/cpu/interrupts_32.c
+++ b/arch/arm/cpu/interrupts_32.c
@@ -67,8 +67,11 @@ void show_regs (struct pt_regs *regs)
 #endif
 }
 
-static void __noreturn do_exception(struct pt_regs *pt_regs)
+static void __noreturn do_exception(const char *reason, struct pt_regs *pt_regs)
 {
+	if (reason)
+		eprintf("PANIC: unable to handle %s\n", reason);
+
 	show_regs(pt_regs);
 
 	panic_no_stacktrace("");
@@ -80,8 +83,7 @@ static void __noreturn do_exception(struct pt_regs *pt_regs)
  */
 void do_undefined_instruction (struct pt_regs *pt_regs)
 {
-	eprintf("undefined instruction\n");
-	do_exception(pt_regs);
+	do_exception("undefined instruction", pt_regs);
 }
 
 /**
@@ -93,8 +95,7 @@ void do_undefined_instruction (struct pt_regs *pt_regs)
  */
 void do_software_interrupt (struct pt_regs *pt_regs)
 {
-	eprintf("software interrupt\n");
-	do_exception(pt_regs);
+	do_exception("software interrupt", pt_regs);
 }
 
 /**
@@ -105,8 +106,7 @@ void do_software_interrupt (struct pt_regs *pt_regs)
  */
 void do_prefetch_abort (struct pt_regs *pt_regs)
 {
-	eprintf("prefetch abort\n");
-	do_exception(pt_regs);
+	do_exception("prefetch abort", pt_regs);
 }
 
 static const char *data_abort_reason(ulong far)
@@ -131,10 +131,10 @@ void do_data_abort (struct pt_regs *pt_regs)
 
 	asm volatile ("mrc     p15, 0, %0, c6, c0, 0" : "=r" (far) : : "cc");
 
-	eprintf("unable to handle %s at address 0x%08x\n",
+	eprintf("PANIC: unable to handle %s at address 0x%08x\n",
 		data_abort_reason(far), far);
 
-	do_exception(pt_regs);
+	do_exception(NULL, pt_regs);
 }
 
 /**
@@ -145,8 +145,7 @@ void do_data_abort (struct pt_regs *pt_regs)
  */
 void do_fiq (struct pt_regs *pt_regs)
 {
-	eprintf("fast interrupt request\n");
-	do_exception(pt_regs);
+	do_exception("fast interrupt request", pt_regs);
 }
 
 /**
@@ -157,8 +156,7 @@ void do_fiq (struct pt_regs *pt_regs)
  */
 void do_irq (struct pt_regs *pt_regs)
 {
-	eprintf("interrupt request\n");
-	do_exception(pt_regs);
+	do_exception("interrupt request", pt_regs);
 }
 
 extern volatile int arm_ignore_data_abort;
diff --git a/arch/arm/cpu/interrupts_64.c b/arch/arm/cpu/interrupts_64.c
index b4787783978e..24eb1516ed6e 100644
--- a/arch/arm/cpu/interrupts_64.c
+++ b/arch/arm/cpu/interrupts_64.c
@@ -84,14 +84,17 @@ void show_regs(struct pt_regs *regs)
 	eprintf("\n");
 }
 
-static void __noreturn do_exception(struct pt_regs *pt_regs)
+static void __noreturn do_exception(const char *reason, struct pt_regs *pt_regs)
 {
+	if (reason)
+		eprintf("PANIC: unable to handle %s\n", reason);
+
 	show_regs(pt_regs);
 
 	if (IN_PROPER)
 		unwind_backtrace(pt_regs);
 
-	panic_no_stacktrace("panic: unhandled exception");
+	panic_no_stacktrace("");
 }
 
 /**
@@ -102,8 +105,7 @@ static void __noreturn do_exception(struct pt_regs *pt_regs)
  */
 void do_fiq(struct pt_regs *pt_regs)
 {
-	eprintf("fast interrupt request\n");
-	do_exception(pt_regs);
+	do_exception("fast interrupt request", pt_regs);
 }
 
 /**
@@ -114,32 +116,27 @@ void do_fiq(struct pt_regs *pt_regs)
  */
 void do_irq(struct pt_regs *pt_regs)
 {
-	eprintf("interrupt request\n");
-	do_exception(pt_regs);
+	do_exception("interrupt request", pt_regs);
 }
 
 void do_bad_sync(struct pt_regs *pt_regs)
 {
-	eprintf("bad sync\n");
-	do_exception(pt_regs);
+	do_exception("bad sync", pt_regs);
 }
 
 void do_bad_irq(struct pt_regs *pt_regs)
 {
-	eprintf("bad irq\n");
-	do_exception(pt_regs);
+	do_exception("bad irq", pt_regs);
 }
 
 void do_bad_fiq(struct pt_regs *pt_regs)
 {
-	eprintf("bad fiq\n");
-	do_exception(pt_regs);
+	do_exception("bad fiq", pt_regs);
 }
 
 void do_bad_error(struct pt_regs *pt_regs)
 {
-	eprintf("bad error\n");
-	do_exception(pt_regs);
+	do_exception("bad error", pt_regs);
 }
 
 extern volatile int arm_ignore_data_abort;
@@ -148,9 +145,10 @@ extern volatile int arm_data_abort_occurred;
 static const char *data_abort_reason(ulong far)
 {
 	if (far < PAGE_SIZE)
-		return "NULL pointer dereference: ";
+		return "NULL pointer dereference";
+
 	if (inside_stack_guard_page(far))
-		return "Stack overflow: ";
+		return "stack overflow";
 
 	return NULL;
 }
@@ -169,16 +167,20 @@ void do_sync(struct pt_regs *pt_regs, unsigned int esr, unsigned long far)
 		extra = data_abort_reason(far);
 	}
 
-	eprintf("%s%s exception (ESR 0x%08x) at 0x%016lx\n", extra ?: "",
-		esr_get_class_string(esr), esr, far);
-	do_exception(pt_regs);
+	if (!extra)
+		extra = "paging request";
+
+	eprintf("PANIC: unable to handle %s at address 0x%016lx\n",
+		extra, far);
+
+	eprintf("%s (ESR 0x%08x)\n", esr_get_class_string(esr), esr);
+	do_exception(NULL, pt_regs);
 }
 
 
 void do_error(struct pt_regs *pt_regs)
 {
-	eprintf("error exception\n");
-	do_exception(pt_regs);
+	do_exception("error exception", pt_regs);
 }
 
 void data_abort_mask(void)
-- 
2.39.5




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] common: prefix panic with PANIC:
  2025-08-06 12:47 [PATCH 1/2] common: prefix panic with PANIC: Ahmad Fatoum
  2025-08-06 12:47 ` [PATCH 2/2] ARM: interrupts: unify panic output on unhandled exception Ahmad Fatoum
@ 2025-08-07  6:06 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-08-07  6:06 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Wed, 06 Aug 2025 14:47:15 +0200, Ahmad Fatoum wrote:
> This makes it easier to match against in the test suite.
> 
> 

Applied, thanks!

[1/2] common: prefix panic with PANIC:
      https://git.pengutronix.de/cgit/barebox/commit/?id=a27b277bbf5d (link may not be stable)
[2/2] ARM: interrupts: unify panic output on unhandled exception
      https://git.pengutronix.de/cgit/barebox/commit/?id=2e12db887c77 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-07  6:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-06 12:47 [PATCH 1/2] common: prefix panic with PANIC: Ahmad Fatoum
2025-08-06 12:47 ` [PATCH 2/2] ARM: interrupts: unify panic output on unhandled exception Ahmad Fatoum
2025-08-07  6:06 ` [PATCH 1/2] common: prefix panic with PANIC: Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox