lib: sbi: allow NULL smrnmi_handlers_init and report init mode at boot

Platforms with fixed or mtvec-based NMI vectors need no vendor
register programming, so calling sbi_panic() when smrnmi_handlers_init
is missing is too strict; an unhandled RNMI already falls back to
sbi_trap_error().

Allow a NULL smrnmi_handlers_init only when the platform has set
SBI_PLATFORM_HAS_FIXED_SMRNMI_VECTOR to indicate it uses a fixed or
mtvec-based vector. This distinguishes platforms that intentionally
have nothing to program from ones that simply forgot to set the
callback, so the latter now fails instead of enabling NMIs and
jumping to an undefined vector on the first RNMI.

Report how Smrnmi was initialized in the boot HART banner: "Platform"
when smrnmi_handlers_init programmed it, "Default" when the flag was
set instead.

Suggested-by: Evgeny Voevodin <evvoevod@tenstorrent.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Co-developed-by: Nia Su <nia.su@sifive.com>
Signed-off-by: Nia Su <nia.su@sifive.com>
Reviewed-by: Evgeny Voevodin <evvoevod@tenstorrent.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260915-smrnmi-context-restore-v3-3-e9dd31152515@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Nia Su authored and Anup Patel committed 2026-11-03 13:15:33 +05:30
1 parent 894435d28f
commit 2c7788e4c3
3 files changed
+31 -9

No files matched your search

+9
View File
@@ -199,6 +199,15 @@ static void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)
sbi_printf("Boot HART Debug Triggers : %d triggers\n",
sbi_dbtr_get_total_triggers());
sbi_hart_delegation_dump(scratch, "Boot HART ", " ");
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMRNMI)) {
const struct sbi_platform *plat = sbi_platform_thishart_ptr();
const struct sbi_platform_operations *ops = sbi_platform_ops(plat);
sbi_printf("Boot HART Smrnmi Init : %s\n",
(ops && ops->smrnmi_handlers_init) ?
"Platform" : "Default");
}
}
static unsigned long coldboot_done;