You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
riscv: advance PC by real instruction size on exception
cpu_handle_exception unconditionally does env->pc += 4 for RISC-V. That
corrupts the PC for 16-bit compressed instructions and for instruction
access/page faults, where env->pc already holds the faulting address and
must not be advanced.
Move the logic into a RISC-V helper, riscv_cpu_prepare_exception_pc(),
which mirrors the trap state riscv_cpu_do_interrupt would set up:
- load mbadaddr from badaddr for every address-bearing exception so the
UC_HOOK_INTR callback can inspect the faulting address
- advance the PC by the real instruction size (2 or 4 bytes, from the low
two opcode bits) for execution-time exceptions
- leave the PC untouched for INST_ADDR_MIS / INST_ACCESS_FAULT /
INST_PAGE_FAULT
Extract the address-bearing exception list into a shared
riscv_cpu_exception_has_badaddr() predicate used by both do_interrupt and
the new helper, instead of duplicating the switch.
0 commit comments