diff mbox series

[07/24] accel/tcg: Implement AccelOpsClass::exit_vcpu_thread() handler

Message ID 20240428221450.26460-8-philmd@linaro.org
State New
Headers show
Series exec: Rework around CPUState user fields (part 2) | expand

Commit Message

Philippe Mathieu-Daudé April 28, 2024, 10:14 p.m. UTC
The TCG-specific code from the system generic cpu_exit()
is equivalent of tcg_cpu_exit(). Define the AccelOpsClass
exit_vcpu_thread() handler to it, making cpu_exit() generic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/tcg-accel-ops.c | 2 ++
 system/cpus.c             | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

Richard Henderson April 29, 2024, 1:09 a.m. UTC | #1
On 4/28/24 15:14, Philippe Mathieu-Daudé wrote:
> The TCG-specific code from the system generic cpu_exit()
> is equivalent of tcg_cpu_exit(). Define the AccelOpsClass
> exit_vcpu_thread() handler to it, making cpu_exit() generic.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/tcg-accel-ops.c | 2 ++
>   system/cpus.c             | 3 ---
>   2 files changed, 2 insertions(+), 3 deletions(-)

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


r~

> 
> diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
> index 7ac5f0c974..56bbad9fcd 100644
> --- a/accel/tcg/tcg-accel-ops.c
> +++ b/accel/tcg/tcg-accel-ops.c
> @@ -43,6 +43,7 @@
>   #include "tcg-accel-ops-mttcg.h"
>   #include "tcg-accel-ops-rr.h"
>   #include "tcg-accel-ops-icount.h"
> +#include "internal-common.h"
>   
>   /* common functionality among all TCG variants */
>   
> @@ -218,6 +219,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops)
>           }
>       }
>   
> +    ops->exit_vcpu_thread = tcg_cpu_exit;
>       ops->cpu_reset_hold = tcg_cpu_reset_hold;
>       ops->supports_guest_debug = tcg_supports_guest_debug;
>       ops->insert_breakpoint = tcg_insert_breakpoint;
> diff --git a/system/cpus.c b/system/cpus.c
> index d0d585e8b9..3e86b488d3 100644
> --- a/system/cpus.c
> +++ b/system/cpus.c
> @@ -422,9 +422,6 @@ void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
>   void cpu_exit(CPUState *cpu)
>   {
>       qatomic_set(&cpu->exit_request, 1);
> -    /* Ensure cpu_exec will see the exit request after TCG has exited.  */
> -    smp_wmb();
> -    qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
>       if (cpus_accel->exit_vcpu_thread) {
>           cpus_accel->exit_vcpu_thread(cpu);
>       }
diff mbox series

Patch

diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 7ac5f0c974..56bbad9fcd 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -43,6 +43,7 @@ 
 #include "tcg-accel-ops-mttcg.h"
 #include "tcg-accel-ops-rr.h"
 #include "tcg-accel-ops-icount.h"
+#include "internal-common.h"
 
 /* common functionality among all TCG variants */
 
@@ -218,6 +219,7 @@  static void tcg_accel_ops_init(AccelOpsClass *ops)
         }
     }
 
+    ops->exit_vcpu_thread = tcg_cpu_exit;
     ops->cpu_reset_hold = tcg_cpu_reset_hold;
     ops->supports_guest_debug = tcg_supports_guest_debug;
     ops->insert_breakpoint = tcg_insert_breakpoint;
diff --git a/system/cpus.c b/system/cpus.c
index d0d585e8b9..3e86b488d3 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -422,9 +422,6 @@  void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
 void cpu_exit(CPUState *cpu)
 {
     qatomic_set(&cpu->exit_request, 1);
-    /* Ensure cpu_exec will see the exit request after TCG has exited.  */
-    smp_wmb();
-    qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
     if (cpus_accel->exit_vcpu_thread) {
         cpus_accel->exit_vcpu_thread(cpu);
     }