Skip to contentSkip to conversation

accel/tcg: Extract user APIs out of 'exec/[cpu, exec]-all.h'

PATCH In review Philippe Mathieu-Daudé 3 participants 43 messages Dec 12, 2024 – Dec 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover accel/tcg: Extract user APIs out of 'exec/[cpu, exec]-all.h'

The goal of this series is to clarify user emulation APIs, and clean the mixed bag of exec/foo-all.h headers.

Move user specific declarations out of the generic
- "exec/cpu-all.h",
- "exec/cpu_ldst.h",
- "exec/exec-all.h" and
- "exec/translate-all.h"
to the generic:
- "accel/tcg/tb-internal.h" and
- "exec/page-protection.h"
and the user specific:
- "user/cpu_loop.h",
- "user/guest-host.h" and
- "user/page-protection.h"

Philippe Mathieu-Daudé (18):
exec: Introduce 'user/guest-host.h' header linux-user/aarch64: Include missing 'user/abitypes.h' header
include: Include missing 'qemu/clang-tsa.h' header accel/tcg: Declare mmap_[un]lock() in 'exec/page-protection.h' accel/tcg: Use tb_page_addr_t type in page_unprotect() accel/tcg: Move page_[un]protect() to 'user/page-protection.h'
system: Remove unnecessary 'exec/translate-all.h' include accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h' accel/tcg: Un-inline log_pc()
accel/tcg: Move TranslationBlock declarations to 'tb-internal.h' accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'

    (1/4)
  accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
    (2/4)
  accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
    (3/4)
  accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
    (4/4)

user: Forward declare target_cpu_copy_regs structure
user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h'
user: Declare cpu_loop() once in 'user/cpu_loop.h'
user: Move various declarations out of 'exec/exec-all.h'

 accel/tcg/internal-target.h          |  43 +---------
 accel/tcg/tb-internal.h              |  53 +++++++++++++
 bsd-user/bsd-mem.h                   |   1 +
 bsd-user/qemu.h                      |   3 +-
 include/block/block_int-common.h     |   1 +
 include/exec/cpu-all.h               | 112 +--------------------------
 include/exec/cpu_ldst.h              |  47 +----------
 include/exec/exec-all.h              |  72 +----------------
 include/exec/page-protection.h       |  24 ++++++
 include/exec/translate-all.h         |  33 --------
 include/user/cpu_loop.h              |  90 +++++++++++++++++++++
 include/user/guest-host.h            |  87 +++++++++++++++++++++
 include/user/page-protection.h       |  99 +++++++++++++++++++++++
 linux-user/aarch64/mte_user_helper.h |   2 +
 linux-user/cpu_loop-common.h         |  31 --------
 linux-user/qemu.h                    |   1 +
 linux-user/user-internals.h          |   1 -
 accel/tcg/cpu-exec.c                 |  13 ++++
 accel/tcg/cputlb.c                   |   3 +-
 accel/tcg/tb-maint.c                 |   6 +-
 accel/tcg/translate-all.c            |   4 +-
 accel/tcg/translator.c               |   1 +
 accel/tcg/user-exec.c                |   6 +-
 accel/tcg/watchpoint.c               |   3 +-
 block/create.c                       |   1 +
 bsd-user/main.c                      |   1 +
 bsd-user/mmap.c                      |   1 +
 bsd-user/signal.c                    |   2 +
 cpu-target.c                         |   2 +-
 linux-user/aarch64/cpu_loop.c        |   4 +-
 linux-user/alpha/cpu_loop.c          |   4 +-
 linux-user/arm/cpu_loop.c            |   5 +-
 linux-user/elfload.c                 |   2 +-
 linux-user/flatload.c                |   1 +
 linux-user/hexagon/cpu_loop.c        |   4 +-
 linux-user/hppa/cpu_loop.c           |   4 +-
 linux-user/i386/cpu_loop.c           |   4 +-
 linux-user/loongarch64/cpu_loop.c    |   4 +-
 linux-user/m68k/cpu_loop.c           |   4 +-
 linux-user/main.c                    |   3 +-
 linux-user/microblaze/cpu_loop.c     |   4 +-
 linux-user/mips/cpu_loop.c           |   4 +-
 linux-user/mmap.c                    |   1 +
 linux-user/openrisc/cpu_loop.c       |   4 +-
 linux-user/ppc/cpu_loop.c            |   4 +-
 linux-user/riscv/cpu_loop.c          |   4 +-
 linux-user/s390x/cpu_loop.c          |   4 +-
 linux-user/sh4/cpu_loop.c            |   4 +-
 linux-user/signal.c                  |   2 +
 linux-user/sparc/cpu_loop.c          |   4 +-
 linux-user/syscall.c                 |   3 +-
 linux-user/xtensa/cpu_loop.c         |   4 +-
 system/physmem.c                     |   1 -
 target/arm/helper.c                  |   1 +
 target/arm/tcg/helper-a64.c          |   3 +
 target/arm/tcg/mte_helper.c          |   4 +
 target/arm/tcg/sve_helper.c          |   3 +
 target/hppa/op_helper.c              |   3 +
 target/s390x/tcg/mem_helper.c        |   4 +-
 target/sparc/ldst_helper.c           |   3 +
 tests/unit/test-bdrv-drain.c         |   1 +
 tests/unit/test-block-iothread.c     |   1 +
 util/qemu-thread-posix.c             |   1 +
 63 files changed, 467 insertions(+), 382 deletions(-)
 create mode 100644 accel/tcg/tb-internal.h
 delete mode 100644 include/exec/translate-all.h
 create mode 100644 include/user/cpu_loop.h
 create mode 100644 include/user/guest-host.h
 create mode 100644 include/user/page-protection.h
 delete mode 100644 linux-user/cpu_loop-common.h
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/18 exec: Introduce 'user/guest-host.h' header

Extract all declarations related to 'guest from/to host' address translation to a new "user/guest-host.h" header.

---
 include/exec/cpu-all.h    | 34 +--------------
 include/exec/cpu_ldst.h   | 47 +--------------------
 include/user/guest-host.h | 87 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 79 deletions(-)
 create mode 100644 include/user/guest-host.h
include/exec/cpu-all.h +1 -33
index 1c40e276728..1c8e0446d06 100644
@@ -64,39 +64,7 @@
 
 /* MMU memory access macros */
 
-#if defined(CONFIG_USER_ONLY)
-#include "user/abitypes.h"
-
-/*
- * If non-zero, the guest virtual address space is a contiguous subset
- * of the host virtual address space, i.e. '-R reserved_va' is in effect
- * either from the command-line or by default.  The value is the last
- * byte of the guest address space e.g. UINT32_MAX.
- *
- * If zero, the host and guest virtual address spaces are intermingled.
- */
-extern unsigned long reserved_va;
-
-/*
- * Limit the guest addresses as best we can.
- *
- * When not using -R reserved_va, we cannot really limit the guest
- * to less address space than the host.  For 32-bit guests, this
- * acts as a sanity check that we're not giving the guest an address
- * that it cannot even represent.  For 64-bit guests... the address
- * might not be what the real kernel would give, but it is at least
- * representable in the guest.
- *
- * TODO: Improve address allocation to avoid this problem, and to
- * avoid setting bits at the top of guest addresses that might need
- * to be used for tags.
- */
-#define GUEST_ADDR_MAX_                                                 \
-    ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ?  \
-     UINT32_MAX : ~0ul)
-#define GUEST_ADDR_MAX    (reserved_va ? : GUEST_ADDR_MAX_)
-
-#else
+#if !defined(CONFIG_USER_ONLY)
 
 #include "exec/hwaddr.h"
 
include/exec/cpu_ldst.h +1 -46

53 lines not on this page · raw message

include/user/guest-host.h new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
2.45.2
Reviewed-by on v1 1/18
#2 lore raw

Re: [PATCH 01/18] exec: Introduce 'user/guest-host.h' header

Quoted 199 lines · Philippe Mathieu-Daudé

Extract all declarations related to 'guest from/to host' address translation to a new "user/guest-host.h" header.

---
  include/exec/cpu-all.h    | 34 +--------------
  include/exec/cpu_ldst.h   | 47 +--------------------
  include/user/guest-host.h | 87 +++++++++++++++++++++++++++++++++++++++
  3 files changed, 89 insertions(+), 79 deletions(-)

create mode 100644 include/user/guest-host.h

include/exec/cpu-all.h +1 -33
index 1c40e276728..1c8e0446d06 100644
@@ -64,39 +64,7 @@
 
  /* MMU memory access macros */
 
-#if defined(CONFIG_USER_ONLY)
-#include "user/abitypes.h"
-
-/*
- * If non-zero, the guest virtual address space is a contiguous subset
- * of the host virtual address space, i.e. '-R reserved_va' is in effect
- * either from the command-line or by default.  The value is the last
- * byte of the guest address space e.g. UINT32_MAX.
- *
- * If zero, the host and guest virtual address spaces are intermingled.
- */
-extern unsigned long reserved_va;
-
-/*
- * Limit the guest addresses as best we can.
- *
- * When not using -R reserved_va, we cannot really limit the guest
- * to less address space than the host.  For 32-bit guests, this
- * acts as a sanity check that we're not giving the guest an address
- * that it cannot even represent.  For 64-bit guests... the address
- * might not be what the real kernel would give, but it is at least
- * representable in the guest.
- *
- * TODO: Improve address allocation to avoid this problem, and to
- * avoid setting bits at the top of guest addresses that might need
- * to be used for tags.
- */
-#define GUEST_ADDR_MAX_                                                 \
-    ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ?  \
-     UINT32_MAX : ~0ul)
-#define GUEST_ADDR_MAX    (reserved_va ? : GUEST_ADDR_MAX_)
-
-#else
+#if !defined(CONFIG_USER_ONLY)
 
  #include "exec/hwaddr.h"
 
include/exec/cpu_ldst.h +1 -46
index dac12bd8eb3..a26ab49b0b4 100644
@@ -72,52 +72,7 @@
  #include "qemu/int128.h"
 
  #if defined(CONFIG_USER_ONLY)
-
-#include "user/guest-base.h"
-
-#ifndef TARGET_TAGGED_ADDRESSES
-static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
-{
-    return x;
-}
-#endif
-
-/* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
-static inline void *g2h_untagged(abi_ptr x)
-{
-    return (void *)((uintptr_t)(x) + guest_base);
-}
-
-static inline void *g2h(CPUState *cs, abi_ptr x)
-{
-    return g2h_untagged(cpu_untagged_addr(cs, x));
-}
-
-static inline bool guest_addr_valid_untagged(abi_ulong x)
-{
-    return x <= GUEST_ADDR_MAX;
-}
-
-static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
-{
-    return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1;
-}
-
-#define h2g_valid(x) \
-    (HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS || \
-     (uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX)
-
-#define h2g_nocheck(x) ({ \
-    uintptr_t __ret = (uintptr_t)(x) - guest_base; \
-    (abi_ptr)__ret; \
-})
-
-#define h2g(x) ({ \
-    /* Check if given address fits target address space */ \
-    assert(h2g_valid(x)); \
-    h2g_nocheck(x); \
-})
-
+#include "user/guest-host.h"
  #endif /* CONFIG_USER_ONLY */
 
  uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
include/user/guest-host.h new file +77 -0
new file mode 100644
index 00000000000..8d2079bbbba
@@ -0,0 +1,87 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * guest <-> host helpers.
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ */
+
+#ifndef USER_GUEST_HOST_H
+#define USER_GUEST_HOST_H
+
+#include "user/abitypes.h"
+#include "user/guest-base.h"
+#include "cpu.h"
+
+/*
+ * If non-zero, the guest virtual address space is a contiguous subset
+ * of the host virtual address space, i.e. '-R reserved_va' is in effect
+ * either from the command-line or by default.  The value is the last
+ * byte of the guest address space e.g. UINT32_MAX.
+ *
+ * If zero, the host and guest virtual address spaces are intermingled.
+ */
+extern unsigned long reserved_va;
+
+/*
+ * Limit the guest addresses as best we can.
+ *
+ * When not using -R reserved_va, we cannot really limit the guest
+ * to less address space than the host.  For 32-bit guests, this
+ * acts as a sanity check that we're not giving the guest an address
+ * that it cannot even represent.  For 64-bit guests... the address
+ * might not be what the real kernel would give, but it is at least
+ * representable in the guest.
+ *
+ * TODO: Improve address allocation to avoid this problem, and to
+ * avoid setting bits at the top of guest addresses that might need
+ * to be used for tags.
+ */
+#define GUEST_ADDR_MAX_                                                 \
+    ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ?  \
+     UINT32_MAX : ~0ul)
+#define GUEST_ADDR_MAX    (reserved_va ? : GUEST_ADDR_MAX_)
+
+#ifndef TARGET_TAGGED_ADDRESSES
+static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
+{
+    return x;
+}
+#endif
+
+/* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
+static inline void *g2h_untagged(abi_ptr x)
+{
+    return (void *)((uintptr_t)(x) + guest_base);
+}
+
+static inline void *g2h(CPUState *cs, abi_ptr x)
+{
+    return g2h_untagged(cpu_untagged_addr(cs, x));
+}
+
+static inline bool guest_addr_valid_untagged(abi_ulong x)
+{
+    return x <= GUEST_ADDR_MAX;
+}
+
+static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
+{
+    return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1;
+}
+
+#define h2g_valid(x) \
+    (HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS || \
+     (uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX)
+
+#define h2g_nocheck(x) ({ \
+    uintptr_t __ret = (uintptr_t)(x) - guest_base; \

include/user/guest-host.h line 87

Quoted 10 lines
include/user/guest-host.h new file +10 -0
+    (abi_ptr)__ret; \
+})
+
+#define h2g(x) ({ \
+    /* Check if given address fits target address space */ \
+    assert(h2g_valid(x)); \
+    h2g_nocheck(x); \
+})
+
+#endif
#3 lore raw

PATCH 2/18 linux-user/aarch64: Include missing 'user/abitypes.h' header

In reply to Philippe Mathieu-Daudé

arm_set_mte_tcf0() uses the abi_long type which is defined in "user/abitypes.h". Include it in order to avoid when refactoring:

In file included from ../../target/arm/gdbstub64.c:28:
../linux-user/aarch64/mte_user_helper.h:30:42: error: unknown type name ‘abi_long’; did you mean ‘u_long’?

     30 | void arm_set_mte_tcf0(CPUArchState *env, abi_long value);
        |                                          ^~~~~~~~
---
 linux-user/aarch64/mte_user_helper.h | 2 ++
 1 file changed, 2 insertions(+)
linux-user/aarch64/mte_user_helper.h +2 -0
index 8685e5175a2..0c53abda222 100644
@@ -9,6 +9,8 @@
 #ifndef AARCH64_MTE_USER_HELPER_H
 #define AARCH64_MTE USER_HELPER_H
 
+#include "user/abitypes.h"
+
 #ifndef PR_MTE_TCF_SHIFT
 # define PR_MTE_TCF_SHIFT       1
 # define PR_MTE_TCF_NONE        (0UL << PR_MTE_TCF_SHIFT)
Signature · 1 line
2.45.2
Reviewed-by on v1 2/18
#4 lore raw

Re: [PATCH 02/18] linux-user/aarch64: Include missing 'user/abitypes.h' header

Quoted 19 lines · Philippe Mathieu-Daudé

arm_set_mte_tcf0() uses the abi_long type which is defined in "user/abitypes.h". Include it in order to avoid when refactoring:

   In file included from ../../target/arm/gdbstub64.c:28:
   ../linux-user/aarch64/mte_user_helper.h:30:42: error: unknown type name ‘abi_long’; did you mean ‘u_long’?
      30 | void arm_set_mte_tcf0(CPUArchState *env, abi_long value);
         |                                          ^~~~~~~~
---
  linux-user/aarch64/mte_user_helper.h | 2 ++
  1 file changed, 2 insertions(+)
linux-user/aarch64/mte_user_helper.h +0 -0
index 8685e5175a2..0c53abda222 100644

linux-user/aarch64/mte_user_helper.h line 16

Quoted 8 lines
linux-user/aarch64/mte_user_helper.h +2 -0
@@ -9,6 +9,8 @@
  #ifndef AARCH64_MTE_USER_HELPER_H
  #define AARCH64_MTE USER_HELPER_H
 
+#include "user/abitypes.h"
+
  #ifndef PR_MTE_TCF_SHIFT
  # define PR_MTE_TCF_SHIFT       1
  # define PR_MTE_TCF_NONE        (0UL << PR_MTE_TCF_SHIFT)
#5 lore raw

PATCH 3/18 include: Include missing 'qemu/clang-tsa.h' header

In reply to Philippe Mathieu-Daudé

The next commit will remove "qemu/clang-tsa.h" of "exec/exec-all.h", however the following files indirectly include it:

  $ git grep -L qemu/clang-tsa.h $(git grep -wl TSA_NO_TSA)
  block/create.c
  include/block/block_int-common.h
  tests/unit/test-bdrv-drain.c
  tests/unit/test-block-iothread.c
  util/qemu-thread-posix.c

Explicitly include it so we can process with the removal in the next commit.

---
 include/block/block_int-common.h | 1 +
 block/create.c                   | 1 +
 tests/unit/test-bdrv-drain.c     | 1 +
 tests/unit/test-block-iothread.c | 1 +
 util/qemu-thread-posix.c         | 1 +
 5 files changed, 5 insertions(+)
include/block/block_int-common.h +1 -0
index ebb4e56a503..bb91a0f62fa 100644
@@ -28,6 +28,7 @@
 #include "block/block-common.h"
 #include "block/block-global-state.h"
 #include "block/snapshot.h"
+#include "qemu/clang-tsa.h"
 #include "qemu/iov.h"
 #include "qemu/rcu.h"
 #include "qemu/stats64.h"
block/create.c +1 -0
index 6b23a216753..72abafb4c12 100644
@@ -24,6 +24,7 @@
 
 #include "qemu/osdep.h"
 #include "block/block_int.h"
+#include "qemu/clang-tsa.h"
 #include "qemu/job.h"
 #include "qemu/main-loop.h"
 #include "qapi/qapi-commands-block-core.h"
tests/unit/test-bdrv-drain.c +1 -0
index 7410e6f3528..98ad89b390c 100644
@@ -28,6 +28,7 @@
 #include "system/block-backend.h"
 #include "qapi/error.h"
 #include "qemu/main-loop.h"
+#include "qemu/clang-tsa.h"
 #include "iothread.h"
 
 static QemuEvent done_event;
tests/unit/test-block-iothread.c +1 -0
index 26a6c051758..1de04a8a13d 100644
@@ -29,6 +29,7 @@
 #include "system/block-backend.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qdict.h"
+#include "qemu/clang-tsa.h"
 #include "qemu/main-loop.h"
 #include "iothread.h"
 
util/qemu-thread-posix.c +1 -0
index b2e26e21205..6fff4162ac6 100644
@@ -17,6 +17,7 @@
 #include "qemu-thread-common.h"
 #include "qemu/tsan.h"
 #include "qemu/bitmap.h"
+#include "qemu/clang-tsa.h"
 
 #ifdef CONFIG_PTHREAD_SET_NAME_NP
 #include <pthread_np.h>
Signature · 1 line
2.45.2
Reviewed-by on v1 3/18
#6 lore raw

Re: [PATCH 03/18] include: Include missing 'qemu/clang-tsa.h' header

Quoted 75 lines · Philippe Mathieu-Daudé

The next commit will remove "qemu/clang-tsa.h" of "exec/exec-all.h", however the following files indirectly include it:

   $ git grep -L qemu/clang-tsa.h $(git grep -wl TSA_NO_TSA)
   block/create.c
   include/block/block_int-common.h
   tests/unit/test-bdrv-drain.c
   tests/unit/test-block-iothread.c
   util/qemu-thread-posix.c

Explicitly include it so we can process with the removal in the next commit.

---
  include/block/block_int-common.h | 1 +
  block/create.c                   | 1 +
  tests/unit/test-bdrv-drain.c     | 1 +
  tests/unit/test-block-iothread.c | 1 +
  util/qemu-thread-posix.c         | 1 +
  5 files changed, 5 insertions(+)
include/block/block_int-common.h +1 -0
index ebb4e56a503..bb91a0f62fa 100644
@@ -28,6 +28,7 @@
  #include "block/block-common.h"
  #include "block/block-global-state.h"
  #include "block/snapshot.h"
+#include "qemu/clang-tsa.h"
  #include "qemu/iov.h"
  #include "qemu/rcu.h"
  #include "qemu/stats64.h"
block/create.c +1 -0
index 6b23a216753..72abafb4c12 100644
@@ -24,6 +24,7 @@
 
  #include "qemu/osdep.h"
  #include "block/block_int.h"
+#include "qemu/clang-tsa.h"
  #include "qemu/job.h"
  #include "qemu/main-loop.h"
  #include "qapi/qapi-commands-block-core.h"
tests/unit/test-bdrv-drain.c +1 -0
index 7410e6f3528..98ad89b390c 100644
@@ -28,6 +28,7 @@
  #include "system/block-backend.h"
  #include "qapi/error.h"
  #include "qemu/main-loop.h"
+#include "qemu/clang-tsa.h"
  #include "iothread.h"
 
  static QemuEvent done_event;
tests/unit/test-block-iothread.c +1 -0
index 26a6c051758..1de04a8a13d 100644
@@ -29,6 +29,7 @@
  #include "system/block-backend.h"
  #include "qapi/error.h"
  #include "qapi/qmp/qdict.h"
+#include "qemu/clang-tsa.h"
  #include "qemu/main-loop.h"
  #include "iothread.h"
 
util/qemu-thread-posix.c +0 -0
index b2e26e21205..6fff4162ac6 100644

util/qemu-thread-posix.c line 23

Quoted 7 lines
util/qemu-thread-posix.c +1 -0
@@ -17,6 +17,7 @@
  #include "qemu-thread-common.h"
  #include "qemu/tsan.h"
  #include "qemu/bitmap.h"
+#include "qemu/clang-tsa.h"
 
  #ifdef CONFIG_PTHREAD_SET_NAME_NP
  #include <pthread_np.h>

Seems like a better place for all this would be in:
include/qemu/compiler.h, instead of a separate clang-tsa header.

But for the current version,

#7 lore raw

Re: [PATCH 03/18] include: Include missing 'qemu/clang-tsa.h' header

Quoted 74 lines · Pierrick Bouvier
Quoted 73 lines · Philippe Mathieu-Daudé

The next commit will remove "qemu/clang-tsa.h" of "exec/exec-all.h", however the following files indirectly include it:

   $ git grep -L qemu/clang-tsa.h $(git grep -wl TSA_NO_TSA)
   block/create.c
   include/block/block_int-common.h
   tests/unit/test-bdrv-drain.c
   tests/unit/test-block-iothread.c
   util/qemu-thread-posix.c

Explicitly include it so we can process with the removal in the next commit.

---
  include/block/block_int-common.h | 1 +
  block/create.c                   | 1 +
  tests/unit/test-bdrv-drain.c     | 1 +
  tests/unit/test-block-iothread.c | 1 +
  util/qemu-thread-posix.c         | 1 +

  5 files changed, 5 insertions(+)
include/block/block_int-common.h +1 -0
index ebb4e56a503..bb91a0f62fa 100644
@@ -28,6 +28,7 @@
   #include "block/block-common.h"
   #include "block/block-global-state.h"
   #include "block/snapshot.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/iov.h"
   #include "qemu/rcu.h"
   #include "qemu/stats64.h"
block/create.c +1 -0
index 6b23a216753..72abafb4c12 100644
@@ -24,6 +24,7 @@
   #include "qemu/osdep.h"
   #include "block/block_int.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/job.h"
   #include "qemu/main-loop.h"
   #include "qapi/qapi-commands-block-core.h"
tests/unit/test-bdrv-drain.c +1 -0
index 7410e6f3528..98ad89b390c 100644
@@ -28,6 +28,7 @@
   #include "system/block-backend.h"
   #include "qapi/error.h"
   #include "qemu/main-loop.h"
+#include "qemu/clang-tsa.h"
   #include "iothread.h"
   static QemuEvent done_event;
tests/unit/test-block-iothread.c +1 -0
index 26a6c051758..1de04a8a13d 100644
@@ -29,6 +29,7 @@
   #include "system/block-backend.h"
   #include "qapi/error.h"
   #include "qapi/qmp/qdict.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/main-loop.h"
   #include "iothread.h"
util/qemu-thread-posix.c +0 -0
index b2e26e21205..6fff4162ac6 100644
@@ -17,6 +17,7 @@
   #include "qemu-thread-common.h"
Quoted 8 lines

util/qemu-thread-posix.c line 23

Quoted 5 lines
util/qemu-thread-posix.c +1 -0
   #include "qemu/tsan.h"
   #include "qemu/bitmap.h"
+#include "qemu/clang-tsa.h"
   #ifdef CONFIG_PTHREAD_SET_NAME_NP
   #include <pthread_np.h>

Seems like a better place for all this would be in:
include/qemu/compiler.h, instead of a separate clang-tsa header.

Yeah I was thinking the same, but since there is already another header, I didn't want to delay this cleanup further by modifying unrelated files.

Quoted 2 lines

But for the current version,

Thanks!

#8 lore raw

Re: [PATCH 03/18] include: Include missing 'qemu/clang-tsa.h' header

Quoted 86 lines · Philippe Mathieu-Daudé
Quoted 76 lines · Pierrick Bouvier
Quoted 75 lines · Philippe Mathieu-Daudé

The next commit will remove "qemu/clang-tsa.h" of "exec/exec-all.h", however the following files indirectly include it:

    $ git grep -L qemu/clang-tsa.h $(git grep -wl TSA_NO_TSA)
    block/create.c
    include/block/block_int-common.h
    tests/unit/test-bdrv-drain.c
    tests/unit/test-block-iothread.c
    util/qemu-thread-posix.c

Explicitly include it so we can process with the removal in the next commit.

---
   include/block/block_int-common.h | 1 +
   block/create.c                   | 1 +
   tests/unit/test-bdrv-drain.c     | 1 +
   tests/unit/test-block-iothread.c | 1 +
   util/qemu-thread-posix.c         | 1 +
   5 files changed, 5 insertions(+)
include/block/ renamed from include/block/block_int-common.h +0 -0

block_int-common.h
index ebb4e56a503..bb91a0f62fa 100644

include/block/block_int-common.h +1 -0
@@ -28,6 +28,7 @@
   #include "block/block-common.h"
   #include "block/block-global-state.h"
   #include "block/snapshot.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/iov.h"
   #include "qemu/rcu.h"
   #include "qemu/stats64.h"
block/create.c +1 -0
index 6b23a216753..72abafb4c12 100644
@@ -24,6 +24,7 @@
   #include "qemu/osdep.h"
   #include "block/block_int.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/job.h"
   #include "qemu/main-loop.h"
   #include "qapi/qapi-commands-block-core.h"
tests/unit/test-bdrv-drain.c +1 -0
index 7410e6f3528..98ad89b390c 100644
@@ -28,6 +28,7 @@
   #include "system/block-backend.h"
   #include "qapi/error.h"
   #include "qemu/main-loop.h"
+#include "qemu/clang-tsa.h"
   #include "iothread.h"
   static QemuEvent done_event;
tests/unit/test-block- renamed from tests/unit/test-block-iothread.c +0 -0

iothread.c
index 26a6c051758..1de04a8a13d 100644

tests/unit/test-block-iothread.c +1 -0
@@ -29,6 +29,7 @@
   #include "system/block-backend.h"
   #include "qapi/error.h"
   #include "qapi/qmp/qdict.h"
+#include "qemu/clang-tsa.h"
   #include "qemu/main-loop.h"
   #include "iothread.h"
util/qemu-thread-posix.c +0 -0
index b2e26e21205..6fff4162ac6 100644
@@ -17,6 +17,7 @@
   #include "qemu-thread-common.h"
Quoted 8 lines

util/qemu-thread-posix.c line 23

Quoted 5 lines
util/qemu-thread-posix.c +1 -0
   #include "qemu/tsan.h"
   #include "qemu/bitmap.h"
+#include "qemu/clang-tsa.h"
   #ifdef CONFIG_PTHREAD_SET_NAME_NP
   #include <pthread_np.h>

Seems like a better place for all this would be in:
include/qemu/compiler.h, instead of a separate clang-tsa header.

Quoted 4 lines

Yeah I was thinking the same, but since there is already another header, I didn't want to delay this cleanup further by modifying unrelated files.

No worries, that's why I still sent a reviewed-by.

Quoted 4 lines
Quoted 2 lines

But for the current version,

Thanks!

#9 lore raw

PATCH 4/18 accel/tcg: Declare mmap_[un]lock() in 'exec/page-protection.h'

In reply to Philippe Mathieu-Daudé

Move mmap_lock(), mmap_unlock() declarations and the WITH_MMAP_LOCK_GUARD() definition to 'exec/page-protection.h'.

---
 include/exec/exec-all.h        | 17 -----------------
 include/exec/page-protection.h | 24 ++++++++++++++++++++++++
 accel/tcg/cpu-exec.c           |  1 +
 accel/tcg/translate-all.c      |  1 +
 accel/tcg/watchpoint.c         |  1 +
 linux-user/flatload.c          |  1 +
 target/arm/helper.c            |  1 +
 7 files changed, 29 insertions(+), 17 deletions(-)
include/exec/exec-all.h +0 -17
index 2e4c4cc4b46..b5ea607cf45 100644
@@ -27,7 +27,6 @@
 #endif
 #include "exec/mmu-access-type.h"
 #include "exec/translation-block.h"
-#include "qemu/clang-tsa.h"
 
 /**
  * cpu_loop_exit_requested:
@@ -520,18 +519,6 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
 }
 
 #if defined(CONFIG_USER_ONLY)
-void TSA_NO_TSA mmap_lock(void);
-void TSA_NO_TSA mmap_unlock(void);
-bool have_mmap_lock(void);
-
-static inline void mmap_unlock_guard(void *unused)
-{
-    mmap_unlock();
-}
-
-#define WITH_MMAP_LOCK_GUARD()                                            \
-    for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard)))  \
-         = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
 
 /**
  * adjust_signal_pc:
@@ -585,10 +572,6 @@ G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
                                      uintptr_t ra);
 
 #else
-static inline void mmap_lock(void) {}
-static inline void mmap_unlock(void) {}
-#define WITH_MMAP_LOCK_GUARD()
-
 void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
 void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
 
include/exec/page-protection.h +24 -0
index c43231af8b5..bae3355f62c 100644
@@ -38,4 +38,28 @@
  */
 #define PAGE_PASSTHROUGH 0x0800
 
+#ifdef CONFIG_USER_ONLY
+
+#include "qemu/clang-tsa.h"
+
+void TSA_NO_TSA mmap_lock(void);
+void TSA_NO_TSA mmap_unlock(void);
+bool have_mmap_lock(void);
+
+static inline void mmap_unlock_guard(void *unused)
+{
+    mmap_unlock();
+}
+
+#define WITH_MMAP_LOCK_GUARD() \
+    for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \
+         = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
+#else
+
+static inline void mmap_lock(void) {}
+static inline void mmap_unlock(void) {}
+#define WITH_MMAP_LOCK_GUARD()
+
+#endif /* !CONFIG_USER_ONLY */
+
 #endif
accel/tcg/cpu-exec.c +1 -0
index c13f4a7cbbf..f82870a1e2a 100644
@@ -25,6 +25,7 @@
 #include "trace.h"
 #include "disas/disas.h"
 #include "exec/exec-all.h"
+#include "exec/page-protection.h"
 #include "tcg/tcg.h"
 #include "qemu/atomic.h"
 #include "qemu/rcu.h"
accel/tcg/translate-all.c +1 -0
index a8b24be0b96..d586ac9bb1d 100644
@@ -44,6 +44,7 @@
 #endif
 
 #include "exec/cputlb.h"
+#include "exec/page-protection.h"
 #include "exec/translate-all.h"
 #include "exec/translator.h"
 #include "exec/tb-flush.h"
accel/tcg/watchpoint.c +1 -0
index ca641eb95cf..8923301b8b8 100644
@@ -22,6 +22,7 @@
 #include "qemu/error-report.h"
 #include "exec/exec-all.h"
 #include "exec/translate-all.h"
+#include "exec/page-protection.h"
 #include "system/tcg.h"
 #include "system/replay.h"
 #include "hw/core/tcg-cpu-ops.h"
linux-user/flatload.c +1 -0
index 0e4be5bf44a..d5cb1830ddf 100644
@@ -34,6 +34,7 @@
 #include "qemu/osdep.h"
 
 #include "qemu.h"
+#include "exec/page-protection.h"
 #include "user-internals.h"
 #include "loader.h"
 #include "user-mmap.h"
target/arm/helper.c +1 -0
index 63fe4ba318b..c35cb0f6a54 100644
@@ -13,6 +13,7 @@
 #include "internals.h"
 #include "cpu-features.h"
 #include "exec/helper-proto.h"
+#include "exec/page-protection.h"
 #include "qemu/main-loop.h"
 #include "qemu/timer.h"
 #include "qemu/bitops.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 4/18
#10 lore raw

Re: [PATCH 04/18] accel/tcg: Declare mmap_[un]lock() in 'exec/page-protection.h'

Quoted 142 lines · Philippe Mathieu-Daudé

Move mmap_lock(), mmap_unlock() declarations and the WITH_MMAP_LOCK_GUARD() definition to 'exec/page-protection.h'.

---
  include/exec/exec-all.h        | 17 -----------------
  include/exec/page-protection.h | 24 ++++++++++++++++++++++++
  accel/tcg/cpu-exec.c           |  1 +
  accel/tcg/translate-all.c      |  1 +
  accel/tcg/watchpoint.c         |  1 +
  linux-user/flatload.c          |  1 +
  target/arm/helper.c            |  1 +
  7 files changed, 29 insertions(+), 17 deletions(-)
include/exec/exec-all.h +0 -17
index 2e4c4cc4b46..b5ea607cf45 100644
@@ -27,7 +27,6 @@
  #endif
  #include "exec/mmu-access-type.h"
  #include "exec/translation-block.h"
-#include "qemu/clang-tsa.h"
 
  /**
   * cpu_loop_exit_requested:
@@ -520,18 +519,6 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
  }
 
  #if defined(CONFIG_USER_ONLY)
-void TSA_NO_TSA mmap_lock(void);
-void TSA_NO_TSA mmap_unlock(void);
-bool have_mmap_lock(void);
-
-static inline void mmap_unlock_guard(void *unused)
-{
-    mmap_unlock();
-}
-
-#define WITH_MMAP_LOCK_GUARD()                                            \
-    for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard)))  \
-         = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
 
  /**
   * adjust_signal_pc:
@@ -585,10 +572,6 @@ G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
                                       uintptr_t ra);
 
  #else
-static inline void mmap_lock(void) {}
-static inline void mmap_unlock(void) {}
-#define WITH_MMAP_LOCK_GUARD()
-
  void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
  void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
 
include/exec/page-protection.h +24 -0
index c43231af8b5..bae3355f62c 100644
@@ -38,4 +38,28 @@
   */
  #define PAGE_PASSTHROUGH 0x0800
 
+#ifdef CONFIG_USER_ONLY
+
+#include "qemu/clang-tsa.h"
+
+void TSA_NO_TSA mmap_lock(void);
+void TSA_NO_TSA mmap_unlock(void);
+bool have_mmap_lock(void);
+
+static inline void mmap_unlock_guard(void *unused)
+{
+    mmap_unlock();
+}
+
+#define WITH_MMAP_LOCK_GUARD() \
+    for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \
+         = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
+#else
+
+static inline void mmap_lock(void) {}
+static inline void mmap_unlock(void) {}
+#define WITH_MMAP_LOCK_GUARD()
+
+#endif /* !CONFIG_USER_ONLY */
+
  #endif
accel/tcg/cpu-exec.c +1 -0
index c13f4a7cbbf..f82870a1e2a 100644
@@ -25,6 +25,7 @@
  #include "trace.h"
  #include "disas/disas.h"
  #include "exec/exec-all.h"
+#include "exec/page-protection.h"
  #include "tcg/tcg.h"
  #include "qemu/atomic.h"
  #include "qemu/rcu.h"
