[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/14] accel: Move HAX hThread to accelerator context
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 08/14] accel: Move HAX hThread to accelerator context |
Date: |
Wed, 5 Apr 2023 12:18:05 +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>
---
include/hw/core/cpu.h | 1 -
target/i386/hax/hax-i386.h | 3 +++
target/i386/hax/hax-accel-ops.c | 2 +-
target/i386/hax/hax-all.c | 2 +-
target/i386/hax/hax-windows.c | 2 +-
5 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 173f47d24e..8d27861ed5 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -334,7 +334,6 @@ struct CPUState {
struct QemuThread *thread;
#ifdef _WIN32
- HANDLE hThread;
QemuSemaphore sem;
#endif
int thread_id;
diff --git a/target/i386/hax/hax-i386.h b/target/i386/hax/hax-i386.h
index d11d43e857..15d16772db 100644
--- a/target/i386/hax/hax-i386.h
+++ b/target/i386/hax/hax-i386.h
@@ -27,6 +27,9 @@ typedef HANDLE hax_fd;
extern struct hax_state hax_global;
typedef struct AccelvCPUState {
+#ifdef _WIN32
+ HANDLE hThread;
+#endif
hax_fd fd;
int vcpu_id;
struct hax_tunnel *tunnel;
diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c
index a8512efcd5..5031096760 100644
--- a/target/i386/hax/hax-accel-ops.c
+++ b/target/i386/hax/hax-accel-ops.c
@@ -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
}
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index a55b18f353..c9ccc411e9 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -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;
diff --git a/target/i386/hax/hax-windows.c b/target/i386/hax/hax-windows.c
index 08ec93a256..b907953321 100644
--- a/target/i386/hax/hax-windows.c
+++ b/target/i386/hax/hax-windows.c
@@ -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);
--
2.38.1
- Re: [PATCH 02/14] accel: Remove unused hThread variable on TCG/WHPX, (continued)
- [PATCH 03/14] accel: Fix a leak on Windows HAX, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 04/14] accel: Destroy HAX vCPU threads once done, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 05/14] accel: Rename 'hax_vcpu' as 'accel' in CPUState, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 06/14] accel: Use a typedef for struct hax_vcpu_state, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 07/14] accel: Rename struct hax_vcpu_state -> struct AccelvCPUState, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 08/14] accel: Move HAX hThread to accelerator context,
Philippe Mathieu-Daudé <=
- [PATCH 09/14] accel: Allocate NVMM vCPU using g_try_FOO(), Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 10/14] accel: Rename NVMM struct qemu_vcpu -> struct AccelvCPUState, Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 11/14] accel: Inline NVMM get_qemu_vcpu(), Philippe Mathieu-Daudé, 2023/04/05
- [PATCH 12/14] accel: Rename WHPX struct whpx_vcpu -> struct AccelvCPUState, Philippe Mathieu-Daudé, 2023/04/05