diff mbox series

[RFC,RESEND,12/42] accel/split: Have thread routine ready to dispatch over HW/SW

Message ID 20250620172751.94231-13-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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/split/split-accel-ops.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

Comments

Richard Henderson June 22, 2025, 2:45 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> @@ -49,10 +56,12 @@ static void *split_cpu_thread_routine(void *arg)
>       cpu->exit_request = 1;
>   
>       do {
> -        r = 0;
> -
>           if (cpu_can_run(cpu)) {
> -            r = 0; /* TODO: exec_vcpu_thread() */
> +            if (acs->use_hw) {
> +                r = hwops->exec_vcpu_thread(cpu);
> +            } else {
> +                r = swops->exec_vcpu_thread(cpu);
> +            }

Maybe

   AccelOpsClass *curops = acs->use_hw ? hwops : swops;
   r = curops->exec_vcpu_thread(cpu);

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
diff mbox series

Patch

diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
index 2c7945b6331..39495fdff14 100644
--- a/accel/split/split-accel-ops.c
+++ b/accel/split/split-accel-ops.c
@@ -19,12 +19,18 @@ 
 static void *split_cpu_thread_routine(void *arg)
 {
     AccelState *as = current_accel();
+    SplitAccelState *sas = SPLIT_ACCEL(as);
+    AccelClass *hwc = ACCEL_GET_CLASS(sas->hw);
+    AccelClass *swc = ACCEL_GET_CLASS(sas->sw);
+    AccelOpsClass *hwops = hwc->ops;
+    AccelOpsClass *swops = swc->ops;
     void *sw_force_rcu;
     CPUState *cpu = arg;
     AccelCPUState *acs;
     int r;
 
-    /* TODO: check accel allowed */
+    assert(swc->allowed);
+    assert(hwc->allowed);
 
     rcu_register_thread();
     sw_force_rcu = mttcg_vcpu_register(cpu);
@@ -35,7 +41,8 @@  static void *split_cpu_thread_routine(void *arg)
     cpu->thread_id = qemu_get_thread_id();
     current_cpu = cpu;
 
-    /* TODO: init_vcpu_thread() */
+    hwops->init_vcpu_thread(cpu);
+    swops->init_vcpu_thread(cpu);
     cpu->accel = g_renew(AccelCPUState, cpu->accel, 1); /* XXX only with current TCG */
     acs = cpu->accel;
     acs->accel = as;
@@ -49,10 +56,12 @@  static void *split_cpu_thread_routine(void *arg)
     cpu->exit_request = 1;
 
     do {
-        r = 0;
-
         if (cpu_can_run(cpu)) {
-            r = 0; /* TODO: exec_vcpu_thread() */
+            if (acs->use_hw) {
+                r = hwops->exec_vcpu_thread(cpu);
+            } else {
+                r = swops->exec_vcpu_thread(cpu);
+            }
             switch (r) {
             case 0:
                 break;
@@ -83,7 +92,8 @@  static void *split_cpu_thread_routine(void *arg)
         qemu_wait_io_event(cpu);
     } while (!cpu->unplug || cpu_can_run(cpu));
 
-    /* TODO: destroy_vcpu_thread() */
+    hwops->destroy_vcpu_thread(cpu);
+    swops->destroy_vcpu_thread(cpu);
 
     cpu_thread_signal_destroyed(cpu);
     bql_unlock();