mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 10:21:38 +00:00
sbi_hart_switch_mode() writes next_addr unmasked into stvec (vstvec, utvec). Bits [1:0] of xtvec are the MODE field, so a 2-byte aligned entry, legal with the C extension, selects a reserved mode: QEMU drops the write, the Sail model keeps the old mode, and the next stage starts with a trap vector that is not its entry. Mask the mode bits and install the entry as a direct-mode vector; mepc still receives the exact address. Signed-off-by: Nickolai Zeldovich <nickolai.zeldovich@gmail.com> Assisted-by: Claude Fable 5.1 Tested-by: Chen Pei <cp0613@linux.alibaba.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20261006193619.735580-1-nickolai@csail.mit.edu Signed-off-by: Anup Patel <anup@brainfault.org>