diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-08-01 14:57:51 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-09-17 19:00:55 +0200 |
| commit | ac6c8a390b451913995ee784ef7261b8928e5ace (patch) | |
| tree | b2b99f844f80bfd081ffe1c388e70d5164e65931 /hw/core/cpu-common.c | |
| parent | 9e1ecd4aaaf9aa2f5b7caf364a10241a2cba02a8 (diff) | |
| download | focaccia-qemu-ac6c8a390b451913995ee784ef7261b8928e5ace.tar.gz focaccia-qemu-ac6c8a390b451913995ee784ef7261b8928e5ace.zip | |
accel: use store_release/load_acquire for cross-thread exit_request
Reads and writes cpu->exit_request do not use a load-acquire/store-release pair right now, but this means that cpu_exit() may not write cpu->exit_request after any flags that are read by the vCPU thread. Probably everything is protected one way or the other by the BQL, because cpu->exit_request leads to the slow path, where the CPU thread often takes the BQL (for example, to go to sleep by waiting on the BQL-protected cpu->halt_cond); but it's not clear, so use load-acquire/store-release consistently. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core/cpu-common.c')
| -rw-r--r-- | hw/core/cpu-common.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 152abc9024..42463e6258 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -74,7 +74,8 @@ 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 reason why the exit request was set. */ + qatomic_store_release(&cpu->exit_request, true); /* Ensure cpu_exec will see the exit request after TCG has exited. */ smp_wmb(); qatomic_set(&cpu->neg.icount_decr.u16.high, -1); |