Skip to contentSkip to conversation

exec: Split some user-mode specific declarations from 'exec/exec-all.h'

PATCH In review Philippe Mathieu-Daudé via 3 participants 24 messages Feb 9, 2022 – Feb 11, 2022

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

cover exec: Split some user-mode specific declarations from 'exec/exec-all.h'

- Add missing headers
- Merge exec/user/ to user/
- Extract MMUAccessType from QOM "hw/core/cpu.h" to "exec/cpu-tlb.h"
- Extract user-specific declarations to "user/cpu-{common,target}.h"
- Share preexit_cleanup() from Linux with BSD

More to come, but flushing for early feedback.

Based-on: <[email protected]>

Philippe Mathieu-Daudé (9):
accel/tcg: Add missing 'tcg/tcg.h' header
coverity-scan: Cover common-user/
include: Move exec/user/ to user/
linux-user/exit: Add missing 'qemu/plugin.h' header linux-user/cpu_loop: Add missing 'exec/cpu-all.h' header
exec: Define MMUAccessType in 'exec/cpu-tlb.h' header
user: Declare target-specific prototypes in 'user/cpu-target.h'
user: Declare target-agnostic prototypes in 'user/cpu-common.h'
user: Share preexit_cleanup() with linux and bsd implementations

 accel/tcg/tcg-accel-ops-icount.c    |  1 +
 accel/tcg/tcg-accel-ops-mttcg.c     |  1 +
 accel/tcg/tcg-accel-ops-rr.c        |  1 +
 accel/tcg/tcg-accel-ops.c           |  1 +
 accel/tcg/user-exec.c               |  1 +
 bsd-user/elfload.c                  |  1 +
 bsd-user/main.c                     |  1 +
 bsd-user/qemu.h                     |  6 ++--
 bsd-user/signal.c                   |  1 +
 {linux-user => common-user}/exit.c  |  4 +--
 common-user/meson.build             |  1 +
 include/exec/cpu-all.h              |  5 ++-
 include/exec/cpu-defs.h             |  1 +
 include/exec/cpu-tlb.h              | 16 +++++++++
 include/exec/cpu_ldst.h             |  1 +
 include/exec/exec-all.h             | 54 ++--------------------------
 include/hw/core/cpu.h               |  6 ----
 include/hw/core/tcg-cpu-ops.h       |  1 +
 include/{exec => }/user/abitypes.h  |  0
 include/user/cpu-common.h           | 36 +++++++++++++++++++
 include/user/cpu-target.h           | 56 +++++++++++++++++++++++++++++
 include/user/safe-syscall.h         |  6 ++--
 include/{exec => }/user/thunk.h     |  2 +-
 linux-user/aarch64/cpu_loop.c       |  1 +
 linux-user/alpha/cpu_loop.c         |  1 +
 linux-user/arm/cpu_loop.c           |  1 +
 linux-user/arm/signal.c             |  1 +
 linux-user/cpu_loop-common.h        |  1 +
 linux-user/cris/cpu_loop.c          |  1 +
 linux-user/elfload.c                |  1 +
 linux-user/hexagon/cpu_loop.c       |  1 +
 linux-user/hppa/cpu_loop.c          |  1 +
 linux-user/hppa/signal.c            |  1 +
 linux-user/i386/cpu_loop.c          |  1 +
 linux-user/linuxload.c              |  1 +
 linux-user/m68k/cpu_loop.c          |  1 +
 linux-user/main.c                   |  1 +
 linux-user/meson.build              |  1 -
 linux-user/microblaze/cpu_loop.c    |  1 +
 linux-user/mips/cpu_loop.c          |  1 +
 linux-user/mmap.c                   |  1 +
 linux-user/nios2/cpu_loop.c         |  1 +
 linux-user/openrisc/cpu_loop.c      |  1 +
 linux-user/ppc/cpu_loop.c           |  1 +
 linux-user/ppc/signal.c             |  1 +
 linux-user/qemu.h                   |  2 +-
 linux-user/riscv/cpu_loop.c         |  1 +
 linux-user/s390x/cpu_loop.c         |  1 +
 linux-user/sh4/cpu_loop.c           |  1 +
 linux-user/signal.c                 |  1 +
 linux-user/sparc/cpu_loop.c         |  1 +
 linux-user/syscall.c                |  1 +
 linux-user/thunk.c                  |  2 +-
 linux-user/uaccess.c                |  1 +
 linux-user/user-internals.h         | 12 +------
 linux-user/xtensa/cpu_loop.c        |  1 +
 scripts/coverity-scan/COMPONENTS.md |  2 +-
 target/arm/internals.h              |  1 +
 target/mips/internal.h              |  1 +
 target/ppc/internal.h               |  2 ++
 target/ppc/mmu-hash32.h             |  2 ++
 target/ppc/mmu-hash64.h             |  2 ++
 target/ppc/mmu-radix64.h            |  2 ++
 target/s390x/s390x-internal.h       |  2 ++
 64 files changed, 178 insertions(+), 85 deletions(-)
 rename {linux-user => common-user}/exit.c (95%)
 create mode 100644 include/exec/cpu-tlb.h
 rename include/{exec => }/user/abitypes.h (100%)
 create mode 100644 include/user/cpu-common.h
 create mode 100644 include/user/cpu-target.h
 rename include/{exec => }/user/thunk.h (99%)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/9 accel/tcg: Add missing 'tcg/tcg.h' header

