mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 18:21:41 +00:00
firmware: Clear scratch->trap_context on warm boot
sbi_trap_handler() links tcntx->prev_context on entry and restores
scratch->trap_context on exit, forming a stack that unwinds through
the same path it was pushed from.
Non-retentive suspend/resume breaks that unwind: the SBI call
requesting suspend jumps straight to warm boot (jump_warmboot())
instead of returning through the normal exit path, leaving
scratch->trap_context stale. Since each hart's scratch space sits at
a fixed address, the next trap taken after warm boot resume reads
that same stale scratch->trap_context as its prev_context, which
sbi_trap_error() then walks to print trap diagnostics -- producing a
broken trap dump.
Clear trap_context in the scratch space on warm boot entry.
Fixes: 60ffc154c8 ("include: sbi: Add trap_context pointer in struct sbi_scratch")
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/20260914-trap-context-fix-v2-1-3a6bedc6fcf0@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
1 parent
2afa777592
commit
f84bdb9877
1 file changed
+3
@@ -458,6 +458,9 @@ _start_warm:
|
||||
/* update the mscratch */
|
||||
csrw CSR_MSCRATCH, tp
|
||||
|
||||
/* Clear trap_context in scratch space */
|
||||
REG_S zero, SBI_SCRATCH_TRAP_CONTEXT_OFFSET(tp)
|
||||
|
||||
/* Setup stack */
|
||||
add sp, tp, zero
|
||||
|
||||
|
||||
Reference in new issue
Block a user