diff mbox series

[RFC,RESEND,09/42] accel/split: Add cpu_thread_routine() stub

Message ID 20250620172751.94231-10-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 | 70 ++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

Comments

Richard Henderson June 22, 2025, 2:32 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/split/split-accel-ops.c | 70 ++++++++++++++++++++++++++++++++++-
>   1 file changed, 69 insertions(+), 1 deletion(-)

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

r~

> 
> diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
> index e5c1d51d426..294ea79420e 100644
> --- a/accel/split/split-accel-ops.c
> +++ b/accel/split/split-accel-ops.c
> @@ -7,11 +7,79 @@
>    */
>   
>   #include "qemu/osdep.h"
> +#include "qemu/main-loop.h"
> +#include "qemu/guest-random.h"
> +#include "exec/cpu-common.h"
>   #include "system/accel-ops.h"
> +#include "system/cpus.h"
>   
>   static void *split_cpu_thread_routine(void *arg)
>   {
> -    g_assert_not_reached();
> +    CPUState *cpu = arg;
> +    int r;
> +
> +    /* TODO: check accel allowed */
> +
> +    rcu_register_thread();
> +
> +    bql_lock();
> +    qemu_thread_get_self(cpu->thread);
> +
> +    cpu->thread_id = qemu_get_thread_id();
> +    current_cpu = cpu;
> +
> +    /* TODO: init_vcpu_thread() */
> +    /* TODO: allocate AccelCPUState */
> +
> +    /* signal CPU creation */
> +    cpu_thread_signal_created(cpu);
> +    qemu_guest_random_seed_thread_part2(cpu->random_seed);
> +
> +    /* process any pending work */
> +    cpu->exit_request = 1;
> +
> +    do {
> +        r = 0;
> +
> +        if (cpu_can_run(cpu)) {
> +            r = 0; /* TODO: exec_vcpu_thread() */
> +            switch (r) {
> +            case 0:
> +                break;
> +            case EXCP_INTERRUPT:
> +                break;
> +            case EXCP_YIELD:
> +                break;
> +            case EXCP_DEBUG:
> +                cpu_handle_guest_debug(cpu);
> +                break;
> +            case EXCP_HALTED:
> +                /*
> +                 * Usually cpu->halted is set, but may have already been
> +                 * reset by another thread by the time we arrive here.
> +                 */
> +                break;
> +            case EXCP_ATOMIC:
> +                bql_unlock();
> +                cpu_exec_step_atomic(cpu);
> +                bql_lock();
> +                break;
> +            default:
> +                /* Ignore everything else? */
> +                break;
> +            }
> +        }
> +        qemu_wait_io_event(cpu);
> +    } while (!cpu->unplug || cpu_can_run(cpu));
> +
> +    /* TODO: destroy_vcpu_thread() */
> +
> +    cpu_thread_signal_destroyed(cpu);
> +    bql_unlock();
> +
> +    rcu_unregister_thread();
> +
> +    return NULL;
>   }
>   
>   static void split_ops_init(AccelClass *ac)
diff mbox series

Patch

diff --git a/accel/split/split-accel-ops.c b/accel/split/split-accel-ops.c
index e5c1d51d426..294ea79420e 100644
--- a/accel/split/split-accel-ops.c
+++ b/accel/split/split-accel-ops.c
@@ -7,11 +7,79 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu/main-loop.h"
+#include "qemu/guest-random.h"
+#include "exec/cpu-common.h"
 #include "system/accel-ops.h"
+#include "system/cpus.h"
 
 static void *split_cpu_thread_routine(void *arg)
 {
-    g_assert_not_reached();
+    CPUState *cpu = arg;
+    int r;
+
+    /* TODO: check accel allowed */
+
+    rcu_register_thread();
+
+    bql_lock();
+    qemu_thread_get_self(cpu->thread);
+
+    cpu->thread_id = qemu_get_thread_id();
+    current_cpu = cpu;
+
+    /* TODO: init_vcpu_thread() */
+    /* TODO: allocate AccelCPUState */
+
+    /* signal CPU creation */
+    cpu_thread_signal_created(cpu);
+    qemu_guest_random_seed_thread_part2(cpu->random_seed);
+
+    /* process any pending work */
+    cpu->exit_request = 1;
+
+    do {
+        r = 0;
+
+        if (cpu_can_run(cpu)) {
+            r = 0; /* TODO: exec_vcpu_thread() */
+            switch (r) {
+            case 0:
+                break;
+            case EXCP_INTERRUPT:
+                break;
+            case EXCP_YIELD:
+                break;
+            case EXCP_DEBUG:
+                cpu_handle_guest_debug(cpu);
+                break;
+            case EXCP_HALTED:
+                /*
+                 * Usually cpu->halted is set, but may have already been
+                 * reset by another thread by the time we arrive here.
+                 */
+                break;
+            case EXCP_ATOMIC:
+                bql_unlock();
+                cpu_exec_step_atomic(cpu);
+                bql_lock();
+                break;
+            default:
+                /* Ignore everything else? */
+                break;
+            }
+        }
+        qemu_wait_io_event(cpu);
+    } while (!cpu->unplug || cpu_can_run(cpu));
+
+    /* TODO: destroy_vcpu_thread() */
+
+    cpu_thread_signal_destroyed(cpu);
+    bql_unlock();
+
+    rcu_unregister_thread();
+
+    return NULL;
 }
 
 static void split_ops_init(AccelClass *ac)