---
 accel/tcg/tcg-accel-ops-icount.c | 1 +
 accel/tcg/tcg-accel-ops-mttcg.c  | 1 +
 accel/tcg/tcg-accel-ops-rr.c     | 1 +
 accel/tcg/tcg-accel-ops.c        | 1 +
 4 files changed, 4 insertions(+)
accel/tcg/tcg-accel-ops-icount.c +1 -0
index bdaf2c943b..379a9d44f4 100644
@@ -31,6 +31,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-icount.h"
accel/tcg/tcg-accel-ops-mttcg.c +1 -0
index dc421c8fd7..de7dcb02e6 100644
@@ -33,6 +33,7 @@
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
 #include "hw/boards.h"
+#include "tcg/tcg.h"
 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-mttcg.h"
accel/tcg/tcg-accel-ops-rr.c +1 -0
index a805fb6bdd..889d0882a2 100644
@@ -32,6 +32,7 @@
 #include "qemu/notify.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-rr.h"
accel/tcg/tcg-accel-ops.c +1 -0
index ea7dcad674..58e4b09043 100644
@@ -33,6 +33,7 @@
 #include "qemu/main-loop.h"
 #include "qemu/guest-random.h"
 #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
 #include "tcg-accel-ops.h"
 #include "tcg-accel-ops-mttcg.h"
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/9] accel/tcg: Add missing 'tcg/tcg.h' header

Quoted 7 lines · Philippe Mathieu-Daudé
---
  accel/tcg/tcg-accel-ops-icount.c | 1 +
  accel/tcg/tcg-accel-ops-mttcg.c  | 1 +
  accel/tcg/tcg-accel-ops-rr.c     | 1 +
  accel/tcg/tcg-accel-ops.c        | 1 +
  4 files changed, 4 insertions(+)

What exactly are these files using from tcg.h?
I briefly scanned tcg-accel-ops-icount.c and didn't see anything.

r~

Quoted 49 lines
accel/tcg/tcg-accel-ops-icount.c +1 -0
index bdaf2c943b..379a9d44f4 100644
@@ -31,6 +31,7 @@
  #include "qemu/main-loop.h"
  #include "qemu/guest-random.h"
  #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
  #include "tcg-accel-ops.h"
  #include "tcg-accel-ops-icount.h"
accel/tcg/tcg-accel-ops-mttcg.c +1 -0
index dc421c8fd7..de7dcb02e6 100644
@@ -33,6 +33,7 @@
  #include "qemu/guest-random.h"
  #include "exec/exec-all.h"
  #include "hw/boards.h"
+#include "tcg/tcg.h"
 
  #include "tcg-accel-ops.h"
  #include "tcg-accel-ops-mttcg.h"
accel/tcg/tcg-accel-ops-rr.c +1 -0
index a805fb6bdd..889d0882a2 100644
@@ -32,6 +32,7 @@
  #include "qemu/notify.h"
  #include "qemu/guest-random.h"
  #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
  #include "tcg-accel-ops.h"
  #include "tcg-accel-ops-rr.h"
accel/tcg/tcg-accel-ops.c +1 -0
index ea7dcad674..58e4b09043 100644
@@ -33,6 +33,7 @@
  #include "qemu/main-loop.h"
  #include "qemu/guest-random.h"
  #include "exec/exec-all.h"
+#include "tcg/tcg.h"
 
  #include "tcg-accel-ops.h"
  #include "tcg-accel-ops-mttcg.h"
#3 lore raw

Re: [PATCH 1/9] accel/tcg: Add missing 'tcg/tcg.h' header

Quoted 11 lines · Richard Henderson
Quoted 7 lines · Philippe Mathieu-Daudé

---
  accel/tcg/tcg-accel-ops-icount.c | 1 +
  accel/tcg/tcg-accel-ops-mttcg.c  | 1 +
  accel/tcg/tcg-accel-ops-rr.c     | 1 +
  accel/tcg/tcg-accel-ops.c        | 1 +

  4 files changed, 4 insertions(+)

What exactly are these files using from tcg.h?
I briefly scanned tcg-accel-ops-icount.c and didn't see anything.

extern __thread TCGContext *tcg_ctx;

I'll mention it in the description.

#4 lore raw

PATCH 2/9 coverity-scan: Cover common-user/

In reply to Philippe Mathieu-Daudé via

common-user/ has been added in commit bbf15aaf7c ("common-user: Move safe-syscall.* from linux-user").

---
 scripts/coverity-scan/COMPONENTS.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coverity-scan/COMPONENTS.md +1 -1
index 183f26a32c..cea6695ecd 100644
@@ -127,7 +127,7 @@ usb
   ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
 
 user
-  ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
 
 util
   ~ (/qemu)?(/util/.*|/include/qemu/.*)
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 2/9] coverity-scan: Cover common-user/

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

common-user/ has been added in commit bbf15aaf7c ("common-user: Move safe-syscall.* from linux-user").

---
 scripts/coverity-scan/COMPONENTS.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coverity-scan/COMPONENTS.md +0 -0
index 183f26a32c..cea6695ecd 100644

scripts/coverity-scan/COMPONENTS.md usb · line 133

Quoted 8 lines
scripts/coverity-scan/COMPONENTS.md +1 -1
@@ -127,7 +127,7 @@ usb
   ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
 
 user
-  ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
 
 util
   ~ (/qemu)?(/util/.*|/include/qemu/.*)

