Introduce the EXCP_HWACCEL definition to switch to
hardware accelerator.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/split/split-accel.h | 1 +
include/exec/cpu-common.h | 1 +
accel/split/split-accel-ops.c | 11 +++++++++++
3 files changed, 13 insertions(+)
diff --git a/accel/split/split-accel.h b/accel/split/split-accel.h
index 87a08454ce6..8a2888507f3 100644
--- a/accel/split/split-accel.h
+++ b/accel/split/split-accel.h
@@ -42,6 +42,7 @@ struct AccelCPUState {
char pad[128];
AccelState *accel;
+
bool use_hw;
};
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index a68485547d5..6216be5f5e3 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -20,6 +20,7 @@
#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */
#define EXCP_YIELD 0x10004 /* cpu wants to yield timeslice to another */
#define EXCP_ATOMIC 0x10005 /* stop-the-world and emulate atomic */
+#define EXCP_HWACCEL 0x10006 /* use hardware accelerator */
void cpu_exec_init_all(void);
void cpu_exec_step_atomic(CPUState *cpu);
diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
index 3278e01f18a..1766834d537 100644
--- a/accel/split/split-accel-ops.c
+++ b/accel/split/split-accel-ops.c
@@ -10,9 +10,12 @@
#include "qemu/main-loop.h"
#include "qemu/guest-random.h"
#include "exec/cpu-common.h"
+#include "exec/cpu-interrupt.h"
#include "hw/core/cpu.h"
#include "system/accel-ops.h"
#include "system/cpus.h"
+#include "system/hw_accel.h"
+#include "system/tcg.h"
#include "split-accel.h"
#include "accel/accel-internal.h"
@@ -66,10 +69,14 @@ static void *split_cpu_thread_routine(void *arg)
}
switch (r) {
case 0:
+ if (acs->use_hw) {
+ acs->use_hw = cpu_acceleratable(cpu);
+ }
break;
case EXCP_INTERRUPT:
break;
case EXCP_YIELD:
+ assert(!acs->use_hw);
break;
case EXCP_DEBUG:
cpu_handle_guest_debug(cpu);
@@ -86,6 +93,10 @@ static void *split_cpu_thread_routine(void *arg)
cpu_exec_step_atomic(cpu);
bql_lock();
break;
+ case EXCP_HWACCEL:
+ assert(!acs->use_hw);
+ acs->use_hw = true;
+ break;
default:
/* Ignore everything else? */
break;
--
2.49.0