diff mbox series

[8/9] accel/tcg: Introduce TCGCPUOps::cpu_exec_halt() handler

Message ID 20240124101639.30056-9-philmd@linaro.org
State New
Headers show
Series accel/tcg: Extract some x86-specific code | expand

Commit Message

Philippe Mathieu-Daudé Jan. 24, 2024, 10:16 a.m. UTC
In order to make accel/tcg/ target agnostic,
introduce the cpu_exec_halt() handler.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/core/tcg-cpu-ops.h | 2 ++
 accel/tcg/cpu-exec.c          | 3 +++
 2 files changed, 5 insertions(+)

Comments

Anton Johansson Jan. 24, 2024, 5:19 p.m. UTC | #1
On 24/01/24, Philippe Mathieu-Daudé wrote:
> In order to make accel/tcg/ target agnostic,
> introduce the cpu_exec_halt() handler.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/core/tcg-cpu-ops.h | 2 ++
>  accel/tcg/cpu-exec.c          | 3 +++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
> index 2fae3ac70f..3307338c80 100644
> --- a/include/hw/core/tcg-cpu-ops.h
> +++ b/include/hw/core/tcg-cpu-ops.h
> @@ -114,6 +114,8 @@ struct TCGCPUOps {
>      void (*record_sigbus)(CPUState *cpu, vaddr addr,
>                            MMUAccessType access_type, uintptr_t ra);
>  #else
> +    /** @cpu_exec_halt: Callback for handling halt in cpu_exec */
> +    void (*cpu_exec_halt)(CPUState *cpu);
>      /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */
>      bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);
>      /**
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 5a978a9e72..390a9644da 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -681,6 +681,9 @@ static inline bool cpu_handle_halt(CPUClass *cc, CPUState *cpu)
>              bql_unlock();
>          }
>  #endif /* TARGET_I386 */
> +        if (cc->tcg_ops->cpu_exec_halt) {
> +            cc->tcg_ops->cpu_exec_halt(cpu);
> +        }
>          if (!cpu_has_work(cpu)) {
>              return true;
>          }
> -- 
> 2.41.0
> 
Reviewed-by: Anton Johansson <anjo@rev.ng>
Richard Henderson Jan. 24, 2024, 11:02 p.m. UTC | #2
On 1/24/24 20:16, Philippe Mathieu-Daudé wrote:
> In order to make accel/tcg/ target agnostic,
> introduce the cpu_exec_halt() handler.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

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


r~
diff mbox series

Patch

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 2fae3ac70f..3307338c80 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -114,6 +114,8 @@  struct TCGCPUOps {
     void (*record_sigbus)(CPUState *cpu, vaddr addr,
                           MMUAccessType access_type, uintptr_t ra);
 #else
+    /** @cpu_exec_halt: Callback for handling halt in cpu_exec */
+    void (*cpu_exec_halt)(CPUState *cpu);
     /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exec */
     bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request);
     /**
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 5a978a9e72..390a9644da 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -681,6 +681,9 @@  static inline bool cpu_handle_halt(CPUClass *cc, CPUState *cpu)
             bql_unlock();
         }
 #endif /* TARGET_I386 */
+        if (cc->tcg_ops->cpu_exec_halt) {
+            cc->tcg_ops->cpu_exec_halt(cpu);
+        }
         if (!cpu_has_work(cpu)) {
             return true;
         }