[PATCH 14/29] tcg_funcs:Add tcg_exec_{realizefn, unrealizefn} to TCGModuleOps

Gerd Hoffmann posted 29 patches 4 years, 5 months ago
Maintainers: Mahmoud Mandour <ma.mandourr@gmail.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Alexandre Iooss <erdnaxe@crans.org>, Aurelien Jarno <aurelien@aurel32.net>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Halil Pasic <pasic@linux.ibm.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Peter Xu <peterx@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Bin Meng <bin.meng@windriver.com>, "Michael S. Tsirkin" <mst@redhat.com>, Alistair Francis <alistair.francis@wdc.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Thomas Huth <thuth@redhat.com>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, Laurent Vivier <laurent@vivier.eu>, Huacai Chen <chenhuacai@kernel.org>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Max Filippov <jcmvbkbc@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Greg Kurz <groug@kaod.org>, Christian Borntraeger <borntraeger@de.ibm.com>, Palmer Dabbelt <palmer@dabbelt.com>, "Alex Bennée" <alex.bennee@linaro.org>, Stafford Horne <shorne@gmail.com>, Richard Henderson <richard.henderson@linaro.org>
[PATCH 14/29] tcg_funcs:Add tcg_exec_{realizefn, unrealizefn} to TCGModuleOps
Posted by Gerd Hoffmann 4 years, 5 months ago
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/exec/cpu-all.h   |  2 --
 include/tcg/tcg-module.h |  2 ++
 accel/tcg/cpu-exec.c     | 12 ++++++++++--
 accel/tcg/tcg-module.c   |  6 ++++++
 cpu.c                    |  4 ++--
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 32cfb634c6a0..c2bfd0ea1de1 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -440,8 +440,6 @@ void dump_opcount_info(void);
 #ifdef CONFIG_TCG
 /* accel/tcg/cpu-exec.c */
 int cpu_exec(CPUState *cpu);
-void tcg_exec_realizefn(CPUState *cpu, Error **errp);
-void tcg_exec_unrealizefn(CPUState *cpu);
 #endif /* CONFIG_TCG */
 
 /* Returns: 0 on success, -1 on error */
diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
index 159cbd3e7ce6..5dd4deb9ed57 100644
--- a/include/tcg/tcg-module.h
+++ b/include/tcg/tcg-module.h
@@ -11,6 +11,8 @@ struct TCGModuleOps {
     bool (*tlb_plugin_lookup)(CPUState *cpu, target_ulong addr, int mmu_idx,
                               bool is_store, struct qemu_plugin_hwaddr *data);
 #endif
+    void (*tcg_exec_unrealizefn)(CPUState *cpu);
+    void (*tcg_exec_realizefn)(CPUState *cpu, Error **errp);
 };
 extern struct TCGModuleOps tcg;
 
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index e5c0ccd1a2ab..d41d1d2bd24f 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -981,7 +981,7 @@ int cpu_exec(CPUState *cpu)
     return ret;
 }
 
-void tcg_exec_realizefn(CPUState *cpu, Error **errp)
+static void tcg_exec_realizefn(CPUState *cpu, Error **errp)
 {
     static bool tcg_target_initialized;
     CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -999,7 +999,7 @@ void tcg_exec_realizefn(CPUState *cpu, Error **errp)
 }
 
 /* undo the initializations in reverse order */
-void tcg_exec_unrealizefn(CPUState *cpu)
+static void tcg_exec_unrealizefn(CPUState *cpu)
 {
 #ifndef CONFIG_USER_ONLY
     tcg_iommu_free_notifier_list(cpu);
@@ -1031,3 +1031,11 @@ void dump_drift_info(void)
 }
 
 #endif /* !CONFIG_USER_ONLY */
+
+static void tcg_module_ops_exec(void)
+{
+    tcg.tcg_exec_realizefn = tcg_exec_realizefn;
+    tcg.tcg_exec_unrealizefn = tcg_exec_unrealizefn;
+}
+
+type_init(tcg_module_ops_exec);
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
index db3d3e9e9318..36c1df564f31 100644
--- a/accel/tcg/tcg-module.c
+++ b/accel/tcg/tcg-module.c
@@ -21,6 +21,10 @@ static bool tlb_plugin_lookup_stub(CPUState *cpu, target_ulong addr, int mmu_idx
 }
 #endif
 
+static void tcg_exec_realizefn_stub(CPUState *cpu, Error **errp)
+{
+}
+
 struct TCGModuleOps tcg = {
     .tlb_flush = update_cpu_stub,
     .tlb_flush_page = tlb_flush_page_stub,
@@ -28,4 +32,6 @@ struct TCGModuleOps tcg = {
     .tlb_reset_dirty = tlb_reset_dirty_stub,
     .tlb_plugin_lookup = tlb_plugin_lookup_stub,
 #endif
+    .tcg_exec_realizefn = tcg_exec_realizefn_stub,
+    .tcg_exec_unrealizefn = update_cpu_stub,
 };
diff --git a/cpu.c b/cpu.c
index 26277f387baf..d1c9f68a26e7 100644
--- a/cpu.c
+++ b/cpu.c
@@ -140,7 +140,7 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp)
 #ifdef CONFIG_TCG
     /* NB: errp parameter is unused currently */
     if (tcg_enabled()) {
-        tcg_exec_realizefn(cpu, errp);
+        tcg.tcg_exec_realizefn(cpu, errp);
     }
 #endif /* CONFIG_TCG */
 
@@ -172,7 +172,7 @@ void cpu_exec_unrealizefn(CPUState *cpu)
 #ifdef CONFIG_TCG
     /* NB: errp parameter is unused currently */
     if (tcg_enabled()) {
-        tcg_exec_unrealizefn(cpu);
+        tcg.tcg_exec_unrealizefn(cpu);
     }
 #endif /* CONFIG_TCG */
 
-- 
2.31.1