accel: Move HAX hThread to accelerator context
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 29 Mar 2023 17:13:09 +0000 (19:13 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 28 Jun 2023 11:55:35 +0000 (13:55 +0200)
hThread variable is only used by the HAX accelerator,
so move it to the accelerator specific context.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230624174121.11508-9-philmd@linaro.org>

include/hw/core/cpu.h
target/i386/hax/hax-accel-ops.c
target/i386/hax/hax-all.c
target/i386/hax/hax-i386.h
target/i386/hax/hax-windows.c

index 45e30911e72b38762d63ce4ee2062b1ca60c7033..476b39e42e27112cf7c9188bd5f2c2590c461f48 100644 (file)
@@ -338,7 +338,6 @@ struct CPUState {
 
     struct QemuThread *thread;
 #ifdef _WIN32
-    HANDLE hThread;
     QemuSemaphore sem;
 #endif
     int thread_id;
index a8512efcd5c3f4a8a98b97bcbd13eac8d83df562..5031096760384cc4b98410ae6208895d4486c76c 100644 (file)
@@ -73,7 +73,7 @@ static void hax_start_vcpu_thread(CPUState *cpu)
                        cpu, QEMU_THREAD_JOINABLE);
     assert(cpu->accel);
 #ifdef _WIN32
-    cpu->hThread = qemu_thread_get_handle(cpu->thread);
+    cpu->accel->hThread = qemu_thread_get_handle(cpu->thread);
 #endif
 }
 
index 9d9011cc38402a0ac04935b34c4326139ce8cad5..18d78e5b6bd5fde95e9ceb1d523618047c68a8d2 100644 (file)
@@ -206,7 +206,7 @@ int hax_vcpu_destroy(CPUState *cpu)
     hax_close_fd(vcpu->fd);
     hax_global.vm->vcpus[vcpu->vcpu_id] = NULL;
 #ifdef _WIN32
-    CloseHandle(cpu->hThread);
+    CloseHandle(vcpu->hThread);
 #endif
     g_free(vcpu);
     cpu->accel = NULL;
index 4372ee596da5a35697dbc0b5fd3681ed0e1d4d01..87153f40ab6b6ff7023b37aa41db5e9eb048da1f 100644 (file)
@@ -27,6 +27,9 @@ typedef HANDLE hax_fd;
 extern struct hax_state hax_global;
 
 struct AccelCPUState {
+#ifdef _WIN32
+    HANDLE hThread;
+#endif
     hax_fd fd;
     int vcpu_id;
     struct hax_tunnel *tunnel;
index bf4b0ad941955b564a3c5c0553e47cab3f64906b..4bf6cc08d26077f5fe5d6ea7b782e471101d1a40 100644 (file)
@@ -476,7 +476,7 @@ void hax_kick_vcpu_thread(CPUState *cpu)
      */
     cpu->exit_request = 1;
     if (!qemu_cpu_is_self(cpu)) {
-        if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) {
+        if (!QueueUserAPC(dummy_apc_func, cpu->accel->hThread, 0)) {
             fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n",
                     __func__, GetLastError());
             exit(1);