[PATCH v2 0/5] Add RISC-V Smrnmi extension support

Evgeny Voevodin evvoevod at tenstorrent.com
Fri May 1 14:16:22 PDT 2026


This is v2 of the Smrnmi series. Rebased on top of upstream/master at
commit 2257e9957103 ("lib: sbi_bitmap_test: add tests for bitmap_empty()").

v1 thread:
https://lore.kernel.org/opensbi/20260310183155.2186463-1-evvoevod@oss.tenstorrent.com/

Changes vs v1:

- Dropped patches 6/7 and 7/7 (Tenstorrent platform support). They will
  go through the Atlantis platform series instead.

- Dropped _rnme_handler assembly entry point, ops->rnme_handler callback
  and sbi_rnme_handler() C function. RNME path now reuses the existing
  _trap_handler since RNME is taken as a regular M-mode trap with NMIE=0.
  ops->smrnmi_handlers_init() now passes _trap_handler in place of
  _rnme_handler.

- Renamed _rnmi_handler to _trap_rnmi_handler.
- Renamed C handler to sbi_trap_rnmi_handler().

- Kept ops->rnmi_handler as the temporary RNMI dispatch mechanism, per
  the v1 discussion. Extending sbi_irqchip to support NMIs is left for
  a separate follow-up series.

Between v1 and v2, upstream introduced ecdb6c90 ("firmware: Initialize
stack guard via Zkr"). The Zkr seed-CSR access can trap if Zkr is not
implemented. On Smrnmi platforms NMIE=0 by default after reset, which
routes that trap to NMEVEC rather than MTVEC. Until Smrnmi handlers are
installed and NMIE=1, no NMEVEC handler is in place, so the early-boot
Zkr probe in _start would crash. To handle this, a new patch (4/5)
refactors the inline seed loop in fw_base.S into a callable
__stack_chk_guard_init function and invokes it from init_coldboot()
after sbi_hart_init() has installed Smrnmi handlers and set NMIE=1.

Testing: Verified on Whisper SW system simulator and on HW emulator.

Evgeny Voevodin (5):
  include: sbi_scratch: Add tmp1 scratch space for RNMI context saving
  lib: sbi: Add Smrnmi extension macros for registers and bits
  firmware: Add RNMI handler infrastructure
  lib: sbi: Create a spot to place Smrnmi detection before traps and
    after DT is ready
  lib: sbi: hart: Detect and enable Smrnmi before trap-based feature
    detection

 firmware/fw_base.S           | 188 ++++++++++++++++++++++++++++++-----
 include/sbi/riscv_encoding.h |  10 ++
 include/sbi/sbi_hart.h       |   2 +
 include/sbi/sbi_platform.h   |   8 ++
 include/sbi/sbi_scratch.h    |  11 +-
 include/sbi/sbi_trap.h       |   2 +
 lib/sbi/sbi_hart.c           |  37 +++++--
 lib/sbi/sbi_init.c           |  10 ++
 lib/sbi/sbi_trap.c           |  39 ++++++++
 9 files changed, 273 insertions(+), 34 deletions(-)


base-commit: 2257e9957103aac7df8089a59b9d4bdda7c592ce
-- 
2.43.0




More information about the opensbi mailing list