accel/tcg/translate-all.c +1 -0
index a8b24be0b96..d586ac9bb1d 100644
@@ -44,6 +44,7 @@
  #endif
 
  #include "exec/cputlb.h"
+#include "exec/page-protection.h"
  #include "exec/translate-all.h"
  #include "exec/translator.h"
  #include "exec/tb-flush.h"
accel/tcg/watchpoint.c +1 -0
index ca641eb95cf..8923301b8b8 100644
@@ -22,6 +22,7 @@
  #include "qemu/error-report.h"
  #include "exec/exec-all.h"
  #include "exec/translate-all.h"
+#include "exec/page-protection.h"
  #include "system/tcg.h"
  #include "system/replay.h"
  #include "hw/core/tcg-cpu-ops.h"
linux-user/flatload.c +1 -0
index 0e4be5bf44a..d5cb1830ddf 100644
@@ -34,6 +34,7 @@
  #include "qemu/osdep.h"
 
  #include "qemu.h"
+#include "exec/page-protection.h"
  #include "user-internals.h"
  #include "loader.h"
  #include "user-mmap.h"
target/arm/helper.c +0 -0
index 63fe4ba318b..c35cb0f6a54 100644

target/arm/helper.c line 19

Quoted 7 lines
target/arm/helper.c +1 -0
@@ -13,6 +13,7 @@
  #include "internals.h"
  #include "cpu-features.h"
  #include "exec/helper-proto.h"
+#include "exec/page-protection.h"
  #include "qemu/main-loop.h"
  #include "qemu/timer.h"
  #include "qemu/bitops.h"
#11 lore raw

PATCH 5/18 accel/tcg: Use tb_page_addr_t type in page_unprotect()

In reply to Philippe Mathieu-Daudé

Match with the page_protect() prototype, use a tb_page_addr_t argument instead of target_ulong.

---
 include/exec/translate-all.h | 2 +-
 accel/tcg/user-exec.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/exec/translate-all.h +1 -1
index 85c9460c7ca..c50661a05d5 100644
@@ -27,7 +27,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
 #ifdef CONFIG_USER_ONLY
 void page_protect(tb_page_addr_t page_addr);
-int page_unprotect(target_ulong address, uintptr_t pc);
+int page_unprotect(tb_page_addr_t address, uintptr_t pc);
 #endif
 
 #endif /* TRANSLATE_ALL_H */
accel/tcg/user-exec.c +1 -1
index 06016eb0301..4ed6dd19f30 100644
@@ -696,7 +696,7 @@ void page_protect(tb_page_addr_t address)
  * immediately exited. (We can only return 2 if the 'pc' argument is
  * non-zero.)
  */
-int page_unprotect(target_ulong address, uintptr_t pc)
+int page_unprotect(tb_page_addr_t address, uintptr_t pc)
 {
     PageFlagsNode *p;
     bool current_tb_invalidated;
Signature · 1 line
2.45.2
Reviewed-by on v1 5/18
#12 lore raw

Re: [PATCH 05/18] accel/tcg: Use tb_page_addr_t type in page_unprotect()

Quoted 27 lines · Philippe Mathieu-Daudé

Match with the page_protect() prototype, use a tb_page_addr_t argument instead of target_ulong.

---
  include/exec/translate-all.h | 2 +-
  accel/tcg/user-exec.c        | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
include/exec/translate-all.h +1 -1
index 85c9460c7ca..c50661a05d5 100644
@@ -27,7 +27,7 @@ void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
  #ifdef CONFIG_USER_ONLY
  void page_protect(tb_page_addr_t page_addr);
-int page_unprotect(target_ulong address, uintptr_t pc);
+int page_unprotect(tb_page_addr_t address, uintptr_t pc);
  #endif
 
  #endif /* TRANSLATE_ALL_H */
accel/tcg/user-exec.c +0 -0
index 06016eb0301..4ed6dd19f30 100644

accel/tcg/user-exec.c void page_protect(tb_page_addr_t address) · line 702

Quoted 8 lines
accel/tcg/user-exec.c +1 -1
@@ -696,7 +696,7 @@ void page_protect(tb_page_addr_t address)
   * immediately exited. (We can only return 2 if the 'pc' argument is
   * non-zero.)
   */
-int page_unprotect(target_ulong address, uintptr_t pc)
+int page_unprotect(tb_page_addr_t address, uintptr_t pc)
  {
      PageFlagsNode *p;
      bool current_tb_invalidated;
#13 lore raw

PATCH 6/18 accel/tcg: Move page_[un]protect() to 'user/page-protection.h'

In reply to Philippe Mathieu-Daudé
---
 accel/tcg/internal-target.h    |  1 +
 include/exec/translate-all.h   |  5 -----
 include/user/page-protection.h | 20 ++++++++++++++++++++
 accel/tcg/user-exec.c          |  2 +-
 linux-user/elfload.c           |  2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)
 create mode 100644 include/user/page-protection.h
accel/tcg/internal-target.h +1 -0
index fe109724c68..a03c05315a4 100644
@@ -37,6 +37,7 @@ void page_table_config_init(void);
 #endif
 
 #ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
 /*
  * For user-only, page_protect sets the page read-only.
  * Since most execution is already on read-only pages, and we'd need to
include/exec/translate-all.h +0 -5
index c50661a05d5..039668ff8ac 100644
@@ -25,9 +25,4 @@
 /* translate-all.c */
 void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
-#ifdef CONFIG_USER_ONLY
-void page_protect(tb_page_addr_t page_addr);
-int page_unprotect(tb_page_addr_t address, uintptr_t pc);
-#endif
-
 #endif /* TRANSLATE_ALL_H */
include/user/page-protection.h new file +20 -0
new file mode 100644
index 00000000000..448c7a03449
@@ -0,0 +1,20 @@
+/*
+ * QEMU page protection declarations.
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+#ifndef USER_PAGE_PROTECTION_H
+#define USER_PAGE_PROTECTION_H
+
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
+#include "exec/translation-block.h"
+
+void page_protect(tb_page_addr_t page_addr);
+int page_unprotect(tb_page_addr_t address, uintptr_t pc);
+
+#endif
accel/tcg/user-exec.c +1 -1
index 4ed6dd19f30..636932303bb 100644
@@ -25,7 +25,7 @@
 #include "qemu/rcu.h"
 #include "exec/cpu_ldst.h"
 #include "qemu/main-loop.h"
-#include "exec/translate-all.h"
+#include "user/page-protection.h"
 #include "exec/page-protection.h"
 #include "exec/helper-proto.h"
 #include "qemu/atomic128.h"
linux-user/elfload.c +1 -1
index 471a384b222..521fdde0aa2 100644
@@ -3918,7 +3918,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
 }
 
 #ifdef USE_ELF_CORE_DUMP
-#include "exec/translate-all.h"
+#include "user/page-protection.h"
 
 /*
  * Definitions to generate Intel SVR4-like core files.
Signature · 1 line
2.45.2
Reviewed-by on v1 6/18
#14 lore raw

Re: [PATCH 06/18] accel/tcg: Move page_[un]protect() to 'user/page-protection.h'

Quoted 80 lines · Philippe Mathieu-Daudé
---
  accel/tcg/internal-target.h    |  1 +
  include/exec/translate-all.h   |  5 -----
  include/user/page-protection.h | 20 ++++++++++++++++++++
  accel/tcg/user-exec.c          |  2 +-
  linux-user/elfload.c           |  2 +-
  5 files changed, 23 insertions(+), 7 deletions(-)

create mode 100644 include/user/page-protection.h

accel/tcg/internal-target.h +1 -0
index fe109724c68..a03c05315a4 100644
@@ -37,6 +37,7 @@ void page_table_config_init(void);
  #endif
 
  #ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
  /*
   * For user-only, page_protect sets the page read-only.
   * Since most execution is already on read-only pages, and we'd need to
include/exec/translate-all.h +0 -5
index c50661a05d5..039668ff8ac 100644
@@ -25,9 +25,4 @@
  /* translate-all.c */
  void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
-#ifdef CONFIG_USER_ONLY
-void page_protect(tb_page_addr_t page_addr);
-int page_unprotect(tb_page_addr_t address, uintptr_t pc);
-#endif
-
  #endif /* TRANSLATE_ALL_H */
include/user/page-protection.h new file +20 -0
new file mode 100644
index 00000000000..448c7a03449
@@ -0,0 +1,20 @@
+/*
+ * QEMU page protection declarations.
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1+
+ */
+#ifndef USER_PAGE_PROTECTION_H
+#define USER_PAGE_PROTECTION_H
+
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
+#include "exec/translation-block.h"
+
+void page_protect(tb_page_addr_t page_addr);
+int page_unprotect(tb_page_addr_t address, uintptr_t pc);
+
+#endif
accel/tcg/user-exec.c +1 -1
index 4ed6dd19f30..636932303bb 100644
@@ -25,7 +25,7 @@
  #include "qemu/rcu.h"
  #include "exec/cpu_ldst.h"
  #include "qemu/main-loop.h"
-#include "exec/translate-all.h"
+#include "user/page-protection.h"
  #include "exec/page-protection.h"
  #include "exec/helper-proto.h"
  #include "qemu/atomic128.h"
linux-user/elfload.c +0 -0
index 471a384b222..521fdde0aa2 100644

linux-user/elfload.c int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) · line 3924

Quoted 8 lines
linux-user/elfload.c +1 -1
@@ -3918,7 +3918,7 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
  }
 
  #ifdef USE_ELF_CORE_DUMP
-#include "exec/translate-all.h"
+#include "user/page-protection.h"
 
  /*
   * Definitions to generate Intel SVR4-like core files.
#15 lore raw

PATCH 7/18 system: Remove unnecessary 'exec/translate-all.h' include

In reply to Philippe Mathieu-Daudé

At this point "exec/translate-all.h" only declare
tb_check_watchpoint(), which isn't used by any of
cpu-target.c or system/physmem.c, so remove its
inclusion.

---
 cpu-target.c     | 1 -
 system/physmem.c | 1 -
 2 files changed, 2 deletions(-)
cpu-target.c +0 -1
index 5a7c3290814..4a88f1c6db8 100644
@@ -41,7 +41,6 @@
 #include "exec/cpu-common.h"
 #include "exec/exec-all.h"
 #include "exec/tb-flush.h"
-#include "exec/translate-all.h"
 #include "exec/log.h"
 #include "hw/core/accel-cpu.h"
 #include "trace/trace-root.h"
system/physmem.c +0 -1
index 93c0ff60eb4..0fa6c37c774 100644
@@ -61,7 +61,6 @@
 
 #include "qemu/rcu_queue.h"
 #include "qemu/main-loop.h"
-#include "exec/translate-all.h"
 #include "system/replay.h"
 
 #include "exec/memory-internal.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 7/18
#16 lore raw

Re: [PATCH 07/18] system: Remove unnecessary 'exec/translate-all.h' include

Quoted 28 lines · Philippe Mathieu-Daudé

At this point "exec/translate-all.h" only declare
tb_check_watchpoint(), which isn't used by any of
cpu-target.c or system/physmem.c, so remove its
inclusion.

---
  cpu-target.c     | 1 -
  system/physmem.c | 1 -
  2 files changed, 2 deletions(-)
cpu-target.c +0 -1
index 5a7c3290814..4a88f1c6db8 100644
@@ -41,7 +41,6 @@
  #include "exec/cpu-common.h"
  #include "exec/exec-all.h"
  #include "exec/tb-flush.h"
-#include "exec/translate-all.h"
  #include "exec/log.h"
  #include "hw/core/accel-cpu.h"
  #include "trace/trace-root.h"
system/physmem.c +0 -0
index 93c0ff60eb4..0fa6c37c774 100644

system/physmem.c line 66

Quoted 7 lines
system/physmem.c +0 -1
@@ -61,7 +61,6 @@
 
  #include "qemu/rcu_queue.h"
  #include "qemu/main-loop.h"
-#include "exec/translate-all.h"
  #include "system/replay.h"
 
  #include "exec/memory-internal.h"
#17 lore raw

PATCH 8/18 accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h'

In reply to Philippe Mathieu-Daudé

"exec/translate-all.h" is only useful to TCG accelerator, so move it to accel/tcg/, after renaming it 'tb-internal.h'.

---
 accel/tcg/internal-target.h  |  2 +-
 accel/tcg/tb-internal.h      | 14 ++++++++++++++
 include/exec/translate-all.h | 28 ----------------------------
 accel/tcg/cputlb.c           |  2 +-
 accel/tcg/tb-maint.c         |  2 +-
 accel/tcg/translate-all.c    |  2 +-
 accel/tcg/user-exec.c        |  1 +
 accel/tcg/watchpoint.c       |  2 +-
 8 files changed, 20 insertions(+), 33 deletions(-)
 create mode 100644 accel/tcg/tb-internal.h
 delete mode 100644 include/exec/translate-all.h
accel/tcg/internal-target.h +1 -1
index a03c05315a4..6f4ec0bd424 100644
@@ -10,7 +10,7 @@
 #define ACCEL_TCG_INTERNAL_TARGET_H
 
 #include "exec/exec-all.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
 
 /*
  * Access to the various translations structures need to be serialised
accel/tcg/tb-internal.h new file +14 -0
new file mode 100644
index 00000000000..8313f90fd71
@@ -0,0 +1,14 @@
+/*
+ * TranslationBlock internal declarations (target specific)
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H
+#define ACCEL_TCG_TB_INTERNAL_TARGET_H
+
+void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
+
+#endif
include/exec/translate-all.h deleted +0 -28
deleted file mode 100644
index 039668ff8ac..00000000000
@@ -1,28 +0,0 @@
-/*
- *  Translated block handling
- *
- *  Copyright (c) 2003 Fabrice Bellard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef TRANSLATE_ALL_H
-#define TRANSLATE_ALL_H
-
-#include "exec/exec-all.h"
-
-
-/* translate-all.c */
-void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
-
-#endif /* TRANSLATE_ALL_H */
accel/tcg/cputlb.c +1 -1
index b76a4eac4e0..451cf13e876 100644
@@ -37,7 +37,7 @@
 #include "exec/helper-proto-common.h"
 #include "qemu/atomic.h"
 #include "qemu/atomic128.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
 #include "trace.h"
 #include "tb-hash.h"
 #include "internal-common.h"
accel/tcg/tb-maint.c +1 -1
index 97d2e39ec0d..bdf5a0b7d58 100644
@@ -25,7 +25,7 @@
 #include "exec/exec-all.h"
 #include "exec/page-protection.h"
 #include "exec/tb-flush.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
 #include "system/tcg.h"
 #include "tcg/tcg.h"
 #include "tb-hash.h"
accel/tcg/translate-all.c +1 -1
index d586ac9bb1d..bad3fce0ffb 100644
@@ -45,7 +45,7 @@
 
 #include "exec/cputlb.h"
 #include "exec/page-protection.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
 #include "exec/translator.h"
 #include "exec/tb-flush.h"
 #include "qemu/bitmap.h"
accel/tcg/user-exec.c +1 -0
index 636932303bb..815a39503f3 100644
@@ -33,6 +33,7 @@
 #include "tcg/tcg-ldst.h"
 #include "internal-common.h"
 #include "internal-target.h"
+#include "tb-internal.h"
 
 __thread uintptr_t helper_retaddr;
 
accel/tcg/watchpoint.c +1 -1
index 8923301b8b8..e24baead562 100644
@@ -21,8 +21,8 @@
 #include "qemu/main-loop.h"
 #include "qemu/error-report.h"
 #include "exec/exec-all.h"
-#include "exec/translate-all.h"
 #include "exec/page-protection.h"
+#include "tb-internal.h"
 #include "system/tcg.h"
 #include "system/replay.h"
 #include "hw/core/tcg-cpu-ops.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 8/18
#18 lore raw

Re: [PATCH 08/18] accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h'

Quoted 140 lines · Philippe Mathieu-Daudé

"exec/translate-all.h" is only useful to TCG accelerator, so move it to accel/tcg/, after renaming it 'tb-internal.h'.

---
  accel/tcg/internal-target.h  |  2 +-
  accel/tcg/tb-internal.h      | 14 ++++++++++++++
  include/exec/translate-all.h | 28 ----------------------------
  accel/tcg/cputlb.c           |  2 +-
  accel/tcg/tb-maint.c         |  2 +-
  accel/tcg/translate-all.c    |  2 +-
  accel/tcg/user-exec.c        |  1 +
  accel/tcg/watchpoint.c       |  2 +-
  8 files changed, 20 insertions(+), 33 deletions(-)

create mode 100644 accel/tcg/tb-internal.h
delete mode 100644 include/exec/translate-all.h

accel/tcg/internal-target.h +1 -1
index a03c05315a4..6f4ec0bd424 100644
@@ -10,7 +10,7 @@
  #define ACCEL_TCG_INTERNAL_TARGET_H
 
  #include "exec/exec-all.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
 
  /*
   * Access to the various translations structures need to be serialised
accel/tcg/tb-internal.h new file +14 -0
new file mode 100644
index 00000000000..8313f90fd71
@@ -0,0 +1,14 @@
+/*
+ * TranslationBlock internal declarations (target specific)
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H
+#define ACCEL_TCG_TB_INTERNAL_TARGET_H
+
+void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
+
+#endif
include/exec/translate-all.h deleted +0 -28
deleted file mode 100644
index 039668ff8ac..00000000000
@@ -1,28 +0,0 @@
-/*
- *  Translated block handling
- *
- *  Copyright (c) 2003 Fabrice Bellard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef TRANSLATE_ALL_H
-#define TRANSLATE_ALL_H
-
-#include "exec/exec-all.h"
-
-
-/* translate-all.c */
-void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
-
-#endif /* TRANSLATE_ALL_H */
accel/tcg/cputlb.c +1 -1
index b76a4eac4e0..451cf13e876 100644
@@ -37,7 +37,7 @@
  #include "exec/helper-proto-common.h"
  #include "qemu/atomic.h"
  #include "qemu/atomic128.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
  #include "trace.h"
  #include "tb-hash.h"
  #include "internal-common.h"