Note that there is no automatic process by which changes to this file get applied to the coverity scan config, so hiding changes to it inside a larger patchset increases the chance they get overlooked (by Paolo, who gets to do the manual config update)...

-- PMM

#7 lore raw

Re: [PATCH 2/9] coverity-scan: Cover common-user/

Quoted 22 lines · Peter Maydell
Quoted 20 lines · Philippe Mathieu-Daudé via

common-user/ has been added in commit bbf15aaf7c ("common-user: Move safe-syscall.* from linux-user").

---
  scripts/coverity-scan/COMPONENTS.md | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coverity-scan/COMPONENTS.md +1 -1
index 183f26a32c..cea6695ecd 100644
@@ -127,7 +127,7 @@ usb
    ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
 
  user
-  ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
 
Quoted 7 lines

scripts/coverity-scan/COMPONENTS.md usb · line 133

Quoted 2 lines
scripts/coverity-scan/COMPONENTS.md +0 -0
  util
    ~ (/qemu)?(/util/.*|/include/qemu/.*)

Note that there is no automatic process by which changes to this file get applied to the coverity scan config, so hiding changes to it inside a larger patchset increases the chance they get overlooked (by Paolo, who gets to do the manual config update)...

Oh OK, I thought this was consumed by a script.

#8 lore raw

Re: [PATCH 2/9] coverity-scan: Cover common-user/

Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Peter Maydell
Quoted 20 lines · Philippe Mathieu-Daudé via

common-user/ has been added in commit bbf15aaf7c ("common-user: Move safe-syscall.* from linux-user").

---
  scripts/coverity-scan/COMPONENTS.md | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coverity-scan/COMPONENTS.md +1 -1
index 183f26a32c..cea6695ecd 100644
@@ -127,7 +127,7 @@ usb
    ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
 
  user
-  ~ (/qemu)?(/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
 
Quoted 7 lines

scripts/coverity-scan/COMPONENTS.md usb · line 133

Quoted 2 lines
scripts/coverity-scan/COMPONENTS.md +0 -0
  util
    ~ (/qemu)?(/util/.*|/include/qemu/.*)

Note that there is no automatic process by which changes to this file get applied to the coverity scan config, so hiding changes to it inside a larger patchset increases the chance they get overlooked (by Paolo, who gets to do the manual config update)...

Quoted 1 line

Oh OK, I thought this was consumed by a script.

Unfortunately Coverity don't provide an API for configuring components, so it all has to be done via their webpage GUI :-(

-- PMM

#9 lore raw

PATCH 3/9 include: Move exec/user/ to user/

In reply to Philippe Mathieu-Daudé via

Avoid spreading the headers in multiple directories, unify exec/user/ and user/.

---
 bsd-user/qemu.h                     | 4 ++--
 include/exec/cpu-all.h              | 2 +-
 include/{exec => }/user/abitypes.h  | 0
 include/user/safe-syscall.h         | 6 +++---
 include/{exec => }/user/thunk.h     | 2 +-
 linux-user/qemu.h                   | 2 +-
 linux-user/thunk.c                  | 2 +-
 linux-user/user-internals.h         | 2 +-
 scripts/coverity-scan/COMPONENTS.md | 2 +-
 9 files changed, 11 insertions(+), 11 deletions(-)
 rename include/{exec => }/user/abitypes.h (100%)
 rename include/{exec => }/user/thunk.h (99%)
bsd-user/qemu.h +2 -2
index 02921ac8b3..2f67776b0b 100644
@@ -25,7 +25,7 @@
 
 #undef DEBUG_REMAP
 
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
 
 extern char **environ;
 
@@ -36,7 +36,7 @@ enum BSDType {
 };
 extern enum BSDType bsd_type;
 
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
 #include "target_arch.h"
 #include "syscall_defs.h"
 #include "target_syscall.h"
include/exec/cpu-all.h +1 -1
index c0f0fab28a..08b2894274 100644
@@ -145,7 +145,7 @@ static inline void tswap64s(uint64_t *s)
 /* MMU memory access macros */
 
 #if defined(CONFIG_USER_ONLY)
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
 
 /* On some host systems the guest address space is reserved on the host.
  * This allows the guest address space to be offset to a convenient location.
include/user/abitypes.h renamed from include/exec/user/abitypes.h +0 -0
similarity index 100%
rename from include/exec/user/abitypes.h
rename to include/user/abitypes.h
include/user/safe-syscall.h +3 -3
index 61a04e2b5a..b2cb76e05b 100644
@@ -1,5 +1,5 @@
 /*
- * safe-syscall.h: prototypes for linux-user signal-race-safe syscalls
+ * safe-syscall.h: prototypes for user signal-race-safe syscalls
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef LINUX_USER_SAFE_SYSCALL_H
-#define LINUX_USER_SAFE_SYSCALL_H
+#ifndef USER_SAFE_SYSCALL_H
+#define USER_SAFE_SYSCALL_H
 
 /**
  * safe_syscall:
include/user/thunk.h renamed from include/exec/user/thunk.h +1 -1
similarity index 99%
rename from include/exec/user/thunk.h
rename to include/user/thunk.h
index 300a840d58..b5796f4304 100644
@@ -21,7 +21,7 @@
 #define THUNK_H
 
 #include "cpu.h"
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
 
 /* types enums definitions */
 
linux-user/qemu.h +1 -1
index 7910ce59cc..b6775f112b 100644
@@ -6,7 +6,7 @@
 
 #undef DEBUG_REMAP
 
-#include "exec/user/abitypes.h"
+#include "user/abitypes.h"
 
 #include "syscall_defs.h"
 #include "target_syscall.h"
linux-user/thunk.c +1 -1
index dac4bf11c6..cd85bbc825 100644
@@ -20,7 +20,7 @@
 #include "qemu/log.h"
 
 #include "qemu.h"
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
 
 //#define DEBUG
 
linux-user/user-internals.h +1 -1
index a8fdd6933b..4d0f682aea 100644
@@ -18,7 +18,7 @@
 #ifndef LINUX_USER_USER_INTERNALS_H
 #define LINUX_USER_USER_INTERNALS_H
 
-#include "exec/user/thunk.h"
+#include "user/thunk.h"
 #include "exec/exec-all.h"
 #include "qemu/log.h"
 
scripts/coverity-scan/COMPONENTS.md +1 -1
index cea6695ecd..0571362a45 100644
@@ -127,7 +127,7 @@ usb
   ~ (/qemu)?(/hw/usb/.*|/include/hw/usb/.*)
 
 user
-  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/exec/user/.*)
+  ~ (/qemu)?(/common-user/.*|/linux-user/.*|/bsd-user/.*|/user-exec\.c|/thunk\.c|/include/user/.*)
 
 util
   ~ (/qemu)?(/util/.*|/include/qemu/.*)
