When ebreak is configured to enter Debug Mode and a Debug Module ROM is present, restart execution from the ROM halt entry instead of reporting a legacy EXCP_DEBUG stop.
This makes ebreak-driven debug entry follow the same ROM-based flow as haltreq and single-step stops. Signed-off-by: Chao Liu <[email protected]> --- target/riscv/op_helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 945688eca8..7f2769f444 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -517,6 +517,10 @@ void helper_sdext_ebreak(CPURISCVState *env, target_ulong pc) if (enter_debug) { riscv_cpu_enter_debug_mode(env, pc, DCSR_CAUSE_EBREAK); + if (env->dm_rom_present) { + env->pc = env->dm_halt_addr; + cpu_loop_exit(cs); + } cs->exception_index = EXCP_DEBUG; cpu_loop_exit_restore(cs, GETPC()); } -- 2.53.0
