diff mbox series

[RFC,RESEND,38/42] accel/tcg: Introduce TCGCPUOps::rebuild_tb_hflags handler

Message ID 20250620172751.94231-39-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
In order to allow rebuilding target specific TB flags,
introduce tcg_rebuild_tb_flags() which dispatches to
a TCGCPUOps handler.

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

Comments

Richard Henderson June 22, 2025, 3:33 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> index 29ebcf45928..20999033c89 100644
> --- a/include/system/accel-ops.h
> +++ b/include/system/accel-ops.h
> @@ -71,6 +71,14 @@ struct AccelOpsClass {
>       void (*synchronize_pre_loadvm)(CPUState *cpu);
>       void (*synchronize_pre_resume)(bool step_pending);
>   
> +    /**
> +     * rebuild_tcg_tb_flags:
> +     *
> +     * Used to rebuild TCG TB flags when a hardware accelerator transitions
> +     * to TCG, prior to calling TCG %exec_vcpu_thread() handler.
> +     */
> +    void (*rebuild_tcg_tb_flags)(CPUState *cpu);

I think this isn't right.  This should be part of synchronize between hw/sw.


r~
diff mbox series

Patch

diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index fb265d0cefa..a3828e34145 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -54,6 +54,7 @@  void tb_reset_jump(TranslationBlock *tb, int n);
 TranslationBlock *tb_link_page(TranslationBlock *tb);
 void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
                                uintptr_t host_pc);
+void tcg_rebuild_tb_flags(CPUState *cpu);
 
 /**
  * tlb_init - initialize a CPU's TLB
diff --git a/include/accel/tcg/cpu-ops.h b/include/accel/tcg/cpu-ops.h
index dd8ea300168..bb047461973 100644
--- a/include/accel/tcg/cpu-ops.h
+++ b/include/accel/tcg/cpu-ops.h
@@ -67,6 +67,8 @@  struct TCGCPUOps {
      * Fill in all data required to select or compile a TranslationBlock.
      */
     TCGTBCPUState (*get_tb_cpu_state)(CPUState *cs);
+    /** @rebuild_tb_hflags: Callback to rebuild TB hflags.  */
+    void (*rebuild_tb_hflags)(CPUState *cpu);
     /**
      * @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock
      *
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 29ebcf45928..20999033c89 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -71,6 +71,14 @@  struct AccelOpsClass {
     void (*synchronize_pre_loadvm)(CPUState *cpu);
     void (*synchronize_pre_resume)(bool step_pending);
 
+    /**
+     * rebuild_tcg_tb_flags:
+     *
+     * Used to rebuild TCG TB flags when a hardware accelerator transitions
+     * to TCG, prior to calling TCG %exec_vcpu_thread() handler.
+     */
+    void (*rebuild_tcg_tb_flags)(CPUState *cpu);
+
     void (*handle_interrupt)(CPUState *cpu, int mask);
 
     void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 713bdb20564..7ded765889c 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1028,6 +1028,15 @@  int cpu_exec(CPUState *cpu)
     return ret;
 }
 
+void tcg_rebuild_tb_flags(CPUState *cpu)
+{
+    const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
+
+    if (tcg_ops->rebuild_tb_hflags) {
+        tcg_ops->rebuild_tb_hflags(cpu);
+    }
+}
+
 bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
 {
     static bool tcg_target_initialized;
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 0e4ef548f99..a141c4702e4 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -242,6 +242,7 @@  static void tcg_accel_ops_init(AccelClass *ac)
     ops->insert_breakpoint = tcg_insert_breakpoint;
     ops->remove_breakpoint = tcg_remove_breakpoint;
     ops->remove_all_breakpoints = tcg_remove_all_breakpoints;
+    ops->rebuild_tcg_tb_flags = tcg_rebuild_tb_flags;
 }
 
 static void tcg_accel_ops_class_init(ObjectClass *oc, const void *data)