diff mbox series

[RFC,RESEND,21/42] accel/split: Set use_hw in cpu_thread_routine() and switch over

Message ID 20250620172751.94231-22-philmd@linaro.org
State New
Headers show
Series accel/split/arm: Run EL2 using TCG and EL1/EL0 in hardware with HVF | expand

Commit Message

Philippe Mathieu-Daudé June 20, 2025, 5:27 p.m. UTC
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(+)

Comments

Richard Henderson June 22, 2025, 3:02 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> 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;

Stray.

> @@ -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;

Why the conditional?  Why can't we enable use_hw here?

>               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;

Why the unconditional?  Why isn't it more correct to check cpu_acceleratable?

r~
diff mbox series

Patch

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;