* [PATCH 0/7] tcg: some small towards more modular tcg
@ 2021-08-04 14:38 Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 1/7] plugins: register qemu_plugin_opts using opts_init() Gerd Hoffmann
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Gerd Hoffmann (7):
plugins: register qemu_plugin_opts using opts_init()
tcg/module: move hmp.c to tcg module
tcg/module: move cpu-exec-common.c from tcg_ss to specific_ss
tcg/module: add some infrastructure for modular tcg.
tcg/module: Add tlb_flush to TCGModuleOps
tcg/module: Add tlb_flush_page to TCGModuleOps
tcg/module: Add tlb_reset_dirty to TCGModuleOps
include/exec/exec-all.h | 8 +-------
include/qemu/plugin.h | 7 -------
include/tcg/tcg-module.h | 15 +++++++++++++++
accel/tcg/cpu-exec-common.c | 8 ++++++++
accel/tcg/cputlb.c | 11 ++++++++++-
accel/tcg/tcg-module.c | 24 ++++++++++++++++++++++++
accel/tcg/translate-all.c | 8 --------
cpu.c | 2 +-
linux-user/main.c | 2 +-
plugins/loader.c | 9 ++++++++-
softmmu/physmem.c | 12 ++++++------
softmmu/vl.c | 1 -
target/arm/helper.c | 26 +++++++++++++-------------
target/i386/helper.c | 8 ++++----
target/i386/machine.c | 2 +-
target/i386/tcg/fpu_helper.c | 2 +-
target/i386/tcg/misc_helper.c | 2 +-
target/mips/sysemu/cp0.c | 2 +-
target/s390x/gdbstub.c | 2 +-
target/s390x/sigp.c | 2 +-
accel/tcg/meson.build | 11 +++++++++--
21 files changed, 106 insertions(+), 58 deletions(-)
create mode 100644 include/tcg/tcg-module.h
create mode 100644 accel/tcg/tcg-module.c
--
2.31.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/7] plugins: register qemu_plugin_opts using opts_init()
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 2/7] tcg/module: move hmp.c to tcg module Gerd Hoffmann
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Little preparation for building tcg modular.
No functional change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/qemu/plugin.h | 7 -------
linux-user/main.c | 2 +-
plugins/loader.c | 9 ++++++++-
softmmu/vl.c | 1 -
4 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 9a8438f6836c..57bdcdecdb42 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -37,13 +37,6 @@ struct qemu_plugin_desc;
typedef QTAILQ_HEAD(, qemu_plugin_desc) QemuPluginList;
#ifdef CONFIG_PLUGIN
-extern QemuOptsList qemu_plugin_opts;
-
-static inline void qemu_plugin_add_opts(void)
-{
- qemu_add_opts(&qemu_plugin_opts);
-}
-
void qemu_plugin_opt_parse(const char *optarg, QemuPluginList *head);
int qemu_plugin_load_list(QemuPluginList *head, Error **errp);
diff --git a/linux-user/main.c b/linux-user/main.c
index 37ed50d98e2e..f9d2c6e2de31 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -661,7 +661,7 @@ int main(int argc, char **argv, char **envp)
cpu_model = NULL;
qemu_add_opts(&qemu_trace_opts);
- qemu_plugin_add_opts();
+ module_call_init(MODULE_INIT_OPTS);
optind = parse_args(argc, argv);
diff --git a/plugins/loader.c b/plugins/loader.c
index 05df40398d62..71b03721dffc 100644
--- a/plugins/loader.c
+++ b/plugins/loader.c
@@ -53,7 +53,7 @@ struct qemu_plugin_parse_arg {
struct qemu_plugin_desc *curr;
};
-QemuOptsList qemu_plugin_opts = {
+static QemuOptsList qemu_plugin_opts = {
.name = "plugin",
.implied_opt_name = "file",
.head = QTAILQ_HEAD_INITIALIZER(qemu_plugin_opts.head),
@@ -403,3 +403,10 @@ void plugin_reset_uninstall(qemu_plugin_id_t id,
plugin_reset_destroy(data);
}
}
+
+static void plugin_register_config(void)
+{
+ qemu_add_opts(&qemu_plugin_opts);
+}
+opts_init(plugin_register_config);
+module_opts("plugin");
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 4dee472c7942..ea87c83db347 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2725,7 +2725,6 @@ void qemu_init(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_global_opts);
qemu_add_opts(&qemu_mon_opts);
qemu_add_opts(&qemu_trace_opts);
- qemu_plugin_add_opts();
qemu_add_opts(&qemu_option_rom_opts);
qemu_add_opts(&qemu_accel_opts);
qemu_add_opts(&qemu_mem_opts);
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] tcg/module: move hmp.c to tcg module
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 1/7] plugins: register qemu_plugin_opts using opts_init() Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 3/7] tcg/module: move cpu-exec-common.c from tcg_ss to specific_ss Gerd Hoffmann
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
One little step in moving more code to the tcg modules.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
accel/tcg/meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 137a1a44cc0a..d4df7681a811 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -15,7 +15,6 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
'cputlb.c',
- 'hmp.c',
))
tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
@@ -23,4 +22,5 @@ tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
'tcg-accel-ops-mttcg.c',
'tcg-accel-ops-icount.c',
'tcg-accel-ops-rr.c',
+ 'hmp.c',
))
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] tcg/module: move cpu-exec-common.c from tcg_ss to specific_ss
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 1/7] plugins: register qemu_plugin_opts using opts_init() Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 2/7] tcg/module: move hmp.c to tcg module Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 4/7] tcg/module: add some infrastructure for modular tcg Gerd Hoffmann
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
That will build cpu-exec-common.c into core qemu.
Moves tcg_allowed variable and some small glue functions.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
accel/tcg/meson.build | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index d4df7681a811..c1ee9dcaed1f 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -1,7 +1,10 @@
+specific_ss.add(when: 'CONFIG_TCG', if_true: files(
+ 'cpu-exec-common.c',
+))
+
tcg_ss = ss.source_set()
tcg_ss.add(files(
'tcg-all.c',
- 'cpu-exec-common.c',
'cpu-exec.c',
'tcg-runtime-gvec.c',
'tcg-runtime.c',
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] tcg/module: add some infrastructure for modular tcg.
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
` (2 preceding siblings ...)
2021-08-04 14:38 ` [PATCH 3/7] tcg/module: move cpu-exec-common.c from tcg_ss to specific_ss Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 5/7] tcg/module: Add tlb_flush to TCGModuleOps Gerd Hoffmann
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Create tcg-module.[ch] files, with struct TCGModuleOps, empty for now.
Followup patches will add function pointers to the struct and stub
functions to tcg-module.c. That will effectively will switch stubs from
compile-time to runtime, which is needed to build tcg as module.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/tcg/tcg-module.h | 8 ++++++++
accel/tcg/tcg-module.c | 5 +++++
accel/tcg/meson.build | 4 ++++
3 files changed, 17 insertions(+)
create mode 100644 include/tcg/tcg-module.h
create mode 100644 accel/tcg/tcg-module.c
diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
new file mode 100644
index 000000000000..7e87aecb2357
--- /dev/null
+++ b/include/tcg/tcg-module.h
@@ -0,0 +1,8 @@
+#ifndef TCG_MODULE_H
+#define TCG_MODULE_H
+
+struct TCGModuleOps {
+};
+extern struct TCGModuleOps tcg;
+
+#endif /* TCG_MODULE_H */
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
new file mode 100644
index 000000000000..e864fb20c141
--- /dev/null
+++ b/accel/tcg/tcg-module.c
@@ -0,0 +1,5 @@
+#include "qemu/osdep.h"
+#include "tcg/tcg-module.h"
+
+struct TCGModuleOps tcg = {
+};
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index c1ee9dcaed1f..eaaf7168ffb6 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -1,3 +1,7 @@
+specific_ss.add(files(
+ 'tcg-module.c',
+))
+
specific_ss.add(when: 'CONFIG_TCG', if_true: files(
'cpu-exec-common.c',
))
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] tcg/module: Add tlb_flush to TCGModuleOps
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
` (3 preceding siblings ...)
2021-08-04 14:38 ` [PATCH 4/7] tcg/module: add some infrastructure for modular tcg Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 6/7] tcg/module: Add tlb_flush_page " Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 7/7] tcg/module: Add tlb_reset_dirty " Gerd Hoffmann
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Move stub from exec-all.h to tcg-module.c.
Move tcg_flush_softmmu_tlb to cpu-exec-common.c
so it gets compiled into core qemu.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/exec/exec-all.h | 4 +---
include/tcg/tcg-module.h | 1 +
accel/tcg/cpu-exec-common.c | 8 ++++++++
accel/tcg/cputlb.c | 7 +++++++
accel/tcg/tcg-module.c | 5 +++++
accel/tcg/translate-all.c | 8 --------
cpu.c | 2 +-
softmmu/physmem.c | 6 +++---
target/arm/helper.c | 22 +++++++++++-----------
target/i386/helper.c | 8 ++++----
target/i386/machine.c | 2 +-
target/i386/tcg/fpu_helper.c | 2 +-
target/i386/tcg/misc_helper.c | 2 +-
target/mips/sysemu/cp0.c | 2 +-
target/s390x/gdbstub.c | 2 +-
target/s390x/sigp.c | 2 +-
16 files changed, 47 insertions(+), 36 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 5d1b6d80fbd3..ddb1ab797978 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -25,6 +25,7 @@
#include "exec/cpu_ldst.h"
#endif
#include "sysemu/cpu-timers.h"
+#include "tcg/tcg-module.h"
/* allow to see translation results - the slowdown should be negligible, so we leave it */
#define DEBUG_DISAS
@@ -337,9 +338,6 @@ static inline void tlb_flush_page_all_cpus_synced(CPUState *src,
target_ulong addr)
{
}
-static inline void tlb_flush(CPUState *cpu)
-{
-}
static inline void tlb_flush_all_cpus(CPUState *src_cpu)
{
}
diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
index 7e87aecb2357..b94bfdd362ed 100644
--- a/include/tcg/tcg-module.h
+++ b/include/tcg/tcg-module.h
@@ -2,6 +2,7 @@
#define TCG_MODULE_H
struct TCGModuleOps {
+ void (*tlb_flush)(CPUState *cpu);
};
extern struct TCGModuleOps tcg;
diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c
index be6fe45aa5a8..777ad00befc8 100644
--- a/accel/tcg/cpu-exec-common.c
+++ b/accel/tcg/cpu-exec-common.c
@@ -81,3 +81,11 @@ void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc)
cpu->exception_index = EXCP_ATOMIC;
cpu_loop_exit_restore(cpu, pc);
}
+
+/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */
+void tcg_flush_softmmu_tlb(CPUState *cs)
+{
+#ifdef CONFIG_SOFTMMU
+ tcg.tlb_flush(cs);
+#endif
+}
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index b1e5471f949f..40c3d1b65ac5 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -2767,3 +2767,10 @@ uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
TCGMemOpIdx oi = make_memop_idx(MO_TEQ, cpu_mmu_index(env, true));
return full_ldq_code(env, addr, oi, 0);
}
+
+static void tcg_module_ops_tlb(void)
+{
+ tcg.tlb_flush = tlb_flush;
+}
+
+type_init(tcg_module_ops_tlb);
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
index e864fb20c141..a1e5728c8c1b 100644
--- a/accel/tcg/tcg-module.c
+++ b/accel/tcg/tcg-module.c
@@ -1,5 +1,10 @@
#include "qemu/osdep.h"
#include "tcg/tcg-module.h"
+static void update_cpu_stub(CPUState *cpu)
+{
+}
+
struct TCGModuleOps tcg = {
+ .tlb_flush = update_cpu_stub,
};
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index bbfcfb698c07..c7547cd923b4 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -2463,11 +2463,3 @@ int page_unprotect(target_ulong address, uintptr_t pc)
return 0;
}
#endif /* CONFIG_USER_ONLY */
-
-/* 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
-}
diff --git a/cpu.c b/cpu.c
index e1799a15bcf5..26277f387baf 100644
--- a/cpu.c
+++ b/cpu.c
@@ -51,7 +51,7 @@ static int cpu_common_post_load(void *opaque, int version_id)
/* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the
version_id is increased. */
cpu->interrupt_request &= ~0x01;
- tlb_flush(cpu);
+ tcg.tlb_flush(cpu);
/* loadvm has just updated the content of RAM, bypassing the
* usual mechanisms that ensure we flush TBs for writes to
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 3c1912a1a07d..d99b4ce55d8f 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -589,7 +589,7 @@ static void tcg_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
if (!notifier->active) {
return;
}
- tlb_flush(notifier->cpu);
+ tcg.tlb_flush(notifier->cpu);
notifier->active = false;
/* We leave the notifier struct on the list to avoid reallocating it later.
* Generally the number of IOMMUs a CPU deals with will be small.
@@ -796,7 +796,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
if (len <= in_page) {
tlb_flush_page(cpu, addr);
} else {
- tlb_flush(cpu);
+ tcg.tlb_flush(cpu);
}
if (watchpoint)
@@ -2652,7 +2652,7 @@ static void tcg_commit(MemoryListener *listener)
*/
d = address_space_to_dispatch(cpuas->as);
qatomic_rcu_set(&cpuas->memory_dispatch, d);
- tlb_flush(cpuas->cpu);
+ tcg.tlb_flush(cpuas->cpu);
}
static void memory_map_init(void)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 155d8bf23997..e0848f9bcea8 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -674,7 +674,7 @@ static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
ARMCPU *cpu = env_archcpu(env);
raw_write(env, ri, value);
- tlb_flush(CPU(cpu)); /* Flush TLB as domain not tracked in TLB */
+ tcg.tlb_flush(CPU(cpu)); /* Flush TLB as domain not tracked in TLB */
}
static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
@@ -685,7 +685,7 @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
/* Unlike real hardware the qemu TLB uses virtual addresses,
* not modified virtual addresses, so this causes a TLB flush.
*/
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
raw_write(env, ri, value);
}
}
@@ -701,7 +701,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri,
* format) this register includes the ASID, so do a TLB flush.
* For PMSA it is purely a process ID and no action is needed.
*/
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
}
raw_write(env, ri, value);
}
@@ -758,7 +758,7 @@ static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (tlb_force_broadcast(env)) {
tlb_flush_all_cpus_synced(cs);
} else {
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
}
}
@@ -785,7 +785,7 @@ static void tlbiasid_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (tlb_force_broadcast(env)) {
tlb_flush_all_cpus_synced(cs);
} else {
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
}
}
@@ -3826,7 +3826,7 @@ static void pmsav7_write(CPUARMState *env, const ARMCPRegInfo *ri,
}
u32p += env->pmsav7.rnr[M_REG_NS];
- tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
+ tcg.tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
*u32p = value;
}
@@ -3968,7 +3968,7 @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
/* With LPAE the TTBCR could result in a change of ASID
* via the TTBCR.A1 bit, so do a TLB flush.
*/
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
}
/* Preserve the high half of TCR_EL1, set via TTBCR2. */
value = deposit64(tcr->raw_tcr, 0, 32, value);
@@ -3994,7 +3994,7 @@ static void vmsa_tcr_el12_write(CPUARMState *env, const ARMCPRegInfo *ri,
TCR *tcr = raw_ptr(env, ri);
/* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
tcr->raw_tcr = value;
}
@@ -4005,7 +4005,7 @@ static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (cpreg_field_is_64bit(ri) &&
extract64(raw_read(env, ri) ^ value, 48, 16) != 0) {
ARMCPU *cpu = env_archcpu(env);
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
}
raw_write(env, ri, value);
}
@@ -5021,7 +5021,7 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
raw_write(env, ri, value);
/* This may enable/disable the MMU, so do a TLB flush. */
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
if (ri->type & ARM_CP_SUPPRESS_TB_END) {
/*
@@ -5560,7 +5560,7 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
* HCR_DCT enables tagging on (disabled) stage1 translation
*/
if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC | HCR_DCT)) {
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
}
env->cp15.hcr_el2 = value;
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 533b29cb91b6..100add713c5d 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -103,7 +103,7 @@ void x86_cpu_set_a20(X86CPU *cpu, int a20_state)
/* when a20 is changed, all the MMU mappings are invalid, so
we must flush everything */
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
env->a20_mask = ~(1 << 20) | (a20_state << 20);
}
}
@@ -116,7 +116,7 @@ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0)
qemu_log_mask(CPU_LOG_MMU, "CR0 update: CR0=0x%08x\n", new_cr0);
if ((new_cr0 & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK)) !=
(env->cr[0] & (CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK))) {
- tlb_flush(CPU(cpu));
+ tcg.tlb_flush(CPU(cpu));
}
#ifdef TARGET_X86_64
@@ -156,7 +156,7 @@ void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3)
if (env->cr[0] & CR0_PG_MASK) {
qemu_log_mask(CPU_LOG_MMU,
"CR3 update: CR3=" TARGET_FMT_lx "\n", new_cr3);
- tlb_flush(env_cpu(env));
+ tcg.tlb_flush(env_cpu(env));
}
}
@@ -170,7 +170,7 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)
if ((new_cr4 ^ env->cr[4]) &
(CR4_PGE_MASK | CR4_PAE_MASK | CR4_PSE_MASK |
CR4_SMEP_MASK | CR4_SMAP_MASK | CR4_LA57_MASK)) {
- tlb_flush(env_cpu(env));
+ tcg.tlb_flush(env_cpu(env));
}
/* Clear bits we're going to recompute. */
diff --git a/target/i386/machine.c b/target/i386/machine.c
index f6f094f1c938..571e98853c64 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -383,7 +383,7 @@ static int cpu_post_load(void *opaque, int version_id)
env->dr[7] = dr7 & ~(DR7_GLOBAL_BP_MASK | DR7_LOCAL_BP_MASK);
cpu_x86_update_dr7(env, dr7);
}
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
return 0;
}
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index cdd8e9f9471f..eddf0bb9dfc4 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -2874,7 +2874,7 @@ void helper_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm)
}
if (env->pkru != old_pkru) {
CPUState *cs = env_cpu(env);
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
}
}
}
diff --git a/target/i386/tcg/misc_helper.c b/target/i386/tcg/misc_helper.c
index baffa5d7ba9a..dc974dad6acc 100644
--- a/target/i386/tcg/misc_helper.c
+++ b/target/i386/tcg/misc_helper.c
@@ -142,5 +142,5 @@ void helper_wrpkru(CPUX86State *env, uint32_t ecx, uint64_t val)
}
env->pkru = val;
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
}
diff --git a/target/mips/sysemu/cp0.c b/target/mips/sysemu/cp0.c
index bae37f515bf8..f966991c7cc9 100644
--- a/target/mips/sysemu/cp0.c
+++ b/target/mips/sysemu/cp0.c
@@ -81,7 +81,7 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val)
#if defined(TARGET_MIPS64)
if ((env->CP0_Status ^ old) & (old & (7 << CP0St_UX))) {
/* Access to at least one of the 64-bit segments has been disabled */
- tlb_flush(env_cpu(env));
+ tcg.tlb_flush(env_cpu(env));
}
#endif
if (ase_mt_available(env)) {
diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c
index a5d69d0e0bc5..b60bdc1fbded 100644
--- a/target/s390x/gdbstub.c
+++ b/target/s390x/gdbstub.c
@@ -191,7 +191,7 @@ static int cpu_write_c_reg(CPUS390XState *env, uint8_t *mem_buf, int n)
case S390_C0_REGNUM ... S390_C15_REGNUM:
env->cregs[n] = ldtul_p(mem_buf);
if (tcg_enabled()) {
- tlb_flush(env_cpu(env));
+ tcg.tlb_flush(env_cpu(env));
}
cpu_synchronize_post_init(env_cpu(env));
return 8;
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index d57427ced84d..d2c0b877cee4 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -294,7 +294,7 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg)
}
cpu->env.psa = addr;
- tlb_flush(cs);
+ tcg.tlb_flush(cs);
cpu_synchronize_post_init(cs);
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] tcg/module: Add tlb_flush_page to TCGModuleOps
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
` (4 preceding siblings ...)
2021-08-04 14:38 ` [PATCH 5/7] tcg/module: Add tlb_flush to TCGModuleOps Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 7/7] tcg/module: Add tlb_reset_dirty " Gerd Hoffmann
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Move stub from exec-all.h to tcg-module.c.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/exec/exec-all.h | 3 ---
include/tcg/tcg-module.h | 3 +++
accel/tcg/cputlb.c | 1 +
accel/tcg/tcg-module.c | 5 +++++
softmmu/physmem.c | 4 ++--
target/arm/helper.c | 4 ++--
6 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index ddb1ab797978..43d89699e989 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -328,9 +328,6 @@ static inline void tlb_init(CPUState *cpu)
static inline void tlb_destroy(CPUState *cpu)
{
}
-static inline void tlb_flush_page(CPUState *cpu, target_ulong addr)
-{
-}
static inline void tlb_flush_page_all_cpus(CPUState *src, target_ulong addr)
{
}
diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
index b94bfdd362ed..a903e3ee62c0 100644
--- a/include/tcg/tcg-module.h
+++ b/include/tcg/tcg-module.h
@@ -1,8 +1,11 @@
#ifndef TCG_MODULE_H
#define TCG_MODULE_H
+#include "exec/exec-all.h"
+
struct TCGModuleOps {
void (*tlb_flush)(CPUState *cpu);
+ void (*tlb_flush_page)(CPUState *cpu, target_ulong addr);
};
extern struct TCGModuleOps tcg;
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 40c3d1b65ac5..1fcdb71a10a0 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -2771,6 +2771,7 @@ uint64_t cpu_ldq_code(CPUArchState *env, abi_ptr addr)
static void tcg_module_ops_tlb(void)
{
tcg.tlb_flush = tlb_flush;
+ tcg.tlb_flush_page = tlb_flush_page;
}
type_init(tcg_module_ops_tlb);
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
index a1e5728c8c1b..4d62160628bd 100644
--- a/accel/tcg/tcg-module.c
+++ b/accel/tcg/tcg-module.c
@@ -5,6 +5,11 @@ static void update_cpu_stub(CPUState *cpu)
{
}
+static void tlb_flush_page_stub(CPUState *cpu, target_ulong addr)
+{
+}
+
struct TCGModuleOps tcg = {
.tlb_flush = update_cpu_stub,
+ .tlb_flush_page = tlb_flush_page_stub,
};
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index d99b4ce55d8f..845b9e99e819 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -794,7 +794,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
in_page = -(addr | TARGET_PAGE_MASK);
if (len <= in_page) {
- tlb_flush_page(cpu, addr);
+ tcg.tlb_flush_page(cpu, addr);
} else {
tcg.tlb_flush(cpu);
}
@@ -825,7 +825,7 @@ void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint)
{
QTAILQ_REMOVE(&cpu->watchpoints, watchpoint, entry);
- tlb_flush_page(cpu, watchpoint->vaddr);
+ tcg.tlb_flush_page(cpu, watchpoint->vaddr);
g_free(watchpoint);
}
diff --git a/target/arm/helper.c b/target/arm/helper.c
index e0848f9bcea8..047d4360b65f 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -772,7 +772,7 @@ static void tlbimva_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (tlb_force_broadcast(env)) {
tlb_flush_page_all_cpus_synced(cs, value);
} else {
- tlb_flush_page(cs, value);
+ tcg.tlb_flush_page(cs, value);
}
}
@@ -799,7 +799,7 @@ static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri,
if (tlb_force_broadcast(env)) {
tlb_flush_page_all_cpus_synced(cs, value);
} else {
- tlb_flush_page(cs, value);
+ tcg.tlb_flush_page(cs, value);
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] tcg/module: Add tlb_reset_dirty to TCGModuleOps
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
` (5 preceding siblings ...)
2021-08-04 14:38 ` [PATCH 6/7] tcg/module: Add tlb_flush_page " Gerd Hoffmann
@ 2021-08-04 14:38 ` Gerd Hoffmann
6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2021-08-04 14:38 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Thomas Huth, Peter Xu,
Philippe Mathieu-Daudé,
Gerd Hoffmann, Alexandre Iooss, Huacai Chen, Halil Pasic,
Christian Borntraeger, Aleksandar Rikalo, Eduardo Habkost,
Richard Henderson, qemu-s390x, qemu-arm, Alex Bennée,
Cornelia Huck, Laurent Vivier, Paolo Bonzini, Mahmoud Mandour,
Aurelien Jarno
Move stub from exec-all.h to tcg-module.c.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/exec/exec-all.h | 1 -
include/tcg/tcg-module.h | 3 +++
accel/tcg/cputlb.c | 3 ++-
accel/tcg/tcg-module.c | 9 +++++++++
softmmu/physmem.c | 2 +-
5 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 43d89699e989..27fc489c57b5 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -691,7 +691,6 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr);
tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
void **hostp);
-void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
MemoryRegionSection *
diff --git a/include/tcg/tcg-module.h b/include/tcg/tcg-module.h
index a903e3ee62c0..a14dcdb002db 100644
--- a/include/tcg/tcg-module.h
+++ b/include/tcg/tcg-module.h
@@ -6,6 +6,9 @@
struct TCGModuleOps {
void (*tlb_flush)(CPUState *cpu);
void (*tlb_flush_page)(CPUState *cpu, target_ulong addr);
+#if defined(CONFIG_SOFTMMU)
+ void (*tlb_reset_dirty)(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
+#endif
};
extern struct TCGModuleOps tcg;
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 1fcdb71a10a0..fa9c9064848c 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1004,7 +1004,7 @@ static inline void copy_tlb_helper_locked(CPUTLBEntry *d, const CPUTLBEntry *s)
* We must take tlb_c.lock to avoid racing with another vCPU update. The only
* thing actually updated is the target TLB entry ->addr_write flags.
*/
-void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
+static void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
{
CPUArchState *env;
@@ -2772,6 +2772,7 @@ static void tcg_module_ops_tlb(void)
{
tcg.tlb_flush = tlb_flush;
tcg.tlb_flush_page = tlb_flush_page;
+ tcg.tlb_reset_dirty = tlb_reset_dirty;
}
type_init(tcg_module_ops_tlb);
diff --git a/accel/tcg/tcg-module.c b/accel/tcg/tcg-module.c
index 4d62160628bd..febf4e49981c 100644
--- a/accel/tcg/tcg-module.c
+++ b/accel/tcg/tcg-module.c
@@ -9,7 +9,16 @@ static void tlb_flush_page_stub(CPUState *cpu, target_ulong addr)
{
}
+#if defined(CONFIG_SOFTMMU)
+static void tlb_reset_dirty_stub(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
+{
+}
+#endif
+
struct TCGModuleOps tcg = {
.tlb_flush = update_cpu_stub,
.tlb_flush_page = tlb_flush_page_stub,
+#if defined(CONFIG_SOFTMMU)
+ .tlb_reset_dirty = tlb_reset_dirty_stub,
+#endif
};
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 845b9e99e819..11932746b6f9 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1015,7 +1015,7 @@ static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length)
assert(block == qemu_get_ram_block(end - 1));
start1 = (uintptr_t)ramblock_ptr(block, start - block->offset);
CPU_FOREACH(cpu) {
- tlb_reset_dirty(cpu, start1, length);
+ tcg.tlb_reset_dirty(cpu, start1, length);
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-08-04 14:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 14:38 [PATCH 0/7] tcg: some small towards more modular tcg Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 1/7] plugins: register qemu_plugin_opts using opts_init() Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 2/7] tcg/module: move hmp.c to tcg module Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 3/7] tcg/module: move cpu-exec-common.c from tcg_ss to specific_ss Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 4/7] tcg/module: add some infrastructure for modular tcg Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 5/7] tcg/module: Add tlb_flush to TCGModuleOps Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 6/7] tcg/module: Add tlb_flush_page " Gerd Hoffmann
2021-08-04 14:38 ` [PATCH 7/7] tcg/module: Add tlb_reset_dirty " Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.