Add cpu_loop_exit_excp next to cpu_loop_exit_restore. Set cpu->exception_index, then restore and exit the current TB the same way as cpu_loop_exit_restore.
Signed-off-by: Yonggang Luo <[email protected]> --- accel/tcg/cpu-exec-common.c | 6 ++++++ include/accel/tcg/cpu-loop.h | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index d20cece1c5f..31fed8e497f 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -118,6 +118,12 @@ void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) cpu_loop_exit(cpu); } +void cpu_loop_exit_excp(CPUState *cpu, int exception_index, uintptr_t pc) +{ + cpu->exception_index = exception_index; + cpu_loop_exit_restore(cpu, pc); +} + void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc) { /* Prevent looping if already executing in a serial context. */ diff --git a/include/accel/tcg/cpu-loop.h b/include/accel/tcg/cpu-loop.h index f4d38bc2bca..856091020f2 100644 --- a/include/accel/tcg/cpu-loop.h +++ b/include/accel/tcg/cpu-loop.h @@ -65,6 +65,18 @@ G_NORETURN void cpu_loop_exit_noexc(CPUState *cpu); G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t host_pc); G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t host_pc); +/** + * cpu_loop_exit_excp: + * @cpu: the cpu context + * @exception_index: EXCP_* or target trap number + * @host_pc: the host pc within the translation + * + * Set cpu->exception_index and exit the current TB, restoring + * guest state from @host_pc the same way as cpu_loop_exit_restore. + */ +G_NORETURN void cpu_loop_exit_excp(CPUState *cpu, int exception_index, + uintptr_t host_pc); + /** * cpu_loop_exit: * @cpu: the cpu context -- 2.52.0.windows.1
