On 4/28/24 15:14, Philippe Mathieu-Daudé wrote:
Extract tcg_cpu_exit() from the user cpu_exit() implementation.
In few commits we will re-use it in the system one (via a
per-accel handler).
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
accel/tcg/internal-common.h | 2 ++
accel/tcg/translate-all.c | 7 +++++++
accel/tcg/user-exec.c | 4 +---
3 files changed, 10 insertions(+), 3 deletions(-)
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
r~
diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index ead53cb8a5..df317e7496 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -24,4 +24,6 @@ static inline bool cpu_in_serial_context(CPUState *cs)
return !tcg_cflags_has(cs, CF_PARALLEL) || cpu_in_exclusive_context(cs);
}
+void tcg_cpu_exit(CPUState *cpu);
+
#endif
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index fdf6d8ac19..b67adce20e 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -663,3 +663,10 @@ void tcg_flush_jmp_cache(CPUState *cpu)
qatomic_set(&jc->array[i].tb, NULL);
}
}
+
+void tcg_cpu_exit(CPUState *cpu)
+{
+ /* Ensure cpu_exec will see the exit request after TCG has exited. */
+ smp_wmb();
+ qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
+}
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 404d8a145c..d7e5f00c97 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -49,9 +49,7 @@ void cpu_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);
+ tcg_cpu_exit(cpu);
}
/*