Keep riscv_raise_exception() for PMU bookkeeping, but delegate exception
handling to cpu_raise_excp_restore(). It restores guest state when pc is
nonzero and falls back to a plain exception exit otherwise.

Signed-off-by: Yonggang Luo <[email protected]>
---
 target/riscv/tcg/op_helper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/target/riscv/tcg/op_helper.c b/target/riscv/tcg/op_helper.c
index b67c7718db4..ca4efadec50 100644
--- a/target/riscv/tcg/op_helper.c
+++ b/target/riscv/tcg/op_helper.c
@@ -47,8 +47,7 @@ G_NORETURN void riscv_raise_exception(CPURISCVState *env,
                           riscv_cpu_get_trap_name(exception, false),
                           env->pc);
 
-    cs->exception_index = exception;
-    cpu_loop_exit_restore(cs, pc);
+    cpu_raise_excp_restore(cs, exception, pc);
 }
 
 void helper_raise_exception(CPURISCVState *env, uint32_t exception)
-- 
2.52.0.windows.1


Reply via email to