[PATCH v2 7/7] arm64: simplify interrupt code
Casey Connolly
casey.connolly at linaro.org
Fri Jul 25 14:57:11 CEST 2025
From: Heinrich Schuchardt <xypron.glpk at gmx.de>
Carve out a function except_msg() to handle the output for most type of
interrupts.
Consistently use 16 digits for printing the exception syndrome register
esr to match the register size.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
arch/arm/lib/interrupts_64.c | 72 +++++++++++++++-----------------------------
1 file changed, 24 insertions(+), 48 deletions(-)
diff --git a/arch/arm/lib/interrupts_64.c b/arch/arm/lib/interrupts_64.c
index 6cb16811566a..9687e2e1c142 100644
--- a/arch/arm/lib/interrupts_64.c
+++ b/arch/arm/lib/interrupts_64.c
@@ -206,63 +206,57 @@ static bool smh_emulate_trap(struct pt_regs *regs)
regs->elr += size;
return true;
}
-/*
- * do_bad_sync handles the impossible case in the Synchronous Abort vector.
+/**
+ * except_msg() - print exception message
+ *
+ * Print exception message, register contents, backtrace, loaded EFI images.
+ *
+ * @msg: message describing exception type
+ * @pt_regs: registers
*/
-void do_bad_sync(struct pt_regs *pt_regs)
+static void except_msg(const char *msg, struct pt_regs *pt_regs)
{
efi_restore_gd();
- printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08lx\n",
- pt_regs->esr);
+ printf("%s handler, esr 0x%016lx\n", msg, pt_regs->esr);
show_regs(pt_regs);
if (CONFIG_IS_ENABLED(FRAMEPOINTER))
show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
show_efi_loaded_images(pt_regs);
panic("Resetting CPU ...\n");
}
+/*
+ * do_bad_sync handles the impossible case in the Synchronous Abort vector.
+ */
+void do_bad_sync(struct pt_regs *pt_regs)
+{
+ except_msg("Bad mode in \"Synchronous Abort\"", pt_regs);
+}
+
/*
* do_bad_irq handles the impossible case in the Irq vector.
*/
void do_bad_irq(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("Bad mode in \"Irq\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("Bad mode in \"Irq\"", pt_regs);
}
/*
* do_bad_fiq handles the impossible case in the Fiq vector.
*/
void do_bad_fiq(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("Bad mode in \"Fiq\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("Bad mode in \"Fiq\"", pt_regs);
}
/*
* do_bad_error handles the impossible case in the Error vector.
*/
void do_bad_error(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("Bad mode in \"Error\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("Bad mode in \"Error\"", pt_regs);
}
/*
* do_sync handles the Synchronous Abort exception.
@@ -272,9 +266,9 @@ void do_sync(struct pt_regs *pt_regs)
if (CONFIG_IS_ENABLED(SEMIHOSTING_FALLBACK) &&
smh_emulate_trap(pt_regs))
return;
efi_restore_gd();
- printf("\"Synchronous Abort\" handler, esr 0x%08lx", pt_regs->esr);
+ printf("\"Synchronous Abort\" handler, esr 0x%016lx", pt_regs->esr);
dump_far(pt_regs->esr);
printf("\n");
show_regs(pt_regs);
if (CONFIG_IS_ENABLED(FRAMEPOINTER))
@@ -287,29 +281,17 @@ void do_sync(struct pt_regs *pt_regs)
* do_irq handles the Irq exception.
*/
void do_irq(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("\"Irq\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("\"Irq\"", pt_regs);
}
/*
* do_fiq handles the Fiq exception.
*/
void do_fiq(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("\"Fiq\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("\"Fiq\"", pt_regs);
}
/*
* do_error handles the Error exception.
@@ -318,12 +300,6 @@ void do_fiq(struct pt_regs *pt_regs)
* in processor specific code.
*/
void __weak do_error(struct pt_regs *pt_regs)
{
- efi_restore_gd();
- printf("\"Error\" handler, esr 0x%08lx\n", pt_regs->esr);
- show_regs(pt_regs);
- if (CONFIG_IS_ENABLED(FRAMEPOINTER))
- show_backtrace(pt_regs->regs[30], pt_regs->regs[29]);
- show_efi_loaded_images(pt_regs);
- panic("Resetting CPU ...\n");
+ except_msg("\"Error\"", pt_regs);
}
--
2.50.1
More information about the U-Boot
mailing list