accel/tcg/tb-maint.c +1 -1
index 97d2e39ec0d..bdf5a0b7d58 100644
@@ -25,7 +25,7 @@
  #include "exec/exec-all.h"
  #include "exec/page-protection.h"
  #include "exec/tb-flush.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
  #include "system/tcg.h"
  #include "tcg/tcg.h"
  #include "tb-hash.h"
accel/tcg/translate-all.c +1 -1
index d586ac9bb1d..bad3fce0ffb 100644
@@ -45,7 +45,7 @@
 
  #include "exec/cputlb.h"
  #include "exec/page-protection.h"
-#include "exec/translate-all.h"
+#include "tb-internal.h"
  #include "exec/translator.h"
  #include "exec/tb-flush.h"
  #include "qemu/bitmap.h"
accel/tcg/user-exec.c +1 -0
index 636932303bb..815a39503f3 100644
@@ -33,6 +33,7 @@
  #include "tcg/tcg-ldst.h"
  #include "internal-common.h"
  #include "internal-target.h"
+#include "tb-internal.h"
 
  __thread uintptr_t helper_retaddr;
 
accel/tcg/watchpoint.c +0 -0
index 8923301b8b8..e24baead562 100644

accel/tcg/watchpoint.c line 28

Quoted 9 lines
accel/tcg/watchpoint.c +1 -1
@@ -21,8 +21,8 @@
  #include "qemu/main-loop.h"
  #include "qemu/error-report.h"
  #include "exec/exec-all.h"
-#include "exec/translate-all.h"
  #include "exec/page-protection.h"
+#include "tb-internal.h"
  #include "system/tcg.h"
  #include "system/replay.h"
  #include "hw/core/tcg-cpu-ops.h"
#19 lore raw

Re: [PATCH 08/18] accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h'

In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

"exec/translate-all.h" is only useful to TCG accelerator, so move it to accel/tcg/, after renaming it 'tb-internal.h'.

---
  accel/tcg/internal-target.h  |  2 +-
  accel/tcg/tb-internal.h      | 14 ++++++++++++++
  include/exec/translate-all.h | 28 ----------------------------
  accel/tcg/cputlb.c           |  2 +-
  accel/tcg/tb-maint.c         |  2 +-
  accel/tcg/translate-all.c    |  2 +-
  accel/tcg/user-exec.c        |  1 +
  accel/tcg/watchpoint.c       |  2 +-
  8 files changed, 20 insertions(+), 33 deletions(-)
Quoted 2 lines

create mode 100644 accel/tcg/tb-internal.h
delete mode 100644 include/exec/translate-all.h

Move it into accel/tcg/internal-common.h rather than create a new header.

r~

#20 lore raw

Re: [PATCH 08/18] accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h'

Quoted 18 lines · Richard Henderson
Quoted 13 lines · Philippe Mathieu-Daudé

"exec/translate-all.h" is only useful to TCG accelerator, so move it to accel/tcg/, after renaming it 'tb-internal.h'.

---
  accel/tcg/internal-target.h  |  2 +- accel/tcg/tb-internal.h      | 14 ++++++++++++++ include/exec/translate-all.h | 28 ---------------------------- accel/tcg/cputlb.c           |  2 +- accel/tcg/tb-maint.c         |  2 +- accel/tcg/translate-all.c    |  2 +- accel/tcg/user-exec.c        |  1 + accel/tcg/watchpoint.c       |  2 +-

Quoted 3 lines
  8 files changed, 20 insertions(+), 33 deletions(-)

  create mode 100644 accel/tcg/tb-internal.h
  delete mode 100644 include/exec/translate-all.h

Quoted 1 line

Move it into accel/tcg/internal-common.h rather than create a new header.

Hmm. Nevermind, I should have read to the end.

r~

#21 lore raw

PATCH 9/18 accel/tcg: Un-inline log_pc()

In reply to Philippe Mathieu-Daudé

log_pc() is only used within cpu-exec.c, no need to expose it via "internal-target.h".

---
 accel/tcg/internal-target.h | 10 ----------
 accel/tcg/cpu-exec.c        | 11 +++++++++++
 2 files changed, 11 insertions(+), 10 deletions(-)
accel/tcg/internal-target.h +0 -10
index 6f4ec0bd424..0437d798295 100644
@@ -72,16 +72,6 @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
 
 bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
 
-/* Return the current PC from CPU, which may be cached in TB. */
-static inline vaddr log_pc(CPUState *cpu, const TranslationBlock *tb)
-{
-    if (tb_cflags(tb) & CF_PCREL) {
-        return cpu->cc->get_pc(cpu);
-    } else {
-        return tb->pc;
-    }
-}
-
 /**
  * tcg_req_mo:
  * @type: TCGBar
accel/tcg/cpu-exec.c +11 -0
index f82870a1e2a..396fa6f4a6b 100644
@@ -21,6 +21,7 @@
 #include "qemu/qemu-print.h"
 #include "qapi/error.h"
 #include "qapi/type-helpers.h"
+#include "hw/core/cpu.h"
 #include "hw/core/tcg-cpu-ops.h"
 #include "trace.h"
 #include "disas/disas.h"
@@ -434,6 +435,16 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env)
     return tb->tc.ptr;
 }
 
+/* Return the current PC from CPU, which may be cached in TB. */
+static vaddr log_pc(CPUState *cpu, const TranslationBlock *tb)
+{
+    if (tb_cflags(tb) & CF_PCREL) {
+        return cpu->cc->get_pc(cpu);
+    } else {
+        return tb->pc;
+    }
+}
+
 /* Execute a TB, and fix up the CPU state afterwards if necessary */
 /*
  * Disable CFI checks.
Signature · 1 line
2.45.2
Reviewed-by on v1 9/18
#22 lore raw

Re: [PATCH 09/18] accel/tcg: Un-inline log_pc()

Quoted 49 lines · Philippe Mathieu-Daudé

log_pc() is only used within cpu-exec.c, no need to expose it via "internal-target.h".

---
  accel/tcg/internal-target.h | 10 ----------
  accel/tcg/cpu-exec.c        | 11 +++++++++++
  2 files changed, 11 insertions(+), 10 deletions(-)
accel/tcg/internal-target.h +0 -10
index 6f4ec0bd424..0437d798295 100644
@@ -72,16 +72,6 @@ G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
 
  bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
 
-/* Return the current PC from CPU, which may be cached in TB. */
-static inline vaddr log_pc(CPUState *cpu, const TranslationBlock *tb)
-{
-    if (tb_cflags(tb) & CF_PCREL) {
-        return cpu->cc->get_pc(cpu);
-    } else {
-        return tb->pc;
-    }
-}
-
  /**
   * tcg_req_mo:
   * @type: TCGBar
accel/tcg/cpu-exec.c +4 -0
index f82870a1e2a..396fa6f4a6b 100644
@@ -21,6 +21,7 @@
  #include "qemu/qemu-print.h"
  #include "qapi/error.h"
  #include "qapi/type-helpers.h"
+#include "hw/core/cpu.h"
  #include "hw/core/tcg-cpu-ops.h"
  #include "trace.h"
  #include "disas/disas.h"
@@ -434,6 +435,16 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env)
      return tb->tc.ptr;
  }
 
+/* Return the current PC from CPU, which may be cached in TB. */
+static vaddr log_pc(CPUState *cpu, const TranslationBlock *tb)
+{

accel/tcg/cpu-exec.c const void *HELPER(lookup_tb_ptr)(CPUArchState *env) · line 450

Quoted 10 lines
accel/tcg/cpu-exec.c +7 -0
+    if (tb_cflags(tb) & CF_PCREL) {
+        return cpu->cc->get_pc(cpu);
+    } else {
+        return tb->pc;
+    }
+}
+
  /* Execute a TB, and fix up the CPU state afterwards if necessary */
  /*
   * Disable CFI checks.
#23 lore raw

PATCH 10/18 accel/tcg: Move TranslationBlock declarations to 'tb-internal.h'

In reply to Philippe Mathieu-Daudé

Move declarations related to TranslationBlock out of the generic "internal-target.h" to "tb-internal.h".

---
 accel/tcg/internal-target.h | 32 ------------------------------
 accel/tcg/tb-internal.h     | 39 +++++++++++++++++++++++++++++++++++++
 accel/tcg/cpu-exec.c        |  1 +
 accel/tcg/cputlb.c          |  1 +
 accel/tcg/tb-maint.c        |  1 +
 accel/tcg/translate-all.c   |  1 +
 accel/tcg/translator.c      |  1 +
 7 files changed, 44 insertions(+), 32 deletions(-)
accel/tcg/internal-target.h +0 -32
index 0437d798295..1cfa318dc6c 100644
@@ -36,42 +36,10 @@ static inline void page_table_config_init(void) { }
 void page_table_config_init(void);
 #endif
 
-#ifdef CONFIG_USER_ONLY
-#include "user/page-protection.h"
-/*
- * For user-only, page_protect sets the page read-only.
- * Since most execution is already on read-only pages, and we'd need to
- * account for other TBs on the same page, defer undoing any page protection
- * until we receive the write fault.
- */
-static inline void tb_lock_page0(tb_page_addr_t p0)
-{
-    page_protect(p0);
-}
-
-static inline void tb_lock_page1(tb_page_addr_t p0, tb_page_addr_t p1)
-{
-    page_protect(p1);
-}
-
-static inline void tb_unlock_page1(tb_page_addr_t p0, tb_page_addr_t p1) { }
-static inline void tb_unlock_pages(TranslationBlock *tb) { }
-#else
-void tb_lock_page0(tb_page_addr_t);
-void tb_lock_page1(tb_page_addr_t, tb_page_addr_t);
-void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
-void tb_unlock_pages(TranslationBlock *);
-#endif
-
 #ifdef CONFIG_SOFTMMU
-void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
-                                   unsigned size,
-                                   uintptr_t retaddr);
 G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
 #endif /* CONFIG_SOFTMMU */
 
-bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
-
 /**
  * tcg_req_mo:
  * @type: TCGBar
accel/tcg/tb-internal.h +39 -0
index 8313f90fd71..90be61f296a 100644
@@ -9,6 +9,45 @@
 #ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H
 #define ACCEL_TCG_TB_INTERNAL_TARGET_H
 
+#include "exec/cpu-all.h"
+#include "exec/exec-all.h"
+#include "exec/translation-block.h"
+
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+/*
+ * For user-only, page_protect sets the page read-only.
+ * Since most execution is already on read-only pages, and we'd need to
+ * account for other TBs on the same page, defer undoing any page protection
+ * until we receive the write fault.
+ */
+static inline void tb_lock_page0(tb_page_addr_t p0)
+{
+    page_protect(p0);
+}
+
+static inline void tb_lock_page1(tb_page_addr_t p0, tb_page_addr_t p1)
+{
+    page_protect(p1);
+}
+
+static inline void tb_unlock_page1(tb_page_addr_t p0, tb_page_addr_t p1) { }
+static inline void tb_unlock_pages(TranslationBlock *tb) { }
+#else
+void tb_lock_page0(tb_page_addr_t);
+void tb_lock_page1(tb_page_addr_t, tb_page_addr_t);
+void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
+void tb_unlock_pages(TranslationBlock *);
+#endif
+
+#ifdef CONFIG_SOFTMMU
+void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
+                                   unsigned size,
+                                   uintptr_t retaddr);
+#endif /* CONFIG_SOFTMMU */
+
+bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
+
 void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
 #endif
accel/tcg/cpu-exec.c +1 -0
index 396fa6f4a6b..e9eaab223f9 100644
@@ -41,6 +41,7 @@
 #include "tb-jmp-cache.h"
 #include "tb-hash.h"
 #include "tb-context.h"
+#include "tb-internal.h"
 #include "internal-common.h"
 #include "internal-target.h"
 
accel/tcg/cputlb.c +1 -0
index 451cf13e876..4f6eebd90ec 100644
@@ -40,6 +40,7 @@
 #include "tb-internal.h"
 #include "trace.h"
 #include "tb-hash.h"
+#include "tb-internal.h"
 #include "internal-common.h"
 #include "internal-target.h"
 #ifdef CONFIG_PLUGIN
accel/tcg/tb-maint.c +1 -0
index bdf5a0b7d58..8e272cf790f 100644
@@ -30,6 +30,7 @@
 #include "tcg/tcg.h"
 #include "tb-hash.h"
 #include "tb-context.h"
+#include "tb-internal.h"
 #include "internal-common.h"
 #include "internal-target.h"
 
accel/tcg/translate-all.c +1 -0
index bad3fce0ffb..572a8a87972 100644
@@ -62,6 +62,7 @@
 #include "tb-jmp-cache.h"
 #include "tb-hash.h"
 #include "tb-context.h"
+#include "tb-internal.h"
 #include "internal-common.h"
 #include "internal-target.h"
 #include "tcg/perf.h"
accel/tcg/translator.c +1 -0
index ff5dabc9014..ce5eae4349e 100644
@@ -19,6 +19,7 @@
 #include "tcg/tcg-op-common.h"
 #include "internal-target.h"
 #include "disas/disas.h"
+#include "tb-internal.h"
 
 static void set_can_do_io(DisasContextBase *db, bool val)
 {
Signature · 1 line
2.45.2
Reviewed-by on v1 10/18
#24 lore raw

Re: [PATCH 10/18] accel/tcg: Move TranslationBlock declarations to 'tb-internal.h'

Quoted 164 lines · Philippe Mathieu-Daudé

Move declarations related to TranslationBlock out of the generic "internal-target.h" to "tb-internal.h".

---
  accel/tcg/internal-target.h | 32 ------------------------------
  accel/tcg/tb-internal.h     | 39 +++++++++++++++++++++++++++++++++++++
  accel/tcg/cpu-exec.c        |  1 +
  accel/tcg/cputlb.c          |  1 +
  accel/tcg/tb-maint.c        |  1 +
  accel/tcg/translate-all.c   |  1 +
  accel/tcg/translator.c      |  1 +
  7 files changed, 44 insertions(+), 32 deletions(-)
accel/tcg/internal-target.h +0 -32
index 0437d798295..1cfa318dc6c 100644
@@ -36,42 +36,10 @@ static inline void page_table_config_init(void) { }
  void page_table_config_init(void);
  #endif
 
-#ifdef CONFIG_USER_ONLY
-#include "user/page-protection.h"
-/*
- * For user-only, page_protect sets the page read-only.
- * Since most execution is already on read-only pages, and we'd need to
- * account for other TBs on the same page, defer undoing any page protection
- * until we receive the write fault.
- */
-static inline void tb_lock_page0(tb_page_addr_t p0)
-{
-    page_protect(p0);
-}
-
-static inline void tb_lock_page1(tb_page_addr_t p0, tb_page_addr_t p1)
-{
-    page_protect(p1);
-}
-
-static inline void tb_unlock_page1(tb_page_addr_t p0, tb_page_addr_t p1) { }
-static inline void tb_unlock_pages(TranslationBlock *tb) { }
-#else
-void tb_lock_page0(tb_page_addr_t);
-void tb_lock_page1(tb_page_addr_t, tb_page_addr_t);
-void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
-void tb_unlock_pages(TranslationBlock *);
-#endif
-
  #ifdef CONFIG_SOFTMMU
-void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
-                                   unsigned size,
-                                   uintptr_t retaddr);
  G_NORETURN void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);
  #endif /* CONFIG_SOFTMMU */
 
-bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
-
  /**
   * tcg_req_mo:
   * @type: TCGBar
accel/tcg/tb-internal.h +39 -0
index 8313f90fd71..90be61f296a 100644
@@ -9,6 +9,45 @@
  #ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H
  #define ACCEL_TCG_TB_INTERNAL_TARGET_H
 
+#include "exec/cpu-all.h"
+#include "exec/exec-all.h"
+#include "exec/translation-block.h"
+
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+/*
+ * For user-only, page_protect sets the page read-only.
+ * Since most execution is already on read-only pages, and we'd need to
+ * account for other TBs on the same page, defer undoing any page protection
+ * until we receive the write fault.
+ */
+static inline void tb_lock_page0(tb_page_addr_t p0)
+{
+    page_protect(p0);
+}
+
+static inline void tb_lock_page1(tb_page_addr_t p0, tb_page_addr_t p1)
+{
+    page_protect(p1);
+}
+
+static inline void tb_unlock_page1(tb_page_addr_t p0, tb_page_addr_t p1) { }
+static inline void tb_unlock_pages(TranslationBlock *tb) { }
+#else
+void tb_lock_page0(tb_page_addr_t);
+void tb_lock_page1(tb_page_addr_t, tb_page_addr_t);
+void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
+void tb_unlock_pages(TranslationBlock *);
+#endif
+
+#ifdef CONFIG_SOFTMMU
+void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
+                                   unsigned size,
+                                   uintptr_t retaddr);
+#endif /* CONFIG_SOFTMMU */
+
+bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
+
  void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
 
  #endif
accel/tcg/cpu-exec.c +1 -0
index 396fa6f4a6b..e9eaab223f9 100644
@@ -41,6 +41,7 @@
  #include "tb-jmp-cache.h"
  #include "tb-hash.h"
  #include "tb-context.h"
+#include "tb-internal.h"
  #include "internal-common.h"
  #include "internal-target.h"
 
accel/tcg/cputlb.c +1 -0
index 451cf13e876..4f6eebd90ec 100644
@@ -40,6 +40,7 @@
  #include "tb-internal.h"
  #include "trace.h"
  #include "tb-hash.h"
+#include "tb-internal.h"
  #include "internal-common.h"
  #include "internal-target.h"
  #ifdef CONFIG_PLUGIN
accel/tcg/tb-maint.c +1 -0
index bdf5a0b7d58..8e272cf790f 100644
@@ -30,6 +30,7 @@
  #include "tcg/tcg.h"
  #include "tb-hash.h"
  #include "tb-context.h"
+#include "tb-internal.h"
  #include "internal-common.h"
  #include "internal-target.h"
 
accel/tcg/translate-all.c +1 -0
index bad3fce0ffb..572a8a87972 100644
@@ -62,6 +62,7 @@
  #include "tb-jmp-cache.h"
  #include "tb-hash.h"
  #include "tb-context.h"
+#include "tb-internal.h"
  #include "internal-common.h"
  #include "internal-target.h"
  #include "tcg/perf.h"
accel/tcg/translator.c +0 -0
index ff5dabc9014..ce5eae4349e 100644

accel/tcg/translator.c line 25

Quoted 7 lines
accel/tcg/translator.c +1 -0
@@ -19,6 +19,7 @@
  #include "tcg/tcg-op-common.h"
  #include "internal-target.h"
  #include "disas/disas.h"
+#include "tb-internal.h"
 
  static void set_can_do_io(DisasContextBase *db, bool val)
  {
#25 lore raw

PATCH 11/18 accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (1/4)

In reply to Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
 include/exec/cpu-all.h         | 5 -----
 include/user/page-protection.h | 8 ++++++++
 bsd-user/main.c                | 1 +
 bsd-user/mmap.c                | 1 +
 linux-user/main.c              | 1 +
 linux-user/mmap.c              | 1 +
 linux-user/syscall.c           | 1 +
 7 files changed, 13 insertions(+), 5 deletions(-)
include/exec/cpu-all.h +0 -5
index 1c8e0446d06..3d97323893b 100644
@@ -127,11 +127,6 @@ extern const TargetPageBits target_page;
 #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
 
 #if defined(CONFIG_USER_ONLY)
-void page_dump(FILE *f);
-
-typedef int (*walk_memory_regions_fn)(void *, target_ulong,
-                                      target_ulong, unsigned long);
-int walk_memory_regions(void *, walk_memory_regions_fn);
 
 int page_get_flags(target_ulong address);
 
include/user/page-protection.h +8 -0
index 448c7a03449..ea11cf9e328 100644
@@ -12,9 +12,17 @@
 #error Cannot include this header from system emulation
 #endif
 
+#include "cpu-param.h"
+#include "exec/target_long.h"
 #include "exec/translation-block.h"
 
 void page_protect(tb_page_addr_t page_addr);
 int page_unprotect(tb_page_addr_t address, uintptr_t pc);
+typedef int (*walk_memory_regions_fn)(void *, target_ulong,
+                                      target_ulong, unsigned long);
+
+int walk_memory_regions(void *, walk_memory_regions_fn);
+
+void page_dump(FILE *f);
 
 #endif
bsd-user/main.c +1 -0
index 61ca73c4781..0a5bc578365 100644
@@ -38,6 +38,7 @@
 #include "qemu/plugin.h"
 #include "exec/exec-all.h"
 #include "user/guest-base.h"
+#include "user/page-protection.h"
 #include "tcg/startup.h"
 #include "qemu/timer.h"
 #include "qemu/envlist.h"
bsd-user/mmap.c +1 -0
index 775e905960b..346f2cefd32 100644
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "exec/page-protection.h"
+#include "user/page-protection.h"
 
 #include "qemu.h"
 
linux-user/main.c +1 -0
index b09af8d4365..06037304cb1 100644
@@ -39,6 +39,7 @@
 #include "qemu/module.h"
 #include "qemu/plugin.h"
 #include "user/guest-base.h"
+#include "user/page-protection.h"
 #include "exec/exec-all.h"
 #include "exec/gdbstub.h"
 #include "gdbstub/user.h"
linux-user/mmap.c +1 -0
index e4bf5d5f39c..4e0444b4cbc 100644
@@ -22,6 +22,7 @@
 #include "exec/log.h"
 #include "exec/page-protection.h"
 #include "qemu.h"
+#include "user/page-protection.h"
 #include "user-internals.h"
 #include "user-mmap.h"
 #include "target_mman.h"
linux-user/syscall.c +1 -0
index 1ce4c79784f..c54b199b6d3 100644
@@ -135,6 +135,7 @@
 #include "signal-common.h"
 #include "loader.h"
 #include "user-mmap.h"
+#include "user/page-protection.h"
 #include "user/safe-syscall.h"
 #include "qemu/guest-random.h"
 #include "qemu/selfmap.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 11/18
#26 lore raw

Re: [PATCH 11/18] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (1/4)

Quoted 105 lines · Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
  include/exec/cpu-all.h         | 5 -----
  include/user/page-protection.h | 8 ++++++++
  bsd-user/main.c                | 1 +
  bsd-user/mmap.c                | 1 +
  linux-user/main.c              | 1 +
  linux-user/mmap.c              | 1 +
  linux-user/syscall.c           | 1 +
  7 files changed, 13 insertions(+), 5 deletions(-)
include/exec/cpu-all.h +0 -5
index 1c8e0446d06..3d97323893b 100644
@@ -127,11 +127,6 @@ extern const TargetPageBits target_page;
  #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
 
  #if defined(CONFIG_USER_ONLY)
-void page_dump(FILE *f);
-
-typedef int (*walk_memory_regions_fn)(void *, target_ulong,
-                                      target_ulong, unsigned long);
-int walk_memory_regions(void *, walk_memory_regions_fn);
 
  int page_get_flags(target_ulong address);
 
include/user/page-protection.h +8 -0
index 448c7a03449..ea11cf9e328 100644
@@ -12,9 +12,17 @@
  #error Cannot include this header from system emulation
  #endif
 
+#include "cpu-param.h"
+#include "exec/target_long.h"
  #include "exec/translation-block.h"
 
  void page_protect(tb_page_addr_t page_addr);
  int page_unprotect(tb_page_addr_t address, uintptr_t pc);
+typedef int (*walk_memory_regions_fn)(void *, target_ulong,
+                                      target_ulong, unsigned long);
+
+int walk_memory_regions(void *, walk_memory_regions_fn);
+
+void page_dump(FILE *f);
 
  #endif
bsd-user/main.c +1 -0
index 61ca73c4781..0a5bc578365 100644
@@ -38,6 +38,7 @@
  #include "qemu/plugin.h"
  #include "exec/exec-all.h"
  #include "user/guest-base.h"
+#include "user/page-protection.h"
  #include "tcg/startup.h"
  #include "qemu/timer.h"
  #include "qemu/envlist.h"
bsd-user/mmap.c +1 -0
index 775e905960b..346f2cefd32 100644
@@ -18,6 +18,7 @@
   */
  #include "qemu/osdep.h"
  #include "exec/page-protection.h"
+#include "user/page-protection.h"
 
  #include "qemu.h"
 
linux-user/main.c +1 -0
index b09af8d4365..06037304cb1 100644
@@ -39,6 +39,7 @@
  #include "qemu/module.h"
  #include "qemu/plugin.h"
  #include "user/guest-base.h"
+#include "user/page-protection.h"
  #include "exec/exec-all.h"
  #include "exec/gdbstub.h"
  #include "gdbstub/user.h"
linux-user/mmap.c +1 -0
index e4bf5d5f39c..4e0444b4cbc 100644
@@ -22,6 +22,7 @@
  #include "exec/log.h"
  #include "exec/page-protection.h"
  #include "qemu.h"
+#include "user/page-protection.h"
  #include "user-internals.h"
  #include "user-mmap.h"
  #include "target_mman.h"
linux-user/syscall.c +0 -0
index 1ce4c79784f..c54b199b6d3 100644

linux-user/syscall.c line 141

Quoted 7 lines
linux-user/syscall.c +1 -0
@@ -135,6 +135,7 @@
  #include "signal-common.h"
  #include "loader.h"
  #include "user-mmap.h"
+#include "user/page-protection.h"
  #include "user/safe-syscall.h"
  #include "qemu/guest-random.h"
  #include "qemu/selfmap.h"
#27 lore raw

PATCH 12/18 accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (2/4)

In reply to Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
 bsd-user/bsd-mem.h             |  1 +
 include/exec/cpu-all.h         | 55 --------------------------------
 include/user/page-protection.h | 57 ++++++++++++++++++++++++++++++++++
 target/arm/tcg/mte_helper.c    |  3 ++
 4 files changed, 61 insertions(+), 55 deletions(-)
bsd-user/bsd-mem.h +1 -0
index eef6b222d9e..f5ec0de24ca 100644
@@ -57,6 +57,7 @@
 
 #include "qemu-bsd.h"
 #include "exec/page-protection.h"
+#include "user/page-protection.h"
 
 extern struct bsd_shm_regions bsd_shm_regions[];
 extern abi_ulong target_brk;
include/exec/cpu-all.h +0 -55

67 lines not on this page · raw message

include/user/page-protection.h +57 -0

63 lines not on this page · raw message

target/arm/tcg/mte_helper.c +3 -0
index 9d2ba287eeb..ae037dc9143 100644
@@ -23,6 +23,9 @@
 #include "internals.h"
 #include "exec/exec-all.h"
 #include "exec/page-protection.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 #include "exec/ram_addr.h"
 #include "exec/cpu_ldst.h"
 #include "exec/helper-proto.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 12/18
#28 lore raw

Re: [PATCH 12/18] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (2/4)

Quoted 169 lines · Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
  bsd-user/bsd-mem.h             |  1 +
  include/exec/cpu-all.h         | 55 --------------------------------
  include/user/page-protection.h | 57 ++++++++++++++++++++++++++++++++++
  target/arm/tcg/mte_helper.c    |  3 ++
  4 files changed, 61 insertions(+), 55 deletions(-)
bsd-user/bsd-mem.h +1 -0
index eef6b222d9e..f5ec0de24ca 100644
@@ -57,6 +57,7 @@
 
  #include "qemu-bsd.h"
  #include "exec/page-protection.h"
+#include "user/page-protection.h"
 
  extern struct bsd_shm_regions bsd_shm_regions[];
  extern abi_ulong target_brk;
include/exec/cpu-all.h +0 -55
index 3d97323893b..86cd40020c9 100644
@@ -130,21 +130,6 @@ extern const TargetPageBits target_page;
 
  int page_get_flags(target_ulong address);
 
-/**
- * page_set_flags:
- * @start: first byte of range
- * @last: last byte of range
- * @flags: flags to set
- * Context: holding mmap lock
- *
- * Modify the flags of a page and invalidate the code if necessary.
- * The flag PAGE_WRITE_ORG is positioned automatically depending
- * on PAGE_WRITE.  The mmap_lock should already be held.
- */
-void page_set_flags(target_ulong start, target_ulong last, int flags);
-
-void page_reset_target_data(target_ulong start, target_ulong last);
-
  /**
   * page_check_range
   * @start: first byte of range
@@ -157,46 +142,6 @@ void page_reset_target_data(target_ulong start, target_ulong last);
   */
  bool page_check_range(target_ulong start, target_ulong last, int flags);
 
-/**
- * page_check_range_empty:
- * @start: first byte of range
- * @last: last byte of range
- * Context: holding mmap lock
- *
- * Return true if the entire range [@start, @last] is unmapped.
- * The memory lock must be held so that the caller will can ensure
- * the result stays true until a new mapping can be installed.
- */
-bool page_check_range_empty(target_ulong start, target_ulong last);
-
-/**
- * page_find_range_empty
- * @min: first byte of search range
- * @max: last byte of search range
- * @len: size of the hole required
- * @align: alignment of the hole required (power of 2)
- *
- * If there is a range [x, x+@len) within [@min, @max] such that
- * x % @align == 0, then return x.  Otherwise return -1.
- * The memory lock must be held, as the caller will want to ensure
- * the returned range stays empty until a new mapping can be installed.
- */
-target_ulong page_find_range_empty(target_ulong min, target_ulong max,
-                                   target_ulong len, target_ulong align);
-
-/**
- * page_get_target_data(address)
- * @address: guest virtual address
- *
- * Return TARGET_PAGE_DATA_SIZE bytes of out-of-band data to associate
- * with the guest page at @address, allocating it if necessary.  The
- * caller should already have verified that the address is valid.
- *
- * The memory will be freed when the guest page is deallocated,
- * e.g. with the munmap system call.
- */
-void *page_get_target_data(target_ulong address)
-    __attribute__((returns_nonnull));
  #endif
 
  CPUArchState *cpu_copy(CPUArchState *env);
include/user/page-protection.h +57 -0
index ea11cf9e328..d21fab1aaf9 100644
@@ -18,6 +18,63 @@
 
  void page_protect(tb_page_addr_t page_addr);
  int page_unprotect(tb_page_addr_t address, uintptr_t pc);
+
+/**
+ * page_set_flags:
+ * @start: first byte of range
+ * @last: last byte of range
+ * @flags: flags to set
+ * Context: holding mmap lock
+ *
+ * Modify the flags of a page and invalidate the code if necessary.
+ * The flag PAGE_WRITE_ORG is positioned automatically depending
+ * on PAGE_WRITE.  The mmap_lock should already be held.
+ */
+void page_set_flags(target_ulong start, target_ulong last, int flags);
+
+void page_reset_target_data(target_ulong start, target_ulong last);
+
+/**
+ * page_check_range_empty:
+ * @start: first byte of range
+ * @last: last byte of range
+ * Context: holding mmap lock
+ *
+ * Return true if the entire range [@start, @last] is unmapped.
+ * The memory lock must be held so that the caller will can ensure
+ * the result stays true until a new mapping can be installed.
+ */
+bool page_check_range_empty(target_ulong start, target_ulong last);
+
+/**
+ * page_find_range_empty
+ * @min: first byte of search range
+ * @max: last byte of search range
+ * @len: size of the hole required
+ * @align: alignment of the hole required (power of 2)
+ *
+ * If there is a range [x, x+@len) within [@min, @max] such that
+ * x % @align == 0, then return x.  Otherwise return -1.
+ * The memory lock must be held, as the caller will want to ensure
+ * the returned range stays empty until a new mapping can be installed.
+ */
+target_ulong page_find_range_empty(target_ulong min, target_ulong max,
+                                   target_ulong len, target_ulong align);
+
+/**
+ * page_get_target_data(address)
+ * @address: guest virtual address
+ *
+ * Return TARGET_PAGE_DATA_SIZE bytes of out-of-band data to associate
+ * with the guest page at @address, allocating it if necessary.  The
+ * caller should already have verified that the address is valid.
+ *
+ * The memory will be freed when the guest page is deallocated,
+ * e.g. with the munmap system call.
+ */
+__attribute__((returns_nonnull))
+void *page_get_target_data(target_ulong address);
+
  typedef int (*walk_memory_regions_fn)(void *, target_ulong,
                                        target_ulong, unsigned long);
 
target/arm/tcg/mte_helper.c +0 -0
index 9d2ba287eeb..ae037dc9143 100644

target/arm/tcg/mte_helper.c line 31

Quoted 9 lines
target/arm/tcg/mte_helper.c +3 -0
@@ -23,6 +23,9 @@
  #include "internals.h"
  #include "exec/exec-all.h"
  #include "exec/page-protection.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
  #include "exec/ram_addr.h"
  #include "exec/cpu_ldst.h"
  #include "exec/helper-proto.h"
#29 lore raw

PATCH 13/18 accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (3/4)

In reply to Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
 bsd-user/qemu.h                |  1 +
 include/exec/cpu-all.h         | 12 ------------
 include/user/page-protection.h | 12 ++++++++++++
 linux-user/qemu.h              |  1 +
 target/arm/tcg/sve_helper.c    |  3 +++
 target/hppa/op_helper.c        |  3 +++
 target/sparc/ldst_helper.c     |  3 +++
 7 files changed, 23 insertions(+), 12 deletions(-)
bsd-user/qemu.h +1 -0
index 3736c417860..04faee459df 100644
@@ -26,6 +26,7 @@
 #include "exec/exec-all.h"
 
 #include "user/abitypes.h"
+#include "user/page-protection.h"
 
 extern char **environ;
 
include/exec/cpu-all.h +0 -12
index 86cd40020c9..73b11f58abb 100644
@@ -130,18 +130,6 @@ extern const TargetPageBits target_page;
 
 int page_get_flags(target_ulong address);
 
-/**
- * page_check_range
- * @start: first byte of range
- * @len: length of range
- * @flags: flags required for each page
- *
- * Return true if every page in [@start, @start+@len) has @flags set.
- * Return false if any page is unmapped.  Thus testing flags == 0 is
- * equivalent to testing for flags == PAGE_VALID.
- */
-bool page_check_range(target_ulong start, target_ulong last, int flags);
-
 #endif
 
 CPUArchState *cpu_copy(CPUArchState *env);
include/user/page-protection.h +12 -0
index d21fab1aaf9..bdd98a37de1 100644
@@ -34,6 +34,18 @@ void page_set_flags(target_ulong start, target_ulong last, int flags);
 
 void page_reset_target_data(target_ulong start, target_ulong last);
 
+/**
+ * page_check_range
+ * @start: first byte of range
+ * @len: length of range
+ * @flags: flags required for each page
+ *
+ * Return true if every page in [@start, @start+@len) has @flags set.
+ * Return false if any page is unmapped.  Thus testing flags == 0 is
+ * equivalent to testing for flags == PAGE_VALID.
+ */
+bool page_check_range(target_ulong start, target_ulong last, int flags);
+
 /**
  * page_check_range_empty:
  * @start: first byte of range
linux-user/qemu.h +1 -0
index 67bc81b1499..5f007501518 100644
@@ -5,6 +5,7 @@
 #include "exec/cpu_ldst.h"
 
 #include "user/abitypes.h"
+#include "user/page-protection.h"
 
 #include "syscall_defs.h"
 #include "target_syscall.h"
target/arm/tcg/sve_helper.c +3 -0
index 904296705c6..5a543b8dbc0 100644
@@ -29,6 +29,9 @@
 #include "vec_internal.h"
 #include "sve_ldst_internal.h"
 #include "hw/core/tcg-cpu-ops.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 
 /* Return a value for NZCV as per the ARM PredTest pseudofunction.
target/hppa/op_helper.c +3 -0
index 744325969f5..beb8f88799e 100644
@@ -25,6 +25,9 @@
 #include "exec/cpu_ldst.h"
 #include "qemu/timer.h"
 #include "trace.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 G_NORETURN void HELPER(excp)(CPUHPPAState *env, int excp)
 {
target/sparc/ldst_helper.c +3 -0
index d92c9f15934..4c54e456553 100644
@@ -26,6 +26,9 @@
 #include "exec/exec-all.h"
 #include "exec/page-protection.h"
 #include "exec/cpu_ldst.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 #include "asi.h"
 
 //#define DEBUG_MMU
Signature · 1 line
2.45.2
Reviewed-by on v1 13/18
#30 lore raw

Re: [PATCH 13/18] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (3/4)

Quoted 117 lines · Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
  bsd-user/qemu.h                |  1 +
  include/exec/cpu-all.h         | 12 ------------
  include/user/page-protection.h | 12 ++++++++++++
  linux-user/qemu.h              |  1 +
  target/arm/tcg/sve_helper.c    |  3 +++
  target/hppa/op_helper.c        |  3 +++
  target/sparc/ldst_helper.c     |  3 +++
  7 files changed, 23 insertions(+), 12 deletions(-)
bsd-user/qemu.h +1 -0
index 3736c417860..04faee459df 100644
@@ -26,6 +26,7 @@
  #include "exec/exec-all.h"
 
  #include "user/abitypes.h"
+#include "user/page-protection.h"
 
  extern char **environ;
 
include/exec/cpu-all.h +0 -12
index 86cd40020c9..73b11f58abb 100644
@@ -130,18 +130,6 @@ extern const TargetPageBits target_page;
 
  int page_get_flags(target_ulong address);
 
-/**
- * page_check_range
- * @start: first byte of range
- * @len: length of range
- * @flags: flags required for each page
- *
- * Return true if every page in [@start, @start+@len) has @flags set.
- * Return false if any page is unmapped.  Thus testing flags == 0 is
- * equivalent to testing for flags == PAGE_VALID.
- */
-bool page_check_range(target_ulong start, target_ulong last, int flags);
-
  #endif
 
  CPUArchState *cpu_copy(CPUArchState *env);
include/user/page-protection.h +12 -0
index d21fab1aaf9..bdd98a37de1 100644
@@ -34,6 +34,18 @@ void page_set_flags(target_ulong start, target_ulong last, int flags);
 
  void page_reset_target_data(target_ulong start, target_ulong last);
 
+/**
+ * page_check_range
+ * @start: first byte of range
+ * @len: length of range
+ * @flags: flags required for each page
+ *
+ * Return true if every page in [@start, @start+@len) has @flags set.
+ * Return false if any page is unmapped.  Thus testing flags == 0 is
+ * equivalent to testing for flags == PAGE_VALID.
+ */
+bool page_check_range(target_ulong start, target_ulong last, int flags);
+
  /**
   * page_check_range_empty:
   * @start: first byte of range
linux-user/qemu.h +1 -0
index 67bc81b1499..5f007501518 100644
@@ -5,6 +5,7 @@
  #include "exec/cpu_ldst.h"
 
  #include "user/abitypes.h"
+#include "user/page-protection.h"
 
  #include "syscall_defs.h"
  #include "target_syscall.h"
target/arm/tcg/sve_helper.c +3 -0
index 904296705c6..5a543b8dbc0 100644
@@ -29,6 +29,9 @@
  #include "vec_internal.h"
  #include "sve_ldst_internal.h"
  #include "hw/core/tcg-cpu-ops.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 
  /* Return a value for NZCV as per the ARM PredTest pseudofunction.
target/hppa/op_helper.c +3 -0
index 744325969f5..beb8f88799e 100644
@@ -25,6 +25,9 @@
  #include "exec/cpu_ldst.h"
  #include "qemu/timer.h"
  #include "trace.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
  G_NORETURN void HELPER(excp)(CPUHPPAState *env, int excp)
  {
target/sparc/ldst_helper.c +0 -0
index d92c9f15934..4c54e456553 100644

target/sparc/ldst_helper.c line 34

Quoted 9 lines
target/sparc/ldst_helper.c +3 -0
@@ -26,6 +26,9 @@
  #include "exec/exec-all.h"
  #include "exec/page-protection.h"
  #include "exec/cpu_ldst.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
  #include "asi.h"
 
  //#define DEBUG_MMU
#31 lore raw

PATCH 14/18 accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (4/4)

In reply to Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
 include/exec/cpu-all.h         | 6 ------
 include/user/page-protection.h | 2 ++
 accel/tcg/tb-maint.c           | 3 +++
 bsd-user/signal.c              | 1 +
 cpu-target.c                   | 1 +
 linux-user/arm/cpu_loop.c      | 1 +
 linux-user/signal.c            | 1 +
 target/arm/tcg/helper-a64.c    | 3 +++
 target/s390x/tcg/mem_helper.c  | 4 +++-
 9 files changed, 15 insertions(+), 7 deletions(-)
include/exec/cpu-all.h +0 -6
index 73b11f58abb..f7eea33b101 100644
@@ -126,12 +126,6 @@ extern const TargetPageBits target_page;
 
 #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
 
-#if defined(CONFIG_USER_ONLY)
-
-int page_get_flags(target_ulong address);
-
-#endif
-
 CPUArchState *cpu_copy(CPUArchState *env);
 
 /* Flags for use in ENV->INTERRUPT_PENDING.
include/user/page-protection.h +2 -0
index bdd98a37de1..51daa186480 100644
@@ -19,6 +19,8 @@
 void page_protect(tb_page_addr_t page_addr);
 int page_unprotect(tb_page_addr_t address, uintptr_t pc);
 
+int page_get_flags(target_ulong address);
+
 /**
  * page_set_flags:
  * @start: first byte of range
accel/tcg/tb-maint.c +3 -0
index 8e272cf790f..3f1bebf6ab5 100644
@@ -33,6 +33,9 @@
 #include "tb-internal.h"
 #include "internal-common.h"
 #include "internal-target.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 
 /* List iterators for lists of tagged pointers in TranslationBlock. */
bsd-user/signal.c +1 -0
index da49b9bffc1..edbcd461bfa 100644
@@ -22,6 +22,7 @@
 #include "qemu/log.h"
 #include "qemu.h"
 #include "exec/page-protection.h"
+#include "user/page-protection.h"
 #include "user/tswap-target.h"
 #include "gdbstub/user.h"
 #include "signal-common.h"
cpu-target.c +1 -0
index 4a88f1c6db8..69a49202110 100644
@@ -29,6 +29,7 @@
 #include "migration/vmstate.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
+#include "user/page-protection.h"
 #else
 #include "hw/core/sysemu-cpu-ops.h"
 #include "exec/address-spaces.h"
linux-user/arm/cpu_loop.c +1 -0
index ec665862d93..709f718a99d 100644
@@ -25,6 +25,7 @@
 #include "signal-common.h"
 #include "semihosting/common-semi.h"
 #include "exec/page-protection.h"
+#include "user/page-protection.h"
 #include "target/arm/syndrome.h"
 
 #define get_user_code_u32(x, gaddr, env)                \
linux-user/signal.c +1 -0
index 9b6d772882d..a191e9b26f2 100644
@@ -33,6 +33,7 @@
 #include "trace.h"
 #include "signal-common.h"
 #include "host-signal.h"
+#include "user/page-protection.h"
 #include "user/safe-syscall.h"
 #include "tcg/tcg.h"
 
target/arm/tcg/helper-a64.c +3 -0
index 8f42a28d07b..bc144688dd5 100644
@@ -34,6 +34,9 @@
 #include "qemu/atomic128.h"
 #include "fpu/softfloat.h"
 #include <zlib.h> /* for crc32 */
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 /* C2.4.7 Multiply and divide */
 /* special cases for 0 and LLONG_MIN are mandated by the standard */
target/s390x/tcg/mem_helper.c +3 -1
index 0e12dae2aa8..307388e5bd1 100644
@@ -31,7 +31,9 @@
 #include "qemu/int128.h"
 #include "qemu/atomic128.h"
 
-#if !defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_USER_ONLY)
+#include "user/page-protection.h"
+#else
 #include "hw/s390x/storage-keys.h"
 #include "hw/boards.h"
 #endif
Signature · 1 line
2.45.2
Reviewed-by on v1 14/18
#32 lore raw

Re: [PATCH 14/18] accel/tcg: Move user-related declarations out of 'exec/cpu-all.h' (4/4)

Quoted 127 lines · Philippe Mathieu-Daudé

Move declarations related to page protection under user emulation from "exec/cpu-all.h" to "user/page-protection.h".

---
  include/exec/cpu-all.h         | 6 ------
  include/user/page-protection.h | 2 ++
  accel/tcg/tb-maint.c           | 3 +++
  bsd-user/signal.c              | 1 +
  cpu-target.c                   | 1 +
  linux-user/arm/cpu_loop.c      | 1 +
  linux-user/signal.c            | 1 +
  target/arm/tcg/helper-a64.c    | 3 +++
  target/s390x/tcg/mem_helper.c  | 4 +++-
  9 files changed, 15 insertions(+), 7 deletions(-)
include/exec/cpu-all.h +0 -6
index 73b11f58abb..f7eea33b101 100644
@@ -126,12 +126,6 @@ extern const TargetPageBits target_page;
 
  #define TARGET_PAGE_ALIGN(addr) ROUND_UP((addr), TARGET_PAGE_SIZE)
 
-#if defined(CONFIG_USER_ONLY)
-
-int page_get_flags(target_ulong address);
-
-#endif
-
  CPUArchState *cpu_copy(CPUArchState *env);
 
  /* Flags for use in ENV->INTERRUPT_PENDING.
include/user/page-protection.h +2 -0
index bdd98a37de1..51daa186480 100644
@@ -19,6 +19,8 @@
  void page_protect(tb_page_addr_t page_addr);
  int page_unprotect(tb_page_addr_t address, uintptr_t pc);
 
+int page_get_flags(target_ulong address);
+
  /**
   * page_set_flags:
   * @start: first byte of range
accel/tcg/tb-maint.c +3 -0
index 8e272cf790f..3f1bebf6ab5 100644
@@ -33,6 +33,9 @@
  #include "tb-internal.h"
  #include "internal-common.h"
  #include "internal-target.h"
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
 
  /* List iterators for lists of tagged pointers in TranslationBlock. */
bsd-user/signal.c +1 -0
index da49b9bffc1..edbcd461bfa 100644
@@ -22,6 +22,7 @@
  #include "qemu/log.h"
  #include "qemu.h"
  #include "exec/page-protection.h"
+#include "user/page-protection.h"
  #include "user/tswap-target.h"
  #include "gdbstub/user.h"
  #include "signal-common.h"
cpu-target.c +1 -0
index 4a88f1c6db8..69a49202110 100644
@@ -29,6 +29,7 @@
  #include "migration/vmstate.h"
  #ifdef CONFIG_USER_ONLY
  #include "qemu.h"
+#include "user/page-protection.h"
  #else
  #include "hw/core/sysemu-cpu-ops.h"
  #include "exec/address-spaces.h"
linux-user/arm/cpu_loop.c +1 -0
index ec665862d93..709f718a99d 100644
@@ -25,6 +25,7 @@
  #include "signal-common.h"
  #include "semihosting/common-semi.h"
  #include "exec/page-protection.h"
+#include "user/page-protection.h"
  #include "target/arm/syndrome.h"
 
  #define get_user_code_u32(x, gaddr, env)                \
linux-user/signal.c +1 -0
index 9b6d772882d..a191e9b26f2 100644
@@ -33,6 +33,7 @@
  #include "trace.h"
  #include "signal-common.h"
  #include "host-signal.h"
+#include "user/page-protection.h"
  #include "user/safe-syscall.h"
  #include "tcg/tcg.h"
 
target/arm/tcg/helper-a64.c +3 -0
index 8f42a28d07b..bc144688dd5 100644
@@ -34,6 +34,9 @@
  #include "qemu/atomic128.h"
  #include "fpu/softfloat.h"
  #include <zlib.h> /* for crc32 */
+#ifdef CONFIG_USER_ONLY
+#include "user/page-protection.h"
+#endif
 
  /* C2.4.7 Multiply and divide */
  /* special cases for 0 and LLONG_MIN are mandated by the standard */
target/s390x/tcg/mem_helper.c +0 -0
index 0e12dae2aa8..307388e5bd1 100644

target/s390x/tcg/mem_helper.c line 39

Quoted 10 lines
target/s390x/tcg/mem_helper.c +3 -1
@@ -31,7 +31,9 @@
  #include "qemu/int128.h"
  #include "qemu/atomic128.h"
 
-#if !defined(CONFIG_USER_ONLY)
+#if defined(CONFIG_USER_ONLY)
+#include "user/page-protection.h"
+#else
  #include "hw/s390x/storage-keys.h"
  #include "hw/boards.h"
  #endif
#33 lore raw

PATCH 15/18 user: Forward declare target_cpu_copy_regs structure

In reply to Philippe Mathieu-Daudé
---
 linux-user/cpu_loop-common.h      | 5 ++++-
 linux-user/aarch64/cpu_loop.c     | 2 +-
 linux-user/alpha/cpu_loop.c       | 2 +-
 linux-user/arm/cpu_loop.c         | 2 +-
 linux-user/hexagon/cpu_loop.c     | 2 +-
 linux-user/hppa/cpu_loop.c        | 2 +-
 linux-user/i386/cpu_loop.c        | 2 +-
 linux-user/loongarch64/cpu_loop.c | 2 +-
 linux-user/m68k/cpu_loop.c        | 2 +-
 linux-user/microblaze/cpu_loop.c  | 2 +-
 linux-user/mips/cpu_loop.c        | 2 +-
 linux-user/openrisc/cpu_loop.c    | 2 +-
 linux-user/ppc/cpu_loop.c         | 2 +-
 linux-user/riscv/cpu_loop.c       | 2 +-
 linux-user/s390x/cpu_loop.c       | 2 +-
 linux-user/sh4/cpu_loop.c         | 2 +-
 linux-user/sparc/cpu_loop.c       | 2 +-
 linux-user/xtensa/cpu_loop.c      | 2 +-
 18 files changed, 21 insertions(+), 18 deletions(-)
linux-user/cpu_loop-common.h +4 -1
index e644d2ef909..aca51f53238 100644
@@ -27,5 +27,8 @@ void target_exception_dump(CPUArchState *env, const char *fmt, int code);
 #define EXCP_DUMP(env, fmt, code) \
     target_exception_dump(env, fmt, code)
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs);
+typedef struct target_pt_regs target_pt_regs;
+
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs);
+
 #endif
