mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 10:21:38 +00:00
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:
1 parent
894435d28f
commit
2c7788e4c3
3 files changed
+31
-9
No files matched your search
@@ -62,8 +62,11 @@ enum sbi_platform_features {
|
||||
/** Platform has fault delegation support */
|
||||
SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1),
|
||||
|
||||
/** Platform uses a fixed or mtvec-based RNMI vector */
|
||||
SBI_PLATFORM_HAS_FIXED_SMRNMI_VECTOR = (1 << 2),
|
||||
|
||||
/** Last index of Platform features*/
|
||||
SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_MFAULTS_DELEGATION,
|
||||
SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_FIXED_SMRNMI_VECTOR,
|
||||
};
|
||||
|
||||
/** Default feature set for a platform */
|
||||
@@ -250,6 +253,10 @@ assert_member_offset(struct sbi_platform, cbom_block_size, SBI_PLATFORM_CBOM_BLO
|
||||
#define sbi_platform_has_mfaults_delegation(__p) \
|
||||
((__p)->features & SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
|
||||
|
||||
/** Check whether the platform uses a fixed/mtvec-based RNMI vector */
|
||||
#define sbi_platform_has_fixed_smrnmi_vector(__p) \
|
||||
((__p)->features & SBI_PLATFORM_HAS_FIXED_SMRNMI_VECTOR)
|
||||
|
||||
/**
|
||||
* Get the platform features in string format
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user