OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] lib: sbi: Fix Smrnmi/RNMI trap handling issues
@ 2026-08-28  6:09 Nia Su
  2026-08-28  6:09 ` [PATCH 1/2] lib: sbi: Fix Smrnmi init and non-retentive suspend handling Nia Su
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Nia Su @ 2026-08-28  6:09 UTC (permalink / raw)
  To: opensbi; +Cc: Nia Su, Nick Hu, Nylon Chen

This series fixes two issues in the Smrnmi extension and RNMI trap
handling code:

Patch 1 moves the Smrnmi CSR setup into a dedicated
sbi_smrnmi_hart_init() helper so it also runs on the non-retentive
suspend resume path (sbi_hart_reinit()), and relaxes
smrnmi_handlers_init to allow a NULL callback and to report failure
via an int return value instead of void.

Patch 2 fixes sbi_trap_rnmi_handler(), which never updates
prev_context and can inherit a stale value from an earlier trap
that reused the same M-mode exception-stack slot. This can make
sbi_trap_error() loop indefinitely instead of printing diagnostics.
The fix maintains the trap-context pointer the same way
sbi_trap_handler() does, so nested contexts always link correctly.

Signed-off-by: Nia Su <nia.su@sifive.com>
---
Nia Su (1):
      lib: sbi: Fix stale prev_context in RNMI handler

Nylon Chen (1):
      lib: sbi: Fix Smrnmi init and non-retentive suspend handling

 include/sbi/sbi_hart.h     |  1 +
 include/sbi/sbi_platform.h |  2 +-
 lib/sbi/sbi_hart.c         | 55 +++++++++++++++++++++++++++++-----------------
 lib/sbi/sbi_trap.c         | 10 +++++++--
 4 files changed, 45 insertions(+), 23 deletions(-)
---
base-commit: 4e79fd7de59f1b2899092c1a84ce68c8ebc68f93
change-id: 20260826-rnmi-trap-fixes-91347b53b0dd

--


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 0/2] lib: sbi: Fix stale trap_context/prev_context linking
@ 2026-09-04  8:16 Nia Su
  2026-09-04  8:16 ` [PATCH 2/2] lib: sbi: Fix stale prev_context in RNMI handler Nia Su
  0 siblings, 1 reply; 8+ messages in thread
From: Nia Su @ 2026-09-04  8:16 UTC (permalink / raw)
  To: opensbi; +Cc: Nia Su, Nylon Chen, Nick Hu, Zong Li, Evgeny Voevodin

Patch 1 clears scratch->trap_context on warm boot, since
non-retentive suspend/resume jumps straight there without restoring
it, leaving a stale pointer misused as the next trap's prev_context.

Patch 2 fixes sbi_trap_rnmi_handler() to link prev_context on entry
and restore it on exit, the same way sbi_trap_handler() does.

Signed-off-by: Nia Su <nia.su@sifive.com>
---
Nia Su (2):
      firmware: Clear scratch->trap_context on warm boot
      lib: sbi: Fix stale prev_context in RNMI handler

 firmware/fw_base.S |  3 +++
 lib/sbi/sbi_trap.c | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
---
base-commit: 35511bc6ee1c9c17b6a89b44c52e2044bb51b979
change-id: 20260902-trap-context-fix-b9e78441953e

--


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-04  8:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28  6:09 [PATCH 0/2] lib: sbi: Fix Smrnmi/RNMI trap handling issues Nia Su
2026-08-28  6:09 ` [PATCH 1/2] lib: sbi: Fix Smrnmi init and non-retentive suspend handling Nia Su
2026-08-28  6:09 ` [PATCH 2/2] lib: sbi: Fix stale prev_context in RNMI handler Nia Su
2026-08-31 17:17 ` [PATCH 0/2] lib: sbi: Fix Smrnmi/RNMI trap handling issues Evgeny Voevodin
2026-09-02  8:22   ` Nia Su
2026-09-02 17:33     ` Evgeny Voevodin
2026-09-03  2:36       ` Nia Su
  -- strict thread matches above, loose matches on Subject: below --
2026-09-04  8:16 [PATCH 0/2] lib: sbi: Fix stale trap_context/prev_context linking Nia Su
2026-09-04  8:16 ` [PATCH 2/2] lib: sbi: Fix stale prev_context in RNMI handler Nia Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox