diff mbox series

[RFC,v2,02/48] system/cpus: Defer memory layout changes until vCPUs are realized

Message ID 20250620171342.92678-3-philmd@linaro.org
State New
Headers show
Series accel: Preparatory cleanups for split-accel | expand

Commit Message

Philippe Mathieu-Daudé June 20, 2025, 5:12 p.m. UTC
vCPUs are not really usable until fully realized. Do not attempt
to commit memory changes in the middle of vCPU realization. Defer
until realization is completed and vCPU fully operational.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/physmem.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/system/physmem.c b/system/physmem.c
index a8a9ca309ea..7004de3992c 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2773,6 +2773,14 @@  static void tcg_commit(MemoryListener *listener)
     cpuas = container_of(listener, CPUAddressSpace, tcg_as_listener);
     cpu = cpuas->cpu;
 
+    if (!qdev_is_realized(DEVICE(cpu))) {
+        /*
+         * The listener is also called during realize, before
+         * all of the tcg machinery for run-on is initialized.
+         */
+        return;
+    }
+
     /*
      * Defer changes to as->memory_dispatch until the cpu is quiescent.
      * Otherwise we race between (1) other cpu threads and (2) ongoing