Signature · 1 line
2.34.1
Reviewed-by on v1 3/9
#10 lore raw

Re: [PATCH 3/9] include: Move exec/user/ to user/

Quoted 15 lines · Philippe Mathieu-Daudé

Avoid spreading the headers in multiple directories, unify exec/user/ and user/.

---
  bsd-user/qemu.h                     | 4 ++--
  include/exec/cpu-all.h              | 2 +-
  include/{exec => }/user/abitypes.h  | 0
  include/user/safe-syscall.h         | 6 +++---
  include/{exec => }/user/thunk.h     | 2 +-
  linux-user/qemu.h                   | 2 +-
  linux-user/thunk.c                  | 2 +-
  linux-user/user-internals.h         | 2 +-
  scripts/coverity-scan/COMPONENTS.md | 2 +-
  9 files changed, 11 insertions(+), 11 deletions(-)
Quoted 2 lines

rename include/{exec => }/user/abitypes.h (100%) rename include/{exec => }/user/thunk.h (99%)

Something I noticed in passing: abitypes.h doesn't need all of cpu.h, only cpu-param.h.

r~

#11 lore raw

PATCH 4/9 linux-user/exit: Add missing 'qemu/plugin.h' header

In reply to Philippe Mathieu-Daudé via

qemu_plugin_user_exit() is declared in "qemu/plugin.h".

---
 linux-user/exit.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/exit.c +1 -0
index fa6ef0b9b4..10989f17f8 100644
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "qemu/osdep.h"
+#include "qemu/plugin.h"
 #include "exec/gdbstub.h"
 #include "qemu.h"
 #include "user-internals.h"
Signature · 1 line
2.34.1
#13 lore raw

PATCH 5/9 linux-user/cpu_loop: Add missing 'exec/cpu-all.h' header

In reply to Philippe Mathieu-Daudé via

env_cpu() is declared in "exec/cpu-all.h".

---
 linux-user/cpu_loop-common.h | 1 +
 1 file changed, 1 insertion(+)
linux-user/cpu_loop-common.h +1 -0
index dc0042e4de..b0fd1ea3b1 100644
@@ -20,6 +20,7 @@
 #ifndef CPU_LOOP_COMMON_H
 #define CPU_LOOP_COMMON_H
 
+#include "exec/cpu-all.h"
 #include "exec/log.h"
 #include "special-errno.h"
 
Signature · 1 line
2.34.1
#15 lore raw

PATCH 6/9 exec: Define MMUAccessType in 'exec/cpu-tlb.h' header

In reply to Philippe Mathieu-Daudé via

To reduce the inclusion of "hw/core/cpu.h", extract MMUAccessType to its own "exec/cpu-tlb.h" header.

---
 include/exec/cpu-defs.h       |  1 +
 include/exec/cpu-tlb.h        | 16 ++++++++++++++++
 include/exec/cpu_ldst.h       |  1 +
 include/exec/exec-all.h       |  3 +++
 include/hw/core/cpu.h         |  6 ------
 include/hw/core/tcg-cpu-ops.h |  1 +
 target/arm/internals.h        |  1 +
 target/mips/internal.h        |  1 +
 target/ppc/internal.h         |  2 ++
 target/ppc/mmu-hash32.h       |  2 ++
 target/ppc/mmu-hash64.h       |  2 ++
 target/ppc/mmu-radix64.h      |  2 ++
 target/s390x/s390x-internal.h |  2 ++
 13 files changed, 34 insertions(+), 6 deletions(-)
 create mode 100644 include/exec/cpu-tlb.h
include/exec/cpu-defs.h +1 -0
index ba3cd32a1e..c7eefb8633 100644
@@ -29,6 +29,7 @@
 #include "exec/hwaddr.h"
 #endif
 #include "exec/memattrs.h"
+#include "exec/cpu-tlb.h"
 #include "hw/core/cpu.h"
 
 #include "cpu-param.h"
