On Tue, Sep 29, 2026 at 1:23 PM Philippe Mathieu-Daudé
<[email protected]> wrote:
>
> On 28/9/26 07:20, Yonggang Luo wrote:
> > 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
>
> I'm not comfortable this is hidding the 'restore' part,
> not even mentioning no restore is done if host_pc==0.
So it's the pitfall of cpu_loop_exit_restore. what would be
better, I have no idea how to improve it.
>
> > + *
> > + * 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
>
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo