accel: Factor tcg_cpu_reset_hold() out of cpu-common.c
cover accel: Factor tcg_cpu_reset_hold() out of cpu-common.c
Hi,
We want to have exec/ code agnostic to accelerators. still we use various call to TCG and KVM. This series factor the TCG code from cpu_common_reset_hold() to an accel-specific handler within AccelOpsClass.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (3):
accel/tcg: Declare tcg_flush_jmp_cache() in 'exec/tb-flush.h'
accel: Introduce cpu_exec_reset_hold()
accel/tcg: Factor tcg_cpu_reset_hold() out
include/exec/cpu-common.h | 3 --- include/exec/tb-flush.h | 2 ++ include/hw/core/cpu.h | 1 + include/sysemu/accel-ops.h | 1 + accel/stubs/tcg-stub.c | 4 ---- accel/tcg/cputlb.c | 1 + accel/tcg/tcg-accel-ops.c | 9 +++++++++ accel/tcg/translate-all.c | 8 -------- accel/tcg/user-exec-stub.c | 4 ++++ hw/core/cpu-common.c | 5 +---- plugins/core.c | 1 - softmmu/cpus.c | 7 +++++++ 12 files changed, 26 insertions(+), 20 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/3 accel/tcg: Declare tcg_flush_jmp_cache() in 'exec/tb-flush.h'
"exec/cpu-common.h" is meant to contain the declarations related to CPU usable with any accelerator / target combination.
tcg_flush_jmp_cache() is specific to TCG, so restrict its declaration by moving it to "exec/tb-flush.h".
--- include/exec/cpu-common.h | 1 - include/exec/tb-flush.h | 2 ++ accel/tcg/cputlb.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + hw/core/cpu-common.c | 1 + plugins/core.c | 1 - 6 files changed, 5 insertions(+), 2 deletions(-)
include/exec/cpu-common.h +0 -1
@@ -39,7 +39,6 @@ void cpu_list_unlock(void);unsigned int cpu_list_generation_id_get (void );void tcg_flush_softmmu_tlb (CPUState *cs); -void tcg_flush_jmp_cache (CPUState *cs);void tcg_iommu_init_notifier_list (CPUState *cpu);void tcg_iommu_free_notifier_list (CPUState *cpu);
include/exec/tb-flush.h +2 -0
@@ -23,4 +23,6 @@*/ void tb_flush (CPUState *cs); +void tcg_flush_jmp_cache (CPUState *cs); +#endif /* _TB_FLUSH_H_ */
accel/tcg/cputlb.c +1 -0
@@ -24,6 +24,7 @@#include "exec/memory.h" #include "exec/cpu_ldst.h" #include "exec/cputlb.h" +#include "exec/tb-flush.h" #include "exec/memory-internal.h" #include "exec/ram_addr.h" #include "tcg/tcg.h"
accel/tcg/tcg-accel-ops.c +1 -0
@@ -34,6 +34,7 @@#include "qemu/timer.h" #include "exec/exec-all.h" #include "exec/hwaddr.h" +#include "exec/tb-flush.h" #include "exec/gdbstub.h" #include "tcg-accel-ops.h"
hw/core/cpu-common.c +1 -0
@@ -27,6 +27,7 @@#include "qemu/main-loop.h" #include "exec/log.h" #include "exec/cpu-common.h" +#include "exec/tb-flush.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "sysemu/tcg.h"
plugins/core.c +0 -1
@@ -21,7 +21,6 @@#include "qemu/xxhash.h" #include "qemu/rcu.h" #include "hw/core/cpu.h" -#include "exec/cpu-common.h" #include "exec/exec-all.h" #include "exec/tb-flush.h"
Signature · 1 line
2.41.0
PATCH 2/3 accel: Introduce cpu_exec_reset_hold()
In reply to Philippe Mathieu-DaudéIntroduce cpu_exec_reset_hold() which call an accelerator specific AccelOpsClass::cpu_reset_hold() handler.
Define a stub on TCG user emulation, because CPU reset is irrelevant there.
--- include/hw/core/cpu.h | 1 + include/sysemu/accel-ops.h | 1 + accel/tcg/user-exec-stub.c | 4 ++++ hw/core/cpu-common.c | 1 + softmmu/cpus.c | 7 +++++++ 5 files changed, 14 insertions(+)
include/hw/core/cpu.h +1 -0
@@ -1011,6 +1011,7 @@ void cpu_class_init_props(DeviceClass *dc);void cpu_exec_initfn (CPUState *cpu);void cpu_exec_realizefn (CPUState *cpu,Error **errp);void cpu_exec_unrealizefn (CPUState *cpu); +void cpu_exec_reset_hold (CPUState *cpu);/** * target_words_bigendian:
include/sysemu/accel-ops.h +1 -0
@@ -30,6 +30,7 @@ struct AccelOpsClass {void (*ops_init)(AccelOpsClass *ops);bool (*cpus_are_resettable)(void ); +void (*cpu_reset_hold)(CPUState *cpu);void (*create_vcpu_thread)(CPUState *cpu);/* MANDATORY NON-NULL */ void (*kick_vcpu_thread)(CPUState *cpu);
accel/tcg/user-exec-stub.c +4 -0
@@ -16,6 +16,10 @@ void qemu_init_vcpu(CPUState *cpu) { } +void cpu_exec_reset_hold (CPUState *cpu) +{ +} +/* User mode emulation does not support record/replay yet. */ bool replay_exception (void )
hw/core/cpu-common.c +1 -0
@@ -137,6 +137,7 @@ static void cpu_common_reset_hold(Object *obj) cpu->crash_occurred = false; cpu->cflags_next_tb =-1 ; +cpu_exec_reset_hold (cpu);if (tcg_enabled ()) {tcg_flush_jmp_cache (cpu);tcg_flush_softmmu_tlb (cpu);
softmmu/cpus.c +7 -0
@@ -201,6 +201,13 @@ bool cpus_are_resettable(void)return true; } +void cpu_exec_reset_hold (CPUState *cpu) +{ +if (cpus_accel->cpu_reset_hold) { + cpus_accel->cpu_reset_hold (cpu); + } +} +int64_t cpus_get_virtual_clock (void ) {/*
Signature · 1 line
2.41.0
PATCH 3/3 accel/tcg: Factor tcg_cpu_reset_hold() out
In reply to Philippe Mathieu-DaudéFactor the TCG specific code from cpu_common_reset_hold() to tcg_cpu_reset_hold() within tcg-accel-ops.c. Since this file is sysemu specific, we can inline tcg_flush_softmmu_tlb(), removing its declaration in "exec/cpu-common.h".
--- include/exec/cpu-common.h | 2 -- accel/stubs/tcg-stub.c | 4 ---- accel/tcg/tcg-accel-ops.c | 8 ++++++++ accel/tcg/translate-all.c | 8 -------- hw/core/cpu-common.c | 5 ----- 5 files changed, 8 insertions(+), 19 deletions(-)
include/exec/cpu-common.h +0 -2
@@ -38,8 +38,6 @@ void cpu_list_lock(void);void cpu_list_unlock (void );unsigned int cpu_list_generation_id_get (void ); -void tcg_flush_softmmu_tlb (CPUState *cs); -void tcg_iommu_init_notifier_list (CPUState *cpu);void tcg_iommu_free_notifier_list (CPUState *cpu);
accel/stubs/tcg-stub.c +0 -4
@@ -22,10 +22,6 @@ void tlb_set_dirty(CPUState *cpu, vaddr vaddr) { } -void tcg_flush_jmp_cache (CPUState *cpu) -{ -} -int probe_access_flags (CPUArchState *env,vaddr addr,int size,MMUAccessType access_type,int mmu_idx,bool nonfault,void **phost,uintptr_t retaddr)
accel/tcg/tcg-accel-ops.c +8 -0
@@ -78,6 +78,13 @@ int tcg_cpus_exec(CPUState *cpu)return ret; } +static void tcg_cpu_reset_hold (CPUState *cpu) +{ +tcg_flush_jmp_cache (cpu); + +tlb_flush (cpu); +} +/* mask must never be zero, except for A20 change call */ void tcg_handle_interrupt (CPUState *cpu,int mask) {
@@ -206,6 +213,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops) } } + ops->cpu_reset_hold = tcg_cpu_reset_hold; ops->supports_guest_debug = tcg_supports_guest_debug; ops->insert_breakpoint = tcg_insert_breakpoint; ops->remove_breakpoint = tcg_remove_breakpoint;
accel/tcg/translate-all.c +0 -8
@@ -801,11 +801,3 @@ void tcg_flush_jmp_cache(CPUState *cpu)qatomic_set (&jc->array[i].tb,NULL ); } } - -/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ -void tcg_flush_softmmu_tlb (CPUState *cs) -{ -#ifdef CONFIG_SOFTMMU -tlb_flush (cs); -#endif -}
hw/core/cpu-common.c +0 -5
@@ -27,7 +27,6 @@#include "qemu/main-loop.h" #include "exec/log.h" #include "exec/cpu-common.h" -#include "exec/tb-flush.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" #include "sysemu/tcg.h"
@@ -138,10 +137,6 @@ static void cpu_common_reset_hold(Object *obj) cpu->cflags_next_tb =-1 ;cpu_exec_reset_hold (cpu); -if (tcg_enabled ()) { -tcg_flush_jmp_cache (cpu); -tcg_flush_softmmu_tlb (cpu); - } }static bool cpu_common_has_work (CPUState *cs)
Signature · 1 line
2.41.0
Quoted 14 lines · Philippe Mathieu-Daudé
Hi,
We want to have exec/ code agnostic to accelerators. still we use various call to TCG and KVM. This series factor the TCG code from
cpu_common_reset_hold()to an accel-specific handler within AccelOpsClass.Based-on: <[email protected]>
Philippe Mathieu-Daudé (3):
accel/tcg: Declaretcg_flush_jmp_cache()in 'exec/tb-flush.h'
accel: Introducecpu_exec_reset_hold()
accel/tcg: Factortcg_cpu_reset_hold()out
Quoted 17 lines
include/exec/cpu-common.h | 3 --- include/exec/tb-flush.h | 2 ++ include/hw/core/cpu.h | 1 + include/sysemu/accel-ops.h | 1 + accel/stubs/tcg-stub.c | 4 ---- accel/tcg/cputlb.c | 1 + accel/tcg/tcg-accel-ops.c | 9 +++++++++ accel/tcg/translate-all.c | 8 -------- accel/tcg/user-exec-stub.c | 4 ++++ hw/core/cpu-common.c | 5 +---- plugins/core.c | 1 - softmmu/cpus.c | 7 +++++++ 12 files changed, 26 insertions(+), 20 deletions(-)Signature · 1 line
2.41.0
Series:
Quoted 4 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (3):
accel/tcg: Declaretcg_flush_jmp_cache()in 'exec/tb-flush.h'
accel: Introducecpu_exec_reset_hold()
accel/tcg: Factortcg_cpu_reset_hold()out
r~