include/exec/cpu-tlb.h new file +16 -0
new file mode 100644
index 0000000000..dccf91a817
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * cpu-tlb.h: MMUAccessType definitions
+ *
+ */
+
+#ifndef EXEC_CPU_TLB_H
+#define EXEC_CPU_TLB_H
+
+typedef enum MMUAccessType {
+    MMU_DATA_LOAD  = 0,
+    MMU_DATA_STORE = 1,
+    MMU_INST_FETCH = 2
+} MMUAccessType;
+
+#endif
include/exec/cpu_ldst.h +1 -0
index 5c999966de..3784316471 100644
@@ -63,6 +63,7 @@
 #define CPU_LDST_H
 
 #include "exec/memopidx.h"
+#include "exec/cpu-tlb.h"
 #include "qemu/int128.h"
 #include "cpu.h"
 
include/exec/exec-all.h +3 -0
index d2cb0981f4..537f465f54 100644
@@ -381,6 +381,9 @@ static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,
 {
 }
 #endif
+
+#include "exec/cpu-tlb.h"
+
 /**
  * probe_access:
  * @env: CPUArchState
include/hw/core/cpu.h +0 -6
index c9d41e4ece..0b844cbf27 100644
@@ -55,12 +55,6 @@ typedef struct CPUClass CPUClass;
 DECLARE_CLASS_CHECKERS(CPUClass, CPU,
                        TYPE_CPU)
 
-typedef enum MMUAccessType {
-    MMU_DATA_LOAD  = 0,
-    MMU_DATA_STORE = 1,
-    MMU_INST_FETCH = 2
-} MMUAccessType;
-
 typedef struct CPUWatchpoint CPUWatchpoint;
 
 /* see tcg-cpu-ops.h */
include/hw/core/tcg-cpu-ops.h +1 -0
index e13898553a..2c81fff428 100644
@@ -10,6 +10,7 @@
 #ifndef TCG_CPU_OPS_H
 #define TCG_CPU_OPS_H
 
+#include "exec/cpu-tlb.h"
 #include "hw/core/cpu.h"
 
 struct TCGCPUOps {
target/arm/internals.h +1 -0
index 3f05748ea4..4c006aa6b4 100644
@@ -25,6 +25,7 @@
 #ifndef TARGET_ARM_INTERNALS_H
 #define TARGET_ARM_INTERNALS_H
 
+#include "exec/cpu-tlb.h"
 #include "hw/registerfields.h"
 #include "tcg/tcg-gvec-desc.h"
 #include "syndrome.h"
target/mips/internal.h +1 -0
index ac6e03e2f2..f0f885005f 100644
@@ -8,6 +8,7 @@
 #ifndef MIPS_INTERNAL_H
 #define MIPS_INTERNAL_H
 
+#include "exec/cpu-tlb.h"
 #include "exec/memattrs.h"
 #ifdef CONFIG_TCG
 #include "tcg/tcg-internal.h"
target/ppc/internal.h +2 -0
index 6aa9484f34..20010f53e7 100644
@@ -18,6 +18,8 @@
 #ifndef PPC_INTERNAL_H
 #define PPC_INTERNAL_H
 
+#include "exec/cpu-tlb.h"
+
 #define FUNC_MASK(name, ret_type, size, max_val)                  \
 static inline ret_type name(uint##size##_t start,                 \
                               uint##size##_t end)                 \
target/ppc/mmu-hash32.h +2 -0
index 3892b693d6..c6fcdebac5 100644
@@ -3,6 +3,8 @@
 
 #ifndef CONFIG_USER_ONLY
 
+#include "exec/cpu-tlb.h"
+
 hwaddr get_pteg_offset32(PowerPCCPU *cpu, hwaddr hash);
 bool ppc_hash32_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type,
                       hwaddr *raddrp, int *psizep, int *protp, int mmu_idx,
target/ppc/mmu-hash64.h +2 -0
index 1496955d38..002dc4aec7 100644
@@ -3,6 +3,8 @@
 
 #ifndef CONFIG_USER_ONLY
 
+#include "exec/cpu-tlb.h"
+
 #ifdef TARGET_PPC64
 void dump_slb(PowerPCCPU *cpu);
 int ppc_store_slb(PowerPCCPU *cpu, target_ulong slot,
target/ppc/mmu-radix64.h +2 -0
index 4c768aa5cc..601967ae82 100644
@@ -3,6 +3,8 @@
 
 #ifndef CONFIG_USER_ONLY
 
+#include "exec/cpu-tlb.h"
+
 /* Radix Quadrants */
 #define R_EADDR_MASK            0x3FFFFFFFFFFFFFFF
 #define R_EADDR_VALID_MASK      0xC00FFFFFFFFFFFFF
target/s390x/s390x-internal.h +2 -0
index 6fc8cad2d5..b451b702d0 100644
@@ -10,6 +10,8 @@
 #ifndef S390X_INTERNAL_H
 #define S390X_INTERNAL_H
 
+#include "exec/cpu-tlb.h"
+
 #include "cpu.h"
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.34.1
#16 lore raw

Re: [PATCH 6/9] exec: Define MMUAccessType in 'exec/cpu-tlb.h' header

Quoted 5 lines · Philippe Mathieu-Daudé

To reduce the inclusion of "hw/core/cpu.h", extract MMUAccessType to its own "exec/cpu-tlb.h" header.

---

Not keen on the name, unless you plan to put something else in there.

r~

#17 lore raw

Re: [PATCH 6/9] exec: Define MMUAccessType in 'exec/cpu-tlb.h' header

Quoted 8 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

To reduce the inclusion of "hw/core/cpu.h", extract MMUAccessType to its own "exec/cpu-tlb.h" header.

---

Not keen on the name, unless you plan to put something else in there.

Not yet.

What about "exec/mmu-types.h", kinda similar to "exec/memattrs.h"?

#18 lore raw

PATCH 7/9 user: Declare target-specific prototypes in 'user/cpu-target.h'

In reply to Philippe Mathieu-Daudé via

Move user-mode specific prototypes from "exec/exec-all.h" to "user/cpu-target.h".

---
 accel/tcg/user-exec.c            |  1 +
 bsd-user/elfload.c               |  1 +
 bsd-user/main.c                  |  1 +
 bsd-user/signal.c                |  1 +
 include/exec/exec-all.h          | 41 ------------------------
 include/user/cpu-target.h        | 55 ++++++++++++++++++++++++++++++++
 linux-user/aarch64/cpu_loop.c    |  1 +
 linux-user/alpha/cpu_loop.c      |  1 +
 linux-user/arm/cpu_loop.c        |  1 +
 linux-user/arm/signal.c          |  1 +
 linux-user/cris/cpu_loop.c       |  1 +
 linux-user/elfload.c             |  1 +
 linux-user/hexagon/cpu_loop.c    |  1 +
 linux-user/hppa/cpu_loop.c       |  1 +
 linux-user/hppa/signal.c         |  1 +
 linux-user/i386/cpu_loop.c       |  1 +
 linux-user/linuxload.c           |  1 +
 linux-user/m68k/cpu_loop.c       |  1 +
 linux-user/main.c                |  1 +
 linux-user/microblaze/cpu_loop.c |  1 +
 linux-user/mips/cpu_loop.c       |  1 +
 linux-user/mmap.c                |  1 +
 linux-user/nios2/cpu_loop.c      |  1 +
 linux-user/openrisc/cpu_loop.c   |  1 +
 linux-user/ppc/cpu_loop.c        |  1 +
 linux-user/ppc/signal.c          |  1 +
 linux-user/riscv/cpu_loop.c      |  1 +
 linux-user/s390x/cpu_loop.c      |  1 +
 linux-user/sh4/cpu_loop.c        |  1 +
 linux-user/signal.c              |  1 +
 linux-user/sparc/cpu_loop.c      |  1 +
 linux-user/syscall.c             |  1 +
 linux-user/uaccess.c             |  1 +
 linux-user/xtensa/cpu_loop.c     |  1 +
 34 files changed, 87 insertions(+), 41 deletions(-)
 create mode 100644 include/user/cpu-target.h
accel/tcg/user-exec.c +1 -0
index 6f5d4933f0..c05bd84f1b 100644
@@ -28,6 +28,7 @@
 #include "qemu/atomic128.h"
 #include "trace/trace-root.h"
 #include "tcg/tcg-ldst.h"
+#include "user/cpu-target.h"
 #include "internal.h"
 
 __thread uintptr_t helper_retaddr;
bsd-user/elfload.c +1 -0
index 142a5bfac2..d64b0de0f4 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "disas/disas.h"
 #include "qemu/path.h"
 
bsd-user/main.c +1 -0
index f1d58e905e..93f7851fdd 100644
@@ -47,6 +47,7 @@
 #include "trace/control.h"
 #include "crypto/init.h"
 #include "qemu/guest-random.h"
+#include "user/cpu-target.h"
 
 #include "host-os.h"
 #include "target_arch_cpu.h"
bsd-user/signal.c +1 -0
index 8a36b696d8..15af69c509 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "signal-common.h"
 #include "trace.h"
 #include "hw/core/tcg-cpu-ops.h"
include/exec/exec-all.h +0 -41

47 lines not on this page · raw message

include/user/cpu-target.h new file +55 -0

55 lines not on this page · raw message

linux-user/aarch64/cpu_loop.c +1 -0
index 1737e2ea65..ce19e2cf7a 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/alpha/cpu_loop.c +1 -0
index de6e0c901c..735603f6f1 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/arm/cpu_loop.c +1 -0
index 032e1ffddf..268e19cbca 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "elf.h"
 #include "cpu_loop-common.h"
linux-user/arm/signal.c +1 -0
index cf99fd7b8a..0cec11ebe4 100644
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "signal-common.h"
 #include "linux-user/trace.h"
linux-user/cris/cpu_loop.c +1 -0
index 0f46b3c1a8..a70b93203c 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/elfload.c +1 -0
index 99829faf89..0f5df23aee 100644
@@ -6,6 +6,7 @@
 #include <sys/shm.h>
 
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "signal-common.h"
 #include "loader.h"
linux-user/hexagon/cpu_loop.c +1 -0
index 0d73934d31..c167da2474 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/hppa/cpu_loop.c +1 -0
index a576d1a249..ebec350047 100644
@@ -19,6 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/hppa/signal.c +1 -0
index 962f551c04..17dbb96f07 100644
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "signal-common.h"
 #include "linux-user/trace.h"
linux-user/i386/cpu_loop.c +1 -0
index 90bffc1956..425b898590 100644
@@ -21,6 +21,7 @@
 #include "qemu-common.h"
 #include "qemu.h"
 #include "qemu/timer.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/linuxload.c +1 -0
index 2ed5fc45ed..e7312be184 100644
@@ -2,6 +2,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "loader.h"
 
linux-user/m68k/cpu_loop.c +1 -0
index 928a18e3cf..2aec60da0d 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/main.c +1 -0
index 16def5215d..e318dcfcf8 100644
@@ -30,6 +30,7 @@
 
 #include "qapi/error.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "qemu/path.h"
 #include "qemu/queue.h"
linux-user/microblaze/cpu_loop.c +1 -0
index 1a2556be2c..3023e5691b 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/mips/cpu_loop.c +1 -0
index 9bb12a07ba..10292a9c40 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/mmap.c +1 -0
index c125031b90..1849bac128 100644
@@ -20,6 +20,7 @@
 #include "trace.h"
 #include "exec/log.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "user-mmap.h"
 
linux-user/nios2/cpu_loop.c +1 -0
index 1e93ef34e6..f10c28f965 100644
@@ -19,6 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/openrisc/cpu_loop.c +1 -0
index 7683bea064..137889d7e0 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/ppc/cpu_loop.c +1 -0
index ffe39851ed..252ee8efbf 100644
@@ -21,6 +21,7 @@
 #include "qemu-common.h"
 #include "qemu.h"
 #include "qemu/timer.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/ppc/signal.c +1 -0
index 176c9d8503..541d70b410 100644
@@ -18,6 +18,7 @@
  */
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "signal-common.h"
 #include "linux-user/trace.h"
linux-user/riscv/cpu_loop.c +1 -0
index 26d446f323..2712f2c675 100644
@@ -21,6 +21,7 @@
 #include "qemu-common.h"
 #include "qemu/error-report.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/s390x/cpu_loop.c +1 -0
index 7901dfe6f5..37d05f127e 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/sh4/cpu_loop.c +1 -0
index 1bd313cb19..bd52b3be93 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/signal.c +1 -0
index 32854bb375..c36f7669ad 100644
@@ -25,6 +25,7 @@
 #include <sys/resource.h>
 
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "strace.h"
 #include "loader.h"
linux-user/sparc/cpu_loop.c +1 -0
index baf3d9ae01..506d4b49f0 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
linux-user/syscall.c +1 -0
index 5950222a77..2cc17c8617 100644
@@ -127,6 +127,7 @@
 #include "uname.h"
 
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "strace.h"
 #include "signal-common.h"
linux-user/uaccess.c +1 -0
index 425cbf677f..99234c52a0 100644
@@ -1,6 +1,7 @@
 /* User memory access */
 #include "qemu/osdep.h"
 #include "qemu/cutils.h"
+#include "user/cpu-target.h"
 
 #include "qemu.h"
 #include "user-internals.h"
linux-user/xtensa/cpu_loop.c +1 -0
index d51ce05392..829659297b 100644
@@ -19,6 +19,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu.h"
+#include "user/cpu-target.h"
 #include "user-internals.h"
 #include "cpu_loop-common.h"
 #include "signal-common.h"
Signature · 1 line
2.34.1
#19 lore raw

Re: [PATCH 7/9] user: Declare target-specific prototypes in 'user/cpu-target.h'

Quoted 5 lines · Philippe Mathieu-Daudé

Move user-mode specific prototypes from "exec/exec-all.h" to "user/cpu-target.h".

---

Why a new cpu-target.h, and what is it supposed to mean? What else is going in there? It all looks cpu_loop related so far.

Why is this separate from the next patch, with "cpu-common.h", which also appears to be basically cpu_loop related?

r~

#20 lore raw

Re: [PATCH 7/9] user: Declare target-specific prototypes in 'user/cpu-target.h'

+Thomas

Quoted 8 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé

Move user-mode specific prototypes from "exec/exec-all.h" to "user/cpu-target.h".

---

Why a new cpu-target.h, and what is it supposed to mean?  What else is going in there?  It all looks cpu_loop related so far.

I'd like to put all declarations using target_ulong in foo-target.h and the ones which don't in foo-common.h (cpu, user, exec).

That way I can move implementations from target-specific to target agnostic meson source set, and better isolate the target-specific APIs.

Quoted 1 line

Why is this separate from the next patch, with "cpu-common.h", which also appears to be basically cpu_loop related?

I can squash both. The commit description could be "Move APIs using target_ulong to cpu-target.h, keep the rest in cpu-common.h".

#21 lore raw

PATCH 8/9 user: Declare target-agnostic prototypes in 'user/cpu-common.h'

In reply to Philippe Mathieu-Daudé via

Move user-mode common prototypes from "exec/exec-all.h" to "user/cpu-common.h".

---
 bsd-user/qemu.h             |  2 --
 include/exec/cpu-all.h      |  3 +--
 include/exec/exec-all.h     | 10 ----------
 include/user/cpu-common.h   | 36 ++++++++++++++++++++++++++++++++++++
 include/user/cpu-target.h   |  1 +
 linux-user/exit.c           |  3 +--
 linux-user/user-internals.h | 10 ----------
 7 files changed, 39 insertions(+), 26 deletions(-)
 create mode 100644 include/user/cpu-common.h
bsd-user/qemu.h +0 -2
index 2f67776b0b..afaf94412e 100644
@@ -182,8 +182,6 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6);
 void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(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/exec/cpu-all.h +1 -2
index 08b2894274..e9cf20560f 100644
@@ -296,9 +296,8 @@ void *page_alloc_target_data(target_ulong address, size_t size);
  * at @address, as per page_alloc_target_data.
  */
 void *page_get_target_data(target_ulong address);
-#endif
 
-CPUArchState *cpu_copy(CPUArchState *env);
+#endif /* CONFIG_USER_ONLY */
 
 /* Flags for use in ENV->INTERRUPT_PENDING.
 
include/exec/exec-all.h +0 -10
index e8f14b6844..545cc16a67 100644
@@ -639,16 +639,6 @@ static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env,
     return addr;
 }
 
-/**
- * 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);
-
 #else
 static inline void mmap_lock(void) {}
 static inline void mmap_unlock(void) {}
include/user/cpu-common.h new file +36 -0
new file mode 100644
index 0000000000..267acb143a
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * cpu-target.h: user-mode target-agnostic execution prototypes
+ *
+ */
+
+#ifndef USER_CPU_COMMON_H
+#define USER_CPU_COMMON_H
+
+#include "exec/cpu-tlb.h"
+
+extern __thread CPUState *thread_cpu;
+
+/**
+ * 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);
+
+void QEMU_NORETURN cpu_loop(CPUArchState *env);
+
+CPUArchState *cpu_copy(CPUArchState *env);
+
+/**
+ * preexit_cleanup: housekeeping before the guest exits
+ *
+ * env: the CPU state
+ * code: the exit code
+ */
+void preexit_cleanup(CPUArchState *env, int code);
+
+#endif
include/user/cpu-target.h +1 -0
index e621fb9f3d..4fbdb35fa4 100644
@@ -9,6 +9,7 @@
 
 #include "exec/cpu-tlb.h"
 #include "exec/cpu_ldst.h" /* abi_ptr */
+#include "user/cpu-common.h"
 
 /**
  * handle_sigsegv_accerr_write:
linux-user/exit.c +1 -2
index 10989f17f8..2c8a8dd75d 100644
@@ -19,8 +19,7 @@
 #include "qemu/osdep.h"
 #include "qemu/plugin.h"
 #include "exec/gdbstub.h"
-#include "qemu.h"
-#include "user-internals.h"
+#include "user/cpu-common.h"
 #ifdef CONFIG_GPROF
 #include <sys/gmon.h>
 #endif
linux-user/user-internals.h +0 -10
index 4d0f682aea..d17f3c9300 100644
@@ -63,8 +63,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8);
-extern __thread CPUState *thread_cpu;
-void QEMU_NORETURN cpu_loop(CPUArchState *env);
 const char *target_strerror(int err);
 int get_osversion(void);
 void init_qemu_uname_release(void);
@@ -166,14 +164,6 @@ static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
 static inline int regpairs_aligned(void *cpu_env, int num) { return 0; }
 #endif
 
-/**
- * preexit_cleanup: housekeeping before the guest exits
- *
- * env: the CPU state
- * code: the exit code
- */
-void preexit_cleanup(CPUArchState *env, int code);
-
 /*
  * Include target-specific struct and function definitions;
  * they may need access to the target-independent structures
Signature · 1 line
2.34.1
#22 lore raw

PATCH 9/9 user: Share preexit_cleanup() with linux and bsd implementations

In reply to Philippe Mathieu-Daudé via

preexit_cleanup() is not Linux specific, move it to common-user/.

---
 {linux-user => common-user}/exit.c | 0
 common-user/meson.build            | 1 +
 linux-user/meson.build             | 1 -
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename {linux-user => common-user}/exit.c (100%)
common-user/exit.c renamed from linux-user/exit.c +0 -0
similarity index 100%
rename from linux-user/exit.c
rename to common-user/exit.c
common-user/meson.build +1 -0
index 26212dda5c..7204f8bd61 100644
@@ -1,6 +1,7 @@
 common_user_inc += include_directories('host/' / host_arch)
 
 user_ss.add(files(
+  'exit.c',
   'safe-syscall.S',
   'safe-syscall-error.c',
 ))
linux-user/meson.build +0 -1
index de4320af05..25756a2518 100644
@@ -9,7 +9,6 @@ common_user_inc += include_directories('include')
 
 linux_user_ss.add(files(
   'elfload.c',
-  'exit.c',
   'fd-trans.c',
   'linuxload.c',
   'main.c',
Signature · 1 line
2.34.1
Reviewed-by on v1 9/9
#23 lore raw

Re: [PATCH 9/9] user: Share preexit_cleanup() with linux and bsd implementations

Quoted 9 lines · Philippe Mathieu-Daudé

preexit_cleanup() is not Linux specific, move it to common-user/.

---
  {linux-user => common-user}/exit.c | 0
  common-user/meson.build            | 1 +
  linux-user/meson.build             | 1 -
  3 files changed, 1 insertion(+), 1 deletion(-)

rename {linux-user => common-user}/exit.c (100%)

Of course, the next step is to use the function (cc Warner).

r~

Quoted 29 lines
common-user/exit.c renamed from linux-user/exit.c +0 -0
similarity index 100%
rename from linux-user/exit.c
rename to common-user/exit.c
common-user/meson.build +1 -0
index 26212dda5c..7204f8bd61 100644
@@ -1,6 +1,7 @@
  common_user_inc += include_directories('host/' / host_arch)
 
  user_ss.add(files(
+  'exit.c',
    'safe-syscall.S',
    'safe-syscall-error.c',
  ))
linux-user/meson.build +0 -1
index de4320af05..25756a2518 100644
@@ -9,7 +9,6 @@ common_user_inc += include_directories('include')
 
  linux_user_ss.add(files(
    'elfload.c',
-  'exit.c',
    'fd-trans.c',
    'linuxload.c',
    'main.c',