From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 2/2] ARM: interrupts: unify panic output on unhandled exception
Date: Wed, 6 Aug 2025 14:47:16 +0200 [thread overview]
Message-ID: <20250806124716.2800716-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250806124716.2800716-1-a.fatoum@barebox.org>
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
next prev parent reply other threads:[~2025-08-06 12:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 12:47 [PATCH 1/2] common: prefix panic with PANIC: Ahmad Fatoum
2025-08-06 12:47 ` Ahmad Fatoum [this message]
2025-08-07 6:06 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250806124716.2800716-2-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox