All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] exec: Rework of various headers (user focused)
@ 2023-12-11 21:19 Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
                   ` (24 more replies)
  0 siblings, 25 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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.

Regards,

Phil.

Philippe Mathieu-Daudé (24):
  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
  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
  hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header
  hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header
  hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header
  target/i386: Include missing 'exec/exec-all.h' header
  accel/tcg: Include missing 'hw/core/cpu.h' header
  gdbstub: Include missing 'hw/core/cpu.h' header
  exec/cpu-all: Remove unused headers
  exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
  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 'tcg/abi_ptr.h' header
  exec/cpu_ldst: Avoid including 'cpu.h'
  exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
  exec/cpu-all: Extract page-protection definitions to
    page-prot-common.h
  target: Restrict 'sysemu/reset.h' to system emulation

 meson.build                                   |  2 +-
 accel/tcg/user-retaddr.h                      | 28 ++++++++++
 bsd-user/bsd-mem.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/cpu-all.h                        | 50 +++---------------
 include/exec/cpu_ldst.h                       | 51 ++++---------------
 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/user/abitypes.h                  |  9 +++-
 include/exec/user/guest-base.h                |  6 +++
 include/semihosting/uaccess.h                 |  3 +-
 include/tcg/abi_ptr.h                         | 32 ++++++++++++
 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                       |  6 +++
 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                             |  1 +
 cpu-target.c                                  |  1 +
 gdbstub/gdbstub.c                             |  1 +
 hw/misc/mips_itu.c                            |  3 +-
 hw/ppc/ppc440_bamboo.c                        |  1 +
 hw/ppc/sam460ex.c                             |  1 +
 hw/ppc/spapr_hcall.c                          |  1 -
 hw/ppc/virtex_ml507.c                         |  1 +
 hw/s390x/ipl.c                                |  1 -
 linux-user/arm/cpu_loop.c                     |  1 +
 linux-user/elfload.c                          |  2 +
 linux-user/main.c                             |  1 +
 linux-user/mmap.c                             |  1 +
 linux-user/nios2/cpu_loop.c                   |  1 +
 linux-user/signal.c                           |  1 +
 linux-user/syscall.c                          |  1 +
 page-target.c                                 | 43 ++++++++++++++++
 semihosting/guestfd.c                         |  1 -
 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/cpu.c                             |  2 +-
 target/i386/tcg/fpu_helper.c                  |  1 +
 target/i386/tcg/sysemu/excp_helper.c          |  1 +
 target/loongarch/cpu.c                        |  2 +
 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 +
 118 files changed, 332 insertions(+), 192 deletions(-)
 create mode 100644 accel/tcg/user-retaddr.h
 create mode 100644 include/exec/page-prot-common.h
 create mode 100644 include/tcg/abi_ptr.h
 create mode 100644 page-target.c

-- 
2.41.0



^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:53   ` Warner Losh
  2023-12-11 21:19 ` [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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] 56+ messages in thread

* [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:54   ` Warner Losh
  2023-12-11 22:14   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
                   ` (22 subsequent siblings)
  24 siblings, 2 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Marc-André Lureau

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>
---
 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] 56+ messages in thread

* [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:27   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2023-12-11 21:19 ` [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
                   ` (21 subsequent siblings)
  24 siblings, 3 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Michael Rolnik, Song Gao, Edgar E. Iglesias, Aurelien Jarno,
	Jiaxun Yang, Aleksandar Rikalo, Stafford Horne, Nicholas Piggin,
	Cédric Le Goater, Palmer Dabbelt, Alistair Francis,
	Bin Meng, Weiwei Li, 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>
---
 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       |  6 ++++++
 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, 64 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..4548103a18 100644
--- a/target/hppa/cpu-param.h
+++ b/target/hppa/cpu-param.h
@@ -21,4 +21,10 @@
 
 #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] 56+ messages in thread

* [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 22:20   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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] 56+ messages in thread

* [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 22:58   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
                   ` (19 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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] 56+ messages in thread

* [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:00   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 07/24] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
                   ` (18 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

Nothing in guestfd.c requires "semihosting/uaccess.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 semihosting/guestfd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
index 955c2efbd0..fd7e609790 100644
--- a/semihosting/guestfd.c
+++ b/semihosting/guestfd.c
@@ -15,7 +15,6 @@
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 #else
-#include "semihosting/uaccess.h"
 #include CONFIG_DEVICES
 #endif
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 07/24] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 08/24] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 08/24] host/atomic128: Include missing 'qemu/atomic.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 07/24] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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] 56+ messages in thread

* [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 08/24] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-22  4:37   ` Nicholas Piggin
  2023-12-11 21:19 ` [PATCH 10/24] hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header Philippe Mathieu-Daudé
                   ` (15 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Nicholas Piggin, Cédric Le Goater, David Gibson,
	Harsh Prateek Bora

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/ppc/spapr_hcall.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 522a2396c7..fcefd1d1c7 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -8,7 +8,6 @@
 #include "qemu/main-loop.h"
 #include "qemu/module.h"
 #include "qemu/error-report.h"
-#include "exec/exec-all.h"
 #include "exec/tb-flush.h"
 #include "helper_regs.h"
 #include "hw/ppc/ppc.h"
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 10/24] hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (8 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 11/24] hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Jiaxun Yang

mips_itu.c only requires declarations from "hw/core/cpu.h"
and "cpu.h". Avoid including the huge "exec/exec-all.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/misc/mips_itu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index 5a83ccc4e8..37aea0e737 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -22,9 +22,10 @@
 #include "qemu/log.h"
 #include "qemu/module.h"
 #include "qapi/error.h"
-#include "exec/exec-all.h"
+#include "hw/core/cpu.h"
 #include "hw/misc/mips_itu.h"
 #include "hw/qdev-properties.h"
+#include "target/mips/cpu.h"
 
 #define ITC_TAG_ADDRSPACE_SZ (ITC_ADDRESSMAP_NUM * 8)
 /* Initialize as 4kB area to fit all 32 cells with default 128B grain.
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 11/24] hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (9 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 10/24] hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Christian Borntraeger, Halil Pasic, Eric Farman

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/s390x/ipl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 515dcf51b5..62182d81a0 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -35,7 +35,6 @@
 #include "qemu/cutils.h"
 #include "qemu/option.h"
 #include "standard-headers/linux/virtio_ids.h"
-#include "exec/exec-all.h"
 
 #define KERN_IMAGE_START                0x010000UL
 #define LINUX_MAGIC_ADDR                0x010008UL
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (10 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 11/24] hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:04   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 13/24] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
                   ` (12 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

The XRSTOR instruction ends calling tlb_flush(), declared
in "exec/exec-all.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@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] 56+ messages in thread

* [PATCH 13/24] accel/tcg: Include missing 'hw/core/cpu.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (11 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 14/24] gdbstub: " Philippe Mathieu-Daudé
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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] 56+ messages in thread

* [PATCH 14/24] gdbstub: Include missing 'hw/core/cpu.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (12 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 13/24] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:57   ` Warner Losh
  2023-12-11 21:19 ` [PATCH 15/24] exec/cpu-all: Remove unused headers Philippe Mathieu-Daudé
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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] 56+ messages in thread

* [PATCH 15/24] exec/cpu-all: Remove unused headers
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (13 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 14/24] gdbstub: " Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:16   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
                   ` (9 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

Nothing is required from the "qemu/thread.h" and
"hw/core/cpu.h" headers.

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 9a7b5737d3..b1e293a08f 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -22,8 +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"
 
 /* some important defines:
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (14 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 15/24] exec/cpu-all: Remove unused headers Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:08   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
                   ` (8 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

"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>
---
 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 b1e293a08f..2d568ae4f0 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/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] 56+ messages in thread

* [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (15 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-22  4:37   ` Nicholas Piggin
  2023-12-11 21:19 ` [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Nicholas Piggin, 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] 56+ messages in thread

* [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (16 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:24   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 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] 56+ messages in thread

* [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (17 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 23:29   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

First, "exec/user/abitypes.h" is missing the following
includes (they are included by "cpu.h"):
 - "exec/target_long.h"
 - "exec/cpu-all.h"
 - "exec/tswap.h"
Second, it only requires the definitions from "cpu-param.h",
not the huge "cpu.h".

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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index 6178453d94..1a8cd1ac74 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -1,7 +1,14 @@
 #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 "cpu-param.h"
+#include "exec/target_long.h"
+#include "exec/cpu-all.h"
+#include "exec/tswap.h"
 
 #ifdef TARGET_ABI32
 #define TARGET_ABI_BITS 32
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (18 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:28   ` Philippe Mathieu-Daudé
  2023-12-12  1:18   ` Richard Henderson
  2023-12-11 21:19 ` [PATCH 21/24] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  24 siblings, 2 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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 "tcg/abi_ptr.h" header.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu_ldst.h   | 17 +++--------------
 include/exec/exec-all.h   |  1 +
 include/exec/translator.h |  5 ++++-
 include/tcg/abi_ptr.h     | 32 ++++++++++++++++++++++++++++++++
 accel/tcg/cputlb.c        |  1 +
 5 files changed, 41 insertions(+), 15 deletions(-)
 create mode 100644 include/tcg/abi_ptr.h

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index 25e7239cc5..c69f02b699 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -65,18 +65,9 @@
 #include "exec/memopidx.h"
 #include "qemu/int128.h"
 #include "cpu.h"
+#include "tcg/abi_ptr.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..6a634c0889 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 "tcg/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..16d2449292 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 "cpu.h"
+#include "tcg/abi_ptr.h"
 
 /**
  * gen_intermediate_code
diff --git a/include/tcg/abi_ptr.h b/include/tcg/abi_ptr.h
new file mode 100644
index 0000000000..415e31cabb
--- /dev/null
+++ b/include/tcg/abi_ptr.h
@@ -0,0 +1,32 @@
+/*
+ * TCG abi_ptr type
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef TCG_ABI_PTR_H
+#define TCG_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/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index db3f93fda9..c4500d3261 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -41,6 +41,7 @@
 #ifdef CONFIG_PLUGIN
 #include "qemu/plugin-memory.h"
 #endif
+#include "tcg/abi_ptr.h"
 #include "tcg/tcg-ldst.h"
 #include "tcg/oversized-guest.h"
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 21/24] exec/cpu_ldst: Avoid including 'cpu.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (19 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-11 21:19 ` [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé

"exec/cpu_ldst.h" doesn't need to huge "cpu.h" header,
but simply:

 - exec/cpu-defs.h
 - exec/tlb-common.h
 - exec/user/abitypes.h
 - exec/user/guest-base.h

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu_ldst.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index c69f02b699..a115553ee8 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -64,11 +64,15 @@
 
 #include "exec/memopidx.h"
 #include "qemu/int128.h"
-#include "cpu.h"
+#include "exec/cpu-defs.h"
+#include "exec/tlb-common.h"
 #include "tcg/abi_ptr.h"
 
 #if defined(CONFIG_USER_ONLY)
 
+#include "exec/user/abitypes.h"
+#include "exec/user/guest-base.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] 56+ messages in thread

* [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (20 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 21/24] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:19 ` Philippe Mathieu-Daudé
  2023-12-12  1:25   ` Richard Henderson
  2023-12-11 21:20 ` [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, 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>
---
 include/exec/cpu-all.h         | 3 ---
 include/exec/user/guest-base.h | 6 ++++++
 bsd-user/main.c                | 1 +
 linux-user/elfload.c           | 1 +
 linux-user/main.c              | 1 +
 5 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 2d568ae4f0..5b75d04ff6 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -74,9 +74,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/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 cf9e74468b..f9e9ac1760 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/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] 56+ messages in thread

* [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (21 preceding siblings ...)
  2023-12-11 21:19 ` [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:20 ` Philippe Mathieu-Daudé
  2023-12-22  8:06   ` Nicholas Piggin
  2023-12-11 21:20 ` [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation Philippe Mathieu-Daudé
  2023-12-11 21:22 ` [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
  24 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Riku Voipio, Kyle Evans, BALATON Zoltan, Edgar E. Iglesias,
	Laurent Vivier, Michael Rolnik, Song Gao, Huacai Chen,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Chris Wulff,
	Marek Vasut, Stafford Horne, Nicholas Piggin,
	Cédric Le Goater, Palmer Dabbelt, Alistair Francis,
	Bin Meng, Weiwei Li, Yoshinori Sato, 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 5b75d04ff6..881288a4de 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"
@@ -165,40 +166,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 c4500d3261..db154fe5ff 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 ca31470772..faf2062123 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 "gdbstub/user.h"
 #include "signal-common.h"
 #include "trace.h"
diff --git a/cpu-target.c b/cpu-target.c
index 997ca2e846..d1953ec037 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 f9e9ac1760..11c45ab293 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -7,6 +7,7 @@
 
 #include "qemu.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] 56+ messages in thread

* [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (22 preceding siblings ...)
  2023-12-11 21:20 ` [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
@ 2023-12-11 21:20 ` Philippe Mathieu-Daudé
  2023-12-11 21:58   ` Warner Losh
  2023-12-12  1:24   ` gaosong
  2023-12-11 21:22 ` [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
  24 siblings, 2 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Philippe Mathieu-Daudé,
	Song Gao

vCPU "reset" is only possible with system emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/i386/cpu.c      | 2 +-
 target/loongarch/cpu.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index dfb96217ad..17b6962d43 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -24,7 +24,6 @@
 #include "qemu/hw-version.h"
 #include "cpu.h"
 #include "tcg/helper-tcg.h"
-#include "sysemu/reset.h"
 #include "sysemu/hvf.h"
 #include "hvf/hvf-i386.h"
 #include "kvm/kvm_i386.h"
@@ -37,6 +36,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/i386/topology.h"
 #ifndef CONFIG_USER_ONLY
+#include "sysemu/reset.h"
 #include "qapi/qapi-commands-machine-target.h"
 #include "exec/address-spaces.h"
 #include "hw/boards.h"
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index fc075952e6..b26187dfde 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -17,7 +17,9 @@
 #include "internals.h"
 #include "fpu/softfloat-helpers.h"
 #include "cpu-csr.h"
+#ifndef CONFIG_USER_ONLY
 #include "sysemu/reset.h"
+#endif
 #include "tcg/tcg.h"
 #include "vec.h"
 
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH 00/24] exec: Rework of various headers (user focused)
  2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
                   ` (23 preceding siblings ...)
  2023-12-11 21:20 ` [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation Philippe Mathieu-Daudé
@ 2023-12-11 21:22 ` Philippe Mathieu-Daudé
  24 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:22 UTC (permalink / raw)
  To: qemu-devel, Anton Johansson, Alessandro Di Federico
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth

(Forgot to Cc rev.ng folks)

On 11/12/23 22:19, Philippe Mathieu-Daudé wrote:
> 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.
> 
> Regards,
> 
> Phil.
> 
> Philippe Mathieu-Daudé (24):
>    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
>    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
>    hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header
>    hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header
>    hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header
>    target/i386: Include missing 'exec/exec-all.h' header
>    accel/tcg: Include missing 'hw/core/cpu.h' header
>    gdbstub: Include missing 'hw/core/cpu.h' header
>    exec/cpu-all: Remove unused headers
>    exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
>    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 'tcg/abi_ptr.h' header
>    exec/cpu_ldst: Avoid including 'cpu.h'
>    exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
>    exec/cpu-all: Extract page-protection definitions to
>      page-prot-common.h
>    target: Restrict 'sysemu/reset.h' to system emulation



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
  2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
@ 2023-12-11 21:27   ` Philippe Mathieu-Daudé
  2023-12-11 22:18   ` Richard Henderson
  2023-12-22  4:36   ` Nicholas Piggin
  2 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Michael Rolnik, Song Gao, Edgar E. Iglesias,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Stafford Horne,
	Nicholas Piggin, Cédric Le Goater, Palmer Dabbelt,
	Alistair Francis, Bin Meng, Weiwei Li, Artyom Tarasenko,
	Max Filippov

On 11/12/23 22:19, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   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       |  6 ++++++
>   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, 64 insertions(+), 62 deletions(-)


> diff --git a/target/hppa/cpu-param.h b/target/hppa/cpu-param.h
> index bb3d7ef6f7..4548103a18 100644
> --- a/target/hppa/cpu-param.h
> +++ b/target/hppa/cpu-param.h
> @@ -21,4 +21,10 @@
>   
>   #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.  */

Forgot to squash:

-- >8 --
@@ -24,5 +24,7 @@
  /* 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.  */
+/*
+ * ??? 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



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header
  2023-12-11 21:19 ` [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header Philippe Mathieu-Daudé
@ 2023-12-11 21:28   ` Philippe Mathieu-Daudé
  2023-12-12  1:18   ` Richard Henderson
  1 sibling, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-11 21:28 UTC (permalink / raw)
  To: qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth

On 11/12/23 22:19, Philippe Mathieu-Daudé wrote:
> 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 "tcg/abi_ptr.h" header.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cpu_ldst.h   | 17 +++--------------
>   include/exec/exec-all.h   |  1 +
>   include/exec/translator.h |  5 ++++-
>   include/tcg/abi_ptr.h     | 32 ++++++++++++++++++++++++++++++++
>   accel/tcg/cputlb.c        |  1 +
>   5 files changed, 41 insertions(+), 15 deletions(-)
>   create mode 100644 include/tcg/abi_ptr.h
> 
> diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
> index 25e7239cc5..c69f02b699 100644
> --- a/include/exec/cpu_ldst.h
> +++ b/include/exec/cpu_ldst.h
> @@ -65,18 +65,9 @@
>   #include "exec/memopidx.h"
>   #include "qemu/int128.h"
>   #include "cpu.h"
> +#include "tcg/abi_ptr.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/tcg/abi_ptr.h b/include/tcg/abi_ptr.h
> new file mode 100644
> index 0000000000..415e31cabb
> --- /dev/null
> +++ b/include/tcg/abi_ptr.h
> @@ -0,0 +1,32 @@
> +/*
> + * TCG abi_ptr type
> + *
> + * SPDX-License-Identifier: LGPL-2.1-or-later
> + */
> +#ifndef TCG_ABI_PTR_H
> +#define TCG_ABI_PTR_H
> +
> +#include "cpu-param.h"
> +
> +#if defined(CONFIG_USER_ONLY)
> +/* sparc32plus has 64bit long but 32bit space address

Forgot to squash:

-- >8 --
@@ -11,3 +11,4 @@
  #if defined(CONFIG_USER_ONLY)
-/* sparc32plus has 64bit long but 32bit space address
+/*
+ * sparc32plus has 64bit long but 32bit space address
   * this can make bad result with g2h() and h2g()
---

> + * 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



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement
  2023-12-11 21:19 ` [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
@ 2023-12-11 21:53   ` Warner Losh
  2023-12-11 21:55     ` Warner Losh
  0 siblings, 1 reply; 56+ messages in thread
From: Warner Losh @ 2023-12-11 21:53 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Ilya Leoshkevich, Peter Xu, Liu Zhiwei,
	Peter Maydell, Mark Cave-Ayland, Eduardo Habkost, qemu-arm,
	Paolo Bonzini, qemu-ppc, qemu-s390x, Alex Bennée,
	Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Claudio Fontana, Brian Cain,
	Daniel Henrique Barboza, Richard Henderson, Thomas Huth

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

On Mon, Dec 11, 2023 at 2:20 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> 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>
> ---
>  include/exec/cpu-all.h | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>

Signed-off-by: Warner Losh <imp@bsdimp.com>

[-- Attachment #2: Type: text/html, Size: 912 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation
  2023-12-11 21:19 ` [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
@ 2023-12-11 21:54   ` Warner Losh
  2023-12-11 22:14   ` Richard Henderson
  1 sibling, 0 replies; 56+ messages in thread
From: Warner Losh @ 2023-12-11 21:54 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Ilya Leoshkevich, Peter Xu, Liu Zhiwei,
	Peter Maydell, Mark Cave-Ayland, Eduardo Habkost, qemu-arm,
	Paolo Bonzini, qemu-ppc, qemu-s390x, Alex Bennée,
	Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Claudio Fontana, Brian Cain,
	Daniel Henrique Barboza, Richard Henderson, Thomas Huth,
	Marc-André Lureau

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

On Mon, Dec 11, 2023 at 2:20 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> 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>
> ---
>  meson.build      |  2 +-
>  page-target.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
>  system/physmem.c | 35 -----------------------------------
>  3 files changed, 44 insertions(+), 36 deletions(-)
>  create mode 100644 page-target.c
>

Reviewed-by: Warner Losh <imp@bsdimp.com>

[-- Attachment #2: Type: text/html, Size: 1055 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement
  2023-12-11 21:53   ` Warner Losh
@ 2023-12-11 21:55     ` Warner Losh
  0 siblings, 0 replies; 56+ messages in thread
From: Warner Losh @ 2023-12-11 21:55 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Ilya Leoshkevich, Peter Xu, Liu Zhiwei,
	Peter Maydell, Mark Cave-Ayland, Eduardo Habkost, qemu-arm,
	Paolo Bonzini, qemu-ppc, qemu-s390x, Alex Bennée,
	Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Claudio Fontana, Brian Cain,
	Daniel Henrique Barboza, Richard Henderson, Thomas Huth

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

On Mon, Dec 11, 2023 at 2:53 PM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Mon, Dec 11, 2023 at 2:20 PM Philippe Mathieu-Daudé <philmd@linaro.org>
> wrote:
>
>> 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>
>> ---
>>  include/exec/cpu-all.h | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
>

Brain f**** I meant:

Reviewed-by: Warner Losh <imp@bsdimp.com>

[-- Attachment #2: Type: text/html, Size: 1456 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 14/24] gdbstub: Include missing 'hw/core/cpu.h' header
  2023-12-11 21:19 ` [PATCH 14/24] gdbstub: " Philippe Mathieu-Daudé
@ 2023-12-11 21:57   ` Warner Losh
  0 siblings, 0 replies; 56+ messages in thread
From: Warner Losh @ 2023-12-11 21:57 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Ilya Leoshkevich, Peter Xu, Liu Zhiwei,
	Peter Maydell, Mark Cave-Ayland, Eduardo Habkost, qemu-arm,
	Paolo Bonzini, qemu-ppc, qemu-s390x, Alex Bennée,
	Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Claudio Fontana, Brian Cain,
	Daniel Henrique Barboza, Richard Henderson, Thomas Huth

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Mon, Dec 11, 2023 at 2:22 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> 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>
> ---
>  gdbstub/gdbstub.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Warner Losh <imp@bsdimp.com>

[-- Attachment #2: Type: text/html, Size: 993 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation
  2023-12-11 21:20 ` [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation Philippe Mathieu-Daudé
@ 2023-12-11 21:58   ` Warner Losh
  2023-12-12  1:24   ` gaosong
  1 sibling, 0 replies; 56+ messages in thread
From: Warner Losh @ 2023-12-11 21:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Ilya Leoshkevich, Peter Xu, Liu Zhiwei,
	Peter Maydell, Mark Cave-Ayland, Eduardo Habkost, qemu-arm,
	Paolo Bonzini, qemu-ppc, qemu-s390x, Alex Bennée,
	Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Claudio Fontana, Brian Cain,
	Daniel Henrique Barboza, Richard Henderson, Thomas Huth,
	Song Gao

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

On Mon, Dec 11, 2023 at 2:23 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> vCPU "reset" is only possible with system emulation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  target/i386/cpu.c      | 2 +-
>  target/loongarch/cpu.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Warner Losh <imp@bsdimp.com>

[-- Attachment #2: Type: text/html, Size: 839 bytes --]

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation
  2023-12-11 21:19 ` [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
  2023-12-11 21:54   ` Warner Losh
@ 2023-12-11 22:14   ` Richard Henderson
  1 sibling, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 22:14 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   meson.build      |  2 +-
>   page-target.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
>   system/physmem.c | 35 -----------------------------------
>   3 files changed, 44 insertions(+), 36 deletions(-)
>   create mode 100644 page-target.c

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
  2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
  2023-12-11 21:27   ` Philippe Mathieu-Daudé
@ 2023-12-11 22:18   ` Richard Henderson
  2023-12-22  4:36   ` Nicholas Piggin
  2 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 22:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> 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>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header
  2023-12-11 21:19 ` [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
@ 2023-12-11 22:20   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 22:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> Theses files call cpu_ldl_code() which is declared
> in "exec/cpu_ldst.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@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(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h'
  2023-12-11 21:19 ` [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
@ 2023-12-11 22:58   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 22:58 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> "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>
> ---
>   include/semihosting/uaccess.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
  2023-12-11 21:19 ` [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
@ 2023-12-11 23:00   ` Richard Henderson
  2023-12-12 11:40     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:00 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> Nothing in guestfd.c requires "semihosting/uaccess.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   semihosting/guestfd.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
> index 955c2efbd0..fd7e609790 100644
> --- a/semihosting/guestfd.c
> +++ b/semihosting/guestfd.c
> @@ -15,7 +15,6 @@
>   #ifdef CONFIG_USER_ONLY
>   #include "qemu.h"
>   #else
> -#include "semihosting/uaccess.h"

Then I would be surprised if qemu.h is required either -- that's where uaccess is done for 
user-only.


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header
  2023-12-11 21:19 ` [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
@ 2023-12-11 23:04   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> The XRSTOR instruction ends calling tlb_flush(), declared
> in "exec/exec-all.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/i386/tcg/fpu_helper.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion
  2023-12-11 21:19 ` [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
@ 2023-12-11 23:08   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> "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>
> ---
>   include/exec/cpu-all.h  | 1 -
>   include/exec/ram_addr.h | 1 +
>   2 files changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 15/24] exec/cpu-all: Remove unused headers
  2023-12-11 21:19 ` [PATCH 15/24] exec/cpu-all: Remove unused headers Philippe Mathieu-Daudé
@ 2023-12-11 23:16   ` Richard Henderson
  2023-12-12 12:24     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Thomas Huth

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> Nothing is required from the "qemu/thread.h" and
> "hw/core/cpu.h" headers.
> 
> 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 9a7b5737d3..b1e293a08f 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -22,8 +22,6 @@
>   #include "exec/cpu-common.h"
>   #include "exec/memory.h"
>   #include "exec/tswap.h"
> -#include "qemu/thread.h"
> -#include "hw/core/cpu.h"

While thread.h is fine, I'm not sure removing hw/core/cpu.h from cpu-all.h is a good idea, 
and would explain the rather surprising changes to add core/cpu.h to other files.


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h'
  2023-12-11 21:19 ` [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
@ 2023-12-11 23:24   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> 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>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h'
  2023-12-11 21:19 ` [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
@ 2023-12-11 23:29   ` Richard Henderson
  2023-12-12 10:15     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 56+ messages in thread
From: Richard Henderson @ 2023-12-11 23:29 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> First, "exec/user/abitypes.h" is missing the following
> includes (they are included by "cpu.h"):
>   - "exec/target_long.h"
>   - "exec/cpu-all.h"
>   - "exec/tswap.h"
> Second, it only requires the definitions from "cpu-param.h",
> not the huge "cpu.h".
> 
> 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>

Why is cpu-all.h required?


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header
  2023-12-11 21:19 ` [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header Philippe Mathieu-Daudé
  2023-12-11 21:28   ` Philippe Mathieu-Daudé
@ 2023-12-12  1:18   ` Richard Henderson
  2023-12-12 10:13     ` Philippe Mathieu-Daudé
  1 sibling, 1 reply; 56+ messages in thread
From: Richard Henderson @ 2023-12-12  1:18 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> 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 "tcg/abi_ptr.h" header.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/exec/cpu_ldst.h   | 17 +++--------------
>   include/exec/exec-all.h   |  1 +
>   include/exec/translator.h |  5 ++++-
>   include/tcg/abi_ptr.h     | 32 ++++++++++++++++++++++++++++++++
>   accel/tcg/cputlb.c        |  1 +
>   5 files changed, 41 insertions(+), 15 deletions(-)
>   create mode 100644 include/tcg/abi_ptr.h

I'm unconvinced about this being tcg related, per se.
Leave it in include/exec/, with exec/user/abitypes.h.

With that,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation
  2023-12-11 21:20 ` [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation Philippe Mathieu-Daudé
  2023-12-11 21:58   ` Warner Losh
@ 2023-12-12  1:24   ` gaosong
  1 sibling, 0 replies; 56+ messages in thread
From: gaosong @ 2023-12-12  1:24 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth

在 2023/12/12 上午5:20, Philippe Mathieu-Daudé 写道:
> vCPU "reset" is only possible with system emulation.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/i386/cpu.c      | 2 +-
>   target/loongarch/cpu.c | 2 ++
>   2 files changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index dfb96217ad..17b6962d43 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -24,7 +24,6 @@
>   #include "qemu/hw-version.h"
>   #include "cpu.h"
>   #include "tcg/helper-tcg.h"
> -#include "sysemu/reset.h"
>   #include "sysemu/hvf.h"
>   #include "hvf/hvf-i386.h"
>   #include "kvm/kvm_i386.h"
> @@ -37,6 +36,7 @@
>   #include "hw/qdev-properties.h"
>   #include "hw/i386/topology.h"
>   #ifndef CONFIG_USER_ONLY
> +#include "sysemu/reset.h"
>   #include "qapi/qapi-commands-machine-target.h"
>   #include "exec/address-spaces.h"
>   #include "hw/boards.h"
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index fc075952e6..b26187dfde 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -17,7 +17,9 @@
>   #include "internals.h"
>   #include "fpu/softfloat-helpers.h"
>   #include "cpu-csr.h"
> +#ifndef CONFIG_USER_ONLY
>   #include "sysemu/reset.h"
> +#endif
>   #include "tcg/tcg.h"
>   #include "vec.h"
>   



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h'
  2023-12-11 21:19 ` [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
@ 2023-12-12  1:25   ` Richard Henderson
  0 siblings, 0 replies; 56+ messages in thread
From: Richard Henderson @ 2023-12-12  1:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel

On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
> 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>
> ---
>   include/exec/cpu-all.h         | 3 ---
>   include/exec/user/guest-base.h | 6 ++++++
>   bsd-user/main.c                | 1 +
>   linux-user/elfload.c           | 1 +
>   linux-user/main.c              | 1 +
>   5 files changed, 9 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header
  2023-12-12  1:18   ` Richard Henderson
@ 2023-12-12 10:13     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 10:13 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 12/12/23 02:18, Richard Henderson wrote:
> On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
>> 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 "tcg/abi_ptr.h" header.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/exec/cpu_ldst.h   | 17 +++--------------
>>   include/exec/exec-all.h   |  1 +
>>   include/exec/translator.h |  5 ++++-
>>   include/tcg/abi_ptr.h     | 32 ++++++++++++++++++++++++++++++++
>>   accel/tcg/cputlb.c        |  1 +
>>   5 files changed, 41 insertions(+), 15 deletions(-)
>>   create mode 100644 include/tcg/abi_ptr.h
> 
> I'm unconvinced about this being tcg related, per se.

Indeed:

$ git grep -w abi_ptr -- tcg
$

> Leave it in include/exec/, with exec/user/abitypes.h.
> 
> With that,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Thanks!



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h'
  2023-12-11 23:29   ` Richard Henderson
@ 2023-12-12 10:15     ` Philippe Mathieu-Daudé
  2023-12-12 10:45       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 10:15 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 12/12/23 00:29, Richard Henderson wrote:
> On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
>> First, "exec/user/abitypes.h" is missing the following
>> includes (they are included by "cpu.h"):
>>   - "exec/target_long.h"
>>   - "exec/cpu-all.h"
>>   - "exec/tswap.h"
>> Second, it only requires the definitions from "cpu-param.h",
>> not the huge "cpu.h".
>>
>> 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>
> 
> Why is cpu-all.h required?

include/exec/user/abitypes.h:85:12: error: implicit declaration of 
function ‘tswapl’; did you mean ‘tswapal’? 
[-Werror=implicit-function-declaration]
    85 |     return tswapl(v);
       |            ^~~~~~
       |            tswapal

$ git grep -w tswapl include
include/exec/cpu-all.h:40:#define tswapl(s) tswap32(s)
include/exec/cpu-all.h:44:#define tswapl(s) tswap64(s)
include/exec/user/abitypes.h:85:    return tswapl(v);

OK, I'll move tswapl() declarations to exec/user/abitypes.h.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h'
  2023-12-12 10:15     ` Philippe Mathieu-Daudé
@ 2023-12-12 10:45       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 10:45 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 12/12/23 11:15, Philippe Mathieu-Daudé wrote:
> On 12/12/23 00:29, Richard Henderson wrote:
>> On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
>>> First, "exec/user/abitypes.h" is missing the following
>>> includes (they are included by "cpu.h"):
>>>   - "exec/target_long.h"
>>>   - "exec/cpu-all.h"
>>>   - "exec/tswap.h"
>>> Second, it only requires the definitions from "cpu-param.h",
>>> not the huge "cpu.h".
>>>
>>> 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>
>>
>> Why is cpu-all.h required?
> 
> include/exec/user/abitypes.h:85:12: error: implicit declaration of 
> function ‘tswapl’; did you mean ‘tswapal’? 
> [-Werror=implicit-function-declaration]
>     85 |     return tswapl(v);
>        |            ^~~~~~
>        |            tswapal
> 
> $ git grep -w tswapl include
> include/exec/cpu-all.h:40:#define tswapl(s) tswap32(s)
> include/exec/cpu-all.h:44:#define tswapl(s) tswap64(s)
> include/exec/user/abitypes.h:85:    return tswapl(v);
> 
> OK, I'll move tswapl() declarations to exec/user/abitypes.h.

Better, to a new header.



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header
  2023-12-11 23:00   ` Richard Henderson
@ 2023-12-12 11:40     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 11:40 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

On 12/12/23 00:00, Richard Henderson wrote:
> On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
>> Nothing in guestfd.c requires "semihosting/uaccess.h".
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   semihosting/guestfd.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c
>> index 955c2efbd0..fd7e609790 100644
>> --- a/semihosting/guestfd.c
>> +++ b/semihosting/guestfd.c
>> @@ -15,7 +15,6 @@
>>   #ifdef CONFIG_USER_ONLY
>>   #include "qemu.h"
>>   #else
>> -#include "semihosting/uaccess.h"
> 
> Then I would be surprised if qemu.h is required either -- that's where 
> uaccess is done for user-only.

Indeed we can remove it.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 15/24] exec/cpu-all: Remove unused headers
  2023-12-11 23:16   ` Richard Henderson
@ 2023-12-12 12:24     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-12 12:24 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Thomas Huth

On 12/12/23 00:16, Richard Henderson wrote:
> On 12/11/23 13:19, Philippe Mathieu-Daudé wrote:
>> Nothing is required from the "qemu/thread.h" and
>> "hw/core/cpu.h" headers.
>>
>> 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 9a7b5737d3..b1e293a08f 100644
>> --- a/include/exec/cpu-all.h
>> +++ b/include/exec/cpu-all.h
>> @@ -22,8 +22,6 @@
>>   #include "exec/cpu-common.h"
>>   #include "exec/memory.h"
>>   #include "exec/tswap.h"
>> -#include "qemu/thread.h"
>> -#include "hw/core/cpu.h"
> 
> While thread.h is fine, I'm not sure removing hw/core/cpu.h from 
> cpu-all.h is a good idea, and would explain the rather surprising 
> changes to add core/cpu.h to other files.

"hw/core/cpu.h" defines the CPUState structure. Any code that
deref CPUState needs to include its definition from "hw/core/cpu.h".

Similarly, files that don't deref CPUState/CPUClass/cpu_foo methods
shouldn't be polluted by its declarations.

This series focuses on useremu, next comes sysemu and "exec/cpu-all.h"
is split. I'll see if I can postpone this change.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h'
  2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
  2023-12-11 21:27   ` Philippe Mathieu-Daudé
  2023-12-11 22:18   ` Richard Henderson
@ 2023-12-22  4:36   ` Nicholas Piggin
  2 siblings, 0 replies; 56+ messages in thread
From: Nicholas Piggin @ 2023-12-22  4:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Michael Rolnik, Song Gao, Edgar E. Iglesias,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Stafford Horne,
	Cédric Le Goater, Palmer Dabbelt, Alistair Francis,
	Bin Meng, Weiwei Li, Artyom Tarasenko, Max Filippov

On Tue Dec 12, 2023 at 7:19 AM AEST, Philippe Mathieu-Daudé wrote:
> 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.

Acked-by: Nicholas Piggin <npiggin@gmail.com> (ppc)

Thanks,
Nick


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header
  2023-12-11 21:19 ` [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
@ 2023-12-22  4:37   ` Nicholas Piggin
  0 siblings, 0 replies; 56+ messages in thread
From: Nicholas Piggin @ 2023-12-22  4:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Cédric Le Goater, David Gibson,
	Harsh Prateek Bora

On Tue Dec 12, 2023 at 7:19 AM AEST, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Acked-by: Nicholas Piggin <npiggin@gmail.com>

> ---
>  hw/ppc/spapr_hcall.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 522a2396c7..fcefd1d1c7 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -8,7 +8,6 @@
>  #include "qemu/main-loop.h"
>  #include "qemu/module.h"
>  #include "qemu/error-report.h"
> -#include "exec/exec-all.h"
>  #include "exec/tb-flush.h"
>  #include "helper_regs.h"
>  #include "hw/ppc/ppc.h"



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation
  2023-12-11 21:19 ` [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
@ 2023-12-22  4:37   ` Nicholas Piggin
  0 siblings, 0 replies; 56+ messages in thread
From: Nicholas Piggin @ 2023-12-22  4:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Cédric Le Goater

On Tue Dec 12, 2023 at 7:19 AM AEST, 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>

Acked-by: Nicholas Piggin <npiggin@gmail.com>

> ---
>  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);
>  



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h
  2023-12-11 21:20 ` [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
@ 2023-12-22  8:06   ` Nicholas Piggin
  2023-12-26 15:22     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 56+ messages in thread
From: Nicholas Piggin @ 2023-12-22  8:06 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Riku Voipio, Kyle Evans, BALATON Zoltan,
	Edgar E. Iglesias, Laurent Vivier, Michael Rolnik, Song Gao,
	Huacai Chen, Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo,
	Chris Wulff, Marek Vasut, Stafford Horne, Cédric Le Goater,
	Palmer Dabbelt, Alistair Francis, Bin Meng, Weiwei Li,
	Yoshinori Sato, Artyom Tarasenko, Bastian Koppelmann,
	Max Filippov

On Tue Dec 12, 2023 at 7:20 AM AEST, Philippe Mathieu-Daudé wrote:
> 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)'

Acked-by: Nicholas Piggin <npiggin@gmail.com> (ppc)

Looks trivial for ppc, so fine. But what's the difference between
-common.h and -all.h suffix?

Thanks,
Nick


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h
  2023-12-22  8:06   ` Nicholas Piggin
@ 2023-12-26 15:22     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 56+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-26 15:22 UTC (permalink / raw)
  To: Nicholas Piggin, qemu-devel
  Cc: Ilya Leoshkevich, Peter Xu, Liu Zhiwei, Peter Maydell,
	Mark Cave-Ayland, Eduardo Habkost, qemu-arm, Paolo Bonzini,
	qemu-ppc, qemu-s390x, Alex Bennée, Daniel P. Berrangé,
	qemu-riscv, David Hildenbrand, Warner Losh, Claudio Fontana,
	Brian Cain, Daniel Henrique Barboza, Richard Henderson,
	Thomas Huth, Riku Voipio, Kyle Evans, BALATON Zoltan,
	Edgar E. Iglesias, Laurent Vivier, Michael Rolnik, Song Gao,
	Huacai Chen, Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo,
	Chris Wulff, Marek Vasut, Stafford Horne, Cédric Le Goater,
	Palmer Dabbelt, Alistair Francis, Bin Meng, Weiwei Li,
	Yoshinori Sato, Artyom Tarasenko, Bastian Koppelmann,
	Max Filippov

Hi Nicholas,

On 22/12/23 09:06, Nicholas Piggin wrote:
> On Tue Dec 12, 2023 at 7:20 AM AEST, Philippe Mathieu-Daudé wrote:
>> 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)'
> 
> Acked-by: Nicholas Piggin <npiggin@gmail.com> (ppc)
> 
> Looks trivial for ppc, so fine. But what's the difference between
> -common.h and -all.h suffix?

We believe historically '-all' was used for target-specific
headers. However then headers got massaged and some ended
using this suffix, although not anymore target specific.

Today for clarity we prefer using '-common' for generic
(target agnostic) headers, and '-target' for target-specific
ones.

I tried to clarify that here:
https://lore.kernel.org/qemu-devel/20231226150441.97501-1-philmd@linaro.org/

Thanks for your review,

Phil.


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2023-12-26 15:23 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 21:19 [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 01/24] exec: Include 'cpu.h' before validating CPUArchState placement Philippe Mathieu-Daudé
2023-12-11 21:53   ` Warner Losh
2023-12-11 21:55     ` Warner Losh
2023-12-11 21:19 ` [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Philippe Mathieu-Daudé
2023-12-11 21:54   ` Warner Losh
2023-12-11 22:14   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 03/24] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h' Philippe Mathieu-Daudé
2023-12-11 21:27   ` Philippe Mathieu-Daudé
2023-12-11 22:18   ` Richard Henderson
2023-12-22  4:36   ` Nicholas Piggin
2023-12-11 21:19 ` [PATCH 04/24] accel: Include missing 'exec/cpu_ldst.h' header Philippe Mathieu-Daudé
2023-12-11 22:20   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 05/24] semihosting/uaccess: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2023-12-11 22:58   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 06/24] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header Philippe Mathieu-Daudé
2023-12-11 23:00   ` Richard Henderson
2023-12-12 11:40     ` Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 07/24] host/load-extract: Include missing 'qemu/atomic.h' and 'qemu/int128.h' Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 08/24] host/atomic128: Include missing 'qemu/atomic.h' header Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 09/24] hw/ppc/spapr_hcall: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
2023-12-22  4:37   ` Nicholas Piggin
2023-12-11 21:19 ` [PATCH 10/24] hw/misc/mips_itu: Remove unnecessary 'exec/exec-all.h' header Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 11/24] hw/s390x/ipl: Remove unused 'exec/exec-all.h' included header Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 12/24] target/i386: Include missing 'exec/exec-all.h' header Philippe Mathieu-Daudé
2023-12-11 23:04   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 13/24] accel/tcg: Include missing 'hw/core/cpu.h' header Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 14/24] gdbstub: " Philippe Mathieu-Daudé
2023-12-11 21:57   ` Warner Losh
2023-12-11 21:19 ` [PATCH 15/24] exec/cpu-all: Remove unused headers Philippe Mathieu-Daudé
2023-12-11 23:16   ` Richard Henderson
2023-12-12 12:24     ` Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 16/24] exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion Philippe Mathieu-Daudé
2023-12-11 23:08   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 17/24] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation Philippe Mathieu-Daudé
2023-12-22  4:37   ` Nicholas Piggin
2023-12-11 21:19 ` [PATCH 18/24] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Philippe Mathieu-Daudé
2023-12-11 23:24   ` Richard Henderson
2023-12-11 21:19 ` [PATCH 19/24] exec/user: Do not include 'cpu.h' in 'abitypes.h' Philippe Mathieu-Daudé
2023-12-11 23:29   ` Richard Henderson
2023-12-12 10:15     ` Philippe Mathieu-Daudé
2023-12-12 10:45       ` Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 20/24] exec: Declare abi_ptr type in its own 'tcg/abi_ptr.h' header Philippe Mathieu-Daudé
2023-12-11 21:28   ` Philippe Mathieu-Daudé
2023-12-12  1:18   ` Richard Henderson
2023-12-12 10:13     ` Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 21/24] exec/cpu_ldst: Avoid including 'cpu.h' Philippe Mathieu-Daudé
2023-12-11 21:19 ` [PATCH 22/24] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' Philippe Mathieu-Daudé
2023-12-12  1:25   ` Richard Henderson
2023-12-11 21:20 ` [PATCH 23/24] exec/cpu-all: Extract page-protection definitions to page-prot-common.h Philippe Mathieu-Daudé
2023-12-22  8:06   ` Nicholas Piggin
2023-12-26 15:22     ` Philippe Mathieu-Daudé
2023-12-11 21:20 ` [PATCH 24/24] target: Restrict 'sysemu/reset.h' to system emulation Philippe Mathieu-Daudé
2023-12-11 21:58   ` Warner Losh
2023-12-12  1:24   ` gaosong
2023-12-11 21:22 ` [PATCH 00/24] exec: Rework of various headers (user focused) Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.