Message ID | 20240428221450.26460-5-philmd@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | exec: Rework around CPUState user fields (part 2) | expand |
On 4/28/24 15:14, Philippe Mathieu-Daudé wrote: > We will introduce a per-accelerator vCPU exit() handler > for system emulation. Duplicate cpu_exit() because the > handler won't be accessible from user emulation. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > accel/tcg/user-exec.c | 8 ++++++++ > hw/core/cpu-common.c | 8 -------- > system/cpus.c | 8 ++++++++ > 3 files changed, 16 insertions(+), 8 deletions(-) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> r~ > > diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c > index f49435df9d..404d8a145c 100644 > --- a/accel/tcg/user-exec.c > +++ b/accel/tcg/user-exec.c > @@ -46,6 +46,14 @@ void cpu_interrupt(CPUState *cpu, int mask) > qatomic_set(&cpu->neg.icount_decr.u16.high, -1); > } > > +void cpu_exit(CPUState *cpu) > +{ > + qatomic_set(&cpu->exit_request, 1); > + /* Ensure cpu_exec will see the exit request after TCG has exited. */ > + smp_wmb(); > + qatomic_set(&cpu->neg.icount_decr.u16.high, -1); > +} > + > /* > * Adjust the pc to pass to cpu_restore_state; return the memop type. > */ > diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c > index 9b3efba82f..cbafc79033 100644 > --- a/hw/core/cpu-common.c > +++ b/hw/core/cpu-common.c > @@ -78,14 +78,6 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) > } > } > > -void cpu_exit(CPUState *cpu) > -{ > - qatomic_set(&cpu->exit_request, 1); > - /* Ensure cpu_exec will see the exit request after TCG has exited. */ > - smp_wmb(); > - qatomic_set(&cpu->neg.icount_decr.u16.high, -1); > -} > - > static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) > { > return 0; > diff --git a/system/cpus.c b/system/cpus.c > index 68d161d96b..e0530ad603 100644 > --- a/system/cpus.c > +++ b/system/cpus.c > @@ -419,6 +419,14 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) > do_run_on_cpu(cpu, func, data, &bql); > } > > +void cpu_exit(CPUState *cpu) > +{ > + qatomic_set(&cpu->exit_request, 1); > + /* Ensure cpu_exec will see the exit request after TCG has exited. */ > + smp_wmb(); > + qatomic_set(&cpu->neg.icount_decr.u16.high, -1); > +} > + > static void qemu_cpu_stop(CPUState *cpu, bool exit) > { > g_assert(qemu_cpu_is_self(cpu));
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index f49435df9d..404d8a145c 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -46,6 +46,14 @@ void cpu_interrupt(CPUState *cpu, int mask) qatomic_set(&cpu->neg.icount_decr.u16.high, -1); } +void cpu_exit(CPUState *cpu) +{ + qatomic_set(&cpu->exit_request, 1); + /* Ensure cpu_exec will see the exit request after TCG has exited. */ + smp_wmb(); + qatomic_set(&cpu->neg.icount_decr.u16.high, -1); +} + /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 9b3efba82f..cbafc79033 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -78,14 +78,6 @@ void cpu_reset_interrupt(CPUState *cpu, int mask) } } -void cpu_exit(CPUState *cpu) -{ - qatomic_set(&cpu->exit_request, 1); - /* Ensure cpu_exec will see the exit request after TCG has exited. */ - smp_wmb(); - qatomic_set(&cpu->neg.icount_decr.u16.high, -1); -} - static int cpu_common_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) { return 0; diff --git a/system/cpus.c b/system/cpus.c index 68d161d96b..e0530ad603 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -419,6 +419,14 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data) do_run_on_cpu(cpu, func, data, &bql); } +void cpu_exit(CPUState *cpu) +{ + qatomic_set(&cpu->exit_request, 1); + /* Ensure cpu_exec will see the exit request after TCG has exited. */ + smp_wmb(); + qatomic_set(&cpu->neg.icount_decr.u16.high, -1); +} + static void qemu_cpu_stop(CPUState *cpu, bool exit) { g_assert(qemu_cpu_is_self(cpu));
We will introduce a per-accelerator vCPU exit() handler for system emulation. Duplicate cpu_exit() because the handler won't be accessible from user emulation. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- accel/tcg/user-exec.c | 8 ++++++++ hw/core/cpu-common.c | 8 -------- system/cpus.c | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-)