]> git.proxmox.com Git - mirror_qemu.git/blobdiff - cpu.c
Merge tag 'pull-aspeed-20230207' of https://github.com/legoater/qemu into staging
[mirror_qemu.git] / cpu.c
diff --git a/cpu.c b/cpu.c
index 4a7d86542780c73a189b7d41dcc59265a8571734..21cf809614deed1a9b8a45af4a3f8265364cda26 100644 (file)
--- a/cpu.c
+++ b/cpu.c
@@ -176,11 +176,20 @@ void cpu_exec_unrealizefn(CPUState *cpu)
         vmstate_unregister(NULL, &vmstate_cpu_common, cpu);
     }
 #endif
+
+    /* Call the plugin hook before clearing cpu->cpu_index in cpu_list_remove */
     if (tcg_enabled()) {
-        tcg_exec_unrealizefn(cpu);
+        qemu_plugin_vcpu_exit_hook(cpu);
     }
 
     cpu_list_remove(cpu);
+    /*
+     * Now that the vCPU has been removed from the RCU list, we can call
+     * tcg_exec_unrealizefn, which may free fields using call_rcu.
+     */
+    if (tcg_enabled()) {
+        tcg_exec_unrealizefn(cpu);
+    }
 }
 
 /*