[PATCH 6/9] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler

Philippe Mathieu-Daudé posted 9 patches 10 months, 1 week ago
[PATCH 6/9] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler
Posted by Philippe Mathieu-Daudé 10 months, 1 week ago
In order to make accel/tcg/ target agnostic,
introduce the need_replay_interrupt() handler.

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

diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index 479713a36e..2fae3ac70f 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -170,6 +170,11 @@ struct TCGCPUOps {
      */
     bool (*io_recompile_replay_branch)(CPUState *cpu,
                                        const TranslationBlock *tb);
+    /**
+     * @need_replay_interrupt: Return %true if @interrupt_request
+     * needs to be recorded for replay purposes.
+     */
+    bool (*need_replay_interrupt)(int interrupt_request);
 #endif /* !CONFIG_USER_ONLY */
 #endif /* NEED_CPU_H */
 
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index b10472cbc7..4ab7d6c896 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -778,7 +778,10 @@ static inline bool need_replay_interrupt(CPUClass *cc, int interrupt_request)
 #if defined(TARGET_I386)
     return !(interrupt_request & CPU_INTERRUPT_POLL);
 #else
-    return true;
+    if (!cc->tcg_ops->need_replay_interrupt) {
+        return true;
+    }
+    return cc->tcg_ops->need_replay_interrupt(interrupt_request);
 #endif
 }
 #endif /* !CONFIG_USER_ONLY */
-- 
2.41.0


Re: [PATCH 6/9] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler
Posted by Pavel Dovgalyuk 10 months ago
Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>

On 24.01.2024 13:16, Philippe Mathieu-Daudé wrote:
> In order to make accel/tcg/ target agnostic,
> introduce the need_replay_interrupt() handler.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/core/tcg-cpu-ops.h | 5 +++++
>   accel/tcg/cpu-exec.c          | 5 ++++-
>   2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
> index 479713a36e..2fae3ac70f 100644
> --- a/include/hw/core/tcg-cpu-ops.h
> +++ b/include/hw/core/tcg-cpu-ops.h
> @@ -170,6 +170,11 @@ struct TCGCPUOps {
>        */
>       bool (*io_recompile_replay_branch)(CPUState *cpu,
>                                          const TranslationBlock *tb);
> +    /**
> +     * @need_replay_interrupt: Return %true if @interrupt_request
> +     * needs to be recorded for replay purposes.
> +     */
> +    bool (*need_replay_interrupt)(int interrupt_request);
>   #endif /* !CONFIG_USER_ONLY */
>   #endif /* NEED_CPU_H */
>   
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index b10472cbc7..4ab7d6c896 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -778,7 +778,10 @@ static inline bool need_replay_interrupt(CPUClass *cc, int interrupt_request)
>   #if defined(TARGET_I386)
>       return !(interrupt_request & CPU_INTERRUPT_POLL);
>   #else
> -    return true;
> +    if (!cc->tcg_ops->need_replay_interrupt) {
> +        return true;
> +    }
> +    return cc->tcg_ops->need_replay_interrupt(interrupt_request);
>   #endif
>   }
>   #endif /* !CONFIG_USER_ONLY */


Re: [PATCH 6/9] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler
Posted by Richard Henderson 10 months ago
On 1/24/24 20:16, Philippe Mathieu-Daudé wrote:
> In order to make accel/tcg/ target agnostic,
> introduce the need_replay_interrupt() handler.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   include/hw/core/tcg-cpu-ops.h | 5 +++++
>   accel/tcg/cpu-exec.c          | 5 ++++-
>   2 files changed, 9 insertions(+), 1 deletion(-)

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


r~

Re: [PATCH 6/9] accel/tcg: Introduce TCGCPUOps::need_replay_interrupt() handler
Posted by Anton Johansson via 10 months, 1 week ago
On 24/01/24, Philippe Mathieu-Daudé wrote:
> In order to make accel/tcg/ target agnostic,
> introduce the need_replay_interrupt() handler.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/core/tcg-cpu-ops.h | 5 +++++
>  accel/tcg/cpu-exec.c          | 5 ++++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
> index 479713a36e..2fae3ac70f 100644
> --- a/include/hw/core/tcg-cpu-ops.h
> +++ b/include/hw/core/tcg-cpu-ops.h
> @@ -170,6 +170,11 @@ struct TCGCPUOps {
>       */
>      bool (*io_recompile_replay_branch)(CPUState *cpu,
>                                         const TranslationBlock *tb);
> +    /**
> +     * @need_replay_interrupt: Return %true if @interrupt_request
> +     * needs to be recorded for replay purposes.
> +     */
> +    bool (*need_replay_interrupt)(int interrupt_request);
>  #endif /* !CONFIG_USER_ONLY */
>  #endif /* NEED_CPU_H */
>  
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index b10472cbc7..4ab7d6c896 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -778,7 +778,10 @@ static inline bool need_replay_interrupt(CPUClass *cc, int interrupt_request)
>  #if defined(TARGET_I386)
>      return !(interrupt_request & CPU_INTERRUPT_POLL);
>  #else
> -    return true;
> +    if (!cc->tcg_ops->need_replay_interrupt) {
> +        return true;
> +    }
> +    return cc->tcg_ops->need_replay_interrupt(interrupt_request);
>  #endif
>  }
>  #endif /* !CONFIG_USER_ONLY */
> -- 
> 2.41.0
> 
Reviewed-by: Anton Johansson <anjo@rev.ng>