linux-user/aarch64/cpu_loop.c +1 -1
index 71cdc8be50c..77f857a8216 100644
@@ -185,7 +185,7 @@ void cpu_loop(CPUARMState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     ARMCPU *cpu = env_archcpu(env);
     CPUState *cs = env_cpu(env);
linux-user/alpha/cpu_loop.c +1 -1
index 2ea039aa71f..b5403ed0e46 100644
@@ -173,7 +173,7 @@ void cpu_loop(CPUAlphaState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
 
linux-user/arm/cpu_loop.c +1 -1
index 709f718a99d..be1f11022a7 100644
@@ -513,7 +513,7 @@ void cpu_loop(CPUARMState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     CPUState *cpu = env_cpu(env);
     TaskState *ts = get_task_state(cpu);
linux-user/hexagon/cpu_loop.c +1 -1
index d41159e52ad..a1794470113 100644
@@ -79,7 +79,7 @@ void cpu_loop(CPUHexagonState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     env->gpr[HEX_REG_PC] = regs->sepc;
     env->gpr[HEX_REG_SP] = regs->sp;
linux-user/hppa/cpu_loop.c +1 -1
index 23b38ff9b28..503a204460e 100644
@@ -188,7 +188,7 @@ void cpu_loop(CPUHPPAState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
     for (i = 1; i < 32; i++) {
linux-user/i386/cpu_loop.c +1 -1
index 7a35215278a..e06aa23de4c 100644
@@ -331,7 +331,7 @@ static void target_cpu_free(void *obj)
     g_free(obj);
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     CPUState *cpu = env_cpu(env);
     bool is64 = (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) != 0;
linux-user/loongarch64/cpu_loop.c +1 -1
index 73d7b6796a4..935d5bcf2c8 100644
@@ -97,7 +97,7 @@ void cpu_loop(CPULoongArchState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
 
linux-user/m68k/cpu_loop.c +1 -1
index f79b8e4ab05..69cdce95518 100644
@@ -92,7 +92,7 @@ void cpu_loop(CPUM68KState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     CPUState *cpu = env_cpu(env);
     TaskState *ts = get_task_state(cpu);
linux-user/microblaze/cpu_loop.c +1 -1
index 212e62d0a62..ee4ba768691 100644
@@ -127,7 +127,7 @@ void cpu_loop(CPUMBState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     env->regs[0] = regs->r0;
     env->regs[1] = regs->r1;
linux-user/mips/cpu_loop.c +1 -1
index 462387a0737..1331a9a2b8d 100644
@@ -211,7 +211,7 @@ done_syscall:
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     CPUState *cpu = env_cpu(env);
     TaskState *ts = get_task_state(cpu);
linux-user/openrisc/cpu_loop.c +1 -1
index a7aa586c8f9..1bf9542d16a 100644
@@ -83,7 +83,7 @@ void cpu_loop(CPUOpenRISCState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
 
linux-user/ppc/cpu_loop.c +1 -1
index 02204ad8beb..e168f1ce947 100644
@@ -378,7 +378,7 @@ void cpu_loop(CPUPPCState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
 
linux-user/riscv/cpu_loop.c +1 -1
index 0af533e186f..a72bc76da3d 100644
@@ -94,7 +94,7 @@ void cpu_loop(CPURISCVState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     CPUState *cpu = env_cpu(env);
     TaskState *ts = get_task_state(cpu);
linux-user/s390x/cpu_loop.c +1 -1
index 8b7ac2879ef..42e4d24102e 100644
@@ -180,7 +180,7 @@ void cpu_loop(CPUS390XState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
     for (i = 0; i < 16; i++) {
linux-user/sh4/cpu_loop.c +1 -1
index c805f9db110..937d9fa265d 100644
@@ -81,7 +81,7 @@ void cpu_loop(CPUSH4State *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
 
linux-user/sparc/cpu_loop.c +1 -1
index 50424a54df5..58a2464da9f 100644
@@ -357,7 +357,7 @@ void cpu_loop (CPUSPARCState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
     env->pc = regs->pc;
linux-user/xtensa/cpu_loop.c +1 -1
index d51ce053926..7564e25a966 100644
@@ -238,7 +238,7 @@ void cpu_loop(CPUXtensaState *env)
     }
 }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
 {
     int i;
     for (i = 0; i < 16; ++i) {
Signature · 1 line
2.45.2
Reviewed-by on v1 15/18
#34 lore raw

Re: [PATCH 15/18] user: Forward declare target_cpu_copy_regs structure

Quoted 249 lines · Philippe Mathieu-Daudé
---
  linux-user/cpu_loop-common.h      | 5 ++++-
  linux-user/aarch64/cpu_loop.c     | 2 +-
  linux-user/alpha/cpu_loop.c       | 2 +-
  linux-user/arm/cpu_loop.c         | 2 +-
  linux-user/hexagon/cpu_loop.c     | 2 +-
  linux-user/hppa/cpu_loop.c        | 2 +-
  linux-user/i386/cpu_loop.c        | 2 +-
  linux-user/loongarch64/cpu_loop.c | 2 +-
  linux-user/m68k/cpu_loop.c        | 2 +-
  linux-user/microblaze/cpu_loop.c  | 2 +-
  linux-user/mips/cpu_loop.c        | 2 +-
  linux-user/openrisc/cpu_loop.c    | 2 +-
  linux-user/ppc/cpu_loop.c         | 2 +-
  linux-user/riscv/cpu_loop.c       | 2 +-
  linux-user/s390x/cpu_loop.c       | 2 +-
  linux-user/sh4/cpu_loop.c         | 2 +-
  linux-user/sparc/cpu_loop.c       | 2 +-
  linux-user/xtensa/cpu_loop.c      | 2 +-
  18 files changed, 21 insertions(+), 18 deletions(-)
linux-user/cpu_loop-common.h +4 -1
index e644d2ef909..aca51f53238 100644
@@ -27,5 +27,8 @@ void target_exception_dump(CPUArchState *env, const char *fmt, int code);
  #define EXCP_DUMP(env, fmt, code) \
      target_exception_dump(env, fmt, code)
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs);
+typedef struct target_pt_regs target_pt_regs;
+
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs);
+
  #endif
linux-user/aarch64/cpu_loop.c +1 -1
index 71cdc8be50c..77f857a8216 100644
@@ -185,7 +185,7 @@ void cpu_loop(CPUARMState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      ARMCPU *cpu = env_archcpu(env);
      CPUState *cs = env_cpu(env);
linux-user/alpha/cpu_loop.c +1 -1
index 2ea039aa71f..b5403ed0e46 100644
@@ -173,7 +173,7 @@ void cpu_loop(CPUAlphaState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
 
linux-user/arm/cpu_loop.c +1 -1
index 709f718a99d..be1f11022a7 100644
@@ -513,7 +513,7 @@ void cpu_loop(CPUARMState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      CPUState *cpu = env_cpu(env);
      TaskState *ts = get_task_state(cpu);
linux-user/hexagon/cpu_loop.c +1 -1
index d41159e52ad..a1794470113 100644
@@ -79,7 +79,7 @@ void cpu_loop(CPUHexagonState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      env->gpr[HEX_REG_PC] = regs->sepc;
      env->gpr[HEX_REG_SP] = regs->sp;
linux-user/hppa/cpu_loop.c +1 -1
index 23b38ff9b28..503a204460e 100644
@@ -188,7 +188,7 @@ void cpu_loop(CPUHPPAState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
      for (i = 1; i < 32; i++) {
linux-user/i386/cpu_loop.c +1 -1
index 7a35215278a..e06aa23de4c 100644
@@ -331,7 +331,7 @@ static void target_cpu_free(void *obj)
      g_free(obj);
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      CPUState *cpu = env_cpu(env);
      bool is64 = (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) != 0;
linux-user/loongarch64/cpu_loop.c +1 -1
index 73d7b6796a4..935d5bcf2c8 100644
@@ -97,7 +97,7 @@ void cpu_loop(CPULoongArchState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
 
linux-user/m68k/cpu_loop.c +1 -1
index f79b8e4ab05..69cdce95518 100644
@@ -92,7 +92,7 @@ void cpu_loop(CPUM68KState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      CPUState *cpu = env_cpu(env);
      TaskState *ts = get_task_state(cpu);
linux-user/microblaze/cpu_loop.c +1 -1
index 212e62d0a62..ee4ba768691 100644
@@ -127,7 +127,7 @@ void cpu_loop(CPUMBState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      env->regs[0] = regs->r0;
      env->regs[1] = regs->r1;
linux-user/mips/cpu_loop.c +1 -1
index 462387a0737..1331a9a2b8d 100644
@@ -211,7 +211,7 @@ done_syscall:
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      CPUState *cpu = env_cpu(env);
      TaskState *ts = get_task_state(cpu);
linux-user/openrisc/cpu_loop.c +1 -1
index a7aa586c8f9..1bf9542d16a 100644
@@ -83,7 +83,7 @@ void cpu_loop(CPUOpenRISCState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
 
linux-user/ppc/cpu_loop.c +1 -1
index 02204ad8beb..e168f1ce947 100644
@@ -378,7 +378,7 @@ void cpu_loop(CPUPPCState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
 
linux-user/riscv/cpu_loop.c +1 -1
index 0af533e186f..a72bc76da3d 100644
@@ -94,7 +94,7 @@ void cpu_loop(CPURISCVState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      CPUState *cpu = env_cpu(env);
      TaskState *ts = get_task_state(cpu);
linux-user/s390x/cpu_loop.c +1 -1
index 8b7ac2879ef..42e4d24102e 100644
@@ -180,7 +180,7 @@ void cpu_loop(CPUS390XState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
      for (i = 0; i < 16; i++) {
linux-user/sh4/cpu_loop.c +1 -1
index c805f9db110..937d9fa265d 100644
@@ -81,7 +81,7 @@ void cpu_loop(CPUSH4State *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
 
linux-user/sparc/cpu_loop.c +1 -1
index 50424a54df5..58a2464da9f 100644
@@ -357,7 +357,7 @@ void cpu_loop (CPUSPARCState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
      env->pc = regs->pc;
linux-user/xtensa/cpu_loop.c +0 -0
index d51ce053926..7564e25a966 100644

linux-user/xtensa/cpu_loop.c void cpu_loop(CPUXtensaState *env) · line 244

Quoted 8 lines
linux-user/xtensa/cpu_loop.c +1 -1
@@ -238,7 +238,7 @@ void cpu_loop(CPUXtensaState *env)
      }
  }
 
-void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
+void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs)
  {
      int i;
      for (i = 0; i < 16; ++i) {
#35 lore raw

PATCH 16/18 user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h'

In reply to Philippe Mathieu-Daudé

"linux-user/cpu_loop-common.h" is generic enough to be used by bsd-user, so rename it as "user/cpu_loop.h".

Mechanical change running:

  $ sed -i -e 's,cpu_loop-common.h,user/cpu_loop.h,' \
                $(git grep -l cpu_loop-common.h)
---
 linux-user/cpu_loop-common.h => include/user/cpu_loop.h | 4 ++--
 linux-user/aarch64/cpu_loop.c                           | 2 +-
 linux-user/alpha/cpu_loop.c                             | 2 +-
 linux-user/arm/cpu_loop.c                               | 2 +-
 linux-user/hexagon/cpu_loop.c                           | 2 +-
 linux-user/hppa/cpu_loop.c                              | 2 +-
 linux-user/i386/cpu_loop.c                              | 2 +-
 linux-user/loongarch64/cpu_loop.c                       | 2 +-
 linux-user/m68k/cpu_loop.c                              | 2 +-
 linux-user/main.c                                       | 2 +-
 linux-user/microblaze/cpu_loop.c                        | 2 +-
 linux-user/mips/cpu_loop.c                              | 2 +-
 linux-user/openrisc/cpu_loop.c                          | 2 +-
 linux-user/ppc/cpu_loop.c                               | 2 +-
 linux-user/riscv/cpu_loop.c                             | 2 +-
 linux-user/s390x/cpu_loop.c                             | 2 +-
 linux-user/sh4/cpu_loop.c                               | 2 +-
 linux-user/sparc/cpu_loop.c                             | 2 +-
 linux-user/syscall.c                                    | 2 +-
 linux-user/xtensa/cpu_loop.c                            | 2 +-
 20 files changed, 21 insertions(+), 21 deletions(-)
 rename linux-user/cpu_loop-common.h => include/user/cpu_loop.h (95%)
include/user/cpu_loop.h renamed from linux-user/cpu_loop-common.h +2 -2
similarity index 95%
rename from linux-user/cpu_loop-common.h
rename to include/user/cpu_loop.h
index aca51f53238..8e2df232758 100644
@@ -17,8 +17,8 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef CPU_LOOP_COMMON_H
-#define CPU_LOOP_COMMON_H
+#ifndef USER_CPU_LOOP_H
+#define USER_CPU_LOOP_H
 
 #include "exec/log.h"
 #include "special-errno.h"
linux-user/aarch64/cpu_loop.c +1 -1
index 77f857a8216..c5d8a483a3f 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "qemu/guest-random.h"
 #include "semihosting/common-semi.h"
linux-user/alpha/cpu_loop.c +1 -1
index b5403ed0e46..80ad536c5f2 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPUAlphaState *env)
linux-user/arm/cpu_loop.c +1 -1
index be1f11022a7..10d8561f9b9 100644
@@ -21,7 +21,7 @@
 #include "qemu.h"
 #include "user-internals.h"
 #include "elf.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "semihosting/common-semi.h"
 #include "exec/page-protection.h"
linux-user/hexagon/cpu_loop.c +1 -1
index a1794470113..de70f736367 100644
@@ -21,7 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "internal.h"
 
linux-user/hppa/cpu_loop.c +1 -1
index 503a204460e..890e758cd1c 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 static abi_ulong hppa_lws(CPUHPPAState *env)
linux-user/i386/cpu_loop.c +1 -1
index e06aa23de4c..d96d5553faf 100644
@@ -21,7 +21,7 @@
 #include "qemu.h"
 #include "qemu/timer.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "user-mmap.h"
 
linux-user/loongarch64/cpu_loop.c +1 -1
index 935d5bcf2c8..0614d3de224 100644
@@ -8,7 +8,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPULoongArchState *env)
linux-user/m68k/cpu_loop.c +1 -1
index 69cdce95518..5da91b997ae 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPUM68KState *env)
linux-user/main.c +1 -1
index 06037304cb1..b97634a32dd 100644
@@ -50,7 +50,7 @@
 #include "elf.h"
 #include "trace/control.h"
 #include "target_elf.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "crypto/init.h"
 #include "fd-trans.h"
 #include "signal-common.h"
linux-user/microblaze/cpu_loop.c +1 -1
index ee4ba768691..87236c166f2 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPUMBState *env)
linux-user/mips/cpu_loop.c +1 -1
index 1331a9a2b8d..6405806eb02 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "elf.h"
 #include "internal.h"
linux-user/openrisc/cpu_loop.c +1 -1
index 1bf9542d16a..306b4f8eb43 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPUOpenRISCState *env)
linux-user/ppc/cpu_loop.c +1 -1
index e168f1ce947..2a0efaffcd6 100644
@@ -21,7 +21,7 @@
 #include "qemu.h"
 #include "qemu/timer.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
linux-user/riscv/cpu_loop.c +1 -1
index a72bc76da3d..3ac8bbfec1f 100644
@@ -21,7 +21,7 @@
 #include "qemu/error-report.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 #include "elf.h"
 #include "semihosting/common-semi.h"
linux-user/s390x/cpu_loop.c +1 -1
index 42e4d24102e..c9124444ed2 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 
linux-user/sh4/cpu_loop.c +1 -1
index 937d9fa265d..ee9eff3428a 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 void cpu_loop(CPUSH4State *env)
linux-user/sparc/cpu_loop.c +1 -1
index 58a2464da9f..68f1e8ecd43 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 #define SPARC64_STACK_BIAS 2047
linux-user/syscall.c +1 -1
index c54b199b6d3..1b335688f12 100644
@@ -143,7 +143,7 @@
 #include "special-errno.h"
 #include "qapi/error.h"
 #include "fd-trans.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 
 #ifndef CLONE_IO
 #define CLONE_IO                0x80000000      /* Clone io context */
linux-user/xtensa/cpu_loop.c +1 -1
index 7564e25a966..c0fcf743e70 100644
@@ -20,7 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu.h"
 #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 #include "signal-common.h"
 
 static void xtensa_rfw(CPUXtensaState *env)
Signature · 1 line
2.45.2
Reviewed-by on v1 16/18
#36 lore raw

Re: [PATCH 16/18] user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h'

Quoted 290 lines · Philippe Mathieu-Daudé

"linux-user/cpu_loop-common.h" is generic enough to be used by bsd-user, so rename it as "user/cpu_loop.h".

Mechanical change running:

   $ sed -i -e 's,cpu_loop-common.h,user/cpu_loop.h,' \
                 $(git grep -l cpu_loop-common.h)
---
  linux-user/cpu_loop-common.h => include/user/cpu_loop.h | 4 ++--
  linux-user/aarch64/cpu_loop.c                           | 2 +-
  linux-user/alpha/cpu_loop.c                             | 2 +-
  linux-user/arm/cpu_loop.c                               | 2 +-
  linux-user/hexagon/cpu_loop.c                           | 2 +-
  linux-user/hppa/cpu_loop.c                              | 2 +-
  linux-user/i386/cpu_loop.c                              | 2 +-
  linux-user/loongarch64/cpu_loop.c                       | 2 +-
  linux-user/m68k/cpu_loop.c                              | 2 +-
  linux-user/main.c                                       | 2 +-
  linux-user/microblaze/cpu_loop.c                        | 2 +-
  linux-user/mips/cpu_loop.c                              | 2 +-
  linux-user/openrisc/cpu_loop.c                          | 2 +-
  linux-user/ppc/cpu_loop.c                               | 2 +-
  linux-user/riscv/cpu_loop.c                             | 2 +-
  linux-user/s390x/cpu_loop.c                             | 2 +-
  linux-user/sh4/cpu_loop.c                               | 2 +-
  linux-user/sparc/cpu_loop.c                             | 2 +-
  linux-user/syscall.c                                    | 2 +-
  linux-user/xtensa/cpu_loop.c                            | 2 +-
  20 files changed, 21 insertions(+), 21 deletions(-)

rename linux-user/cpu_loop-common.h => include/user/cpu_loop.h (95%)

include/user/cpu_loop.h renamed from linux-user/cpu_loop-common.h +2 -2
similarity index 95%
rename from linux-user/cpu_loop-common.h
rename to include/user/cpu_loop.h
index aca51f53238..8e2df232758 100644
@@ -17,8 +17,8 @@
   *  along with this program; if not, see <http://www.gnu.org/licenses/>.
   */
 
-#ifndef CPU_LOOP_COMMON_H
-#define CPU_LOOP_COMMON_H
+#ifndef USER_CPU_LOOP_H
+#define USER_CPU_LOOP_H
 
  #include "exec/log.h"
  #include "special-errno.h"
linux-user/aarch64/cpu_loop.c +1 -1
index 77f857a8216..c5d8a483a3f 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "qemu/guest-random.h"
  #include "semihosting/common-semi.h"
linux-user/alpha/cpu_loop.c +1 -1
index b5403ed0e46..80ad536c5f2 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPUAlphaState *env)
linux-user/arm/cpu_loop.c +1 -1
index be1f11022a7..10d8561f9b9 100644
@@ -21,7 +21,7 @@
  #include "qemu.h"
  #include "user-internals.h"
  #include "elf.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "semihosting/common-semi.h"
  #include "exec/page-protection.h"
linux-user/hexagon/cpu_loop.c +1 -1
index a1794470113..de70f736367 100644
@@ -21,7 +21,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "internal.h"
 
linux-user/hppa/cpu_loop.c +1 -1
index 503a204460e..890e758cd1c 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  static abi_ulong hppa_lws(CPUHPPAState *env)
linux-user/i386/cpu_loop.c +1 -1
index e06aa23de4c..d96d5553faf 100644
@@ -21,7 +21,7 @@
  #include "qemu.h"
  #include "qemu/timer.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "user-mmap.h"
 
linux-user/loongarch64/cpu_loop.c +1 -1
index 935d5bcf2c8..0614d3de224 100644
@@ -8,7 +8,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPULoongArchState *env)
linux-user/m68k/cpu_loop.c +1 -1
index 69cdce95518..5da91b997ae 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPUM68KState *env)
linux-user/main.c +1 -1
index 06037304cb1..b97634a32dd 100644
@@ -50,7 +50,7 @@
  #include "elf.h"
  #include "trace/control.h"
  #include "target_elf.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "crypto/init.h"
  #include "fd-trans.h"
  #include "signal-common.h"
linux-user/microblaze/cpu_loop.c +1 -1
index ee4ba768691..87236c166f2 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPUMBState *env)
linux-user/mips/cpu_loop.c +1 -1
index 1331a9a2b8d..6405806eb02 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "elf.h"
  #include "internal.h"
linux-user/openrisc/cpu_loop.c +1 -1
index 1bf9542d16a..306b4f8eb43 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPUOpenRISCState *env)
linux-user/ppc/cpu_loop.c +1 -1
index e168f1ce947..2a0efaffcd6 100644
@@ -21,7 +21,7 @@
  #include "qemu.h"
  #include "qemu/timer.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env)
linux-user/riscv/cpu_loop.c +1 -1
index a72bc76da3d..3ac8bbfec1f 100644
@@ -21,7 +21,7 @@
  #include "qemu/error-report.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
  #include "elf.h"
  #include "semihosting/common-semi.h"
linux-user/s390x/cpu_loop.c +1 -1
index 42e4d24102e..c9124444ed2 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
 
linux-user/sh4/cpu_loop.c +1 -1
index 937d9fa265d..ee9eff3428a 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  void cpu_loop(CPUSH4State *env)
linux-user/sparc/cpu_loop.c +1 -1
index 58a2464da9f..68f1e8ecd43 100644
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  #define SPARC64_STACK_BIAS 2047
linux-user/syscall.c +1 -1
index c54b199b6d3..1b335688f12 100644
@@ -143,7 +143,7 @@
  #include "special-errno.h"
  #include "qapi/error.h"
  #include "fd-trans.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
 
  #ifndef CLONE_IO
  #define CLONE_IO                0x80000000      /* Clone io context */
linux-user/xtensa/cpu_loop.c +0 -0
index 7564e25a966..c0fcf743e70 100644

linux-user/xtensa/cpu_loop.c line 26

Quoted 8 lines
linux-user/xtensa/cpu_loop.c +1 -1
@@ -20,7 +20,7 @@
  #include "qemu/osdep.h"
  #include "qemu.h"
  #include "user-internals.h"
-#include "cpu_loop-common.h"
+#include "user/cpu_loop.h"
  #include "signal-common.h"
 
  static void xtensa_rfw(CPUXtensaState *env)
#37 lore raw

PATCH 17/18 user: Declare cpu_loop() once in 'user/cpu_loop.h'

In reply to Philippe Mathieu-Daudé

Declare cpu_loop() once in "user/cpu_loop.h".
bsd-user gets the G_NORETURN attribute.

---
 bsd-user/qemu.h             | 2 +-
 include/user/cpu_loop.h     | 2 ++
 linux-user/user-internals.h | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)
bsd-user/qemu.h +1 -1
index 04faee459df..3eaa14f3f56 100644
@@ -26,6 +26,7 @@
 #include "exec/exec-all.h"
 
 #include "user/abitypes.h"
+#include "user/cpu_loop.h"
 #include "user/page-protection.h"
 
 extern char **environ;
@@ -187,7 +188,6 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg5, abi_long arg6);
 void gemu_log(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
 extern __thread CPUState *thread_cpu;
-void cpu_loop(CPUArchState *env);
 char *target_strerror(int err);
 int get_osversion(void);
 void fork_start(void);
include/user/cpu_loop.h +2 -0
index 8e2df232758..b0d4704018d 100644
@@ -23,6 +23,8 @@
 #include "exec/log.h"
 #include "special-errno.h"
 
+G_NORETURN void cpu_loop(CPUArchState *env);
+
 void target_exception_dump(CPUArchState *env, const char *fmt, int code);
 #define EXCP_DUMP(env, fmt, code) \
     target_exception_dump(env, fmt, code)
linux-user/user-internals.h +0 -1
index 46ffc093f40..b9b05c1d11f 100644
@@ -65,7 +65,6 @@ abi_long do_syscall(CPUArchState *cpu_env, int num, abi_long arg1,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8);
 extern __thread CPUState *thread_cpu;
-G_NORETURN void cpu_loop(CPUArchState *env);
 abi_long get_errno(abi_long ret);
 const char *target_strerror(int err);
 int get_osversion(void);
Signature · 1 line
2.45.2
Reviewed-by on v1 17/18
#38 lore raw

Re: [PATCH 17/18] user: Declare cpu_loop() once in 'user/cpu_loop.h'

Quoted 48 lines · Philippe Mathieu-Daudé

Declare cpu_loop() once in "user/cpu_loop.h".
bsd-user gets the G_NORETURN attribute.

---
  bsd-user/qemu.h             | 2 +-
  include/user/cpu_loop.h     | 2 ++
  linux-user/user-internals.h | 1 -
  3 files changed, 3 insertions(+), 2 deletions(-)
bsd-user/qemu.h +1 -1
index 04faee459df..3eaa14f3f56 100644
@@ -26,6 +26,7 @@
  #include "exec/exec-all.h"
 
  #include "user/abitypes.h"
+#include "user/cpu_loop.h"
  #include "user/page-protection.h"
 
  extern char **environ;
@@ -187,7 +188,6 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                              abi_long arg5, abi_long arg6);
  void gemu_log(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
  extern __thread CPUState *thread_cpu;
-void cpu_loop(CPUArchState *env);
  char *target_strerror(int err);
  int get_osversion(void);
  void fork_start(void);
include/user/cpu_loop.h +2 -0
index 8e2df232758..b0d4704018d 100644
@@ -23,6 +23,8 @@
  #include "exec/log.h"
  #include "special-errno.h"
 
+G_NORETURN void cpu_loop(CPUArchState *env);
+
  void target_exception_dump(CPUArchState *env, const char *fmt, int code);
  #define EXCP_DUMP(env, fmt, code) \
      target_exception_dump(env, fmt, code)
linux-user/user-internals.h +0 -0
index 46ffc093f40..b9b05c1d11f 100644

linux-user/user-internals.h abi_long do_syscall(CPUArchState *cpu_env, int num, abi_long arg1, · line 70

Quoted 7 lines
linux-user/user-internals.h +0 -1
@@ -65,7 +65,6 @@ abi_long do_syscall(CPUArchState *cpu_env, int num, abi_long arg1,
                      abi_long arg5, abi_long arg6, abi_long arg7,
                      abi_long arg8);
  extern __thread CPUState *thread_cpu;
-G_NORETURN void cpu_loop(CPUArchState *env);
  abi_long get_errno(abi_long ret);
  const char *target_strerror(int err);
  int get_osversion(void);
#39 lore raw

PATCH 18/18 user: Move various declarations out of 'exec/exec-all.h'

In reply to Philippe Mathieu-Daudé

Move various declarations related to user emulation from "exec/exec-all.h" to "user/cpu_loop.h".

---
 include/exec/exec-all.h     | 55 +------------------------------------
 include/user/cpu_loop.h     | 54 ++++++++++++++++++++++++++++++++++++
 accel/tcg/user-exec.c       |  1 +
 bsd-user/signal.c           |  1 +
 linux-user/signal.c         |  1 +
 target/arm/tcg/mte_helper.c |  1 +
 6 files changed, 59 insertions(+), 54 deletions(-)
include/exec/exec-all.h +1 -54
index b5ea607cf45..c4a6ad3af2d 100644
@@ -22,7 +22,6 @@
 
 #include "cpu.h"
 #if defined(CONFIG_USER_ONLY)
-#include "exec/abi_ptr.h"
 #include "exec/cpu_ldst.h"
 #endif
 #include "exec/mmu-access-type.h"
@@ -518,60 +517,8 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
     return get_page_addr_code_hostp(env, addr, NULL);
 }
 
-#if defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
 
-/**
- * adjust_signal_pc:
- * @pc: raw pc from the host signal ucontext_t.
- * @is_write: host memory operation was write, or read-modify-write.
- *
- * Alter @pc as required for unwinding.  Return the type of the
- * guest memory access -- host reads may be for guest execution.
- */
-MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
-
-/**
- * handle_sigsegv_accerr_write:
- * @cpu: the cpu context
- * @old_set: the sigset_t from the signal ucontext_t
- * @host_pc: the host pc, adjusted for the signal
- * @host_addr: the host address of the fault
- *
- * Return true if the write fault has been handled, and should be re-tried.
- */
-bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
-                                 uintptr_t host_pc, abi_ptr guest_addr);
-
-/**
- * cpu_loop_exit_sigsegv:
- * @cpu: the cpu context
- * @addr: the guest address of the fault
- * @access_type: access was read/write/execute
- * @maperr: true for invalid page, false for permission fault
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGSEGV, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
-                                      MMUAccessType access_type,
-                                      bool maperr, uintptr_t ra);
-
-/**
- * cpu_loop_exit_sigbus:
- * @cpu: the cpu context
- * @addr: the guest address of the alignment fault
- * @access_type: access was read/write/execute
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGBUS, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
-                                     MMUAccessType access_type,
-                                     uintptr_t ra);
-
-#else
 void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
 void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
 
include/user/cpu_loop.h +54 -0

65 lines not on this page · raw message

accel/tcg/user-exec.c +1 -0
index 815a39503f3..0561c4f6dc7 100644
@@ -24,6 +24,7 @@
 #include "qemu/bitops.h"
 #include "qemu/rcu.h"
 #include "exec/cpu_ldst.h"
+#include "user/cpu_loop.h"
 #include "qemu/main-loop.h"
 #include "user/page-protection.h"
 #include "exec/page-protection.h"
bsd-user/signal.c +1 -0
index edbcd461bfa..b4e1458237a 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qemu.h"
+#include "user/cpu_loop.h"
 #include "exec/page-protection.h"
 #include "user/page-protection.h"
 #include "user/tswap-target.h"
linux-user/signal.c +1 -0
index a191e9b26f2..087c4d270e4 100644
@@ -33,6 +33,7 @@
 #include "trace.h"
 #include "signal-common.h"
 #include "host-signal.h"
+#include "user/cpu_loop.h"
 #include "user/page-protection.h"
 #include "user/safe-syscall.h"
 #include "tcg/tcg.h"
target/arm/tcg/mte_helper.c +1 -0
index ae037dc9143..846d659ff77 100644
@@ -25,6 +25,7 @@
 #include "exec/page-protection.h"
 #ifdef CONFIG_USER_ONLY
 #include "user/page-protection.h"
+#include "user/cpu_loop.h"
 #endif
 #include "exec/ram_addr.h"
 #include "exec/cpu_ldst.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 18/18
#40 lore raw

Re: [PATCH 18/18] user: Move various declarations out of 'exec/exec-all.h'

Quoted 199 lines · Philippe Mathieu-Daudé

Move various declarations related to user emulation from "exec/exec-all.h" to "user/cpu_loop.h".

---
  include/exec/exec-all.h     | 55 +------------------------------------
  include/user/cpu_loop.h     | 54 ++++++++++++++++++++++++++++++++++++
  accel/tcg/user-exec.c       |  1 +
  bsd-user/signal.c           |  1 +
  linux-user/signal.c         |  1 +
  target/arm/tcg/mte_helper.c |  1 +
  6 files changed, 59 insertions(+), 54 deletions(-)
include/exec/exec-all.h +1 -54
index b5ea607cf45..c4a6ad3af2d 100644
@@ -22,7 +22,6 @@
 
  #include "cpu.h"
  #if defined(CONFIG_USER_ONLY)
-#include "exec/abi_ptr.h"
  #include "exec/cpu_ldst.h"
  #endif
  #include "exec/mmu-access-type.h"
@@ -518,60 +517,8 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env,
      return get_page_addr_code_hostp(env, addr, NULL);
  }
 
-#if defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
 
-/**
- * adjust_signal_pc:
- * @pc: raw pc from the host signal ucontext_t.
- * @is_write: host memory operation was write, or read-modify-write.
- *
- * Alter @pc as required for unwinding.  Return the type of the
- * guest memory access -- host reads may be for guest execution.
- */
-MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
-
-/**
- * handle_sigsegv_accerr_write:
- * @cpu: the cpu context
- * @old_set: the sigset_t from the signal ucontext_t
- * @host_pc: the host pc, adjusted for the signal
- * @host_addr: the host address of the fault
- *
- * Return true if the write fault has been handled, and should be re-tried.
- */
-bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
-                                 uintptr_t host_pc, abi_ptr guest_addr);
-
-/**
- * cpu_loop_exit_sigsegv:
- * @cpu: the cpu context
- * @addr: the guest address of the fault
- * @access_type: access was read/write/execute
- * @maperr: true for invalid page, false for permission fault
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGSEGV, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
-                                      MMUAccessType access_type,
-                                      bool maperr, uintptr_t ra);
-
-/**
- * cpu_loop_exit_sigbus:
- * @cpu: the cpu context
- * @addr: the guest address of the alignment fault
- * @access_type: access was read/write/execute
- * @ra: host pc for unwinding
- *
- * Use the TCGCPUOps hook to record cpu state, do guest operating system
- * specific things to raise SIGBUS, and jump to the main cpu loop.
- */
-G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
-                                     MMUAccessType access_type,
-                                     uintptr_t ra);
-
-#else
  void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
  void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
 
include/user/cpu_loop.h +54 -0
index b0d4704018d..2f93575e2f4 100644
@@ -20,7 +20,10 @@
  #ifndef USER_CPU_LOOP_H
  #define USER_CPU_LOOP_H
 
+#include "exec/abi_ptr.h"
+#include "exec/mmu-access-type.h"
  #include "exec/log.h"
+#include "exec/target_long.h"
  #include "special-errno.h"
 
  G_NORETURN void cpu_loop(CPUArchState *env);
@@ -33,4 +36,55 @@ typedef struct target_pt_regs target_pt_regs;
 
  void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs);
 
+/**
+ * adjust_signal_pc:
+ * @pc: raw pc from the host signal ucontext_t.
+ * @is_write: host memory operation was write, or read-modify-write.
+ *
+ * Alter @pc as required for unwinding.  Return the type of the
+ * guest memory access -- host reads may be for guest execution.
+ */
+MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write);
+
+/**
+ * handle_sigsegv_accerr_write:
+ * @cpu: the cpu context
+ * @old_set: the sigset_t from the signal ucontext_t
+ * @host_pc: the host pc, adjusted for the signal
+ * @host_addr: the host address of the fault
+ *
+ * Return true if the write fault has been handled, and should be re-tried.
+ */
+bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set,
+                                 uintptr_t host_pc, abi_ptr guest_addr);
+
+/**
+ * cpu_loop_exit_sigsegv:
+ * @cpu: the cpu context
+ * @addr: the guest address of the fault
+ * @access_type: access was read/write/execute
+ * @maperr: true for invalid page, false for permission fault
+ * @ra: host pc for unwinding
+ *
+ * Use the TCGCPUOps hook to record cpu state, do guest operating system
+ * specific things to raise SIGSEGV, and jump to the main cpu loop.
+ */
+G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
+                                      MMUAccessType access_type,
+                                      bool maperr, uintptr_t ra);
+
+/**
+ * cpu_loop_exit_sigbus:
+ * @cpu: the cpu context
+ * @addr: the guest address of the alignment fault
+ * @access_type: access was read/write/execute
+ * @ra: host pc for unwinding
+ *
+ * Use the TCGCPUOps hook to record cpu state, do guest operating system
+ * specific things to raise SIGBUS, and jump to the main cpu loop.
+ */
+G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
+                                     MMUAccessType access_type,
+                                     uintptr_t ra);
+
  #endif
accel/tcg/user-exec.c +1 -0
index 815a39503f3..0561c4f6dc7 100644
@@ -24,6 +24,7 @@
  #include "qemu/bitops.h"
  #include "qemu/rcu.h"
  #include "exec/cpu_ldst.h"
+#include "user/cpu_loop.h"
  #include "qemu/main-loop.h"
  #include "user/page-protection.h"
  #include "exec/page-protection.h"
bsd-user/signal.c +1 -0
index edbcd461bfa..b4e1458237a 100644
@@ -21,6 +21,7 @@
  #include "qemu/osdep.h"
  #include "qemu/log.h"
  #include "qemu.h"
+#include "user/cpu_loop.h"
  #include "exec/page-protection.h"
  #include "user/page-protection.h"
  #include "user/tswap-target.h"
linux-user/signal.c +1 -0
index a191e9b26f2..087c4d270e4 100644
@@ -33,6 +33,7 @@
  #include "trace.h"
  #include "signal-common.h"
  #include "host-signal.h"
+#include "user/cpu_loop.h"
  #include "user/page-protection.h"
  #include "user/safe-syscall.h"
  #include "tcg/tcg.h"
target/arm/tcg/mte_helper.c +0 -0
index ae037dc9143..846d659ff77 100644

target/arm/tcg/mte_helper.c line 31

Quoted 7 lines
target/arm/tcg/mte_helper.c +1 -0
@@ -25,6 +25,7 @@
  #include "exec/page-protection.h"
  #ifdef CONFIG_USER_ONLY
  #include "user/page-protection.h"
+#include "user/cpu_loop.h"
  #endif
  #include "exec/ram_addr.h"
  #include "exec/cpu_ldst.h"
Reviewed-by on the v1 series
#41 lore raw

Re: [PATCH 00/18] accel/tcg: Extract user APIs out of 'exec/[cpu,exec]-all.h'

In reply to Philippe Mathieu-Daudé
Quoted 35 lines · Philippe Mathieu-Daudé

The goal of this series is to clarify user emulation APIs, and clean the mixed bag of exec/foo-all.h headers.

Move user specific declarations out of the generic
- "exec/cpu-all.h",
- "exec/cpu_ldst.h",
- "exec/exec-all.h" and
- "exec/translate-all.h"
to the generic:
- "accel/tcg/tb-internal.h" and
- "exec/page-protection.h"
and the user specific:
- "user/cpu_loop.h",
- "user/guest-host.h" and
- "user/page-protection.h"

Philippe Mathieu-Daudé (18):
exec: Introduce 'user/guest-host.h' header linux-user/aarch64: Include missing 'user/abitypes.h' header
include: Include missing 'qemu/clang-tsa.h' header accel/tcg: Declare mmap_[un]lock() in 'exec/page-protection.h' accel/tcg: Use tb_page_addr_t type in page_unprotect() accel/tcg: Move page_[un]protect() to 'user/page-protection.h'
system: Remove unnecessary 'exec/translate-all.h' include accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h' accel/tcg: Un-inline log_pc()
accel/tcg: Move TranslationBlock declarations to 'tb-internal.h' accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'

     (1/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (2/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (3/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (4/4)
Quoted 4 lines

user: Forward declare target_cpu_copy_regs structure
user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h'
user: Declare cpu_loop() once in 'user/cpu_loop.h'
user: Move various declarations out of 'exec/exec-all.h'

Series:

r~

#42 lore raw

Re: [PATCH 00/18] accel/tcg: Extract user APIs out of 'exec/[cpu,exec]-all.h'

In reply to Philippe Mathieu-Daudé
Quoted 19 lines · Philippe Mathieu-Daudé

Philippe Mathieu-Daudé (18):
exec: Introduce 'user/guest-host.h' header linux-user/aarch64: Include missing 'user/abitypes.h' header
include: Include missing 'qemu/clang-tsa.h' header accel/tcg: Declare mmap_[un]lock() in 'exec/page-protection.h' accel/tcg: Use tb_page_addr_t type in page_unprotect() accel/tcg: Move page_[un]protect() to 'user/page-protection.h'
system: Remove unnecessary 'exec/translate-all.h' include accel/tcg: Move 'exec/translate-all.h' -> 'tb-internal.h' accel/tcg: Un-inline log_pc()
accel/tcg: Move TranslationBlock declarations to 'tb-internal.h' accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'

     (1/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (2/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (3/4)
   accel/tcg: Move user-related declarations out of 'exec/cpu-all.h'
     (4/4)
Quoted 4 lines

user: Forward declare target_cpu_copy_regs structure
user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h'
user: Declare cpu_loop() once in 'user/cpu_loop.h'
user: Move various declarations out of 'exec/exec-all.h'

Series queued, thanks.