[PATCH v2 09/16] LoongArch: Exception handling
Simon Glass
sjg at chromium.org
Thu Jul 2 12:25:51 CEST 2026
Hi Jiaxun,
On 2026-07-01T11:17:53, Yao Zi <me at ziyao.cc> wrote:
> LoongArch: Exception handling
>
> Add exception entry assembly code, import stackframe.h
> from Linux, provide debug prints when exception happens.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com>
> Signed-off-by: Yao Zi <me at ziyao.cc>
>
> arch/loongarch/Kconfig | 3 +
> arch/loongarch/cpu/Makefile | 2 +-
> arch/loongarch/cpu/genex.S | 21 ++++
> arch/loongarch/include/asm/stackframe.h | 175 +++++++++++++++++++++++++++++
> arch/loongarch/lib/interrupts.c | 189 ++++++++++++++++++++++++++++++++
> 5 files changed, 389 insertions(+), 1 deletion(-)
> diff --git a/arch/loongarch/lib/interrupts.c b/arch/loongarch/lib/interrupts.c
> @@ -0,0 +1,189 @@
> +static void show_regs(struct pt_regs *regs)
> +{
> +#if IS_ENABLED(CONFIG_SHOW_REGS)
> + const int field = 2 * sizeof(unsigned long);
Please use 'if (CONFIG_IS_ENABLED(SHOW_REGS))' at the call site (as
you do for FRAMEPOINTER below) rather than wrapping the function
body in #if - that also lets you honour SPL_SHOW_REGS.
> diff --git a/arch/loongarch/lib/interrupts.c b/arch/loongarch/lib/interrupts.c
> @@ -0,0 +1,189 @@
> +static void __maybe_unused show_backtrace(struct pt_regs *regs)
> +{
> + uintptr_t *fp = (uintptr_t *)regs->regs[0x16];
Magic 0x16 (= 22 = fp) is hard to read. Please use a named constant,
or add an fp accessor / use the regdef indices.
> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
> @@ -30,6 +30,9 @@ config DMA_ADDR_T_64BIT
> +config SHOW_REGS
> + bool "Show registers on unhandled exception"
Missing help text, and please follow the RISC-V pattern: default y
plus a matching SPL_SHOW_REGS entry. Otherwise the default on
LoongArch is to hide all GPRs on a crash, making triage harder.
Regards,
Simon
More information about the U-Boot
mailing list