* [PATCH v2 00/23] exec: Rework of various headers (user focused)
@ 2023-12-12 12:33 Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 01/23] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
` (23 more replies)
0 siblings, 24 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
Hi,
These patches are extracted from a bigger work where
"exec/{exec,cpu,translate}-all.h" are split in various
specific APIs. This helped:
- differenciate/build:
. user VS system
. target-specific VS generic
which is necessary for heterogeneous build
- reduced header pressure
- clarify APIs
This series is focused on user (vs system) cleanups.
More useful changes will come after.
Since v1:
- Addressed Richard comments
- Added R-b tags
Regards,
Phil.
Philippe Mathieu-Daudé (23):
exec: Include 'cpu.h' before validating CPUArchState placement
exec: Expose 'target_page.h' API to user emulation
target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
accel: Include missing 'exec/cpu_ldst.h' header
gdbstub: Include missing 'hw/core/cpu.h' header
semihosting/uaccess: Avoid including 'cpu.h'
semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h'
host/atomic128: Include missing 'qemu/atomic.h' header
target/i386: Include missing 'exec/exec-all.h' header
accel/tcg: Include missing 'hw/core/cpu.h' header
exec/cpu-all: Remove unused 'qemu/thread.h' header
exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
exec/cpu-all: Remove unused tswapls() definitions
exec: Declare target_words_bigendian() in 'exec/tswap.h'
exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h'
target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h'
exec/user: Do not include 'cpu.h' in 'abitypes.h'
exec: Declare abi_ptr type in its own 'abi_ptr.h' header
exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
exec/cpu-all: Extract page-protection definitions to
page-prot-common.h
exec/cpu_ldst: Avoid including 'cpu.h'
meson.build | 2 +-
accel/tcg/user-retaddr.h | 28 +++++++++
bsd-user/bsd-mem.h | 1 +
bsd-user/freebsd/target_os_elf.h | 1 +
bsd-user/freebsd/target_os_stack.h | 1 +
bsd-user/netbsd/target_os_elf.h | 1 +
bsd-user/openbsd/target_os_elf.h | 1 +
bsd-user/qemu.h | 1 +
host/include/generic/host/atomic128-cas.h | 2 +
host/include/generic/host/atomic128-ldst.h | 2 +
.../generic/host/load-extract-al16-al8.h | 3 +
include/exec/abi_ptr.h | 33 +++++++++++
include/exec/cpu-all.h | 59 ++-----------------
include/exec/cpu_ldst.h | 52 ++++------------
include/exec/exec-all.h | 1 +
include/exec/page-prot-common.h | 38 ++++++++++++
include/exec/ram_addr.h | 1 +
include/exec/translator.h | 5 +-
include/exec/tswap.h | 12 +++-
include/exec/user/abitypes.h | 8 ++-
include/exec/user/guest-base.h | 6 ++
include/exec/user/tswap-target.h | 22 +++++++
include/hw/core/cpu.h | 11 ----
include/semihosting/uaccess.h | 3 +-
target/alpha/cpu-param.h | 3 +
target/alpha/cpu.h | 3 -
target/arm/cpu-param.h | 8 ++-
target/arm/cpu.h | 4 +-
target/avr/cpu-param.h | 2 +
target/avr/cpu.h | 2 -
target/hppa/cpu-param.h | 8 +++
target/hppa/cpu.h | 6 --
target/i386/cpu-param.h | 3 +
target/i386/cpu.h | 3 -
target/loongarch/cpu-param.h | 2 +
target/loongarch/cpu.h | 2 -
target/microblaze/cpu-param.h | 3 +
target/microblaze/cpu.h | 3 -
target/mips/cpu-param.h | 2 +
target/mips/cpu.h | 2 -
target/openrisc/cpu-param.h | 2 +
target/openrisc/cpu.h | 2 -
target/ppc/cpu-param.h | 2 +
target/ppc/cpu.h | 2 -
target/ppc/internal.h | 1 +
target/ppc/mmu-radix64.h | 2 +
target/riscv/cpu-param.h | 2 +
target/riscv/cpu.h | 2 -
target/s390x/cpu-param.h | 6 ++
target/s390x/cpu.h | 3 -
target/sparc/cpu-param.h | 23 ++++++++
target/sparc/cpu.h | 23 --------
target/xtensa/cpu-param.h | 3 +
target/xtensa/cpu.h | 3 -
accel/tcg/cpu-exec.c | 3 +
accel/tcg/cputlb.c | 2 +
accel/tcg/tb-maint.c | 1 +
accel/tcg/tcg-accel-ops.c | 2 +
accel/tcg/translator.c | 1 +
accel/tcg/user-exec.c | 2 +
bsd-user/main.c | 1 +
bsd-user/mmap.c | 1 +
bsd-user/signal.c | 2 +
bsd-user/strace.c | 1 +
cpu-target.c | 2 +
disas/disas.c | 1 +
gdbstub/gdbstub.c | 1 +
hw/audio/virtio-snd.c | 2 +-
hw/core/cpu-sysemu.c | 2 +-
hw/core/generic-loader.c | 2 +-
hw/display/vga.c | 2 +-
hw/ppc/ppc440_bamboo.c | 1 +
hw/ppc/sam460ex.c | 1 +
hw/ppc/virtex_ml507.c | 1 +
hw/virtio/virtio.c | 1 +
linux-user/arm/cpu_loop.c | 1 +
linux-user/elfload.c | 3 +
linux-user/i386/signal.c | 1 +
linux-user/main.c | 1 +
linux-user/mmap.c | 1 +
linux-user/nios2/cpu_loop.c | 1 +
linux-user/ppc/signal.c | 1 +
linux-user/signal.c | 1 +
linux-user/syscall.c | 1 +
page-target.c | 43 ++++++++++++++
semihosting/guestfd.c | 5 +-
system/physmem.c | 36 +----------
target/alpha/helper.c | 1 +
target/arm/ptw.c | 1 +
target/arm/tcg/m_helper.c | 1 +
target/arm/tcg/mte_helper.c | 1 +
target/arm/tcg/sve_helper.c | 1 +
target/avr/helper.c | 1 +
target/cris/mmu.c | 1 +
target/hexagon/translate.c | 1 +
target/hppa/mem_helper.c | 1 +
target/hppa/translate.c | 1 +
target/i386/tcg/fpu_helper.c | 1 +
target/i386/tcg/sysemu/excp_helper.c | 1 +
target/loongarch/tlb_helper.c | 1 +
target/m68k/helper.c | 1 +
target/microblaze/cpu.c | 1 +
target/microblaze/helper.c | 1 +
target/microblaze/mmu.c | 1 +
target/microblaze/translate.c | 1 +
target/mips/sysemu/physaddr.c | 1 +
target/mips/tcg/sysemu/tlb_helper.c | 1 +
target/nios2/helper.c | 1 +
target/nios2/mmu.c | 1 +
target/nios2/translate.c | 1 +
target/openrisc/mmu.c | 1 +
target/ppc/excp_helper.c | 2 +-
target/ppc/mmu-hash32.c | 1 +
target/ppc/mmu-hash64.c | 1 +
target/ppc/mmu-radix64.c | 1 +
target/ppc/mmu_common.c | 1 +
target/ppc/mmu_helper.c | 1 +
target/riscv/cpu_helper.c | 1 +
target/riscv/pmp.c | 1 +
target/riscv/vector_helper.c | 1 +
target/rx/cpu.c | 1 +
target/s390x/mmu_helper.c | 1 +
target/s390x/tcg/mem_helper.c | 1 +
target/sh4/helper.c | 1 +
target/sparc/ldst_helper.c | 1 +
target/sparc/mmu_helper.c | 1 +
target/tricore/helper.c | 1 +
target/xtensa/mmu_helper.c | 1 +
target/xtensa/op_helper.c | 1 +
129 files changed, 380 insertions(+), 216 deletions(-)
create mode 100644 accel/tcg/user-retaddr.h
create mode 100644 include/exec/abi_ptr.h
create mode 100644 include/exec/page-prot-common.h
create mode 100644 include/exec/user/tswap-target.h
create mode 100644 page-target.c
--
2.41.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 01/23] exec: Include 'cpu.h' before validating CPUArchState placement
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 02/23] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
` (22 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
CPUArchState 'env' field is defined within the ArchCPU structure,
so we need to include each target "cpu.h" header which defines it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
---
include/exec/cpu-all.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 5340907cfd..9a7b5737d3 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -411,10 +411,6 @@ static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr)
/* accel/tcg/cpu-exec.c */
int cpu_exec(CPUState *cpu);
-/* Validate correct placement of CPUArchState. */
-QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
-QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
-
/**
* env_archcpu(env)
* @env: The architecture environment
@@ -437,4 +433,9 @@ static inline CPUState *env_cpu(CPUArchState *env)
return (void *)env - sizeof(CPUState);
}
+/* Validate correct placement of CPUArchState. */
+#include "cpu.h"
+QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
+QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
+
#endif /* CPU_ALL_H */
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 02/23] exec: Expose 'target_page.h' API to user emulation
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 01/23] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 03/23] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
` (21 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Marc-André Lureau,
Daniel P. Berrangé, Peter Xu, David Hildenbrand
User-only objects might benefit from the "exec/target_page.h"
API, which allows to build some objects once for all targets.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
meson.build | 2 +-
page-target.c | 43 +++++++++++++++++++++++++++++++++++++++++++
system/physmem.c | 35 -----------------------------------
3 files changed, 44 insertions(+), 36 deletions(-)
create mode 100644 page-target.c
diff --git a/meson.build b/meson.build
index d2c4c2adb3..5fdc4ef8db 100644
--- a/meson.build
+++ b/meson.build
@@ -3488,7 +3488,7 @@ if get_option('b_lto')
pagevary = declare_dependency(link_with: pagevary)
endif
common_ss.add(pagevary)
-specific_ss.add(files('page-vary-target.c'))
+specific_ss.add(files('page-target.c', 'page-vary-target.c'))
subdir('backends')
subdir('disas')
diff --git a/page-target.c b/page-target.c
new file mode 100644
index 0000000000..d286e2d58b
--- /dev/null
+++ b/page-target.c
@@ -0,0 +1,43 @@
+/*
+ * QEMU page values getters (target independent)
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "exec/target_page.h"
+#include "exec/cpu-defs.h"
+#include "exec/cpu-all.h"
+
+size_t qemu_target_page_size(void)
+{
+ return TARGET_PAGE_SIZE;
+}
+
+int qemu_target_page_mask(void)
+{
+ return TARGET_PAGE_MASK;
+}
+
+int qemu_target_page_bits(void)
+{
+ return TARGET_PAGE_BITS;
+}
+
+int qemu_target_page_bits_min(void)
+{
+ return TARGET_PAGE_BITS_MIN;
+}
+
+/* Convert target pages to MiB (2**20). */
+size_t qemu_target_pages_to_MiB(size_t pages)
+{
+ int page_bits = TARGET_PAGE_BITS;
+
+ /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
+ g_assert(page_bits < 20);
+
+ return pages >> (20 - page_bits);
+}
diff --git a/system/physmem.c b/system/physmem.c
index a63853a7bc..4bdb3d0592 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3422,41 +3422,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
return 0;
}
-/*
- * Allows code that needs to deal with migration bitmaps etc to still be built
- * target independent.
- */
-size_t qemu_target_page_size(void)
-{
- return TARGET_PAGE_SIZE;
-}
-
-int qemu_target_page_mask(void)
-{
- return TARGET_PAGE_MASK;
-}
-
-int qemu_target_page_bits(void)
-{
- return TARGET_PAGE_BITS;
-}
-
-int qemu_target_page_bits_min(void)
-{
- return TARGET_PAGE_BITS_MIN;
-}
-
-/* Convert target pages to MiB (2**20). */
-size_t qemu_target_pages_to_MiB(size_t pages)
-{
- int page_bits = TARGET_PAGE_BITS;
-
- /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
- g_assert(page_bits < 20);
-
- return pages >> (20 - page_bits);
-}
-
bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegion*mr;
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 03/23] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 01/23] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 02/23] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 04/23] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
` (20 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Peter Maydell,
Michael Rolnik, Song Gao, Edgar E. Iglesias, Aurelien Jarno,
Jiaxun Yang, Aleksandar Rikalo, Stafford Horne, Nicholas Piggin,
Daniel Henrique Barboza, Cédric Le Goater, Palmer Dabbelt,
Alistair Francis, Bin Meng, Weiwei Li, Liu Zhiwei,
David Hildenbrand, Ilya Leoshkevich, Mark Cave-Ayland,
Artyom Tarasenko, Max Filippov
accel/tcg/ files requires the following definitions:
- TARGET_LONG_BITS
- TARGET_PAGE_BITS
- TARGET_PHYS_ADDR_SPACE_BITS
- TCG_GUEST_DEFAULT_MO
The first 3 are defined in "cpu-param.h". The last one
in "cpu.h", with a bunch of definitions irrelevant for
TCG. By moving the TCG_GUEST_DEFAULT_MO definition to
"cpu-param.h", we can simplify various accel/tcg includes.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/alpha/cpu-param.h | 3 +++
target/alpha/cpu.h | 3 ---
target/arm/cpu-param.h | 8 +++++---
target/arm/cpu.h | 3 ---
target/avr/cpu-param.h | 2 ++
target/avr/cpu.h | 2 --
target/hppa/cpu-param.h | 8 ++++++++
target/hppa/cpu.h | 6 ------
target/i386/cpu-param.h | 3 +++
target/i386/cpu.h | 3 ---
target/loongarch/cpu-param.h | 2 ++
target/loongarch/cpu.h | 2 --
target/microblaze/cpu-param.h | 3 +++
target/microblaze/cpu.h | 3 ---
target/mips/cpu-param.h | 2 ++
target/mips/cpu.h | 2 --
target/openrisc/cpu-param.h | 2 ++
target/openrisc/cpu.h | 2 --
target/ppc/cpu-param.h | 2 ++
target/ppc/cpu.h | 2 --
target/riscv/cpu-param.h | 2 ++
target/riscv/cpu.h | 2 --
target/s390x/cpu-param.h | 6 ++++++
target/s390x/cpu.h | 3 ---
target/sparc/cpu-param.h | 23 +++++++++++++++++++++++
target/sparc/cpu.h | 23 -----------------------
target/xtensa/cpu-param.h | 3 +++
target/xtensa/cpu.h | 3 ---
28 files changed, 66 insertions(+), 62 deletions(-)
diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h
index 68c46f7998..419e454702 100644
--- a/target/alpha/cpu-param.h
+++ b/target/alpha/cpu-param.h
@@ -15,4 +15,7 @@
#define TARGET_PHYS_ADDR_SPACE_BITS 44
#define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS)
+/* Alpha processors have a weak memory model */
+#define TCG_GUEST_DEFAULT_MO (0)
+
#endif
diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index d672e911dd..5d9aa09ed9 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -24,9 +24,6 @@
#include "exec/cpu-defs.h"
#include "qemu/cpu-float.h"
-/* Alpha processors have a weak memory model */
-#define TCG_GUEST_DEFAULT_MO (0)
-
#define ICACHE_LINE_SIZE 32
#define DCACHE_LINE_SIZE 32
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
index f9b462a98f..59a5f9e480 100644
--- a/target/arm/cpu-param.h
+++ b/target/arm/cpu-param.h
@@ -23,14 +23,16 @@
# ifdef TARGET_AARCH64
# define TARGET_TAGGED_ADDRESSES
# endif
-#else
+#else /* !CONFIG_USER_ONLY */
/*
* ARMv7 and later CPUs have 4K pages minimum, but ARMv5 and v6
* have to support 1K tiny pages.
*/
# define TARGET_PAGE_BITS_VARY
# define TARGET_PAGE_BITS_MIN 10
-
-#endif
+#endif /* !CONFIG_USER_ONLY */
+
+/* ARM processors have a weak memory model */
+#define TCG_GUEST_DEFAULT_MO (0)
#endif
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index a0282e0d28..ea5c8660dc 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -27,9 +27,6 @@
#include "exec/cpu-defs.h"
#include "qapi/qapi-types-common.h"
-/* ARM processors have a weak memory model */
-#define TCG_GUEST_DEFAULT_MO (0)
-
#ifdef TARGET_AARCH64
#define KVM_HAVE_MCE_INJECTION 1
#endif
diff --git a/target/avr/cpu-param.h b/target/avr/cpu-param.h
index 9a92bc74fc..93c2f470d0 100644
--- a/target/avr/cpu-param.h
+++ b/target/avr/cpu-param.h
@@ -32,4 +32,6 @@
#define TARGET_PHYS_ADDR_SPACE_BITS 24
#define TARGET_VIRT_ADDR_SPACE_BITS 24
+#define TCG_GUEST_DEFAULT_MO 0
+
#endif
diff --git a/target/avr/cpu.h b/target/avr/cpu.h
index 7960c5c57a..02a787b4f3 100644
--- a/target/avr/cpu.h
+++ b/target/avr/cpu.h
@@ -30,8 +30,6 @@
#define CPU_RESOLVING_TYPE TYPE_AVR_CPU
-#define TCG_GUEST_DEFAULT_MO 0
-
/*
* AVR has two memory spaces, data & code.
* e.g. both have 0 address
diff --git a/target/hppa/cpu-param.h b/target/hppa/cpu-param.h
index bb3d7ef6f7..473d489f01 100644
--- a/target/hppa/cpu-param.h
+++ b/target/hppa/cpu-param.h
@@ -21,4 +21,12 @@
#define TARGET_PAGE_BITS 12
+/* PA-RISC 1.x processors have a strong memory model. */
+/*
+ * ??? While we do not yet implement PA-RISC 2.0, those processors have
+ * a weak memory model, but with TLB bits that force ordering on a per-page
+ * basis. It's probably easier to fall back to a strong memory model.
+ */
+#define TCG_GUEST_DEFAULT_MO TCG_MO_ALL
+
#endif
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 8be45c69c9..6b10ab20ba 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -25,12 +25,6 @@
#include "qemu/cpu-float.h"
#include "qemu/interval-tree.h"
-/* PA-RISC 1.x processors have a strong memory model. */
-/* ??? While we do not yet implement PA-RISC 2.0, those processors have
- a weak memory model, but with TLB bits that force ordering on a per-page
- basis. It's probably easier to fall back to a strong memory model. */
-#define TCG_GUEST_DEFAULT_MO TCG_MO_ALL
-
#define MMU_ABS_W_IDX 6
#define MMU_ABS_IDX 7
#define MMU_KERNEL_IDX 8
diff --git a/target/i386/cpu-param.h b/target/i386/cpu-param.h
index 911b4cd51b..5e15335203 100644
--- a/target/i386/cpu-param.h
+++ b/target/i386/cpu-param.h
@@ -24,4 +24,7 @@
#endif
#define TARGET_PAGE_BITS 12
+/* The x86 has a strong memory model with some store-after-load re-ordering */
+#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
+
#endif
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index cd2e295bd6..852adf35db 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -30,9 +30,6 @@
#define XEN_NR_VIRQS 24
-/* The x86 has a strong memory model with some store-after-load re-ordering */
-#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
-
#define KVM_HAVE_MCE_INJECTION 1
/* support for self modifying code even if the modified instruction is
diff --git a/target/loongarch/cpu-param.h b/target/loongarch/cpu-param.h
index cfe195db4e..db5ad1c69f 100644
--- a/target/loongarch/cpu-param.h
+++ b/target/loongarch/cpu-param.h
@@ -14,4 +14,6 @@
#define TARGET_PAGE_BITS 12
+#define TCG_GUEST_DEFAULT_MO (0)
+
#endif
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 00d1fba597..dd1ab75ce9 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -39,8 +39,6 @@
#define IOCSR_MEM_SIZE 0x428
-#define TCG_GUEST_DEFAULT_MO (0)
-
#define FCSR0_M1 0x1f /* FCSR1 mask, Enables */
#define FCSR0_M2 0x1f1f0000 /* FCSR2 mask, Cause and Flags */
#define FCSR0_M3 0x300 /* FCSR3 mask, Round Mode */
diff --git a/target/microblaze/cpu-param.h b/target/microblaze/cpu-param.h
index 9770b0eb52..e530fead1c 100644
--- a/target/microblaze/cpu-param.h
+++ b/target/microblaze/cpu-param.h
@@ -29,4 +29,7 @@
/* FIXME: MB uses variable pages down to 1K but linux only uses 4k. */
#define TARGET_PAGE_BITS 12
+/* MicroBlaze is always in-order. */
+#define TCG_GUEST_DEFAULT_MO TCG_MO_ALL
+
#endif
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index b5374365f5..943bae67d1 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -24,9 +24,6 @@
#include "exec/cpu-defs.h"
#include "qemu/cpu-float.h"
-/* MicroBlaze is always in-order. */
-#define TCG_GUEST_DEFAULT_MO TCG_MO_ALL
-
typedef struct CPUArchState CPUMBState;
#if !defined(CONFIG_USER_ONLY)
#include "mmu.h"
diff --git a/target/mips/cpu-param.h b/target/mips/cpu-param.h
index 594c91a156..6f6ac1688f 100644
--- a/target/mips/cpu-param.h
+++ b/target/mips/cpu-param.h
@@ -30,4 +30,6 @@
#define TARGET_PAGE_BITS_MIN 12
#endif
+#define TCG_GUEST_DEFAULT_MO (0)
+
#endif
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 52f13f0363..620db820f8 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -10,8 +10,6 @@
#include "hw/clock.h"
#include "mips-defs.h"
-#define TCG_GUEST_DEFAULT_MO (0)
-
typedef struct CPUMIPSTLBContext CPUMIPSTLBContext;
/* MSA Context */
diff --git a/target/openrisc/cpu-param.h b/target/openrisc/cpu-param.h
index 3f08207485..fbfc0f568b 100644
--- a/target/openrisc/cpu-param.h
+++ b/target/openrisc/cpu-param.h
@@ -13,4 +13,6 @@
#define TARGET_PHYS_ADDR_SPACE_BITS 32
#define TARGET_VIRT_ADDR_SPACE_BITS 32
+#define TCG_GUEST_DEFAULT_MO (0)
+
#endif
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index dedeb89f8e..e757e84caf 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -24,8 +24,6 @@
#include "exec/cpu-defs.h"
#include "fpu/softfloat-types.h"
-#define TCG_GUEST_DEFAULT_MO (0)
-
/**
* OpenRISCCPUClass:
* @parent_realize: The parent class' realize handler.
diff --git a/target/ppc/cpu-param.h b/target/ppc/cpu-param.h
index 0a0416e0a8..c5565beae2 100644
--- a/target/ppc/cpu-param.h
+++ b/target/ppc/cpu-param.h
@@ -33,4 +33,6 @@
#endif
#define TARGET_PAGE_BITS 12
+#define TCG_GUEST_DEFAULT_MO 0
+
#endif
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index f8101ffa29..f21d8de6ff 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -29,8 +29,6 @@
#define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
-#define TCG_GUEST_DEFAULT_MO 0
-
#define TARGET_PAGE_BITS_64K 16
#define TARGET_PAGE_BITS_16M 24
diff --git a/target/riscv/cpu-param.h b/target/riscv/cpu-param.h
index b2a9396dec..1fbd64939d 100644
--- a/target/riscv/cpu-param.h
+++ b/target/riscv/cpu-param.h
@@ -28,4 +28,6 @@
* - M mode HLV/HLVX/HSV 0b111
*/
+#define TCG_GUEST_DEFAULT_MO 0
+
#endif
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index d74b361be6..01cddf5180 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -42,8 +42,6 @@ typedef struct CPUArchState CPURISCVState;
# define TYPE_RISCV_CPU_BASE TYPE_RISCV_CPU_BASE64
#endif
-#define TCG_GUEST_DEFAULT_MO 0
-
/*
* RISC-V-specific extra insn start words:
* 1: Original instruction opcode
diff --git a/target/s390x/cpu-param.h b/target/s390x/cpu-param.h
index 84ca08626b..11d23b600d 100644
--- a/target/s390x/cpu-param.h
+++ b/target/s390x/cpu-param.h
@@ -13,4 +13,10 @@
#define TARGET_PHYS_ADDR_SPACE_BITS 64
#define TARGET_VIRT_ADDR_SPACE_BITS 64
+/*
+ * The z/Architecture has a strong memory model with some
+ * store-after-load re-ordering.
+ */
+#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
+
#endif
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index fa3aac4f97..10a63821b5 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -33,9 +33,6 @@
#define ELF_MACHINE_UNAME "S390X"
-/* The z/Architecture has a strong memory model with some store-after-load re-ordering */
-#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD)
-
#define TARGET_HAS_PRECISE_SMC
#define TARGET_INSN_START_EXTRA_WORDS 2
diff --git a/target/sparc/cpu-param.h b/target/sparc/cpu-param.h
index cb11980404..82293fb844 100644
--- a/target/sparc/cpu-param.h
+++ b/target/sparc/cpu-param.h
@@ -23,4 +23,27 @@
# define TARGET_VIRT_ADDR_SPACE_BITS 32
#endif
+/*
+ * From Oracle SPARC Architecture 2015:
+ *
+ * Compatibility notes: The PSO memory model described in SPARC V8 and
+ * SPARC V9 compatibility architecture specifications was never implemented
+ * in a SPARC V9 implementation and is not included in the Oracle SPARC
+ * Architecture specification.
+ *
+ * The RMO memory model described in the SPARC V9 specification was
+ * implemented in some non-Sun SPARC V9 implementations, but is not
+ * directly supported in Oracle SPARC Architecture 2015 implementations.
+ *
+ * Therefore always use TSO in QEMU.
+ *
+ * D.5 Specification of Partial Store Order (PSO)
+ * ... [loads] are followed by an implied MEMBAR #LoadLoad | #LoadStore.
+ *
+ * D.6 Specification of Total Store Order (TSO)
+ * ... PSO with the additional requirement that all [stores] are followed
+ * by an implied MEMBAR #StoreStore.
+ */
+#define TCG_GUEST_DEFAULT_MO (TCG_MO_LD_LD | TCG_MO_LD_ST | TCG_MO_ST_ST)
+
#endif
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index 6999a10a40..10b04d37c6 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -6,29 +6,6 @@
#include "exec/cpu-defs.h"
#include "qemu/cpu-float.h"
-/*
- * From Oracle SPARC Architecture 2015:
- *
- * Compatibility notes: The PSO memory model described in SPARC V8 and
- * SPARC V9 compatibility architecture specifications was never implemented
- * in a SPARC V9 implementation and is not included in the Oracle SPARC
- * Architecture specification.
- *
- * The RMO memory model described in the SPARC V9 specification was
- * implemented in some non-Sun SPARC V9 implementations, but is not
- * directly supported in Oracle SPARC Architecture 2015 implementations.
- *
- * Therefore always use TSO in QEMU.
- *
- * D.5 Specification of Partial Store Order (PSO)
- * ... [loads] are followed by an implied MEMBAR #LoadLoad | #LoadStore.
- *
- * D.6 Specification of Total Store Order (TSO)
- * ... PSO with the additional requirement that all [stores] are followed
- * by an implied MEMBAR #StoreStore.
- */
-#define TCG_GUEST_DEFAULT_MO (TCG_MO_LD_LD | TCG_MO_LD_ST | TCG_MO_ST_ST)
-
#if !defined(TARGET_SPARC64)
#define TARGET_DPREGS 16
#else
diff --git a/target/xtensa/cpu-param.h b/target/xtensa/cpu-param.h
index b1da0555de..0000725f2f 100644
--- a/target/xtensa/cpu-param.h
+++ b/target/xtensa/cpu-param.h
@@ -17,4 +17,7 @@
#define TARGET_VIRT_ADDR_SPACE_BITS 32
#endif
+/* Xtensa processors have a weak memory model */
+#define TCG_GUEST_DEFAULT_MO (0)
+
#endif
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 8a423706d8..ca32657041 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -34,9 +34,6 @@
#include "hw/clock.h"
#include "xtensa-isa.h"
-/* Xtensa processors have a weak memory model */
-#define TCG_GUEST_DEFAULT_MO (0)
-
enum {
/* Additional instructions */
XTENSA_OPTION_CODE_DENSITY,
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 04/23] accel: Include missing 'exec/cpu_ldst.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 03/23] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 05/23] gdbstub: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
` (19 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Edgar E. Iglesias,
Chris Wulff, Marek Vasut
Theses files call cpu_ldl_code() which is declared
in "exec/cpu_ldst.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/translator.c | 1 +
target/hexagon/translate.c | 1 +
target/microblaze/cpu.c | 1 +
target/microblaze/translate.c | 1 +
target/nios2/translate.c | 1 +
5 files changed, 5 insertions(+)
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 38c34009a5..5b019a0852 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -12,6 +12,7 @@
#include "qemu/error-report.h"
#include "exec/exec-all.h"
#include "exec/translator.h"
+#include "exec/cpu_ldst.h"
#include "exec/plugin-gen.h"
#include "tcg/tcg-op-common.h"
#include "internal-target.h"
diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c
index 666c061180..744dc4fc3f 100644
--- a/target/hexagon/translate.c
+++ b/target/hexagon/translate.c
@@ -23,6 +23,7 @@
#include "exec/helper-gen.h"
#include "exec/helper-proto.h"
#include "exec/translation-block.h"
+#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "internal.h"
#include "attribs.h"
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
index bbb3335cad..91d7cd9061 100644
--- a/target/microblaze/cpu.c
+++ b/target/microblaze/cpu.c
@@ -28,6 +28,7 @@
#include "qemu/module.h"
#include "hw/qdev-properties.h"
#include "exec/exec-all.h"
+#include "exec/cpu_ldst.h"
#include "exec/gdbstub.h"
#include "fpu/softfloat-helpers.h"
#include "tcg/tcg.h"
diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
index 49bfb4a0ea..1c9a364c2b 100644
--- a/target/microblaze/translate.c
+++ b/target/microblaze/translate.c
@@ -22,6 +22,7 @@
#include "cpu.h"
#include "disas/disas.h"
#include "exec/exec-all.h"
+#include "exec/cpu_ldst.h"
#include "tcg/tcg-op.h"
#include "exec/helper-proto.h"
#include "exec/helper-gen.h"
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index e806623594..a74eb6909f 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -25,6 +25,7 @@
#include "cpu.h"
#include "tcg/tcg-op.h"
#include "exec/exec-all.h"
+#include "exec/cpu_ldst.h"
#include "disas/disas.h"
#include "exec/helper-proto.h"
#include "exec/helper-gen.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 05/23] gdbstub: Include missing 'hw/core/cpu.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 04/23] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 06/23] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
` (18 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
Functions such gdb_get_cpu_pid() dereference CPUState so
require the structure declaration from "hw/core/cpu.h":
static uint32_t gdb_get_cpu_pid(CPUState *cpu)
{
...
return cpu->cluster_index + 1;
}
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
---
gdbstub/gdbstub.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 46d752bbc2..034a4ac211 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -37,6 +37,7 @@
#include "hw/cpu/cluster.h"
#include "hw/boards.h"
#endif
+#include "hw/core/cpu.h"
#include "sysemu/hw_accel.h"
#include "sysemu/runstate.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 06/23] semihosting/uaccess: Avoid including 'cpu.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 05/23] gdbstub: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
` (17 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
"semihosting/uaccess.h" only requires declarations
from "exec/cpu-defs.h". Avoid including the huge "cpu.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/semihosting/uaccess.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h
index 3963eafc3e..6c8835fbcb 100644
--- a/include/semihosting/uaccess.h
+++ b/include/semihosting/uaccess.h
@@ -14,7 +14,7 @@
#error Cannot include semihosting/uaccess.h from user emulation
#endif
-#include "cpu.h"
+#include "exec/cpu-defs.h"
#define get_user_u64(val, addr) \
({ uint64_t val_ = 0; \
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 06/23] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 10:58 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
` (16 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
Nothing in guestfd.c requires "semihosting/uaccess.h" nor "qemu.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
semihosting/guestfd.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
index 955c2efbd0..d3241434c5 100644
--- a/semihosting/guestfd.c
+++ b/semihosting/guestfd.c
@@ -12,10 +12,7 @@
#include "gdbstub/syscalls.h"
#include "semihosting/semihost.h"
#include "semihosting/guestfd.h"
-#ifdef CONFIG_USER_ONLY
-#include "qemu.h"
-#else
-#include "semihosting/uaccess.h"
+#ifndef CONFIG_USER_ONLY
#include CONFIG_DEVICES
#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 11:46 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
` (15 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
int128_make128(), int128_getlo() and int128_urshift() are
declared in "qemu/int128.h". qatomic_read__nocheck() is
declared in "qemu/atomic.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
| 3 +++
1 file changed, 3 insertions(+)
--git a/host/include/generic/host/load-extract-al16-al8.h b/host/include/generic/host/load-extract-al16-al8.h
index d95556130f..6b47339b57 100644
--- a/host/include/generic/host/load-extract-al16-al8.h
+++ b/host/include/generic/host/load-extract-al16-al8.h
@@ -8,6 +8,9 @@
#ifndef HOST_LOAD_EXTRACT_AL16_AL8_H
#define HOST_LOAD_EXTRACT_AL16_AL8_H
+#include "qemu/atomic.h"
+#include "qemu/int128.h"
+
/**
* load_atom_extract_al16_or_al8:
* @pv: host address
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 11:56 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 10/23] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
` (14 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
qatomic_cmpxchg__nocheck(), qatomic_read__nocheck(),
qatomic_set__nocheck() are defined in "qemu/atomic.h".
Include it in order to avoid:
In file included from include/exec/helper-proto.h:10:
In file included from include/exec/helper-proto-common.h:10:
In file included from include/qemu/atomic128.h:61:
In file included from host/include/aarch64/host/atomic128-cas.h:16:
host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i);
^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
host/include/generic/host/atomic128-cas.h | 2 ++
host/include/generic/host/atomic128-ldst.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/host/include/generic/host/atomic128-cas.h b/host/include/generic/host/atomic128-cas.h
index 6b40cc2271..4824f14659 100644
--- a/host/include/generic/host/atomic128-cas.h
+++ b/host/include/generic/host/atomic128-cas.h
@@ -11,6 +11,8 @@
#ifndef HOST_ATOMIC128_CAS_H
#define HOST_ATOMIC128_CAS_H
+#include "qemu/atomic.h"
+
#if defined(CONFIG_ATOMIC128)
static inline Int128 ATTRIBUTE_ATOMIC128_OPT
atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new)
diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h
index 691e6a8531..12e4aca2da 100644
--- a/host/include/generic/host/atomic128-ldst.h
+++ b/host/include/generic/host/atomic128-ldst.h
@@ -11,6 +11,8 @@
#ifndef HOST_ATOMIC128_LDST_H
#define HOST_ATOMIC128_LDST_H
+#include "qemu/atomic.h"
+
#if defined(CONFIG_ATOMIC128)
# define HAVE_ATOMIC128_RO 1
# define HAVE_ATOMIC128_RW 1
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 10/23] target/i386: Include missing 'exec/exec-all.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
` (13 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Eduardo Habkost
The XRSTOR instruction ends calling tlb_flush(), declared
in "exec/exec-all.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/fpu_helper.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index 4430d3d380..3bb018fbae 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -21,6 +21,7 @@
#include <math.h>
#include "cpu.h"
#include "tcg-cpu.h"
+#include "exec/exec-all.h"
#include "exec/cpu_ldst.h"
#include "exec/helper-proto.h"
#include "fpu/softfloat.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 10/23] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 13:38 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header Philippe Mathieu-Daudé
` (12 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
tcg_cpu_init_cflags() accesses CPUState fields, so requires
"hw/core/cpu.h" to get its structure definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
accel/tcg/tcg-accel-ops.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index 1b57290682..58806e2d7f 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -37,6 +37,8 @@
#include "exec/tb-flush.h"
#include "exec/gdbstub.h"
+#include "hw/core/cpu.h"
+
#include "tcg-accel-ops.h"
#include "tcg-accel-ops-mttcg.h"
#include "tcg-accel-ops-rr.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 13:44 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 13/23] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
` (11 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
Nothing is required from the "qemu/thread.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/cpu-all.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 9a7b5737d3..26b44ca125 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -22,7 +22,6 @@
#include "exec/cpu-common.h"
#include "exec/memory.h"
#include "exec/tswap.h"
-#include "qemu/thread.h"
#include "hw/core/cpu.h"
#include "qemu/rcu.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 13/23] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions Philippe Mathieu-Daudé
` (10 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Peter Xu,
David Hildenbrand
"exec/cpu-all.h" doesn't need definitions from "qemu/rcu.h",
however "exec/ram_addr.h" does.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/cpu-all.h | 1 -
include/exec/ram_addr.h | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 26b44ca125..5b5379b94c 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -23,7 +23,6 @@
#include "exec/memory.h"
#include "exec/tswap.h"
#include "hw/core/cpu.h"
-#include "qemu/rcu.h"
/* some important defines:
*
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 90676093f5..aab7d6c57c 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -25,6 +25,7 @@
#include "sysemu/tcg.h"
#include "exec/ramlist.h"
#include "exec/ramblock.h"
+#include "qemu/rcu.h"
extern uint64_t total_dirty_pages;
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 13/23] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 13:44 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h' Philippe Mathieu-Daudé
` (9 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
Last use of tswapls() was removed 2 years ago in commit
aee14c77f4 ("linux-user: Rewrite do_getdents, do_getdents64").
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/cpu-all.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 5b5379b94c..b042d94892 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -38,11 +38,9 @@
#if TARGET_LONG_SIZE == 4
#define tswapl(s) tswap32(s)
-#define tswapls(s) tswap32s((uint32_t *)(s))
#define bswaptls(s) bswap32s(s)
#else
#define tswapl(s) tswap64(s)
-#define tswapls(s) tswap64s((uint64_t *)(s))
#define bswaptls(s) bswap64s(s)
#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 11:20 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' Philippe Mathieu-Daudé
` (8 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Gerd Hoffmann,
Michael S. Tsirkin, Alistair Francis, Eduardo Habkost,
Marcel Apfelbaum, Yanan Wang
We usually check target endianess before swapping values,
so target_words_bigendian() declaration makes sense in
"exec/tswap.h" with the target swapping helpers.
Remove "hw/core/cpu.h" when it was only included to get
the target_words_bigendian() declaration.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/tswap.h | 12 +++++++++++-
include/hw/core/cpu.h | 11 -----------
cpu-target.c | 1 +
disas/disas.c | 1 +
hw/audio/virtio-snd.c | 2 +-
hw/core/cpu-sysemu.c | 2 +-
hw/core/generic-loader.c | 2 +-
hw/display/vga.c | 2 +-
hw/virtio/virtio.c | 1 +
9 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index 68944a880b..77954bbc2b 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -8,9 +8,19 @@
#ifndef TSWAP_H
#define TSWAP_H
-#include "hw/core/cpu.h"
#include "qemu/bswap.h"
+/**
+ * target_words_bigendian:
+ * Returns true if the (default) endianness of the target is big endian,
+ * false otherwise. Note that in target-specific code, you can use
+ * TARGET_BIG_ENDIAN directly instead. On the other hand, common
+ * code should normally never need to know about the endianness of the
+ * target, so please do *not* use this function unless you know very well
+ * what you are doing!
+ */
+bool target_words_bigendian(void);
+
/*
* If we're in target-specific code, we can hard-code the swapping
* condition, otherwise we have to do (slower) run-time checks.
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 3208b938f7..d6b077da71 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1153,17 +1153,6 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
-/**
- * target_words_bigendian:
- * Returns true if the (default) endianness of the target is big endian,
- * false otherwise. Note that in target-specific code, you can use
- * TARGET_BIG_ENDIAN directly instead. On the other hand, common
- * code should normally never need to know about the endianness of the
- * target, so please do *not* use this function unless you know very well
- * what you are doing!
- */
-bool target_words_bigendian(void);
-
const char *target_name(void);
void page_size_init(void);
diff --git a/cpu-target.c b/cpu-target.c
index 997ca2e846..4c1e19ca81 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -33,6 +33,7 @@
#endif
#include "sysemu/cpus.h"
#include "sysemu/tcg.h"
+#include "exec/tswap.h"
#include "exec/replay-core.h"
#include "exec/cpu-common.h"
#include "exec/exec-all.h"
diff --git a/disas/disas.c b/disas/disas.c
index 0d2d06c2ec..89a1e7d767 100644
--- a/disas/disas.c
+++ b/disas/disas.c
@@ -6,6 +6,7 @@
#include "disas/disas.h"
#include "disas/capstone.h"
#include "hw/core/cpu.h"
+#include "exec/tswap.h"
#include "exec/memory.h"
/* Filled in by elfload.c. Simplistic, but will do for now. */
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
index 137fa77a01..a80f23aa71 100644
--- a/hw/audio/virtio-snd.c
+++ b/hw/audio/virtio-snd.c
@@ -20,11 +20,11 @@
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "include/qemu/lockable.h"
+#include "exec/tswap.h"
#include "sysemu/runstate.h"
#include "trace.h"
#include "qapi/error.h"
#include "hw/audio/virtio-snd.h"
-#include "hw/core/cpu.h"
#define VIRTIO_SOUND_VM_VERSION 1
#define VIRTIO_SOUND_JACK_DEFAULT 0
diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c
index d0d6a910f9..2a9a2a4eb5 100644
--- a/hw/core/cpu-sysemu.c
+++ b/hw/core/cpu-sysemu.c
@@ -20,7 +20,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "hw/core/cpu.h"
+#include "exec/tswap.h"
#include "hw/core/sysemu-cpu-ops.h"
bool cpu_paging_enabled(const CPUState *cpu)
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
index d4b5c501d8..ea8628b892 100644
--- a/hw/core/generic-loader.c
+++ b/hw/core/generic-loader.c
@@ -31,7 +31,7 @@
*/
#include "qemu/osdep.h"
-#include "hw/core/cpu.h"
+#include "exec/tswap.h"
#include "sysemu/dma.h"
#include "sysemu/reset.h"
#include "hw/boards.h"
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 37557c3442..d11a30a785 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -26,7 +26,7 @@
#include "qemu/units.h"
#include "sysemu/reset.h"
#include "qapi/error.h"
-#include "hw/core/cpu.h"
+#include "exec/tswap.h"
#include "hw/display/vga.h"
#include "hw/i386/x86.h"
#include "hw/pci/pci.h"
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 3a160f86ed..28dc1f4c15 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -20,6 +20,7 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
+#include "exec/tswap.h"
#include "qom/object_interfaces.h"
#include "hw/core/cpu.h"
#include "hw/virtio/virtio.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-13 13:45 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
` (7 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Kyle Evans,
Laurent Vivier
tswapl() and bswaptls() are target-dependent and only used
by user emulation. Move their definitions to a new header:
"exec/user/tswap-target.h".
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
bsd-user/freebsd/target_os_elf.h | 1 +
bsd-user/freebsd/target_os_stack.h | 1 +
bsd-user/netbsd/target_os_elf.h | 1 +
bsd-user/openbsd/target_os_elf.h | 1 +
include/exec/cpu-all.h | 8 --------
include/exec/user/abitypes.h | 1 +
include/exec/user/tswap-target.h | 22 ++++++++++++++++++++++
bsd-user/signal.c | 1 +
bsd-user/strace.c | 1 +
linux-user/elfload.c | 1 +
linux-user/i386/signal.c | 1 +
linux-user/ppc/signal.c | 1 +
12 files changed, 32 insertions(+), 8 deletions(-)
create mode 100644 include/exec/user/tswap-target.h
diff --git a/bsd-user/freebsd/target_os_elf.h b/bsd-user/freebsd/target_os_elf.h
index 9df17d56d8..27d8ce036c 100644
--- a/bsd-user/freebsd/target_os_elf.h
+++ b/bsd-user/freebsd/target_os_elf.h
@@ -22,6 +22,7 @@
#include "target_arch_elf.h"
#include "elf.h"
+#include "exec/user/tswap-target.h"
#define bsd_get_ncpu() 1 /* until we pull in bsd-proc.[hc] */
diff --git a/bsd-user/freebsd/target_os_stack.h b/bsd-user/freebsd/target_os_stack.h
index d15fc3263f..6125208182 100644
--- a/bsd-user/freebsd/target_os_stack.h
+++ b/bsd-user/freebsd/target_os_stack.h
@@ -23,6 +23,7 @@
#include <sys/param.h>
#include "target_arch_sigtramp.h"
#include "qemu/guest-random.h"
+#include "exec/user/tswap-target.h"
/*
* The initial FreeBSD stack is as follows:
diff --git a/bsd-user/netbsd/target_os_elf.h b/bsd-user/netbsd/target_os_elf.h
index 2f3cb20871..23b422bfce 100644
--- a/bsd-user/netbsd/target_os_elf.h
+++ b/bsd-user/netbsd/target_os_elf.h
@@ -22,6 +22,7 @@
#include "target_arch_elf.h"
#include "elf.h"
+#include "exec/user/tswap-target.h"
/* this flag is uneffective under linux too, should be deleted */
#ifndef MAP_DENYWRITE
diff --git a/bsd-user/openbsd/target_os_elf.h b/bsd-user/openbsd/target_os_elf.h
index 6dca9c5a85..fc1dfa2e49 100644
--- a/bsd-user/openbsd/target_os_elf.h
+++ b/bsd-user/openbsd/target_os_elf.h
@@ -22,6 +22,7 @@
#include "target_arch_elf.h"
#include "elf.h"
+#include "exec/user/tswap-target.h"
/* this flag is uneffective under linux too, should be deleted */
#ifndef MAP_DENYWRITE
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index b042d94892..95af418920 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -36,14 +36,6 @@
#define BSWAP_NEEDED
#endif
-#if TARGET_LONG_SIZE == 4
-#define tswapl(s) tswap32(s)
-#define bswaptls(s) bswap32s(s)
-#else
-#define tswapl(s) tswap64(s)
-#define bswaptls(s) bswap64s(s)
-#endif
-
/* Target-endianness CPU memory access functions. These fit into the
* {ld,st}{type}{sign}{size}{endian}_p naming scheme described in bswap.h.
*/
diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index 6178453d94..ed10d5fe7e 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -2,6 +2,7 @@
#define EXEC_USER_ABITYPES_H
#include "cpu.h"
+#include "exec/user/tswap-target.h"
#ifdef TARGET_ABI32
#define TARGET_ABI_BITS 32
diff --git a/include/exec/user/tswap-target.h b/include/exec/user/tswap-target.h
new file mode 100644
index 0000000000..ff302436fe
--- /dev/null
+++ b/include/exec/user/tswap-target.h
@@ -0,0 +1,22 @@
+/*
+ * target-specific swap() definitions
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef EXEC_USER_TSWAP_H
+#define EXEC_USER_TSWAP_H
+
+#include "exec/cpu-defs.h"
+#include "exec/tswap.h"
+
+#if TARGET_LONG_SIZE == 4
+#define tswapl(s) tswap32(s)
+#define bswaptls(s) bswap32s(s)
+#else
+#define tswapl(s) tswap64(s)
+#define bswaptls(s) bswap64s(s)
+#endif
+
+#endif
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index ca31470772..7b2d25230a 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu.h"
+#include "exec/user/tswap-target.h"
#include "gdbstub/user.h"
#include "signal-common.h"
#include "trace.h"
diff --git a/bsd-user/strace.c b/bsd-user/strace.c
index 96499751eb..a1b738e63c 100644
--- a/bsd-user/strace.c
+++ b/bsd-user/strace.c
@@ -22,6 +22,7 @@
#include <sys/ioccom.h>
#include "qemu.h"
+#include "exec/user/tswap-target.h"
#include "os-strace.h" /* OS dependent strace print functions */
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index cf9e74468b..debea5c355 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -6,6 +6,7 @@
#include <sys/shm.h>
#include "qemu.h"
+#include "exec/user/tswap-target.h"
#include "user-internals.h"
#include "signal-common.h"
#include "loader.h"
diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
index bc5d45302e..eea1fa68c9 100644
--- a/linux-user/i386/signal.c
+++ b/linux-user/i386/signal.c
@@ -21,6 +21,7 @@
#include "user-internals.h"
#include "signal-common.h"
#include "linux-user/trace.h"
+#include "exec/user/tswap-target.h"
/* from the Linux kernel - /arch/x86/include/uapi/asm/sigcontext.h */
diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
index 7e7302823b..988b59a916 100644
--- a/linux-user/ppc/signal.c
+++ b/linux-user/ppc/signal.c
@@ -21,6 +21,7 @@
#include "user-internals.h"
#include "signal-common.h"
#include "linux-user/trace.h"
+#include "exec/user/tswap-target.h"
#include "vdso-asmoffset.h"
/* See arch/powerpc/include/asm/ucontext.h. Only used for 32-bit PPC;
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-14 18:27 ` Thomas Huth
2023-12-12 12:33 ` [PATCH v2 18/23] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
` (6 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Nicholas Piggin,
Daniel Henrique Barboza, Cédric Le Goater
'abi_ptr' is a user specific type. The system emulation
equivalent is 'target_ulong'. Use it in ppc_ldl_code()
to emphasis this is not an user emulation function.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/ppc/excp_helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
index a42743a3e0..3d7c9bbf1a 100644
--- a/target/ppc/excp_helper.c
+++ b/target/ppc/excp_helper.c
@@ -142,7 +142,7 @@ static inline bool insn_need_byteswap(CPUArchState *env)
return !!(env->msr & ((target_ulong)1 << MSR_LE));
}
-static uint32_t ppc_ldl_code(CPUArchState *env, abi_ptr addr)
+static uint32_t ppc_ldl_code(CPUArchState *env, target_ulong addr)
{
uint32_t insn = cpu_ldl_code(env, addr);
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 18/23] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
` (5 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Riku Voipio
set_helper_retaddr() is only used in accel/tcg/user-exec.c.
clear_helper_retaddr() is only used in accel/tcg/user-exec.c
and accel/tcg/user-exec.c.
No need to expose their definitions to all user-emulation
files including "exec/cpu_ldst.h", move them to a new
"user-retaddr.h" header (restricted to accel/tcg/).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/user-retaddr.h | 28 ++++++++++++++++++++++++++++
include/exec/cpu_ldst.h | 28 ++--------------------------
accel/tcg/cpu-exec.c | 3 +++
accel/tcg/user-exec.c | 1 +
4 files changed, 34 insertions(+), 26 deletions(-)
create mode 100644 accel/tcg/user-retaddr.h
diff --git a/accel/tcg/user-retaddr.h b/accel/tcg/user-retaddr.h
new file mode 100644
index 0000000000..e0f57e1994
--- /dev/null
+++ b/accel/tcg/user-retaddr.h
@@ -0,0 +1,28 @@
+#ifndef ACCEL_TCG_USER_RETADDR_H
+#define ACCEL_TCG_USER_RETADDR_H
+
+#include "qemu/atomic.h"
+
+extern __thread uintptr_t helper_retaddr;
+
+static inline void set_helper_retaddr(uintptr_t ra)
+{
+ helper_retaddr = ra;
+ /*
+ * Ensure that this write is visible to the SIGSEGV handler that
+ * may be invoked due to a subsequent invalid memory operation.
+ */
+ signal_barrier();
+}
+
+static inline void clear_helper_retaddr(void)
+{
+ /*
+ * Ensure that previous memory operations have succeeded before
+ * removing the data visible to the signal handler.
+ */
+ signal_barrier();
+ helper_retaddr = 0;
+}
+
+#endif
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 6061e33ac9..25e7239cc5 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -300,31 +300,7 @@ Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, abi_ptr addr,
Int128 cmpv, Int128 newv,
MemOpIdx oi, uintptr_t retaddr);
-#if defined(CONFIG_USER_ONLY)
-
-extern __thread uintptr_t helper_retaddr;
-
-static inline void set_helper_retaddr(uintptr_t ra)
-{
- helper_retaddr = ra;
- /*
- * Ensure that this write is visible to the SIGSEGV handler that
- * may be invoked due to a subsequent invalid memory operation.
- */
- signal_barrier();
-}
-
-static inline void clear_helper_retaddr(void)
-{
- /*
- * Ensure that previous memory operations have succeeded before
- * removing the data visible to the signal handler.
- */
- signal_barrier();
- helper_retaddr = 0;
-}
-
-#else
+#if !defined(CONFIG_USER_ONLY)
#include "tcg/oversized-guest.h"
@@ -376,7 +352,7 @@ static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx,
return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)];
}
-#endif /* defined(CONFIG_USER_ONLY) */
+#endif /* !defined(CONFIG_USER_ONLY) */
#if TARGET_BIG_ENDIAN
# define cpu_lduw_data cpu_lduw_be_data
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index c938eb96f8..e591992d0c 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -44,6 +44,9 @@
#include "tb-context.h"
#include "internal-common.h"
#include "internal-target.h"
+#if defined(CONFIG_USER_ONLY)
+#include "user-retaddr.h"
+#endif
/* -icount align implementation. */
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 68b252cb8e..2575f0842f 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -31,6 +31,7 @@
#include "tcg/tcg-ldst.h"
#include "internal-common.h"
#include "internal-target.h"
+#include "user-retaddr.h"
__thread uintptr_t helper_retaddr;
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 18/23] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-14 18:30 ` Thomas Huth
2023-12-12 12:33 ` [PATCH v2 20/23] exec: Declare abi_ptr type in its own 'abi_ptr.h' header Philippe Mathieu-Daudé
` (4 subsequent siblings)
23 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
"exec/user/abitypes.h" requires:
- "exec/cpu-defs.h" (TARGET_LONG_BITS)
- "exec/tswap.h" (tswap32)
In order to avoid "cpu.h", pick the minimum required headers.
Assert this user-specific header is only included from user
emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/exec/user/abitypes.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index ed10d5fe7e..fbb55684d3 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -1,7 +1,12 @@
#ifndef EXEC_USER_ABITYPES_H
#define EXEC_USER_ABITYPES_H
-#include "cpu.h"
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
+#include "exec/cpu-defs.h"
+#include "exec/tswap.h"
#include "exec/user/tswap-target.h"
#ifdef TARGET_ABI32
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 20/23] exec: Declare abi_ptr type in its own 'abi_ptr.h' header
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
` (3 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
The abi_ptr type is declared in "exec/cpu_ldst.h" with all
the load/store helpers. Some source files requiring abi_ptr
type don't need the load/store helpers. In order to simplify,
create a new "exec/abi_ptr.h" header.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/abi_ptr.h | 33 +++++++++++++++++++++++++++++++++
include/exec/cpu_ldst.h | 17 +++--------------
include/exec/exec-all.h | 1 +
include/exec/translator.h | 5 ++++-
accel/tcg/cputlb.c | 1 +
5 files changed, 42 insertions(+), 15 deletions(-)
create mode 100644 include/exec/abi_ptr.h
diff --git a/include/exec/abi_ptr.h b/include/exec/abi_ptr.h
new file mode 100644
index 0000000000..2b6ae470c4
--- /dev/null
+++ b/include/exec/abi_ptr.h
@@ -0,0 +1,33 @@
+/*
+ * QEMU abi_ptr type
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef EXEC_ABI_PTR_H
+#define EXEC_ABI_PTR_H
+
+#include "cpu-param.h"
+
+#if defined(CONFIG_USER_ONLY)
+/*
+ * sparc32plus has 64bit long but 32bit space address
+ * this can make bad result with g2h() and h2g()
+ */
+#if TARGET_VIRT_ADDR_SPACE_BITS <= 32
+typedef uint32_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%x"
+#else
+typedef uint64_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%"PRIx64
+#endif
+
+#else /* !CONFIG_USER_ONLY */
+
+#include "exec/target_long.h"
+
+typedef target_ulong abi_ptr;
+#define TARGET_ABI_FMT_ptr TARGET_FMT_lx
+
+#endif /* !CONFIG_USER_ONLY */
+
+#endif
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 25e7239cc5..64e0319996 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -63,20 +63,11 @@
#define CPU_LDST_H
#include "exec/memopidx.h"
+#include "exec/abi_ptr.h"
#include "qemu/int128.h"
#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
-/* sparc32plus has 64bit long but 32bit space address
- * this can make bad result with g2h() and h2g()
- */
-#if TARGET_VIRT_ADDR_SPACE_BITS <= 32
-typedef uint32_t abi_ptr;
-#define TARGET_ABI_FMT_ptr "%x"
-#else
-typedef uint64_t abi_ptr;
-#define TARGET_ABI_FMT_ptr "%"PRIx64
-#endif
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
@@ -120,10 +111,8 @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
assert(h2g_valid(x)); \
h2g_nocheck(x); \
})
-#else
-typedef target_ulong abi_ptr;
-#define TARGET_ABI_FMT_ptr TARGET_FMT_lx
-#endif
+
+#endif /* CONFIG_USER_ONLY */
uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index df3d93a2e2..5b6be2de6c 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -22,6 +22,7 @@
#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
+#include "exec/abi_ptr.h"
#include "exec/cpu_ldst.h"
#endif
#include "exec/translation-block.h"
diff --git a/include/exec/translator.h b/include/exec/translator.h
index 6d3f59d095..574058b900 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -19,7 +19,10 @@
*/
#include "qemu/bswap.h"
-#include "exec/cpu_ldst.h" /* for abi_ptr */
+#include "exec/cpu-common.h"
+#include "exec/cpu-defs.h"
+#include "exec/abi_ptr.h"
+#include "cpu.h"
/**
* gen_intermediate_code
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index db3f93fda9..852a55fbb6 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -34,6 +34,7 @@
#include "qemu/atomic.h"
#include "qemu/atomic128.h"
#include "exec/translate-all.h"
+#include "exec/abi_ptr.h"
#include "trace.h"
#include "tb-hash.h"
#include "internal-common.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 20/23] exec: Declare abi_ptr type in its own 'abi_ptr.h' header Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 22/23] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
` (2 subsequent siblings)
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Kyle Evans,
Laurent Vivier
Declare 'have_guest_base' in "exec/user/guest-base.h".
Very few files require this header, so explicitly include
it there instead of "exec/cpu-all.h" which is used in many
source files.
Assert this user-specific header is only included from user
emulation.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/cpu-all.h | 3 ---
include/exec/cpu_ldst.h | 2 ++
include/exec/user/guest-base.h | 6 ++++++
bsd-user/main.c | 1 +
linux-user/elfload.c | 1 +
linux-user/main.c | 1 +
6 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 95af418920..d2ddfae286 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -65,9 +65,6 @@
#if defined(CONFIG_USER_ONLY)
#include "exec/user/abitypes.h"
-#include "exec/user/guest-base.h"
-
-extern bool have_guest_base;
/*
* If non-zero, the guest virtual address space is a contiguous subset
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 64e0319996..e039cc7f80 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -69,6 +69,8 @@
#if defined(CONFIG_USER_ONLY)
+#include "exec/user/guest-base.h"
+
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
{
diff --git a/include/exec/user/guest-base.h b/include/exec/user/guest-base.h
index afe2ab7fbb..cf40151360 100644
--- a/include/exec/user/guest-base.h
+++ b/include/exec/user/guest-base.h
@@ -7,6 +7,12 @@
#ifndef EXEC_USER_GUEST_BASE_H
#define EXEC_USER_GUEST_BASE_H
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
extern uintptr_t guest_base;
+extern bool have_guest_base;
+
#endif
diff --git a/bsd-user/main.c b/bsd-user/main.c
index e6014f517e..c331d727e1 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -36,6 +36,7 @@
#include "qemu/help_option.h"
#include "qemu/module.h"
#include "exec/exec-all.h"
+#include "exec/user/guest-base.h"
#include "tcg/startup.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index debea5c355..a8c106ec0c 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -7,6 +7,7 @@
#include "qemu.h"
#include "exec/user/tswap-target.h"
+#include "exec/user/guest-base.h"
#include "user-internals.h"
#include "signal-common.h"
#include "loader.h"
diff --git a/linux-user/main.c b/linux-user/main.c
index 0cdaf30d34..84691d707b 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -38,6 +38,7 @@
#include "qemu/help_option.h"
#include "qemu/module.h"
#include "qemu/plugin.h"
+#include "exec/user/guest-base.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
#include "gdbstub/user.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 22/23] exec/cpu-all: Extract page-protection definitions to page-prot-common.h
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 23/23] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2023-12-12 12:41 ` [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé, Riku Voipio, Kyle Evans,
BALATON Zoltan, Edgar E. Iglesias, Laurent Vivier, Peter Xu,
David Hildenbrand, Peter Maydell, Michael Rolnik, Eduardo Habkost,
Song Gao, Huacai Chen, Aurelien Jarno, Jiaxun Yang,
Aleksandar Rikalo, Chris Wulff, Marek Vasut, Stafford Horne,
Nicholas Piggin, Daniel Henrique Barboza, Cédric Le Goater,
Palmer Dabbelt, Alistair Francis, Bin Meng, Weiwei Li, Liu Zhiwei,
Yoshinori Sato, Ilya Leoshkevich, Mark Cave-Ayland,
Artyom Tarasenko, Bastian Koppelmann, Max Filippov
Extract page-protection definitions from "exec/cpu-all.h"
to "exec/page-prot-common.h".
The list of files requiring the new header was generated
using:
$ git grep -wE \
'PAGE_(READ|WRITE|EXEC|BITS|VALID|ANON|RESERVED|TARGET_.|PASSTHROUGH)'
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
bsd-user/bsd-mem.h | 1 +
bsd-user/qemu.h | 1 +
include/exec/cpu-all.h | 35 +------------------------
include/exec/page-prot-common.h | 38 ++++++++++++++++++++++++++++
include/semihosting/uaccess.h | 1 +
target/arm/cpu.h | 1 +
target/ppc/internal.h | 1 +
target/ppc/mmu-radix64.h | 2 ++
accel/tcg/cputlb.c | 1 +
accel/tcg/tb-maint.c | 1 +
accel/tcg/user-exec.c | 1 +
bsd-user/mmap.c | 1 +
bsd-user/signal.c | 1 +
cpu-target.c | 1 +
hw/ppc/ppc440_bamboo.c | 1 +
hw/ppc/sam460ex.c | 1 +
hw/ppc/virtex_ml507.c | 1 +
linux-user/arm/cpu_loop.c | 1 +
linux-user/elfload.c | 1 +
linux-user/mmap.c | 1 +
linux-user/nios2/cpu_loop.c | 1 +
linux-user/signal.c | 1 +
linux-user/syscall.c | 1 +
system/physmem.c | 1 +
target/alpha/helper.c | 1 +
target/arm/ptw.c | 1 +
target/arm/tcg/m_helper.c | 1 +
target/arm/tcg/mte_helper.c | 1 +
target/arm/tcg/sve_helper.c | 1 +
target/avr/helper.c | 1 +
target/cris/mmu.c | 1 +
target/hppa/mem_helper.c | 1 +
target/hppa/translate.c | 1 +
target/i386/tcg/sysemu/excp_helper.c | 1 +
target/loongarch/tlb_helper.c | 1 +
target/m68k/helper.c | 1 +
target/microblaze/helper.c | 1 +
target/microblaze/mmu.c | 1 +
target/mips/sysemu/physaddr.c | 1 +
target/mips/tcg/sysemu/tlb_helper.c | 1 +
target/nios2/helper.c | 1 +
target/nios2/mmu.c | 1 +
target/openrisc/mmu.c | 1 +
target/ppc/mmu-hash32.c | 1 +
target/ppc/mmu-hash64.c | 1 +
target/ppc/mmu-radix64.c | 1 +
target/ppc/mmu_common.c | 1 +
target/ppc/mmu_helper.c | 1 +
target/riscv/cpu_helper.c | 1 +
target/riscv/pmp.c | 1 +
target/riscv/vector_helper.c | 1 +
target/rx/cpu.c | 1 +
target/s390x/mmu_helper.c | 1 +
target/s390x/tcg/mem_helper.c | 1 +
target/sh4/helper.c | 1 +
target/sparc/ldst_helper.c | 1 +
target/sparc/mmu_helper.c | 1 +
target/tricore/helper.c | 1 +
target/xtensa/mmu_helper.c | 1 +
target/xtensa/op_helper.c | 1 +
60 files changed, 98 insertions(+), 34 deletions(-)
create mode 100644 include/exec/page-prot-common.h
diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index 21d9bab889..f95472bcab 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -56,6 +56,7 @@
#include <fcntl.h>
#include "qemu-bsd.h"
+#include "exec/page-prot-common.h"
extern struct bsd_shm_regions bsd_shm_regions[];
extern abi_ulong target_brk;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index dc842fffa7..1e38d2cb66 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -36,6 +36,7 @@ extern char **environ;
#include "target_os_signal.h"
#include "target.h"
#include "exec/gdbstub.h"
+#include "exec/page-prot-common.h"
#include "qemu/clang-tsa.h"
#include "qemu-os.h"
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index d2ddfae286..1e67085d47 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -19,6 +19,7 @@
#ifndef CPU_ALL_H
#define CPU_ALL_H
+#include "exec/page-prot-common.h"
#include "exec/cpu-common.h"
#include "exec/memory.h"
#include "exec/tswap.h"
@@ -156,40 +157,6 @@ extern const TargetPageBits target_page;
#define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
-/* same as PROT_xxx */
-#define PAGE_READ 0x0001
-#define PAGE_WRITE 0x0002
-#define PAGE_EXEC 0x0004
-#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
-#define PAGE_VALID 0x0008
-/*
- * Original state of the write flag (used when tracking self-modifying code)
- */
-#define PAGE_WRITE_ORG 0x0010
-/*
- * Invalidate the TLB entry immediately, helpful for s390x
- * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs()
- */
-#define PAGE_WRITE_INV 0x0020
-/* For use with page_set_flags: page is being replaced; target_data cleared. */
-#define PAGE_RESET 0x0040
-/* For linux-user, indicates that the page is MAP_ANON. */
-#define PAGE_ANON 0x0080
-
-#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY)
-/* FIXME: Code that sets/uses this is broken and needs to go away. */
-#define PAGE_RESERVED 0x0100
-#endif
-/* Target-specific bits that will be used via page_get_flags(). */
-#define PAGE_TARGET_1 0x0200
-#define PAGE_TARGET_2 0x0400
-
-/*
- * For linux-user, indicates that the page is mapped with the same semantics
- * in both guest and host.
- */
-#define PAGE_PASSTHROUGH 0x0800
-
#if defined(CONFIG_USER_ONLY)
void page_dump(FILE *f);
diff --git a/include/exec/page-prot-common.h b/include/exec/page-prot-common.h
new file mode 100644
index 0000000000..a38157e8b9
--- /dev/null
+++ b/include/exec/page-prot-common.h
@@ -0,0 +1,38 @@
+#ifndef EXEC_PAGE_PROT_COMMON_H
+#define EXEC_PAGE_PROT_COMMON_H
+
+/* same as PROT_xxx */
+#define PAGE_READ 0x0001
+#define PAGE_WRITE 0x0002
+#define PAGE_EXEC 0x0004
+#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
+#define PAGE_VALID 0x0008
+/*
+ * Original state of the write flag (used when tracking self-modifying code)
+ */
+#define PAGE_WRITE_ORG 0x0010
+/*
+ * Invalidate the TLB entry immediately, helpful for s390x
+ * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs()
+ */
+#define PAGE_WRITE_INV 0x0020
+/* For use with page_set_flags: page is being replaced; target_data cleared. */
+#define PAGE_RESET 0x0040
+/* For linux-user, indicates that the page is MAP_ANON. */
+#define PAGE_ANON 0x0080
+
+#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY)
+/* FIXME: Code that sets/uses this is broken and needs to go away. */
+#define PAGE_RESERVED 0x0100
+#endif
+/* Target-specific bits that will be used via page_get_flags(). */
+#define PAGE_TARGET_1 0x0200
+#define PAGE_TARGET_2 0x0400
+
+/*
+ * For linux-user, indicates that the page is mapped with the same semantics
+ * in both guest and host.
+ */
+#define PAGE_PASSTHROUGH 0x0800
+
+#endif
diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h
index 6c8835fbcb..02783cca33 100644
--- a/include/semihosting/uaccess.h
+++ b/include/semihosting/uaccess.h
@@ -15,6 +15,7 @@
#endif
#include "exec/cpu-defs.h"
+#include "exec/page-prot-common.h"
#define get_user_u64(val, addr) \
({ uint64_t val_ = 0; \
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index ea5c8660dc..c14012e07d 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -25,6 +25,7 @@
#include "hw/registerfields.h"
#include "cpu-qom.h"
#include "exec/cpu-defs.h"
+#include "exec/page-prot-common.h"
#include "qapi/qapi-types-common.h"
#ifdef TARGET_AARCH64
diff --git a/target/ppc/internal.h b/target/ppc/internal.h
index 5b20ecbd33..6bcfbcbed8 100644
--- a/target/ppc/internal.h
+++ b/target/ppc/internal.h
@@ -19,6 +19,7 @@
#define PPC_INTERNAL_H
#include "hw/registerfields.h"
+#include "exec/page-prot-common.h"
/* PM instructions */
typedef enum {
diff --git a/target/ppc/mmu-radix64.h b/target/ppc/mmu-radix64.h
index 4c768aa5cc..1a3fd8f65b 100644
--- a/target/ppc/mmu-radix64.h
+++ b/target/ppc/mmu-radix64.h
@@ -3,6 +3,8 @@
#ifndef CONFIG_USER_ONLY
+#include "exec/page-prot-common.h"
+
/* Radix Quadrants */
#define R_EADDR_MASK 0x3FFFFFFFFFFFFFFF
#define R_EADDR_VALID_MASK 0xC00FFFFFFFFFFFFF
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 852a55fbb6..4e9d6fdb19 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -21,6 +21,7 @@
#include "qemu/main-loop.h"
#include "hw/core/tcg-cpu-ops.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/memory.h"
#include "exec/cpu_ldst.h"
#include "exec/cputlb.h"
diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
index da39a43bd8..717e31e602 100644
--- a/accel/tcg/tb-maint.c
+++ b/accel/tcg/tb-maint.c
@@ -23,6 +23,7 @@
#include "exec/cputlb.h"
#include "exec/log.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/tb-flush.h"
#include "exec/translate-all.h"
#include "sysemu/tcg.h"
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 2575f0842f..5ce602b8d6 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -25,6 +25,7 @@
#include "qemu/rcu.h"
#include "exec/cpu_ldst.h"
#include "exec/translate-all.h"
+#include "exec/page-prot-common.h"
#include "exec/helper-proto.h"
#include "qemu/atomic128.h"
#include "trace/trace-root.h"
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index 3ef11b2807..deb384605e 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -17,6 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
+#include "exec/page-prot-common.h"
#include "qemu.h"
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 7b2d25230a..699ac60837 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu.h"
+#include "exec/page-prot-common.h"
#include "exec/user/tswap-target.h"
#include "gdbstub/user.h"
#include "signal-common.h"
diff --git a/cpu-target.c b/cpu-target.c
index 4c1e19ca81..a7209e8de9 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -21,6 +21,7 @@
#include "qapi/error.h"
#include "exec/target_page.h"
+#include "exec/page-prot-common.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index a189942de4..45a215be6d 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -15,6 +15,7 @@
#include "qemu/units.h"
#include "qemu/datadir.h"
#include "qemu/error-report.h"
+#include "exec/page-prot-common.h"
#include "net/net.h"
#include "hw/pci/pci.h"
#include "hw/boards.h"
diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
index 1e615b8d35..ffe467fb16 100644
--- a/hw/ppc/sam460ex.c
+++ b/hw/ppc/sam460ex.c
@@ -21,6 +21,7 @@
#include "kvm_ppc.h"
#include "sysemu/device_tree.h"
#include "sysemu/block-backend.h"
+#include "exec/page-prot-common.h"
#include "hw/loader.h"
#include "elf.h"
#include "exec/memory.h"
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index d02f330650..e2da13c064 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
+#include "exec/page-prot-common.h"
#include "cpu.h"
#include "hw/sysbus.h"
#include "hw/char/serial.h"
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index b404117ff3..0d05daea91 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -24,6 +24,7 @@
#include "cpu_loop-common.h"
#include "signal-common.h"
#include "semihosting/common-semi.h"
+#include "exec/page-prot-common.h"
#include "target/arm/syndrome.h"
#define get_user_code_u32(x, gaddr, env) \
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index a8c106ec0c..84484fee97 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -8,6 +8,7 @@
#include "qemu.h"
#include "exec/user/tswap-target.h"
#include "exec/user/guest-base.h"
+#include "exec/page-prot-common.h"
#include "user-internals.h"
#include "signal-common.h"
#include "loader.h"
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 96c9433e27..d37803fc8c 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -20,6 +20,7 @@
#include <sys/shm.h>
#include "trace.h"
#include "exec/log.h"
+#include "exec/page-prot-common.h"
#include "qemu.h"
#include "user-internals.h"
#include "user-mmap.h"
diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
index da77ede76b..03434abe3b 100644
--- a/linux-user/nios2/cpu_loop.c
+++ b/linux-user/nios2/cpu_loop.c
@@ -22,6 +22,7 @@
#include "user-internals.h"
#include "cpu_loop-common.h"
#include "signal-common.h"
+#include "exec/page-prot-common.h"
void cpu_loop(CPUNios2State *env)
{
diff --git a/linux-user/signal.c b/linux-user/signal.c
index b35d1e512f..50cba136db 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qemu/bitops.h"
#include "gdbstub/user.h"
+#include "exec/page-prot-common.h"
#include "hw/core/tcg-cpu-ops.h"
#include <sys/ucontext.h>
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e384e14248..3d2467d7c8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -25,6 +25,7 @@
#include "qemu/plugin.h"
#include "tcg/startup.h"
#include "target_mman.h"
+#include "exec/page-prot-common.h"
#include <elf.h>
#include <endian.h>
#include <grp.h>
diff --git a/system/physmem.c b/system/physmem.c
index 4bdb3d0592..0bea47b5d2 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -31,6 +31,7 @@
#endif /* CONFIG_TCG */
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/target_page.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
diff --git a/target/alpha/helper.c b/target/alpha/helper.c
index 970c869771..ea7a769644 100644
--- a/target/alpha/helper.c
+++ b/target/alpha/helper.c
@@ -21,6 +21,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "fpu/softfloat-types.h"
#include "exec/helper-proto.h"
#include "qemu/qemu-print.h"
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 1762b058ae..5eca492db4 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -11,6 +11,7 @@
#include "qemu/range.h"
#include "qemu/main-loop.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "cpu.h"
#include "internals.h"
#include "cpu-features.h"
diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c
index a26adb75aa..1198b32929 100644
--- a/target/arm/tcg/m_helper.c
+++ b/target/arm/tcg/m_helper.c
@@ -16,6 +16,7 @@
#include "qemu/bitops.h"
#include "qemu/log.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#ifdef CONFIG_TCG
#include "exec/cpu_ldst.h"
#include "semihosting/common-semi.h"
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
index ffb8ea1c34..47f512e6c6 100644
--- a/target/arm/tcg/mte_helper.c
+++ b/target/arm/tcg/mte_helper.c
@@ -22,6 +22,7 @@
#include "cpu.h"
#include "internals.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/ram_addr.h"
#include "exec/cpu_ldst.h"
#include "exec/helper-proto.h"
diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c
index f006d152cc..7713b7a4d4 100644
--- a/target/arm/tcg/sve_helper.c
+++ b/target/arm/tcg/sve_helper.c
@@ -21,6 +21,7 @@
#include "cpu.h"
#include "internals.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/helper-proto.h"
#include "tcg/tcg-gvec-desc.h"
#include "fpu/softfloat.h"
diff --git a/target/avr/helper.c b/target/avr/helper.c
index fdc9884ea0..62758b00ed 100644
--- a/target/avr/helper.c
+++ b/target/avr/helper.c
@@ -24,6 +24,7 @@
#include "cpu.h"
#include "hw/core/tcg-cpu-ops.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "exec/address-spaces.h"
#include "exec/helper-proto.h"
diff --git a/target/cris/mmu.c b/target/cris/mmu.c
index b574ec6e5b..dee485419d 100644
--- a/target/cris/mmu.c
+++ b/target/cris/mmu.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "mmu.h"
#ifdef DEBUG
diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 08abd1a9f9..0d78e273f6 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -21,6 +21,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/helper-proto.h"
#include "hw/core/cpu.h"
#include "trace.h"
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 3ef39b1bd7..7e3867e4aa 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -22,6 +22,7 @@
#include "disas/disas.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "tcg/tcg-op.h"
#include "tcg/tcg-op-gvec.h"
#include "exec/helper-proto.h"
diff --git a/target/i386/tcg/sysemu/excp_helper.c b/target/i386/tcg/sysemu/excp_helper.c
index 5b86f439ad..a3bf3b7292 100644
--- a/target/i386/tcg/sysemu/excp_helper.c
+++ b/target/i386/tcg/sysemu/excp_helper.c
@@ -21,6 +21,7 @@
#include "cpu.h"
#include "exec/cpu_ldst.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "tcg/helper-tcg.h"
typedef struct TranslateParams {
diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c
index 449043c68b..7f0e413e1e 100644
--- a/target/loongarch/tlb_helper.c
+++ b/target/loongarch/tlb_helper.c
@@ -13,6 +13,7 @@
#include "internals.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "cpu-csr.h"
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
index 0a1544cd68..7a69c4a28d 100644
--- a/target/m68k/helper.c
+++ b/target/m68k/helper.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/gdbstub.h"
#include "exec/helper-proto.h"
#include "gdbstub/helpers.h"
diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c
index 98bdb82de8..e4ce57560d 100644
--- a/target/microblaze/helper.c
+++ b/target/microblaze/helper.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "qemu/host-utils.h"
#include "exec/log.h"
diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c
index 75651979a9..c0b0844f71 100644
--- a/target/microblaze/mmu.c
+++ b/target/microblaze/mmu.c
@@ -22,6 +22,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
static unsigned int tlb_decode_size(unsigned int f)
{
diff --git a/target/mips/sysemu/physaddr.c b/target/mips/sysemu/physaddr.c
index 05990aa5bb..7ac51c6019 100644
--- a/target/mips/sysemu/physaddr.c
+++ b/target/mips/sysemu/physaddr.c
@@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "../internal.h"
static int is_seg_am_mapped(unsigned int am, bool eu, int mmu_idx)
diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/tlb_helper.c
index 4ede904800..d0cb46bd1b 100644
--- a/target/mips/tcg/sysemu/tlb_helper.c
+++ b/target/mips/tcg/sysemu/tlb_helper.c
@@ -22,6 +22,7 @@
#include "cpu.h"
#include "internal.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "exec/helper-proto.h"
diff --git a/target/nios2/helper.c b/target/nios2/helper.c
index bb3b09e5a7..b64caa11f6 100644
--- a/target/nios2/helper.c
+++ b/target/nios2/helper.c
@@ -23,6 +23,7 @@
#include "cpu.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "exec/helper-proto.h"
diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c
index d9b690b78e..da7f20cc07 100644
--- a/target/nios2/mmu.c
+++ b/target/nios2/mmu.c
@@ -22,6 +22,7 @@
#include "qemu/qemu-print.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "mmu.h"
#include "exec/helper-proto.h"
#include "trace/trace-target_nios2.h"
diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c
index 603c26715e..6ca7cc023e 100644
--- a/target/openrisc/mmu.c
+++ b/target/openrisc/mmu.c
@@ -22,6 +22,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "gdbstub/helpers.h"
#include "qemu/host-utils.h"
#include "hw/loader.h"
diff --git a/target/ppc/mmu-hash32.c b/target/ppc/mmu-hash32.c
index 3976416840..da446632c9 100644
--- a/target/ppc/mmu-hash32.c
+++ b/target/ppc/mmu-hash32.c
@@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "sysemu/kvm.h"
#include "kvm_ppc.h"
#include "internal.h"
diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c
index d645c0bb94..1633a0e5d0 100644
--- a/target/ppc/mmu-hash64.c
+++ b/target/ppc/mmu-hash64.c
@@ -21,6 +21,7 @@
#include "qemu/units.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
#include "sysemu/hw_accel.h"
diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c
index 5823e039e6..13f5ed7fb7 100644
--- a/target/ppc/mmu-radix64.c
+++ b/target/ppc/mmu-radix64.c
@@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "qemu/error-report.h"
#include "sysemu/kvm.h"
#include "kvm_ppc.h"
diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index 6ca5d12207..83a91a92ea 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -25,6 +25,7 @@
#include "mmu-hash64.h"
#include "mmu-hash32.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/log.h"
#include "helper_regs.h"
#include "qemu/error-report.h"
diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c
index f87d35379a..6368dceb16 100644
--- a/target/ppc/mmu_helper.c
+++ b/target/ppc/mmu_helper.c
@@ -25,6 +25,7 @@
#include "mmu-hash64.h"
#include "mmu-hash32.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/log.h"
#include "helper_regs.h"
#include "qemu/error-report.h"
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index e7e23b34f4..565e6614d9 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -24,6 +24,7 @@
#include "internals.h"
#include "pmu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "instmap.h"
#include "tcg/tcg-op.h"
#include "trace.h"
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
index 162e88a90a..59f4c3d481 100644
--- a/target/riscv/pmp.c
+++ b/target/riscv/pmp.c
@@ -25,6 +25,7 @@
#include "cpu.h"
#include "trace.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,
uint8_t val);
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index c1c3a4d1ea..968bff34f2 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -22,6 +22,7 @@
#include "cpu.h"
#include "exec/memop.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "exec/helper-proto.h"
#include "fpu/softfloat.h"
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
index 9cc9d9d15e..6cc3173a1e 100644
--- a/target/rx/cpu.c
+++ b/target/rx/cpu.c
@@ -22,6 +22,7 @@
#include "cpu.h"
#include "migration/vmstate.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "hw/loader.h"
#include "fpu/softfloat.h"
#include "tcg/debug-assert.h"
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index fbb2f1b4d4..0b2240e39a 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -24,6 +24,7 @@
#include "sysemu/kvm.h"
#include "sysemu/tcg.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "trace.h"
#include "hw/hw.h"
#include "hw/s390x/storage-keys.h"
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 84103251b9..2a8ee4df6b 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -25,6 +25,7 @@
#include "tcg_s390x.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "hw/core/tcg-cpu-ops.h"
#include "qemu/int128.h"
diff --git a/target/sh4/helper.c b/target/sh4/helper.c
index 5a6f653c12..c9f41d1e2e 100644
--- a/target/sh4/helper.c
+++ b/target/sh4/helper.c
@@ -21,6 +21,7 @@
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/log.h"
#if !defined(CONFIG_USER_ONLY)
diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 09066d5487..078e25e363 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -23,6 +23,7 @@
#include "tcg/tcg.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "exec/cpu_ldst.h"
#include "asi.h"
diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c
index 453498c670..e723868148 100644
--- a/target/sparc/mmu_helper.c
+++ b/target/sparc/mmu_helper.c
@@ -21,6 +21,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "qemu/qemu-print.h"
#include "trace.h"
diff --git a/target/tricore/helper.c b/target/tricore/helper.c
index 7e5da3cb23..e736630a79 100644
--- a/target/tricore/helper.c
+++ b/target/tricore/helper.c
@@ -20,6 +20,7 @@
#include "hw/registerfields.h"
#include "cpu.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#include "fpu/softfloat-helpers.h"
#include "qemu/qemu-print.h"
diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c
index 12552a3347..d7611f1168 100644
--- a/target/xtensa/mmu_helper.c
+++ b/target/xtensa/mmu_helper.c
@@ -33,6 +33,7 @@
#include "exec/helper-proto.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
+#include "exec/page-prot-common.h"
#define XTENSA_MPU_SEGMENT_MASK 0x0000001f
#define XTENSA_MPU_ACC_RIGHTS_MASK 0x00000f00
diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c
index 496754ba57..a9048ad6ac 100644
--- a/target/xtensa/op_helper.c
+++ b/target/xtensa/op_helper.c
@@ -28,6 +28,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/helper-proto.h"
+#include "exec/page-prot-common.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
#include "qemu/atomic.h"
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 23/23] exec/cpu_ldst: Avoid including 'cpu.h'
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 22/23] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
@ 2023-12-12 12:33 ` Philippe Mathieu-Daudé
2023-12-12 12:41 ` [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:33 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Philippe Mathieu-Daudé
"exec/cpu_ldst.h" doesn't need to huge "cpu.h" header,
but simply:
- exec/cpu-defs.h (TARGET_LONG_BITS)
- exec/tlb-common.h (CPUTLBEntry)
- exec/user/abitypes.h (abi_ulong)
- exec/user/guest-base.h (guest_base)
- exec/cpu-all.h (GUEST_ADDR_MAX and env_cpu)
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
env_cpu() will soon be removed from "exec/cpu-all.h". Do we
want to move GUEST_ADDR_MAX declaration to "user/guest-base.h",
eventually renaming it as "user/guest-addr.h"?
---
include/exec/cpu_ldst.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index e039cc7f80..ec0784bf15 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -65,11 +65,14 @@
#include "exec/memopidx.h"
#include "exec/abi_ptr.h"
#include "qemu/int128.h"
-#include "cpu.h"
+#include "exec/cpu-defs.h"
+#include "exec/tlb-common.h"
#if defined(CONFIG_USER_ONLY)
+#include "exec/user/abitypes.h"
#include "exec/user/guest-base.h"
+#include "exec/cpu-all.h"
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
--
2.41.0
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v2 00/23] exec: Rework of various headers (user focused)
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2023-12-12 12:33 ` [PATCH v2 23/23] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
@ 2023-12-12 12:41 ` Philippe Mathieu-Daudé
23 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:41 UTC (permalink / raw)
To: qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Thomas Huth, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh
On 12/12/23 13:33, Philippe Mathieu-Daudé wrote:
> Philippe Mathieu-Daudé (23):
> exec/cpu-all: Remove unused tswapls() definitions
> exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h'
> target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
> accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h'
> exec/user: Do not include 'cpu.h' in 'abitypes.h'
> exec: Declare abi_ptr type in its own 'abi_ptr.h' header
> exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
> include/exec/user/abitypes.h | 8 ++-
> include/exec/user/guest-base.h | 6 ++
> include/exec/user/tswap-target.h | 22 +++++++
Missing:
-- >8 --
diff --git a/MAINTAINERS b/MAINTAINERS
index 695e0bd34f..1341862c2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3615,6 +3615,7 @@ Overall usermode emulation
M: Riku Voipio <riku.voipio@iki.fi>
S: Maintained
F: accel/tcg/user-exec*.c
+F: include/exec/user/
F: include/user/
F: common-user/
---
(Although maybe the M: tag need some update)
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
2023-12-12 12:33 ` [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
@ 2023-12-13 10:58 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 10:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> Nothing in guestfd.c requires "semihosting/uaccess.h" nor "qemu.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> semihosting/guestfd.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
> index 955c2efbd0..d3241434c5 100644
> --- a/semihosting/guestfd.c
> +++ b/semihosting/guestfd.c
> @@ -12,10 +12,7 @@
> #include "gdbstub/syscalls.h"
> #include "semihosting/semihost.h"
> #include "semihosting/guestfd.h"
> -#ifdef CONFIG_USER_ONLY
> -#include "qemu.h"
> -#else
> -#include "semihosting/uaccess.h"
> +#ifndef CONFIG_USER_ONLY
> #include CONFIG_DEVICES
> #endif
>
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
--
Anton Johansson
rev.ng Labs Srl.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h'
2023-12-12 12:33 ` [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h' Philippe Mathieu-Daudé
@ 2023-12-13 11:20 ` Anton Johansson via
2023-12-13 15:13 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 11:20 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh, Gerd Hoffmann, Michael S. Tsirkin, Alistair Francis,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang
On 12/12/23, Philippe Mathieu-Daudé wrote:
> We usually check target endianess before swapping values,
> so target_words_bigendian() declaration makes sense in
> "exec/tswap.h" with the target swapping helpers.
>
> Remove "hw/core/cpu.h" when it was only included to get
> the target_words_bigendian() declaration.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/exec/tswap.h | 12 +++++++++++-
> include/hw/core/cpu.h | 11 -----------
> cpu-target.c | 1 +
> disas/disas.c | 1 +
> hw/audio/virtio-snd.c | 2 +-
> hw/core/cpu-sysemu.c | 2 +-
> hw/core/generic-loader.c | 2 +-
> hw/display/vga.c | 2 +-
> hw/virtio/virtio.c | 1 +
> 9 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/include/exec/tswap.h b/include/exec/tswap.h
> index 68944a880b..77954bbc2b 100644
> --- a/include/exec/tswap.h
> +++ b/include/exec/tswap.h
> @@ -8,9 +8,19 @@
> #ifndef TSWAP_H
> #define TSWAP_H
>
> -#include "hw/core/cpu.h"
> #include "qemu/bswap.h"
This breaks system/qtest.c which gets first_cpu from hw/core/cpu.h
through the inclusion of tswap.h...
../system/qtest.c:548:33: error: ‘first_cpu’ undeclared (first use in this function);
548 | address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
| ^~~~~~~~~
Adding hw/core/cpu.h to system/qtest.c seems sufficient.
Otherwise,
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h'
2023-12-12 12:33 ` [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
@ 2023-12-13 11:46 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 11:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> int128_make128(), int128_getlo() and int128_urshift() are
> declared in "qemu/int128.h". qatomic_read__nocheck() is
> declared in "qemu/atomic.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> host/include/generic/host/load-extract-al16-al8.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/host/include/generic/host/load-extract-al16-al8.h b/host/include/generic/host/load-extract-al16-al8.h
> index d95556130f..6b47339b57 100644
> --- a/host/include/generic/host/load-extract-al16-al8.h
> +++ b/host/include/generic/host/load-extract-al16-al8.h
> @@ -8,6 +8,9 @@
> #ifndef HOST_LOAD_EXTRACT_AL16_AL8_H
> #define HOST_LOAD_EXTRACT_AL16_AL8_H
>
> +#include "qemu/atomic.h"
> +#include "qemu/int128.h"
> +
> /**
> * load_atom_extract_al16_or_al8:
> * @pv: host address
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header
2023-12-12 12:33 ` [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
@ 2023-12-13 11:56 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 11:56 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> qatomic_cmpxchg__nocheck(), qatomic_read__nocheck(),
> qatomic_set__nocheck() are defined in "qemu/atomic.h".
> Include it in order to avoid:
>
> In file included from include/exec/helper-proto.h:10:
> In file included from include/exec/helper-proto-common.h:10:
> In file included from include/qemu/atomic128.h:61:
> In file included from host/include/aarch64/host/atomic128-cas.h:16:
> host/include/generic/host/atomic128-cas.h:23:11: error: call to undeclared function 'qatomic_cmpxchg__nocheck'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> r.i = qatomic_cmpxchg__nocheck(ptr_align, c.i, n.i);
> ^
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> host/include/generic/host/atomic128-cas.h | 2 ++
> host/include/generic/host/atomic128-ldst.h | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/host/include/generic/host/atomic128-cas.h b/host/include/generic/host/atomic128-cas.h
> index 6b40cc2271..4824f14659 100644
> --- a/host/include/generic/host/atomic128-cas.h
> +++ b/host/include/generic/host/atomic128-cas.h
> @@ -11,6 +11,8 @@
> #ifndef HOST_ATOMIC128_CAS_H
> #define HOST_ATOMIC128_CAS_H
>
> +#include "qemu/atomic.h"
> +
> #if defined(CONFIG_ATOMIC128)
> static inline Int128 ATTRIBUTE_ATOMIC128_OPT
> atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new)
> diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h
> index 691e6a8531..12e4aca2da 100644
> --- a/host/include/generic/host/atomic128-ldst.h
> +++ b/host/include/generic/host/atomic128-ldst.h
> @@ -11,6 +11,8 @@
> #ifndef HOST_ATOMIC128_LDST_H
> #define HOST_ATOMIC128_LDST_H
>
> +#include "qemu/atomic.h"
> +
> #if defined(CONFIG_ATOMIC128)
> # define HAVE_ATOMIC128_RO 1
> # define HAVE_ATOMIC128_RW 1
> --
> 2.41.0
>
What about the int128.h includes? I guess those definitions are acquired
from atomic128.h that includes -cas.h/-ldst.h?
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header
2023-12-12 12:33 ` [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
@ 2023-12-13 13:38 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 13:38 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> tcg_cpu_init_cflags() accesses CPUState fields, so requires
> "hw/core/cpu.h" to get its structure definition.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> accel/tcg/tcg-accel-ops.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
> index 1b57290682..58806e2d7f 100644
> --- a/accel/tcg/tcg-accel-ops.c
> +++ b/accel/tcg/tcg-accel-ops.c
> @@ -37,6 +37,8 @@
> #include "exec/tb-flush.h"
> #include "exec/gdbstub.h"
>
> +#include "hw/core/cpu.h"
> +
> #include "tcg-accel-ops.h"
> #include "tcg-accel-ops-mttcg.h"
> #include "tcg-accel-ops-rr.h"
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header
2023-12-12 12:33 ` [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header Philippe Mathieu-Daudé
@ 2023-12-13 13:44 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 13:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> Nothing is required from the "qemu/thread.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/exec/cpu-all.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
> index 9a7b5737d3..26b44ca125 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -22,7 +22,6 @@
> #include "exec/cpu-common.h"
> #include "exec/memory.h"
> #include "exec/tswap.h"
> -#include "qemu/thread.h"
> #include "hw/core/cpu.h"
> #include "qemu/rcu.h"
>
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions
2023-12-12 12:33 ` [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions Philippe Mathieu-Daudé
@ 2023-12-13 13:44 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 13:44 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh
On 12/12/23, Philippe Mathieu-Daudé wrote:
> Last use of tswapls() was removed 2 years ago in commit
> aee14c77f4 ("linux-user: Rewrite do_getdents, do_getdents64").
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/exec/cpu-all.h | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
> index 5b5379b94c..b042d94892 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -38,11 +38,9 @@
>
> #if TARGET_LONG_SIZE == 4
> #define tswapl(s) tswap32(s)
> -#define tswapls(s) tswap32s((uint32_t *)(s))
> #define bswaptls(s) bswap32s(s)
> #else
> #define tswapl(s) tswap64(s)
> -#define tswapls(s) tswap64s((uint64_t *)(s))
> #define bswaptls(s) bswap64s(s)
> #endif
>
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h'
2023-12-12 12:33 ` [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' Philippe Mathieu-Daudé
@ 2023-12-13 13:45 ` Anton Johansson via
0 siblings, 0 replies; 36+ messages in thread
From: Anton Johansson via @ 2023-12-13 13:45 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh, Kyle Evans, Laurent Vivier
On 12/12/23, Philippe Mathieu-Daudé wrote:
> tswapl() and bswaptls() are target-dependent and only used
> by user emulation. Move their definitions to a new header:
> "exec/user/tswap-target.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> bsd-user/freebsd/target_os_elf.h | 1 +
> bsd-user/freebsd/target_os_stack.h | 1 +
> bsd-user/netbsd/target_os_elf.h | 1 +
> bsd-user/openbsd/target_os_elf.h | 1 +
> include/exec/cpu-all.h | 8 --------
> include/exec/user/abitypes.h | 1 +
> include/exec/user/tswap-target.h | 22 ++++++++++++++++++++++
> bsd-user/signal.c | 1 +
> bsd-user/strace.c | 1 +
> linux-user/elfload.c | 1 +
> linux-user/i386/signal.c | 1 +
> linux-user/ppc/signal.c | 1 +
> 12 files changed, 32 insertions(+), 8 deletions(-)
> create mode 100644 include/exec/user/tswap-target.h
>
> diff --git a/bsd-user/freebsd/target_os_elf.h b/bsd-user/freebsd/target_os_elf.h
> index 9df17d56d8..27d8ce036c 100644
> --- a/bsd-user/freebsd/target_os_elf.h
> +++ b/bsd-user/freebsd/target_os_elf.h
> @@ -22,6 +22,7 @@
>
> #include "target_arch_elf.h"
> #include "elf.h"
> +#include "exec/user/tswap-target.h"
>
> #define bsd_get_ncpu() 1 /* until we pull in bsd-proc.[hc] */
>
> diff --git a/bsd-user/freebsd/target_os_stack.h b/bsd-user/freebsd/target_os_stack.h
> index d15fc3263f..6125208182 100644
> --- a/bsd-user/freebsd/target_os_stack.h
> +++ b/bsd-user/freebsd/target_os_stack.h
> @@ -23,6 +23,7 @@
> #include <sys/param.h>
> #include "target_arch_sigtramp.h"
> #include "qemu/guest-random.h"
> +#include "exec/user/tswap-target.h"
>
> /*
> * The initial FreeBSD stack is as follows:
> diff --git a/bsd-user/netbsd/target_os_elf.h b/bsd-user/netbsd/target_os_elf.h
> index 2f3cb20871..23b422bfce 100644
> --- a/bsd-user/netbsd/target_os_elf.h
> +++ b/bsd-user/netbsd/target_os_elf.h
> @@ -22,6 +22,7 @@
>
> #include "target_arch_elf.h"
> #include "elf.h"
> +#include "exec/user/tswap-target.h"
>
> /* this flag is uneffective under linux too, should be deleted */
> #ifndef MAP_DENYWRITE
> diff --git a/bsd-user/openbsd/target_os_elf.h b/bsd-user/openbsd/target_os_elf.h
> index 6dca9c5a85..fc1dfa2e49 100644
> --- a/bsd-user/openbsd/target_os_elf.h
> +++ b/bsd-user/openbsd/target_os_elf.h
> @@ -22,6 +22,7 @@
>
> #include "target_arch_elf.h"
> #include "elf.h"
> +#include "exec/user/tswap-target.h"
>
> /* this flag is uneffective under linux too, should be deleted */
> #ifndef MAP_DENYWRITE
> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
> index b042d94892..95af418920 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -36,14 +36,6 @@
> #define BSWAP_NEEDED
> #endif
>
> -#if TARGET_LONG_SIZE == 4
> -#define tswapl(s) tswap32(s)
> -#define bswaptls(s) bswap32s(s)
> -#else
> -#define tswapl(s) tswap64(s)
> -#define bswaptls(s) bswap64s(s)
> -#endif
> -
> /* Target-endianness CPU memory access functions. These fit into the
> * {ld,st}{type}{sign}{size}{endian}_p naming scheme described in bswap.h.
> */
> diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
> index 6178453d94..ed10d5fe7e 100644
> --- a/include/exec/user/abitypes.h
> +++ b/include/exec/user/abitypes.h
> @@ -2,6 +2,7 @@
> #define EXEC_USER_ABITYPES_H
>
> #include "cpu.h"
> +#include "exec/user/tswap-target.h"
>
> #ifdef TARGET_ABI32
> #define TARGET_ABI_BITS 32
> diff --git a/include/exec/user/tswap-target.h b/include/exec/user/tswap-target.h
> new file mode 100644
> index 0000000000..ff302436fe
> --- /dev/null
> +++ b/include/exec/user/tswap-target.h
> @@ -0,0 +1,22 @@
> +/*
> + * target-specific swap() definitions
> + *
> + * Copyright (c) 2003 Fabrice Bellard
> + *
> + * SPDX-License-Identifier: LGPL-2.1-or-later
> + */
> +#ifndef EXEC_USER_TSWAP_H
> +#define EXEC_USER_TSWAP_H
> +
> +#include "exec/cpu-defs.h"
> +#include "exec/tswap.h"
> +
> +#if TARGET_LONG_SIZE == 4
> +#define tswapl(s) tswap32(s)
> +#define bswaptls(s) bswap32s(s)
> +#else
> +#define tswapl(s) tswap64(s)
> +#define bswaptls(s) bswap64s(s)
> +#endif
> +
> +#endif
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index ca31470772..7b2d25230a 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -21,6 +21,7 @@
> #include "qemu/osdep.h"
> #include "qemu/log.h"
> #include "qemu.h"
> +#include "exec/user/tswap-target.h"
> #include "gdbstub/user.h"
> #include "signal-common.h"
> #include "trace.h"
> diff --git a/bsd-user/strace.c b/bsd-user/strace.c
> index 96499751eb..a1b738e63c 100644
> --- a/bsd-user/strace.c
> +++ b/bsd-user/strace.c
> @@ -22,6 +22,7 @@
> #include <sys/ioccom.h>
>
> #include "qemu.h"
> +#include "exec/user/tswap-target.h"
>
> #include "os-strace.h" /* OS dependent strace print functions */
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index cf9e74468b..debea5c355 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -6,6 +6,7 @@
> #include <sys/shm.h>
>
> #include "qemu.h"
> +#include "exec/user/tswap-target.h"
> #include "user-internals.h"
> #include "signal-common.h"
> #include "loader.h"
> diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c
> index bc5d45302e..eea1fa68c9 100644
> --- a/linux-user/i386/signal.c
> +++ b/linux-user/i386/signal.c
> @@ -21,6 +21,7 @@
> #include "user-internals.h"
> #include "signal-common.h"
> #include "linux-user/trace.h"
> +#include "exec/user/tswap-target.h"
>
> /* from the Linux kernel - /arch/x86/include/uapi/asm/sigcontext.h */
>
> diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c
> index 7e7302823b..988b59a916 100644
> --- a/linux-user/ppc/signal.c
> +++ b/linux-user/ppc/signal.c
> @@ -21,6 +21,7 @@
> #include "user-internals.h"
> #include "signal-common.h"
> #include "linux-user/trace.h"
> +#include "exec/user/tswap-target.h"
> #include "vdso-asmoffset.h"
>
> /* See arch/powerpc/include/asm/ucontext.h. Only used for 32-bit PPC;
> --
> 2.41.0
>
Reviewed-by: Anton Johansson <anjo@rev.ng>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h'
2023-12-13 11:20 ` Anton Johansson via
@ 2023-12-13 15:13 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-13 15:13 UTC (permalink / raw)
To: Anton Johansson
Cc: qemu-devel, Claudio Fontana, qemu-ppc, qemu-s390x,
Richard Henderson, qemu-riscv, Brian Cain, Thomas Huth,
Paolo Bonzini, qemu-arm, Manos Pitsidianakis, Alex Bennée,
Warner Losh, Gerd Hoffmann, Michael S. Tsirkin, Alistair Francis,
Eduardo Habkost, Marcel Apfelbaum, Yanan Wang
On 13/12/23 12:20, Anton Johansson wrote:
> On 12/12/23, Philippe Mathieu-Daudé wrote:
>> We usually check target endianess before swapping values,
>> so target_words_bigendian() declaration makes sense in
>> "exec/tswap.h" with the target swapping helpers.
>>
>> Remove "hw/core/cpu.h" when it was only included to get
>> the target_words_bigendian() declaration.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> include/exec/tswap.h | 12 +++++++++++-
>> include/hw/core/cpu.h | 11 -----------
>> cpu-target.c | 1 +
>> disas/disas.c | 1 +
>> hw/audio/virtio-snd.c | 2 +-
>> hw/core/cpu-sysemu.c | 2 +-
>> hw/core/generic-loader.c | 2 +-
>> hw/display/vga.c | 2 +-
>> hw/virtio/virtio.c | 1 +
>> 9 files changed, 18 insertions(+), 16 deletions(-)
>>
>> diff --git a/include/exec/tswap.h b/include/exec/tswap.h
>> index 68944a880b..77954bbc2b 100644
>> --- a/include/exec/tswap.h
>> +++ b/include/exec/tswap.h
>> @@ -8,9 +8,19 @@
>> #ifndef TSWAP_H
>> #define TSWAP_H
>>
>> -#include "hw/core/cpu.h"
>> #include "qemu/bswap.h"
>
> This breaks system/qtest.c which gets first_cpu from hw/core/cpu.h
> through the inclusion of tswap.h...
>
> ../system/qtest.c:548:33: error: ‘first_cpu’ undeclared (first use in this function);
> 548 | address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
> | ^~~~~~~~~
Doh sorry, in this series I dropped some already reviewed patches,
and extracted some not-that-related series. I was lazy to add the
many 'Based-on:' tags on the cover.
What you mentioned here is fixed here:
https://lore.kernel.org/qemu-devel/20231212113016.29808-1-philmd@linaro.org/
> Adding hw/core/cpu.h to system/qtest.c seems sufficient.
>
> Otherwise,
> Reviewed-by: Anton Johansson <anjo@rev.ng>
Thanks!
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
2023-12-12 12:33 ` [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
@ 2023-12-14 18:27 ` Thomas Huth
0 siblings, 0 replies; 36+ messages in thread
From: Thomas Huth @ 2023-12-14 18:27 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh, Nicholas Piggin, Daniel Henrique Barboza,
Cédric Le Goater
On 12/12/2023 13.33, Philippe Mathieu-Daudé wrote:
> 'abi_ptr' is a user specific type. The system emulation
> equivalent is 'target_ulong'. Use it in ppc_ldl_code()
> to emphasis this is not an user emulation function.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> target/ppc/excp_helper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c
> index a42743a3e0..3d7c9bbf1a 100644
> --- a/target/ppc/excp_helper.c
> +++ b/target/ppc/excp_helper.c
> @@ -142,7 +142,7 @@ static inline bool insn_need_byteswap(CPUArchState *env)
> return !!(env->msr & ((target_ulong)1 << MSR_LE));
> }
>
> -static uint32_t ppc_ldl_code(CPUArchState *env, abi_ptr addr)
> +static uint32_t ppc_ldl_code(CPUArchState *env, target_ulong addr)
> {
> uint32_t insn = cpu_ldl_code(env, addr);
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h'
2023-12-12 12:33 ` [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
@ 2023-12-14 18:30 ` Thomas Huth
0 siblings, 0 replies; 36+ messages in thread
From: Thomas Huth @ 2023-12-14 18:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Claudio Fontana, qemu-ppc, qemu-s390x, Richard Henderson,
qemu-riscv, Brian Cain, Paolo Bonzini, qemu-arm,
Manos Pitsidianakis, Alex Bennée, Anton Johansson,
Warner Losh
On 12/12/2023 13.33, Philippe Mathieu-Daudé wrote:
> "exec/user/abitypes.h" requires:
>
> - "exec/cpu-defs.h" (TARGET_LONG_BITS)
> - "exec/tswap.h" (tswap32)
>
> In order to avoid "cpu.h", pick the minimum required headers.
>
> Assert this user-specific header is only included from user
> emulation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/exec/user/abitypes.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2023-12-14 18:31 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12 12:33 [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 01/23] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 02/23] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 03/23] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 04/23] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 05/23] gdbstub: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 06/23] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 07/23] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
2023-12-13 10:58 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 08/23] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
2023-12-13 11:46 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 09/23] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
2023-12-13 11:56 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 10/23] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 11/23] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
2023-12-13 13:38 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 12/23] exec/cpu-all: Remove unused 'qemu/thread.h' header Philippe Mathieu-Daudé
2023-12-13 13:44 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 13/23] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions Philippe Mathieu-Daudé
2023-12-13 13:44 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 15/23] exec: Declare target_words_bigendian() in 'exec/tswap.h' Philippe Mathieu-Daudé
2023-12-13 11:20 ` Anton Johansson via
2023-12-13 15:13 ` Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' Philippe Mathieu-Daudé
2023-12-13 13:45 ` Anton Johansson via
2023-12-12 12:33 ` [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
2023-12-14 18:27 ` Thomas Huth
2023-12-12 12:33 ` [PATCH v2 18/23] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
2023-12-14 18:30 ` Thomas Huth
2023-12-12 12:33 ` [PATCH v2 20/23] exec: Declare abi_ptr type in its own 'abi_ptr.h' header Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 22/23] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
2023-12-12 12:33 ` [PATCH v2 23/23] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2023-12-12 12:41 ` [PATCH v2 00/23] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
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).