[PATCH v4 3/3] firmware: fw_base.S: Add common NMI trap handler

Ember Sawady ecs at d2evs.net
Mon Apr 27 09:18:24 PDT 2026


On Fri Mar 13, 2026 at 1:39 PM UTC, Nylon Chen wrote:
> diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
> index 731a0c98..6a56e64e 100644
> --- a/include/sbi/sbi_trap.h
> +++ b/include/sbi/sbi_trap.h
> @@ -289,6 +289,24 @@ static inline void sbi_trap_set_context(struct sbi_scratch *scratch,
-%<-
> +/**
> + * Default RNMI trap handler called from sbi_rnmi_vector.
> + *
> + * This is the default handler for Resumable Non-Maskable Interrupts (RNMI).
> + * It prints diagnostic information and hangs the hart. Platforms that can
> + * handle and resume from an NMI should override this function.
> + */
> +void __attribute__((weak)) sbi_rnmi_trap_handler(struct sbi_trap_regs *regs,
> +						  unsigned long mncause);

Putting __attribute__((weak)) in the header makes it apply to custom 
trap handlers as well, which prevents them from overriding the default 
one. Better to only use __attribute__((weak)) in the implementation.

Other than that, this LGTM. I've been using this patchset on a custom 
platform with rNMI support, and I haven't had any other issues.



More information about the opensbi mailing list