On 8/9/25 04:58, Paolo Bonzini wrote:
cpu->exit_request do not use a load-acquire/store-release pair right now,
but this means that cpu_exit() does not store it after any flags that are
read in the slow path.

Probably everything is protected one way or the other by the BQL, because
after reading cpu->exit_request the CPU thread often goes to sleep
(by waiting on the BQL-protected cpu->halt_cond), but it's not clear.
Use load-acquire/store-release consistently.

Signed-off-by: Paolo Bonzini <[email protected]>
---
  accel/kvm/kvm-all.c          | 19 +++++++++----------
  accel/tcg/cpu-exec.c         |  7 +++++--
  accel/tcg/tcg-accel-ops-rr.c |  2 +-
  hw/core/cpu-common.c         |  3 ++-
  target/i386/nvmm/nvmm-all.c  |  5 ++---
  target/i386/whpx/whpx-all.c  |  3 ++-
  6 files changed, 21 insertions(+), 18 deletions(-)

Reviewed-by: Richard Henderson <[email protected]>

diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
index 39e674aca21..f189ce861c9 100644
--- a/hw/core/cpu-common.c
+++ b/hw/core/cpu-common.c
@@ -84,7 +84,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, 1);


While you're touching the lines, since exit_request is bool, let's use true (and elsewhere in other patches, false).


r~

Reply via email to