register a "CpusAccel" interface for HAX as well.
Signed-off-by: Claudio Fontana
---
softmmu/cpus.c| 80 +---
target/i386/Makefile.objs | 5 +--
target/i386/hax-all.c | 6 +++-
target/i386/hax-cpus.c| 85 +++
target/i386/hax-cpus.h| 17 ++
target/i386/hax-i386.h| 2 ++
target/i386/hax-posix.c | 12 +++
target/i386/hax-windows.c | 20 +++
8 files changed, 145 insertions(+), 82 deletions(-)
create mode 100644 target/i386/hax-cpus.c
create mode 100644 target/i386/hax-cpus.h
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index bd535c68e0..c314e22bd2 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -33,7 +33,6 @@
#include "exec/gdbstub.h"
#include "sysemu/hw_accel.h"
#include "sysemu/kvm.h"
-#include "sysemu/hax.h"
#include "sysemu/hvf.h"
#include "sysemu/whpx.h"
#include "exec/exec-all.h"
@@ -179,9 +178,6 @@ void cpu_synchronize_state(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_state) {
cpus_accel->synchronize_state(cpu);
}
-if (hax_enabled()) {
-hax_cpu_synchronize_state(cpu);
-}
if (whpx_enabled()) {
whpx_cpu_synchronize_state(cpu);
}
@@ -192,9 +188,6 @@ void cpu_synchronize_post_reset(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_post_reset) {
cpus_accel->synchronize_post_reset(cpu);
}
-if (hax_enabled()) {
-hax_cpu_synchronize_post_reset(cpu);
-}
if (whpx_enabled()) {
whpx_cpu_synchronize_post_reset(cpu);
}
@@ -205,9 +198,6 @@ void cpu_synchronize_post_init(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_post_init) {
cpus_accel->synchronize_post_init(cpu);
}
-if (hax_enabled()) {
-hax_cpu_synchronize_post_init(cpu);
-}
if (whpx_enabled()) {
whpx_cpu_synchronize_post_init(cpu);
}
@@ -218,9 +208,6 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu)
if (cpus_accel && cpus_accel->synchronize_pre_loadvm) {
cpus_accel->synchronize_pre_loadvm(cpu);
}
-if (hax_enabled()) {
-hax_cpu_synchronize_pre_loadvm(cpu);
-}
if (hvf_enabled()) {
hvf_cpu_synchronize_pre_loadvm(cpu);
}
@@ -416,35 +403,6 @@ void qemu_wait_io_event(CPUState *cpu)
qemu_wait_io_event_common(cpu);
}
-static void *qemu_hax_cpu_thread_fn(void *arg)
-{
-CPUState *cpu = arg;
-int r;
-
-rcu_register_thread();
-qemu_mutex_lock_iothread();
-qemu_thread_get_self(cpu->thread);
-
-cpu->thread_id = qemu_get_thread_id();
-current_cpu = cpu;
-hax_init_vcpu(cpu);
-cpu_thread_signal_created(cpu);
-qemu_guest_random_seed_thread_part2(cpu->random_seed);
-
-do {
-if (cpu_can_run(cpu)) {
-r = hax_smp_cpu_exec(cpu);
-if (r == EXCP_DEBUG) {
-cpu_handle_guest_debug(cpu);
-}
-}
-
-qemu_wait_io_event(cpu);
-} while (!cpu->unplug || cpu_can_run(cpu));
-rcu_unregister_thread();
-return NULL;
-}
-
/* The HVF-specific vCPU thread function. This one should only run when the
host
* CPU supports the VMX "unrestricted guest" feature. */
static void *qemu_hvf_cpu_thread_fn(void *arg)
@@ -529,12 +487,6 @@ static void *qemu_whpx_cpu_thread_fn(void *arg)
return NULL;
}
-#ifdef _WIN32
-static void CALLBACK dummy_apc_func(ULONG_PTR unused)
-{
-}
-#endif
-
void cpus_kick_thread(CPUState *cpu)
{
#ifndef _WIN32
@@ -553,10 +505,6 @@ void cpus_kick_thread(CPUState *cpu)
if (!qemu_cpu_is_self(cpu)) {
if (whpx_enabled()) {
whpx_vcpu_kick(cpu);
-} else if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) {
-fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n",
-__func__, GetLastError());
-exit(1);
}
}
#endif
@@ -567,14 +515,7 @@ void qemu_cpu_kick(CPUState *cpu)
qemu_cond_broadcast(cpu->halt_cond);
if (cpus_accel && cpus_accel->kick_vcpu_thread) {
cpus_accel->kick_vcpu_thread(cpu);
-} else {
-if (hax_enabled()) {
-/*
- * FIXME: race condition with the exit_request check in
- * hax_vcpu_hax_exec
- */
-cpu->exit_request = 1;
-}
+} else { /* default */
cpus_kick_thread(cpu);
}
}
@@ -722,23 +663,6 @@ void cpu_remove_sync(CPUState *cpu)
qemu_mutex_lock_iothread();
}
-static void qemu_hax_start_vcpu(CPUState *cpu)
-{
-char thread_name[VCPU_THREAD_NAME_SIZE];
-
-cpu->thread = g_malloc0(sizeof(QemuThread));
-cpu->halt_cond = g_malloc0(sizeof(QemuCond));
-qemu_cond_init(cpu->halt_cond);
-
-snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
- cpu->cpu_index);
-qemu_thread_create(cpu->thread, thread_name, qemu_hax_cpu_thread_fn,
- cpu, QEMU_THREAD_JOINABLE);
-#ifdef _WIN32
-