* [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1
@ 2015-09-11 5:39 Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 01/15] cpu-exec: Migrate some generic fns to cpu-exec-common Peter Crosthwaite
` (15 more replies)
0 siblings, 16 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
This is the first set of patches needed to enable Multi-arch system
emulation. For full context refer to RFCv3:
[PATCH v3 00/35] Multi Architecture System Emulation
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03929.html
This is the first patch-pack intended for merge.
Original cover, as well as overall series state below for further
information.
Regards,
Peter
Original Multi-arch arch patch series cover:
***
This is target-multi, a system-mode build that can support multiple
cpu-types.
Two architectures are initially converted. Microblaze and ARM. Step
by step conversion in done for each. A microblaze is added to
Xilinx Zynq platform as a test case. This will be elaborted more in
future spins. This use case is valid, as Microblazes can be added (any
number of them!) in Zynq FPGA programmable logic configuration.
The general approach (radically different to approach in V1 RFC) is to build
and prelink an object (arch-obj.o) per-arch containing:
1: target-foo/*
2: All uses of env internals and CPU_GET_ENV
* cputlb, translate-all, cpu-exec
* TCG backend
This means cputlb and friends are compiled multiple times fo each arch. The
symbols for each of these pre-links are then localised to avoid link time name
collisions. This is based on Paolo's suggestion to templatify cputlb and
friends. Just the net of what to multi-compile is widened to include the TCG
stuff as well now.
Despite being some "major surgery" this approach actually solves many of big
the problems raised in V1. Big problems sovled:
1: With the multi-compile TCG backends there are now multiple tcg_ctx's for
each architecture. This solves the issue PMM raised WRT false positives on TB
hashing as archs no longer share translation context.
2: There is no longer a need to reorder the CPU_COMMON within the ENV or the ENV
within the CPU. This was flagged as a performance issue by multiple people in
V1.
All users of the env internals as well as ENV_GET_CPU are now in multi-compile
code and so multi-arch does not need to define a generic ENV nor does in need to
def the problematic ENV_GET_CPU.
3: With the prelink symbol localisation, link time namespace collision of
helpers from multiple arches is no longer an issue. No need to bloat all the
function names with arch specific prefixes.
4: The architecture specifics used/defined by cpu-defs can now vary from arch to
arch (incl. target_ulong) greatly reducing coversion effort needed. The list
of restrictions for multi-arch capability is much reduced since V1. No
target_long issues anymore.
include/exec/*.h and some of the common code needs some refactoring to setup
this single vs multi compile split. Mostly code movements.
Some functions (like tcg_enabled) need to be listified for each of the
now-multiple TCG engines.
The interface between the multi compile and single compiled files needs to be
virtualised using QOM cpu functions. But this is now a very low footprint
change as most of the virtualised hooks are now in mutli-compiled code (they
only exist as text once). There are more new hooks than before, but the per
target change pattern is reduced.
For the implementation of the series, the trickiest part is (still) cpu.h
inclusion management. There are now more than one cpu.h's and different
parts of the tree need a different include scheme. target-multi defines
it's own cpu.h which is bare minimum defs as needed by core code only.
target-foo/cpu.h are mostly the same but refactored to avoid collisions
with other cpu.h's. Inclusion scheme goes something like
this (for the multi-arch build):
*: Core code includes only target-multi/cpu.h
*: target-foo/ implementation code includes target-foo/cpu.h locally
*: System level code (e.g. mach models) can use multiple target-foo/cpu.h's
The hardest unasnwered Q is (still) what to do about bootloading. Currently
each arch has it's own architecture specific bootloading which may assume a
single architecture. I have applied some hacks to at least get this
RFC testable using a -kernel -firmware split but going forward being
able to associate an elf/image with a cpu explictitly needs to be
solved.
No support for KVM, im not sure if a mix of TCG and KVM is supported even for
a single arch? (which would be prerequisite to MA KVM).
***
Current review state of full multi-arch work in progress branch:
cpu-exec: Migrate some generic fns to cpu-exec-common
translate: Listify tcg_exec_init() R:rth
translate-all: Move tcg_handle_interrupt() to -common R:rth
tcg: split tcg_op_defs to -common
tcg: Move tcg_tb_ptr to -common
translate: move real_host_page setting to -common
cpus: Listify cpu_list() function
translate-common: Listify tcg_enabled()
core: Convert tcg_enabled() uses to any/all variants
exec-all: Move cpu_can_do_io() to qom/cpu.h R:rth
cputlb: move CPU_LOOP() for tlb_reset() to exec.c
cputlb: Change tlb_set_dirty() arg to cpu
include/exec: Move cputlb exec.c defs out R:rth
cpu-common: Define tb_page_addr_t for everyone
monitor: uninclude cpu_ldst
disas: s390x: QOMify target specific disas setup A:rth
disas: moxie: QOMify target specific disas setup
disas: m68k: QOMify target specific disas setup R:laurentv R:gerg
disas: sparc: QOMify target specific disas setup
disas: lm32: QOMify target specific disas setup A:mwalle
disas: sh4: QOMify target specific disas setup A:aurel
disas: mips: QOMify target specific disas setup A:lalrae
disas: alpha: QOMify target specific disas setup A:rth
linux_user: elfload: Default ELF_MACHINE to ELF_ARCH R:rth
linux-user: elfload: Provide default for elf_check_arch R:rth
elf_ops: Fix coding style for EM alias case statement R:rth
elf: Update EM_MOXIE definition R:rth
arm: Remove ELF_MACHINE from cpu.h R:rth
mb: Remove ELF_MACHINE from cpu.h R:rth
m68k: Remove ELF_MACHINE from cpu.h R:rth R:gerg R:laurentv
cris: Remove ELF_MACHINE from cpu.h R:rth
moxie: Remove ELF_MACHINE from cpu.h R:rth
unicore: Remove ELF_MACHINE from cpu.h R:rth
lm32: Remove ELF_MACHINE from cpu.h R:rth
or32: Remove ELF_MACHINE from cpu.h R:rth
tricore: Remove ELF_MACHINE from cpu.h R:rth
xtensa: Remove ELF_MACHINE from cpu.h R:rth
sh4: Remove ELF_MACHINE from cpu.h A:aurel R:rth
s390: Remove ELF_MACHINE from cpu.h R:rth
sparc: Remove ELF_MACHINE from cpu.h R:rth
mips: Remove ELF_MACHINE from cpu.h R:aurel R:rth
alpha: Remove ELF_MACHINE from cpu.h R:rth
i386: Rename ELF_MACHINE to be x86 specific R:eduardo A:eduardo R:rth
ppc: Rename ELF_MACHINE to be PPC specific R:rth
arm: cpu: assert() on no-EL2 virt IRQ error condition. R:pmm
arm: Remove hw_error() usages. R:pmm
configure: factor out adding disas configure R:pmm
target-*: Don't redefine cpu_exec()
include/exec: Split target_long def to new header
cpu-defs: Allow multiple inclusions
target-*: cpu.h: Undefine core code symbols
Makefile.target: Introduce arch-obj
core: virtualise CPU interfaces completely
core: Introduce multi-arch build
arm: cpu: static inline cpu_arm_init()
target-arm: Split cp helper API to new C file
arm: register cpu_list() function
arm: enable multi-arch
hw: arm: Explicitly include cpu.h for consumers
hw: mb: Explicitly include cpu.h for consumers
microblaze: enable multi-arch
arm: boot: Don't assume all CPUs are ARM
arm: xilinx_zynq: Add a Microblaze
HACK: mb: boot: Assume using -firmware for mb software
HACK: mb: boot: Disable dtb load in multi-arch
Peter Crosthwaite (15):
cpu-exec: Migrate some generic fns to cpu-exec-common
translate: Listify tcg_exec_init()
translate-all: Move tcg_handle_interrupt() to -common
tcg: split tcg_op_defs to -common
tcg: Move tcg_tb_ptr to -common
translate: move real_host_page setting to -common
cpus: Listify cpu_list() function
translate-common: Listify tcg_enabled()
core: Convert tcg_enabled() uses to any/all variants
exec-all: Move cpu_can_do_io() to qom/cpu.h
cputlb: move CPU_LOOP() for tlb_reset() to exec.c
cputlb: Change tlb_set_dirty() arg to cpu
include/exec: Move cputlb exec.c defs out
cpu-common: Define tb_page_addr_t for everyone
monitor: uninclude cpu_ldst
Makefile.target | 3 ++
cpu-exec-common.c | 108 ++++++++++++++++++++++++++++++++++++++
cpu-exec.c | 49 -----------------
cpus.c | 10 +---
cputlb.c | 30 +++++------
exec.c | 13 ++---
include/exec/cpu-common.h | 4 ++
include/exec/cputlb.h | 16 ------
include/exec/exec-all.h | 20 ++++++-
include/exec/ram_addr.h | 5 +-
include/qemu-common.h | 6 +++
include/qom/cpu.h | 22 ++++++++
include/sysemu/cpus.h | 7 +++
memory.c | 8 +--
monitor.c | 1 -
tcg/tcg-common.c | 35 +++++++++++++
tcg/tcg.c | 8 +--
tcg/tci/tcg-target.c | 2 +-
tci.c | 6 ---
translate-all.c | 46 ++++------------
translate-common.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++
21 files changed, 375 insertions(+), 154 deletions(-)
create mode 100644 cpu-exec-common.c
create mode 100644 tcg/tcg-common.c
create mode 100644 translate-common.c
--
1.9.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 01/15] cpu-exec: Migrate some generic fns to cpu-exec-common
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 02/15] translate: Listify tcg_exec_init() Peter Crosthwaite
` (14 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
The goal is to split the functions such that cpu-exec is CPU specific
content, while cpus-exec-common.c is generic code only. The function
interface to cpu-exec needs to be virtualised to prepare support for
multi-arch and moving these definitions out saves bloating the QOM
interface. So move these definitions out of cpu-exec to a new module,
cpu-exec-common.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Changed since RFCv3
Get rid of CPU_HOOK (paolo review)
Changed since RFCv2
Make a new file instead of move stuff to cpus.c
Makefile.target | 1 +
cpu-exec-common.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
cpu-exec.c | 49 -----------------------------------
3 files changed, 77 insertions(+), 49 deletions(-)
create mode 100644 cpu-exec-common.c
diff --git a/Makefile.target b/Makefile.target
index 3e7aafd..6435c96 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -85,6 +85,7 @@ all: $(PROGS) stap
#########################################################
# cpu emulator library
obj-y = exec.o translate-all.o cpu-exec.o
+obj-y += cpu-exec-common.o
obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
obj-$(CONFIG_TCG_INTERPRETER) += tci.o
obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
diff --git a/cpu-exec-common.c b/cpu-exec-common.c
new file mode 100644
index 0000000..f9cf25b
--- /dev/null
+++ b/cpu-exec-common.c
@@ -0,0 +1,76 @@
+/*
+ * emulator main execution loop
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "cpu.h"
+#include "sysemu/cpus.h"
+#include "exec/memory-internal.h"
+
+volatile sig_atomic_t exit_request;
+
+/* exit the current TB from a signal handler. The host registers are
+ restored in a state compatible with the CPU emulator
+ */
+#if defined(CONFIG_SOFTMMU)
+void cpu_resume_from_signal(CPUState *cpu, void *puc)
+{
+ /* XXX: restore cpu registers saved in host registers */
+
+ cpu->exception_index = -1;
+ siglongjmp(cpu->jmp_env, 1);
+}
+
+void cpu_reload_memory_map(CPUState *cpu)
+{
+ AddressSpaceDispatch *d;
+
+ if (qemu_in_vcpu_thread()) {
+ /* Do not let the guest prolong the critical section as much as it
+ * as it desires.
+ *
+ * Currently, this is prevented by the I/O thread's periodinc kicking
+ * of the VCPU thread (iothread_requesting_mutex, qemu_cpu_kick_thread)
+ * but this will go away once TCG's execution moves out of the global
+ * mutex.
+ *
+ * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which
+ * only protects cpu->as->dispatch. Since we reload it below, we can
+ * split the critical section.
+ */
+ rcu_read_unlock();
+ rcu_read_lock();
+ }
+
+ /* The CPU and TLB are protected by the iothread lock. */
+ d = atomic_rcu_read(&cpu->as->dispatch);
+ cpu->memory_dispatch = d;
+ tlb_flush(cpu, 1);
+}
+#endif
+
+void cpu_loop_exit(CPUState *cpu)
+{
+ cpu->current_tb = NULL;
+ siglongjmp(cpu->jmp_env, 1);
+}
+
+typedef struct CPUListFn {
+ void (*do_cpu_list)(FILE *f, fprintf_function cpu_fprintf);
+ QLIST_ENTRY(CPUListFn) list;
+} CPUListFn;
diff --git a/cpu-exec.c b/cpu-exec.c
index 713540f..0072565 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -25,7 +25,6 @@
#include "sysemu/qtest.h"
#include "qemu/timer.h"
#include "exec/address-spaces.h"
-#include "exec/memory-internal.h"
#include "qemu/rcu.h"
#include "exec/tb-hash.h"
@@ -128,52 +127,6 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu)
}
#endif /* CONFIG USER ONLY */
-void cpu_loop_exit(CPUState *cpu)
-{
- cpu->current_tb = NULL;
- siglongjmp(cpu->jmp_env, 1);
-}
-
-/* exit the current TB from a signal handler. The host registers are
- restored in a state compatible with the CPU emulator
- */
-#if defined(CONFIG_SOFTMMU)
-void cpu_resume_from_signal(CPUState *cpu, void *puc)
-{
- /* XXX: restore cpu registers saved in host registers */
-
- cpu->exception_index = -1;
- siglongjmp(cpu->jmp_env, 1);
-}
-
-void cpu_reload_memory_map(CPUState *cpu)
-{
- AddressSpaceDispatch *d;
-
- if (qemu_in_vcpu_thread()) {
- /* Do not let the guest prolong the critical section as much as it
- * as it desires.
- *
- * Currently, this is prevented by the I/O thread's periodinc kicking
- * of the VCPU thread (iothread_requesting_mutex, qemu_cpu_kick_thread)
- * but this will go away once TCG's execution moves out of the global
- * mutex.
- *
- * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which
- * only protects cpu->as->dispatch. Since we reload it below, we can
- * split the critical section.
- */
- rcu_read_unlock();
- rcu_read_lock();
- }
-
- /* The CPU and TLB are protected by the iothread lock. */
- d = atomic_rcu_read(&cpu->as->dispatch);
- cpu->memory_dispatch = d;
- tlb_flush(cpu, 1);
-}
-#endif
-
/* Execute a TB, and fix up the CPU state afterwards if necessary */
static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr)
{
@@ -341,8 +294,6 @@ static void cpu_handle_debug_exception(CPUState *cpu)
/* main execution loop */
-volatile sig_atomic_t exit_request;
-
int cpu_exec(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 02/15] translate: Listify tcg_exec_init()
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 01/15] cpu-exec: Migrate some generic fns to cpu-exec-common Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common Peter Crosthwaite
` (13 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Create a global list of tcg_exec_init() functions that is populated at
startup. Multiple translation engines can register an init function
and all will be called on the master call to tcg_exec_init().
Introduce a new module, translate-common. This is common code for
translation functionality such as this.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Reviewed-by: Richard Henderson <rth@twiddle.net>
Changed since RFCv2
Move to obj-y (needed by linux-user)
Makefile.target | 1 +
include/qemu-common.h | 1 +
translate-all.c | 7 ++++++-
translate-common.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 translate-common.c
diff --git a/Makefile.target b/Makefile.target
index 6435c96..7dc6d0c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -85,6 +85,7 @@ all: $(PROGS) stap
#########################################################
# cpu emulator library
obj-y = exec.o translate-all.o cpu-exec.o
+obj-y += translate-common.o
obj-y += cpu-exec-common.o
obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
obj-$(CONFIG_TCG_INTERPRETER) += tci.o
diff --git a/include/qemu-common.h b/include/qemu-common.h
index bbaffd1..abb2030 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -309,6 +309,7 @@ typedef struct PCIHostDeviceAddress {
unsigned int function;
} PCIHostDeviceAddress;
+void tcg_exec_init_add(void (*fn)(unsigned long));
void tcg_exec_init(unsigned long tb_size);
bool tcg_enabled(void);
diff --git a/translate-all.c b/translate-all.c
index 2a40530..1228f9c 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -681,7 +681,7 @@ static inline void code_gen_alloc(size_t tb_size)
/* Must be called before using the QEMU cpus. 'tb_size' is the size
(in bytes) allocated to the translation buffer. Zero means default
size. */
-void tcg_exec_init(unsigned long tb_size)
+static void do_tcg_exec_init(unsigned long tb_size)
{
cpu_gen_init();
code_gen_alloc(tb_size);
@@ -695,6 +695,11 @@ void tcg_exec_init(unsigned long tb_size)
#endif
}
+static __attribute__((constructor)) void register_tcg_exec_init(void)
+{
+ tcg_exec_init_add(do_tcg_exec_init);
+}
+
bool tcg_enabled(void)
{
return tcg_ctx.code_gen_buffer != NULL;
diff --git a/translate-common.c b/translate-common.c
new file mode 100644
index 0000000..563ae5a
--- /dev/null
+++ b/translate-common.c
@@ -0,0 +1,50 @@
+/*
+ * Host code generation common components
+ *
+ * Copyright (c) 2015 Peter Crosthwaite <crosthwaite.peter@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu-common.h"
+
+typedef struct TCGExecInitFn {
+ void (*do_tcg_exec_init)(unsigned long tb_size);
+ QLIST_ENTRY(TCGExecInitFn) list;
+} TCGExecInitFn;
+
+static QLIST_HEAD(, TCGExecInitFn) tcg_exec_init_list;
+
+void tcg_exec_init_add(void (*fn)(unsigned long))
+{
+ static bool inited;
+ TCGExecInitFn *lelem = g_malloc0(sizeof *lelem);
+
+ if (!inited) {
+ inited = true;
+ QLIST_INIT(&tcg_exec_init_list);
+ }
+
+ lelem->do_tcg_exec_init = fn;
+ QLIST_INSERT_HEAD(&tcg_exec_init_list, lelem, list);
+}
+
+void tcg_exec_init(unsigned long tb_size)
+{
+ TCGExecInitFn *t;
+
+ QLIST_FOREACH(t, &tcg_exec_init_list, list) {
+ t->do_tcg_exec_init(tb_size);
+ }
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 01/15] cpu-exec: Migrate some generic fns to cpu-exec-common Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 02/15] translate: Listify tcg_exec_init() Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 15:10 ` Richard Henderson
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 04/15] tcg: split tcg_op_defs " Peter Crosthwaite
` (12 subsequent siblings)
15 siblings, 1 reply; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Move this function to common code. It has no arch specific
dependencies. Prepares support for multi-arch where the translate-all
interface needs to be virtualised. One less thing to virtualise.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
translate-all.c | 32 --------------------------------
translate-common.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/translate-all.c b/translate-all.c
index 1228f9c..950e991 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -1457,38 +1457,6 @@ void tb_check_watchpoint(CPUState *cpu)
}
#ifndef CONFIG_USER_ONLY
-/* mask must never be zero, except for A20 change call */
-static void tcg_handle_interrupt(CPUState *cpu, int mask)
-{
- int old_mask;
-
- old_mask = cpu->interrupt_request;
- cpu->interrupt_request |= mask;
-
- /*
- * If called from iothread context, wake the target cpu in
- * case its halted.
- */
- if (!qemu_cpu_is_self(cpu)) {
- qemu_cpu_kick(cpu);
- return;
- }
-
- if (use_icount) {
- cpu->icount_decr.u16.high = 0xffff;
- if (!cpu->can_do_io
- && (mask & ~old_mask) != 0) {
- cpu_abort(cpu, "Raised interrupt while not in I/O function");
- }
- } else {
- cpu->tcg_exit_req = 1;
- }
-}
-
-CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
-
-/* in deterministic execution mode, instructions doing device I/Os
- must be at the end of the TB */
void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
{
#if defined(TARGET_MIPS) || defined(TARGET_SH4)
diff --git a/translate-common.c b/translate-common.c
index 563ae5a..368a117 100644
--- a/translate-common.c
+++ b/translate-common.c
@@ -1,6 +1,7 @@
/*
* Host code generation common components
*
+ * Copyright (c) 2003 Fabrice Bellard
* Copyright (c) 2015 Peter Crosthwaite <crosthwaite.peter@gmail.com>
*
* This library is free software; you can redistribute it and/or
@@ -18,6 +19,39 @@
*/
#include "qemu-common.h"
+#include "qom/cpu.h"
+
+#ifndef CONFIG_USER_ONLY
+/* mask must never be zero, except for A20 change call */
+static void tcg_handle_interrupt(CPUState *cpu, int mask)
+{
+ int old_mask;
+
+ old_mask = cpu->interrupt_request;
+ cpu->interrupt_request |= mask;
+
+ /*
+ * If called from iothread context, wake the target cpu in
+ * case its halted.
+ */
+ if (!qemu_cpu_is_self(cpu)) {
+ qemu_cpu_kick(cpu);
+ return;
+ }
+
+ if (use_icount) {
+ cpu->icount_decr.u16.high = 0xffff;
+ if (!cpu->can_do_io
+ && (mask & ~old_mask) != 0) {
+ cpu_abort(cpu, "Raised interrupt while not in I/O function");
+ }
+ } else {
+ cpu->tcg_exit_req = 1;
+ }
+}
+
+CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
+#endif
typedef struct TCGExecInitFn {
void (*do_tcg_exec_init)(unsigned long tb_size);
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 04/15] tcg: split tcg_op_defs to -common
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (2 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 05/15] tcg: Move tcg_tb_ptr " Peter Crosthwaite
` (11 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
tcg_op_defs (and the _max) are both needed by the TCI disassembler. For
multi-arch, tcg.c will be multiple-compiled (arch-obj) with its symbols
hidden from common code. So split the definition off to new file,
tcg-common.c which will remain a regular obj-y for use by both the TCI
disas as well as the multiple tcg.c's.
Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Changed since v3:
Fix 80 char violation on moved code.
Makefile.target | 1 +
tcg/tcg-common.c | 33 +++++++++++++++++++++++++++++++++
tcg/tcg.c | 8 +-------
tcg/tci/tcg-target.c | 2 +-
4 files changed, 36 insertions(+), 8 deletions(-)
create mode 100644 tcg/tcg-common.c
diff --git a/Makefile.target b/Makefile.target
index 7dc6d0c..6186f03 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -89,6 +89,7 @@ obj-y += translate-common.o
obj-y += cpu-exec-common.o
obj-y += tcg/tcg.o tcg/tcg-op.o tcg/optimize.o
obj-$(CONFIG_TCG_INTERPRETER) += tci.o
+obj-y += tcg/tcg-common.o
obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
obj-y += fpu/softfloat.o
obj-y += target-$(TARGET_BASE_ARCH)/
diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c
new file mode 100644
index 0000000..6a68c42
--- /dev/null
+++ b/tcg/tcg-common.c
@@ -0,0 +1,33 @@
+/*
+ * Tiny Code Generator for QEMU
+ *
+ * Copyright (c) 2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "tcg/tcg.h"
+
+TCGOpDef tcg_op_defs[] = {
+#define DEF(s, oargs, iargs, cargs, flags) \
+ { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
+#include "tcg-opc.h"
+#undef DEF
+};
+const size_t tcg_op_defs_max = ARRAY_SIZE(tcg_op_defs);
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 0892a9b..2152231 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -113,12 +113,6 @@ static void tcg_out_tb_init(TCGContext *s);
static void tcg_out_tb_finalize(TCGContext *s);
-TCGOpDef tcg_op_defs[] = {
-#define DEF(s, oargs, iargs, cargs, flags) { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
-#include "tcg-opc.h"
-#undef DEF
-};
-const size_t tcg_op_defs_max = ARRAY_SIZE(tcg_op_defs);
static TCGRegSet tcg_target_available_regs[2];
static TCGRegSet tcg_target_call_clobber_regs;
@@ -1240,7 +1234,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs)
#if defined(CONFIG_DEBUG_TCG)
i = 0;
- for (op = 0; op < ARRAY_SIZE(tcg_op_defs); op++) {
+ for (op = 0; op < tcg_op_defs_max; op++) {
const TCGOpDef *def = &tcg_op_defs[op];
if (def->flags & TCG_OPF_NOT_PRESENT) {
/* Wrong entry in op definitions? */
diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
index bbb54d4..4afe4d7 100644
--- a/tcg/tci/tcg-target.c
+++ b/tcg/tci/tcg-target.c
@@ -850,7 +850,7 @@ static void tcg_target_init(TCGContext *s)
#endif
/* The current code uses uint8_t for tcg operations. */
- assert(ARRAY_SIZE(tcg_op_defs) <= UINT8_MAX);
+ assert(tcg_op_defs_max <= UINT8_MAX);
/* Registers available for 32 bit operations. */
tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0,
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 05/15] tcg: Move tcg_tb_ptr to -common
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (3 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 04/15] tcg: split tcg_op_defs " Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 06/15] translate: move real_host_page setting " Peter Crosthwaite
` (10 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
This requires global visibility to common code. Move to tcg-common.
Cc: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
tcg/tcg-common.c | 2 ++
tci.c | 6 ------
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/tcg/tcg-common.c b/tcg/tcg-common.c
index 6a68c42..bcbd073 100644
--- a/tcg/tcg-common.c
+++ b/tcg/tcg-common.c
@@ -24,6 +24,8 @@
#include "tcg/tcg.h"
+uintptr_t tci_tb_ptr;
+
TCGOpDef tcg_op_defs[] = {
#define DEF(s, oargs, iargs, cargs, flags) \
{ #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
diff --git a/tci.c b/tci.c
index 3d6d177..70eaab2 100644
--- a/tci.c
+++ b/tci.c
@@ -52,12 +52,6 @@ typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong,
tcg_target_ulong);
#endif
-/* Targets which don't use GETPC also don't need tci_tb_ptr
- which makes them a little faster. */
-#if defined(GETPC)
-uintptr_t tci_tb_ptr;
-#endif
-
static tcg_target_ulong tci_reg[TCG_TARGET_NB_REGS];
static tcg_target_ulong tci_read_reg(TCGReg index)
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 06/15] translate: move real_host_page setting to -common
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (4 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 05/15] tcg: Move tcg_tb_ptr " Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 07/15] cpus: Listify cpu_list() function Peter Crosthwaite
` (9 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Move the size and mask globals for the "real" host page size to
translate-common. This is to allow system-level code to use
REAL_HOST_PAGE_ALIGN and friends in builds which hide translate-all
behind arch-obj.
Cc: dgilbert@redhat.com
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
translate-all.c | 2 --
translate-common.c | 3 +++
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/translate-all.c b/translate-all.c
index 950e991..7532fe3 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -117,8 +117,6 @@ typedef struct PageDesc {
#define V_L1_SHIFT (L1_MAP_ADDR_SPACE_BITS - TARGET_PAGE_BITS - V_L1_BITS)
-uintptr_t qemu_real_host_page_size;
-uintptr_t qemu_real_host_page_mask;
uintptr_t qemu_host_page_size;
uintptr_t qemu_host_page_mask;
diff --git a/translate-common.c b/translate-common.c
index 368a117..339aac2 100644
--- a/translate-common.c
+++ b/translate-common.c
@@ -21,6 +21,9 @@
#include "qemu-common.h"
#include "qom/cpu.h"
+uintptr_t qemu_real_host_page_size;
+uintptr_t qemu_real_host_page_mask;
+
#ifndef CONFIG_USER_ONLY
/* mask must never be zero, except for A20 change call */
static void tcg_handle_interrupt(CPUState *cpu, int mask)
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 07/15] cpus: Listify cpu_list() function
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (5 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 06/15] translate: move real_host_page setting " Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 08/15] translate-common: Listify tcg_enabled() Peter Crosthwaite
` (8 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Multiple multi-arch targets may wish to implement cpu_list(). When the
command is called each should be called one after other. Create a list
to allow registrations. When cpu_list() is called the list is iterated
calling all implementors.
The original singleton #define'able cpu_list() mechanism remains in
place to allow gradual conversion of the target arches to the new way.
cpu_list_add() needs to visible from target-foo/*.c which means it
cannot be placed in cpus.c (common-obj). So put it in
cpu-exec-common.c. For consistency, move cpu_list() alongside it.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
cpu-exec-common.c | 32 ++++++++++++++++++++++++++++++++
cpus.c | 8 --------
include/sysemu/cpus.h | 7 +++++++
3 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/cpu-exec-common.c b/cpu-exec-common.c
index f9cf25b..6fd7bbd 100644
--- a/cpu-exec-common.c
+++ b/cpu-exec-common.c
@@ -74,3 +74,35 @@ typedef struct CPUListFn {
void (*do_cpu_list)(FILE *f, fprintf_function cpu_fprintf);
QLIST_ENTRY(CPUListFn) list;
} CPUListFn;
+
+static bool cpu_list_list_inited;
+static QLIST_HEAD(, CPUListFn) cpu_list_list;
+
+void cpu_list_add(void (*fn)(FILE *, fprintf_function))
+{
+ CPUListFn *lelem = g_malloc0(sizeof(*lelem));
+
+ if (!cpu_list_list_inited) {
+ cpu_list_list_inited = true;
+ QLIST_INIT(&cpu_list_list);
+ }
+
+ lelem->do_cpu_list = fn;
+ QLIST_INSERT_HEAD(&cpu_list_list, lelem, list);
+}
+
+void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
+{
+ CPUListFn *c;
+
+ /* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+ cpu_list(f, cpu_fprintf);
+#endif
+ if (!cpu_list_list_inited) {
+ return;
+ }
+ QLIST_FOREACH(c, &cpu_list_list, list) {
+ c->do_cpu_list(f, cpu_fprintf);
+ }
+}
diff --git a/cpus.c b/cpus.c
index c1e74d9..9365e03 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1443,14 +1443,6 @@ static void tcg_exec_all(void)
exit_request = 0;
}
-void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
-{
- /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
- cpu_list(f, cpu_fprintf);
-#endif
-}
-
CpuInfoList *qmp_query_cpus(Error **errp)
{
CpuInfoList *head = NULL, *cur_item = NULL;
diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h
index 3f162a9..e8f8763 100644
--- a/include/sysemu/cpus.h
+++ b/include/sysemu/cpus.h
@@ -24,6 +24,13 @@ extern int smp_threads;
#define smp_threads 1
#endif
+void cpu_list_add(void (*fn)(FILE *, fprintf_function cpu_fprintf));
void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg);
+#define cpu_list_register(fn) \
+static __attribute__((constructor)) void register_cpu_list ## fn(void) \
+{ \
+ cpu_list_add(fn); \
+}
+
#endif
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 08/15] translate-common: Listify tcg_enabled()
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (6 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 07/15] cpus: Listify cpu_list() function Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 09/15] core: Convert tcg_enabled() uses to any/all variants Peter Crosthwaite
` (7 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Add an interface for TCG engines to register their tcg_enabled()
function for addition to a global list. Each TCG engine will
register and then two functions, tcg_any_enabled() & tcg_all_enabled()
can be used to query the overall tcg enablement state.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
include/qemu-common.h | 5 +++++
translate-all.c | 5 +++++
translate-common.c | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/include/qemu-common.h b/include/qemu-common.h
index abb2030..a458e92 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -311,6 +311,11 @@ typedef struct PCIHostDeviceAddress {
void tcg_exec_init_add(void (*fn)(unsigned long));
void tcg_exec_init(unsigned long tb_size);
+
+void tcg_enabled_add(bool (*fn)(void));
+bool tcg_any_enabled(void);
+bool tcg_all_enabled(void);
+
bool tcg_enabled(void);
void cpu_exec_init_all(void);
diff --git a/translate-all.c b/translate-all.c
index 7532fe3..fb81a2f 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -703,6 +703,11 @@ bool tcg_enabled(void)
return tcg_ctx.code_gen_buffer != NULL;
}
+static __attribute__((constructor)) void register_tcg_enabled(void)
+{
+ tcg_enabled_add(tcg_enabled);
+}
+
/* Allocate a new translation block. Flush the translation buffer if
too many translation blocks or too much generated code. */
static TranslationBlock *tb_alloc(target_ulong pc)
diff --git a/translate-common.c b/translate-common.c
index 339aac2..d6d04db 100644
--- a/translate-common.c
+++ b/translate-common.c
@@ -85,3 +85,46 @@ void tcg_exec_init(unsigned long tb_size)
t->do_tcg_exec_init(tb_size);
}
}
+
+typedef struct TCGEnabledFn {
+ bool (*do_tcg_enabled)(void);
+ QLIST_ENTRY(TCGEnabledFn) list;
+} TCGEnabledFn;
+
+static QLIST_HEAD(, TCGEnabledFn) tcg_enabled_fn_list;
+
+void tcg_enabled_add(bool (*fn)(void))
+{
+ static bool inited;
+ TCGEnabledFn *lelem = g_malloc0(sizeof *lelem);
+
+ if (!inited) {
+ inited = true;
+ QLIST_INIT(&tcg_enabled_fn_list);
+ }
+
+ lelem->do_tcg_enabled = fn;
+ QLIST_INSERT_HEAD(&tcg_enabled_fn_list, lelem, list);
+}
+
+static inline bool tcg_any_all_enabled(bool all)
+{
+ TCGEnabledFn *t;
+
+ QLIST_FOREACH(t, &tcg_enabled_fn_list, list) {
+ if (t->do_tcg_enabled() != all) {
+ return !all;
+ }
+ }
+ return all;
+}
+
+bool tcg_any_enabled(void)
+{
+ return tcg_any_all_enabled(false);
+}
+
+bool tcg_all_enabled(void)
+{
+ return tcg_any_all_enabled(true);
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 09/15] core: Convert tcg_enabled() uses to any/all variants
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (7 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 08/15] translate-common: Listify tcg_enabled() Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h Peter Crosthwaite
` (6 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Convert core code usages of tcg_enabled() which don't have a specific
CPU associated with, to either tcg_any_enabled() or tcg_all_enabled().
This is to prepare support for multiple tcg engines, where queries must
query a specific CPU or use global any/all logic.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Changed since RFCv3:
Tweak commit subject (too long)
cpus.c | 2 +-
exec.c | 4 ++--
include/exec/ram_addr.h | 5 +++--
memory.c | 8 ++++----
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/cpus.c b/cpus.c
index 9365e03..da4026e 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1165,7 +1165,7 @@ void qemu_mutex_lock_iothread(void)
/* In the simple case there is no need to bump the VCPU thread out of
* TCG code execution.
*/
- if (!tcg_enabled() || qemu_in_vcpu_thread() ||
+ if (!tcg_any_enabled() || qemu_in_vcpu_thread() ||
!first_cpu || !first_cpu->thread) {
qemu_mutex_lock(&qemu_global_mutex);
atomic_dec(&iothread_requesting_mutex);
diff --git a/exec.c b/exec.c
index 54cd70a..c120730 100644
--- a/exec.c
+++ b/exec.c
@@ -926,7 +926,7 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_addr_t start,
dirty = bitmap_test_and_clear_atomic(ram_list.dirty_memory[client],
page, end - page);
- if (dirty && tcg_enabled()) {
+ if (dirty && tcg_any_enabled()) {
tlb_reset_dirty_range_all(start, length);
}
@@ -2592,7 +2592,7 @@ void cpu_flush_icache_range(hwaddr start, int len)
* so there is no need to flush anything. For KVM / Xen we need to flush
* the host's instruction cache at least.
*/
- if (tcg_enabled()) {
+ if (!tcg_all_enabled()) {
return;
}
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index c113f21..2e8fdd1 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -164,14 +164,15 @@ static inline void cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap,
atomic_or(&d[DIRTY_MEMORY_MIGRATION][page + k], temp);
atomic_or(&d[DIRTY_MEMORY_VGA][page + k], temp);
- if (tcg_enabled()) {
+ if (tcg_any_enabled()) {
atomic_or(&d[DIRTY_MEMORY_CODE][page + k], temp);
}
}
}
xen_modified_memory(start, pages << TARGET_PAGE_BITS);
} else {
- uint8_t clients = tcg_enabled() ? DIRTY_CLIENTS_ALL : DIRTY_CLIENTS_NOCODE;
+ uint8_t clients = tcg_any_enabled() ? DIRTY_CLIENTS_ALL
+ : DIRTY_CLIENTS_NOCODE;
/*
* bitmap-traveling is faster than memory-traveling (for addr...)
* especially when most of the memory is not dirty.
diff --git a/memory.c b/memory.c
index 0d8b2d9..59c65f1 100644
--- a/memory.c
+++ b/memory.c
@@ -1198,7 +1198,7 @@ void memory_region_init_ram(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(size, mr, errp);
- mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+ mr->dirty_log_mask = tcg_any_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
void memory_region_init_resizeable_ram(MemoryRegion *mr,
@@ -1216,7 +1216,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
- mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+ mr->dirty_log_mask = tcg_any_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
#ifdef __linux__
@@ -1233,7 +1233,7 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc_from_file(size, mr, share, path, errp);
- mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+ mr->dirty_log_mask = tcg_any_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
}
#endif
@@ -1247,7 +1247,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram_from_ptr;
- mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
+ mr->dirty_log_mask = tcg_any_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */
assert(ptr != NULL);
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (8 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 09/15] core: Convert tcg_enabled() uses to any/all variants Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 7:24 ` Paolo Bonzini
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 11/15] cputlb: move CPU_LOOP() for tlb_reset() to exec.c Peter Crosthwaite
` (5 subsequent siblings)
15 siblings, 1 reply; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
This function has no architecture specific dependencies and should be
callable from core code. Move it to qom/cpu.h.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
include/qom/cpu.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 39712ab..7e5f3b0 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -696,6 +696,27 @@ void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
void cpu_exec_exit(CPUState *cpu);
+/**
+ * cpu_can_do_io:
+ * @cpu: The CPU for which to check IO.
+ *
+ * Deterministic execution requires that IO only be performed on the last
+ * instruction of a TB so that interrupts take effect immediately.
+ *
+ * Returns: %true if memory-mapped IO is safe, %false otherwise.
+ */
+static inline bool cpu_can_do_io(CPUState *cpu)
+{
+ if (!use_icount) {
+ return true;
+ }
+ /* If not executing code then assume we are ok. */
+ if (cpu->current_tb == NULL) {
+ return true;
+ }
+ return cpu->can_do_io != 0;
+}
+
#ifdef CONFIG_SOFTMMU
extern const struct VMStateDescription vmstate_cpu_common;
#else
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 11/15] cputlb: move CPU_LOOP() for tlb_reset() to exec.c
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (9 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 12/15] cputlb: Change tlb_set_dirty() arg to cpu Peter Crosthwaite
` (4 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
To prepare for multi-arch, cputlb.c should only have awareness of one
single architecture. This means it should not have access to the full
CPU lists which may be heterogeneous. Instead, push the CPU_LOOP() up
to the one and only caller in exec.c.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Easier reading with git diff -w
Changed since RFCv2:
split off to new patch (previously part of core virtualisation patch)
cputlb.c | 27 ++++++++++++---------------
exec.c | 5 ++++-
include/exec/cputlb.h | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/cputlb.c b/cputlb.c
index 4bc6c24..5ccd545 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -262,27 +262,24 @@ static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
return ram_addr;
}
-void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length)
+void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length)
{
- CPUState *cpu;
CPUArchState *env;
- CPU_FOREACH(cpu) {
- int mmu_idx;
+ int mmu_idx;
- env = cpu->env_ptr;
- for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
- unsigned int i;
+ env = cpu->env_ptr;
+ for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
+ unsigned int i;
- for (i = 0; i < CPU_TLB_SIZE; i++) {
- tlb_reset_dirty_range(&env->tlb_table[mmu_idx][i],
- start1, length);
- }
+ for (i = 0; i < CPU_TLB_SIZE; i++) {
+ tlb_reset_dirty_range(&env->tlb_table[mmu_idx][i],
+ start1, length);
+ }
- for (i = 0; i < CPU_VTLB_SIZE; i++) {
- tlb_reset_dirty_range(&env->tlb_v_table[mmu_idx][i],
- start1, length);
- }
+ for (i = 0; i < CPU_VTLB_SIZE; i++) {
+ tlb_reset_dirty_range(&env->tlb_v_table[mmu_idx][i],
+ start1, length);
}
}
}
diff --git a/exec.c b/exec.c
index c120730..e3568c3 100644
--- a/exec.c
+++ b/exec.c
@@ -894,6 +894,7 @@ found:
static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length)
{
+ CPUState *cpu;
ram_addr_t start1;
RAMBlock *block;
ram_addr_t end;
@@ -905,7 +906,9 @@ static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length)
block = qemu_get_ram_block(start);
assert(block == qemu_get_ram_block(end - 1));
start1 = (uintptr_t)ramblock_ptr(block, start - block->offset);
- cpu_tlb_reset_dirty_all(start1, length);
+ CPU_FOREACH(cpu) {
+ tlb_reset_dirty(cpu, start1, length);
+ }
rcu_read_unlock();
}
diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
index 360815e..c3aaa30 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/cputlb.h
@@ -25,7 +25,7 @@ void tlb_protect_code(ram_addr_t ram_addr);
void tlb_unprotect_code(ram_addr_t ram_addr);
void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,
uintptr_t length);
-void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length);
+void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
void tlb_set_dirty(CPUArchState *env, target_ulong vaddr);
extern int tlb_flush_count;
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 12/15] cputlb: Change tlb_set_dirty() arg to cpu
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (10 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 11/15] cputlb: move CPU_LOOP() for tlb_reset() to exec.c Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 13/15] include/exec: Move cputlb exec.c defs out Peter Crosthwaite
` (3 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Change tlb_set_dirty() to accept a CPU instead of an env pointer. This
allows for removal of another CPUArchState usage from prototypes that
need to be QOMified.
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
cputlb.c | 3 ++-
exec.c | 3 +--
include/exec/cputlb.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cputlb.c b/cputlb.c
index 5ccd545..6264e49 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -293,8 +293,9 @@ static inline void tlb_set_dirty1(CPUTLBEntry *tlb_entry, target_ulong vaddr)
/* update the TLB corresponding to virtual page vaddr
so that it is no longer dirty */
-void tlb_set_dirty(CPUArchState *env, target_ulong vaddr)
+void tlb_set_dirty(CPUState *cpu, target_ulong vaddr)
{
+ CPUArchState *env = cpu->env_ptr;
int i;
int mmu_idx;
diff --git a/exec.c b/exec.c
index e3568c3..567854e 100644
--- a/exec.c
+++ b/exec.c
@@ -1903,8 +1903,7 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
/* we remove the notdirty callback only if the code has been
flushed */
if (!cpu_physical_memory_is_clean(ram_addr)) {
- CPUArchState *env = current_cpu->env_ptr;
- tlb_set_dirty(env, current_cpu->mem_io_vaddr);
+ tlb_set_dirty(current_cpu, current_cpu->mem_io_vaddr);
}
}
diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
index c3aaa30..7ad5c9a 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/cputlb.h
@@ -26,7 +26,7 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,
uintptr_t length);
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
-void tlb_set_dirty(CPUArchState *env, target_ulong vaddr);
+void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
extern int tlb_flush_count;
/* exec.c */
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 13/15] include/exec: Move cputlb exec.c defs out
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (11 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 12/15] cputlb: Change tlb_set_dirty() arg to cpu Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone Peter Crosthwaite
` (2 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
Move the architecture agnostic function prototypes for exec.c out of
cputlb.h to exec-all.h. This allows hiding of the arch specific
cputlb.h from exec.c which should be getting close to having no
architecture specifics. Prepares support for multi-arch, which will have
a minimal cpu.h that services exec.c but not cputlb.h.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
Possible follow up (Paolo):
Since you are at it, tlb_protect_code/tlb_unprotect_code can also be
moved to this new header (and to translate-common.c).
exec.c | 1 -
include/exec/cputlb.h | 16 ----------------
include/exec/exec-all.h | 18 ++++++++++++++++++
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/exec.c b/exec.c
index 567854e..53e1d84 100644
--- a/exec.c
+++ b/exec.c
@@ -49,7 +49,6 @@
#include "exec/cpu-all.h"
#include "qemu/rcu_queue.h"
#include "qemu/main-loop.h"
-#include "exec/cputlb.h"
#include "translate-all.h"
#include "exec/memory-internal.h"
diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
index 7ad5c9a..d454c00 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/cputlb.h
@@ -25,23 +25,7 @@ void tlb_protect_code(ram_addr_t ram_addr);
void tlb_unprotect_code(ram_addr_t ram_addr);
void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,
uintptr_t length);
-void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
-void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
extern int tlb_flush_count;
-/* exec.c */
-void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr);
-
-MemoryRegionSection *
-address_space_translate_for_iotlb(CPUState *cpu, hwaddr addr, hwaddr *xlat,
- hwaddr *plen);
-hwaddr memory_region_section_get_iotlb(CPUState *cpu,
- MemoryRegionSection *section,
- target_ulong vaddr,
- hwaddr paddr, hwaddr xlat,
- int prot,
- target_ulong *address);
-bool memory_region_is_unassigned(MemoryRegion *mr);
-
#endif
#endif
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 83b9251..3dd9f31 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -381,6 +381,24 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong
#else
/* cputlb.c */
tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr);
+
+void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
+void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
+
+/* exec.c */
+void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr);
+
+MemoryRegionSection *
+address_space_translate_for_iotlb(CPUState *cpu, hwaddr addr, hwaddr *xlat,
+ hwaddr *plen);
+hwaddr memory_region_section_get_iotlb(CPUState *cpu,
+ MemoryRegionSection *section,
+ target_ulong vaddr,
+ hwaddr paddr, hwaddr xlat,
+ int prot,
+ target_ulong *address);
+bool memory_region_is_unassigned(MemoryRegion *mr);
+
#endif
/* vl.c */
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (12 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 13/15] include/exec: Move cputlb exec.c defs out Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 7:36 ` Paolo Bonzini
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 15/15] monitor: uninclude cpu_ldst Peter Crosthwaite
2015-09-11 7:42 ` [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Paolo Bonzini
15 siblings, 1 reply; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
In system mode emulation (at least) this definition has no architecture
specific dependencies. Move it to common code such that common code can
use it (primarily for defining function prototypes).
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
So this is the same as in RFCv2 and the comment there was that it will not
work for linux-user mode WRT to qom/cpu.h fn prototypes needed this def.
But the solution there is instead to conditionalise the def of those hooks on
NEED_CPU_H. Then this patch is just needed for some misc. system-mode-only
core code usages.
include/exec/cpu-common.h | 4 ++++
include/exec/exec-all.h | 2 --
include/qom/cpu.h | 1 +
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 9fb1d54..47d416d 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -53,6 +53,10 @@ typedef uintptr_t ram_addr_t;
# define RAM_ADDR_FMT "%" PRIxPTR
#endif
+#ifndef CONFIG_USER_ONLY
+typedef ram_addr_t tb_page_addr_t;
+#endif
+
extern ram_addr_t ram_size;
ram_addr_t get_current_ram_size(void);
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 3dd9f31..63d0baf 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -30,8 +30,6 @@
type. */
#if defined(CONFIG_USER_ONLY)
typedef abi_ulong tb_page_addr_t;
-#else
-typedef ram_addr_t tb_page_addr_t;
#endif
/* is_jmp field values */
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 7e5f3b0..bcd4a3b 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -24,6 +24,7 @@
#include <setjmp.h>
#include "hw/qdev-core.h"
#include "disas/bfd.h"
+#include "exec/cpu-common.h"
#include "exec/hwaddr.h"
#include "exec/memattrs.h"
#include "qemu/queue.h"
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [Qemu-devel] [PATCH v1 15/15] monitor: uninclude cpu_ldst
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (13 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone Peter Crosthwaite
@ 2015-09-11 5:39 ` Peter Crosthwaite
2015-09-11 7:42 ` [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Paolo Bonzini
15 siblings, 0 replies; 20+ messages in thread
From: Peter Crosthwaite @ 2015-09-11 5:39 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, pbonzini, rth
This header is non-needed anymore and wont work in multi-arch where
this service is not provided to core code.
Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
monitor.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/monitor.c b/monitor.c
index fc32f12..0de1643 100644
--- a/monitor.c
+++ b/monitor.c
@@ -67,7 +67,6 @@
#include "trace/simple.h"
#endif
#include "exec/memory.h"
-#include "exec/cpu_ldst.h"
#include "qmp-commands.h"
#include "hmp.h"
#include "qemu/thread.h"
--
1.9.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h Peter Crosthwaite
@ 2015-09-11 7:24 ` Paolo Bonzini
0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2015-09-11 7:24 UTC (permalink / raw)
To: Peter Crosthwaite, qemu-devel; +Cc: peter.maydell, rth
On 11/09/2015 07:39, Peter Crosthwaite wrote:
> This function has no architecture specific dependencies and should be
> callable from core code.
It also does not exist anymore. :-P
Paolo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone Peter Crosthwaite
@ 2015-09-11 7:36 ` Paolo Bonzini
0 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2015-09-11 7:36 UTC (permalink / raw)
To: Peter Crosthwaite, qemu-devel; +Cc: peter.maydell, rth
On 11/09/2015 07:39, Peter Crosthwaite wrote:
> So this is the same as in RFCv2 and the comment there was that it will not
> work for linux-user mode WRT to qom/cpu.h fn prototypes needed this def.
> But the solution there is instead to conditionalise the def of those hooks on
> NEED_CPU_H. Then this patch is just needed for some misc. system-mode-only
> core code usages.
Sounds good, please squash that in this patch.
Paolo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
` (14 preceding siblings ...)
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 15/15] monitor: uninclude cpu_ldst Peter Crosthwaite
@ 2015-09-11 7:42 ` Paolo Bonzini
15 siblings, 0 replies; 20+ messages in thread
From: Paolo Bonzini @ 2015-09-11 7:42 UTC (permalink / raw)
To: Peter Crosthwaite, qemu-devel; +Cc: peter.maydell, rth
On 11/09/2015 07:39, Peter Crosthwaite wrote:
> This is the first set of patches needed to enable Multi-arch system
> emulation. For full context refer to RFCv3:
>
> [PATCH v3 00/35] Multi Architecture System Emulation
> https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03929.html
>
> This is the first patch-pack intended for merge.
>
> Original cover, as well as overall series state below for further
> information.
I think we can already merge patches 1, 3, 4, 5, 6, 11, 12, 13, 15
(plus, patch 10 is gone). The others do not make much sense without
multiarch support.
I suppose the next part of the surgery could be
target-*: Don't redefine cpu_exec()
target-*: cpu.h: Undefine core code symbols
arm: cpu: static inline cpu_arm_init()
target-arm: Split cp helper API to new C file
hw: arm: Explicitly include cpu.h for consumers
hw: mb: Explicitly include cpu.h for consumers
Paolo
>
> Regards,
> Peter
>
> Original Multi-arch arch patch series cover:
>
> ***
>
> This is target-multi, a system-mode build that can support multiple
> cpu-types.
>
> Two architectures are initially converted. Microblaze and ARM. Step
> by step conversion in done for each. A microblaze is added to
> Xilinx Zynq platform as a test case. This will be elaborted more in
> future spins. This use case is valid, as Microblazes can be added (any
> number of them!) in Zynq FPGA programmable logic configuration.
>
> The general approach (radically different to approach in V1 RFC) is to build
> and prelink an object (arch-obj.o) per-arch containing:
>
> 1: target-foo/*
> 2: All uses of env internals and CPU_GET_ENV
> * cputlb, translate-all, cpu-exec
> * TCG backend
>
> This means cputlb and friends are compiled multiple times fo each arch. The
> symbols for each of these pre-links are then localised to avoid link time name
> collisions. This is based on Paolo's suggestion to templatify cputlb and
> friends. Just the net of what to multi-compile is widened to include the TCG
> stuff as well now.
>
> Despite being some "major surgery" this approach actually solves many of big
> the problems raised in V1. Big problems sovled:
>
> 1: With the multi-compile TCG backends there are now multiple tcg_ctx's for
> each architecture. This solves the issue PMM raised WRT false positives on TB
> hashing as archs no longer share translation context.
>
> 2: There is no longer a need to reorder the CPU_COMMON within the ENV or the ENV
> within the CPU. This was flagged as a performance issue by multiple people in
> V1.
> All users of the env internals as well as ENV_GET_CPU are now in multi-compile
> code and so multi-arch does not need to define a generic ENV nor does in need to
> def the problematic ENV_GET_CPU.
>
> 3: With the prelink symbol localisation, link time namespace collision of
> helpers from multiple arches is no longer an issue. No need to bloat all the
> function names with arch specific prefixes.
>
> 4: The architecture specifics used/defined by cpu-defs can now vary from arch to
> arch (incl. target_ulong) greatly reducing coversion effort needed. The list
> of restrictions for multi-arch capability is much reduced since V1. No
> target_long issues anymore.
>
> include/exec/*.h and some of the common code needs some refactoring to setup
> this single vs multi compile split. Mostly code movements.
>
> Some functions (like tcg_enabled) need to be listified for each of the
> now-multiple TCG engines.
>
> The interface between the multi compile and single compiled files needs to be
> virtualised using QOM cpu functions. But this is now a very low footprint
> change as most of the virtualised hooks are now in mutli-compiled code (they
> only exist as text once). There are more new hooks than before, but the per
> target change pattern is reduced.
>
> For the implementation of the series, the trickiest part is (still) cpu.h
> inclusion management. There are now more than one cpu.h's and different
> parts of the tree need a different include scheme. target-multi defines
> it's own cpu.h which is bare minimum defs as needed by core code only.
> target-foo/cpu.h are mostly the same but refactored to avoid collisions
> with other cpu.h's. Inclusion scheme goes something like
> this (for the multi-arch build):
>
> *: Core code includes only target-multi/cpu.h
> *: target-foo/ implementation code includes target-foo/cpu.h locally
> *: System level code (e.g. mach models) can use multiple target-foo/cpu.h's
>
> The hardest unasnwered Q is (still) what to do about bootloading. Currently
> each arch has it's own architecture specific bootloading which may assume a
> single architecture. I have applied some hacks to at least get this
> RFC testable using a -kernel -firmware split but going forward being
> able to associate an elf/image with a cpu explictitly needs to be
> solved.
>
> No support for KVM, im not sure if a mix of TCG and KVM is supported even for
> a single arch? (which would be prerequisite to MA KVM).
>
> ***
>
> Current review state of full multi-arch work in progress branch:
>
> cpu-exec: Migrate some generic fns to cpu-exec-common
> translate: Listify tcg_exec_init() R:rth
> translate-all: Move tcg_handle_interrupt() to -common R:rth
> tcg: split tcg_op_defs to -common
> tcg: Move tcg_tb_ptr to -common
> translate: move real_host_page setting to -common
> cpus: Listify cpu_list() function
> translate-common: Listify tcg_enabled()
> core: Convert tcg_enabled() uses to any/all variants
> exec-all: Move cpu_can_do_io() to qom/cpu.h R:rth
> cputlb: move CPU_LOOP() for tlb_reset() to exec.c
> cputlb: Change tlb_set_dirty() arg to cpu
> include/exec: Move cputlb exec.c defs out R:rth
> cpu-common: Define tb_page_addr_t for everyone
> monitor: uninclude cpu_ldst
> disas: s390x: QOMify target specific disas setup A:rth
> disas: moxie: QOMify target specific disas setup
> disas: m68k: QOMify target specific disas setup R:laurentv R:gerg
> disas: sparc: QOMify target specific disas setup
> disas: lm32: QOMify target specific disas setup A:mwalle
> disas: sh4: QOMify target specific disas setup A:aurel
> disas: mips: QOMify target specific disas setup A:lalrae
> disas: alpha: QOMify target specific disas setup A:rth
> linux_user: elfload: Default ELF_MACHINE to ELF_ARCH R:rth
> linux-user: elfload: Provide default for elf_check_arch R:rth
> elf_ops: Fix coding style for EM alias case statement R:rth
> elf: Update EM_MOXIE definition R:rth
> arm: Remove ELF_MACHINE from cpu.h R:rth
> mb: Remove ELF_MACHINE from cpu.h R:rth
> m68k: Remove ELF_MACHINE from cpu.h R:rth R:gerg R:laurentv
> cris: Remove ELF_MACHINE from cpu.h R:rth
> moxie: Remove ELF_MACHINE from cpu.h R:rth
> unicore: Remove ELF_MACHINE from cpu.h R:rth
> lm32: Remove ELF_MACHINE from cpu.h R:rth
> or32: Remove ELF_MACHINE from cpu.h R:rth
> tricore: Remove ELF_MACHINE from cpu.h R:rth
> xtensa: Remove ELF_MACHINE from cpu.h R:rth
> sh4: Remove ELF_MACHINE from cpu.h A:aurel R:rth
> s390: Remove ELF_MACHINE from cpu.h R:rth
> sparc: Remove ELF_MACHINE from cpu.h R:rth
> mips: Remove ELF_MACHINE from cpu.h R:aurel R:rth
> alpha: Remove ELF_MACHINE from cpu.h R:rth
> i386: Rename ELF_MACHINE to be x86 specific R:eduardo A:eduardo R:rth
> ppc: Rename ELF_MACHINE to be PPC specific R:rth
> arm: cpu: assert() on no-EL2 virt IRQ error condition. R:pmm
> arm: Remove hw_error() usages. R:pmm
> configure: factor out adding disas configure R:pmm
> target-*: Don't redefine cpu_exec()
> include/exec: Split target_long def to new header
> cpu-defs: Allow multiple inclusions
> target-*: cpu.h: Undefine core code symbols
> Makefile.target: Introduce arch-obj
> core: virtualise CPU interfaces completely
> core: Introduce multi-arch build
> arm: cpu: static inline cpu_arm_init()
> target-arm: Split cp helper API to new C file
> arm: register cpu_list() function
> arm: enable multi-arch
> hw: arm: Explicitly include cpu.h for consumers
> hw: mb: Explicitly include cpu.h for consumers
> microblaze: enable multi-arch
> arm: boot: Don't assume all CPUs are ARM
> arm: xilinx_zynq: Add a Microblaze
> HACK: mb: boot: Assume using -firmware for mb software
> HACK: mb: boot: Disable dtb load in multi-arch
>
>
> Peter Crosthwaite (15):
> cpu-exec: Migrate some generic fns to cpu-exec-common
> translate: Listify tcg_exec_init()
> translate-all: Move tcg_handle_interrupt() to -common
> tcg: split tcg_op_defs to -common
> tcg: Move tcg_tb_ptr to -common
> translate: move real_host_page setting to -common
> cpus: Listify cpu_list() function
> translate-common: Listify tcg_enabled()
> core: Convert tcg_enabled() uses to any/all variants
> exec-all: Move cpu_can_do_io() to qom/cpu.h
> cputlb: move CPU_LOOP() for tlb_reset() to exec.c
> cputlb: Change tlb_set_dirty() arg to cpu
> include/exec: Move cputlb exec.c defs out
> cpu-common: Define tb_page_addr_t for everyone
> monitor: uninclude cpu_ldst
>
> Makefile.target | 3 ++
> cpu-exec-common.c | 108 ++++++++++++++++++++++++++++++++++++++
> cpu-exec.c | 49 -----------------
> cpus.c | 10 +---
> cputlb.c | 30 +++++------
> exec.c | 13 ++---
> include/exec/cpu-common.h | 4 ++
> include/exec/cputlb.h | 16 ------
> include/exec/exec-all.h | 20 ++++++-
> include/exec/ram_addr.h | 5 +-
> include/qemu-common.h | 6 +++
> include/qom/cpu.h | 22 ++++++++
> include/sysemu/cpus.h | 7 +++
> memory.c | 8 +--
> monitor.c | 1 -
> tcg/tcg-common.c | 35 +++++++++++++
> tcg/tcg.c | 8 +--
> tcg/tci/tcg-target.c | 2 +-
> tci.c | 6 ---
> translate-all.c | 46 ++++------------
> translate-common.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++
> 21 files changed, 375 insertions(+), 154 deletions(-)
> create mode 100644 cpu-exec-common.c
> create mode 100644 tcg/tcg-common.c
> create mode 100644 translate-common.c
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common Peter Crosthwaite
@ 2015-09-11 15:10 ` Richard Henderson
0 siblings, 0 replies; 20+ messages in thread
From: Richard Henderson @ 2015-09-11 15:10 UTC (permalink / raw)
To: Peter Crosthwaite, qemu-devel; +Cc: pbonzini, peter.maydell
On 09/10/2015 10:39 PM, Peter Crosthwaite wrote:
> -CPUInterruptHandler cpu_interrupt_handler = tcg_handle_interrupt;
> -
> -/* in deterministic execution mode, instructions doing device I/Os
> - must be at the end of the TB */
> void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
Deleting the block comment for the next function?
r~
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2015-09-11 15:10 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-11 5:39 [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 01/15] cpu-exec: Migrate some generic fns to cpu-exec-common Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 02/15] translate: Listify tcg_exec_init() Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 03/15] translate-all: Move tcg_handle_interrupt() to -common Peter Crosthwaite
2015-09-11 15:10 ` Richard Henderson
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 04/15] tcg: split tcg_op_defs " Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 05/15] tcg: Move tcg_tb_ptr " Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 06/15] translate: move real_host_page setting " Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 07/15] cpus: Listify cpu_list() function Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 08/15] translate-common: Listify tcg_enabled() Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 09/15] core: Convert tcg_enabled() uses to any/all variants Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h Peter Crosthwaite
2015-09-11 7:24 ` Paolo Bonzini
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 11/15] cputlb: move CPU_LOOP() for tlb_reset() to exec.c Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 12/15] cputlb: Change tlb_set_dirty() arg to cpu Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 13/15] include/exec: Move cputlb exec.c defs out Peter Crosthwaite
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 14/15] cpu-common: Define tb_page_addr_t for everyone Peter Crosthwaite
2015-09-11 7:36 ` Paolo Bonzini
2015-09-11 5:39 ` [Qemu-devel] [PATCH v1 15/15] monitor: uninclude cpu_ldst Peter Crosthwaite
2015-09-11 7:42 ` [Qemu-devel] [PATCH v1 00/15] Multi-Arch Phase 1 Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).