diff options
| author | Michael Ellerman <mpe@kernel.org> | 2026-05-30 00:42:18 +1000 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2026-06-15 10:21:03 +0530 |
| commit | 1157eb37e29500b5e30d4c70bda6979fb516c7fc (patch) | |
| tree | 659aea11613fb30590eb4520b2367fd45fa16528 | |
| parent | dec9141a77058dc941f2d0f07107f7306a995c35 (diff) | |
| download | opensbi-1157eb37e29500b5e30d4c70bda6979fb516c7fc.tar.gz opensbi-1157eb37e29500b5e30d4c70bda6979fb516c7fc.zip | |
lib: sbi_trap_v_ldst: Redirect unhandled traps
When SBI is built with a compiler that doesn't support vector, the
misaligned vector load/store emulation is not built in, the handlers are
just stubs.
Currently the stubs just return 0, causing sbi_trap_emulate_load() to
return without incrementing mepc, meaning the instruction will just
fault again, an infinite loop.
Fix the stubs to use sbi_trap_redirect(), which forwards the trap to the
previous mode, allowing it to be handled there.
Fixes: c2acc5e5 ("lib: sbi_misaligned_ldst: Add handling of vector load/store")
Signed-off-by: Michael Ellerman <mpe@kernel.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260530-trap-redirect-v1-1-45d4d333d8c9@kernel.org
Signed-off-by: Anup Patel <anup@brainfault.org>
| -rw-r--r-- | lib/sbi/sbi_trap_v_ldst.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sbi/sbi_trap_v_ldst.c b/lib/sbi/sbi_trap_v_ldst.c index f4d469dc..1e4336f9 100644 --- a/lib/sbi/sbi_trap_v_ldst.c +++ b/lib/sbi/sbi_trap_v_ldst.c @@ -334,11 +334,13 @@ int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, int sbi_misaligned_v_ld_emulator(int rlen, union sbi_ldst_data *out_val, struct sbi_trap_context *tcntx) { - return 0; + /* Unable to emulate, send trap to previous mode. */ + return sbi_trap_redirect(&tcntx->regs, &tcntx->trap); } int sbi_misaligned_v_st_emulator(int wlen, union sbi_ldst_data in_val, struct sbi_trap_context *tcntx) { - return 0; + /* Unable to emulate, send trap to previous mode. */ + return sbi_trap_redirect(&tcntx->regs, &tcntx->trap); } #endif /* OPENSBI_CC_SUPPORT_VECTOR */ |
