aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-08-08 14:09:48 -0700
committerRichard Henderson <richard.henderson@linaro.org>2023-08-08 14:09:48 -0700
commitcef297a9d7506299e98e72c4f5dc89d0d1eae774 (patch)
tree56eaceba8e830e7f32a26df6a13e83f0652b16d6
parent0450cf08976f9036feaded438031b4cba94f6452 (diff)
parent971fac2731e60f2143f35648b14fd2f1b5b2c1af (diff)
downloadqemu-cef297a9d7506299e98e72c4f5dc89d0d1eae774.zip
qemu-cef297a9d7506299e98e72c4f5dc89d0d1eae774.tar.gz
qemu-cef297a9d7506299e98e72c4f5dc89d0d1eae774.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* cleanup architecture canonicalization once and for all # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmTSjQAUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroPc8Qf/XjwCmHzRm6VSengi5OywjeanKpO6 # yJ8mbA0tqx7DxH+ke3y0kH7QGbScnV7mh/s5SnjHDR38K0z604E773UVEk5JwtMb # b64jsaCiq0XhiPKHA0xtYo2F4W17LxIIcyG2d1Fgmngvnat3LpswXGEXJbKCnIV9 # KzgKNpCf6o+o1f/U6LaxInHbYRaDW03HSFfCHgNyYOBxgbPC/UYRuslqC8pIdp/5 # mGLhloJh/WKi8iL0Xsjl1GN/0d9UHC6bUAW+f1JjET5IjeOtdxh6hgDr9hAc3ZC+ # stTTri7pM6VeCv+lT5tSN+o7IdzpGjMXb0kozjkinoafhDfp8EvJyOdfrg== # =5Z/e # -----END PGP SIGNATURE----- # gpg: Signature made Tue 08 Aug 2023 11:44:16 AM PDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: configure: unify case statements for CPU canonicalization linux-user: cleanup unused linux-user/include/host directories configure: fix detection for x32 linux-user Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rwxr-xr-xconfigure163
-rw-r--r--linux-user/include/host/alpha/host-signal.h55
-rw-r--r--linux-user/include/host/s390/host-signal.h138
-rw-r--r--linux-user/include/host/s390x/host-signal.h139
-rw-r--r--linux-user/include/host/x32/host-signal.h1
5 files changed, 235 insertions, 261 deletions
diff --git a/configure b/configure
index 98dc782..133f4e3 100755
--- a/configure
+++ b/configure
@@ -469,57 +469,119 @@ else
echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
fi
-case "$cpu" in
- riscv*)
- host_arch=riscv ;;
- *)
- host_arch="$cpu" ;;
-esac
-
-# Normalise host CPU name and set multilib cflags. The canonicalization
-# isn't really necessary, because the architectures that we check for
-# should not hit the 'uname -m' case, but better safe than sorry.
+# Normalise host CPU name to the values used by Meson cross files and in source
+# directories, and set multilib cflags. The canonicalization isn't really
+# necessary, because the architectures that we check for should not hit the
+# 'uname -m' case, but better safe than sorry in case --cpu= is used.
+#
# Note that this case should only have supported host CPUs, not guests.
+# Please keep it sorted and synchronized with meson.build's host_arch.
+host_arch=
+linux_arch=
case "$cpu" in
+ aarch64)
+ host_arch=aarch64
+ linux_arch=arm64
+ ;;
+
armv*b|armv*l|arm)
- cpu="arm" ;;
+ cpu=arm
+ host_arch=arm
+ linux_arch=arm
+ ;;
i386|i486|i586|i686)
cpu="i386"
- CPU_CFLAGS="-m32" ;;
- x32)
- cpu="x86_64"
- CPU_CFLAGS="-mx32" ;;
- x86_64|amd64)
- cpu="x86_64"
- # ??? Only extremely old AMD cpus do not have cmpxchg16b.
- # If we truly care, we should simply detect this case at
- # runtime and generate the fallback to serial emulation.
- CPU_CFLAGS="-m64 -mcx16" ;;
+ host_arch=i386
+ linux_arch=x86
+ CPU_CFLAGS="-m32"
+ ;;
+
+ loongarch*)
+ cpu=loongarch64
+ host_arch=loongarch64
+ ;;
+ mips64*)
+ cpu=mips64
+ host_arch=mips
+ linux_arch=mips
+ ;;
mips*)
- cpu="mips" ;;
+ cpu=mips
+ host_arch=mips
+ linux_arch=mips
+ ;;
ppc)
- CPU_CFLAGS="-m32" ;;
+ host_arch=ppc
+ linux_arch=powerpc
+ CPU_CFLAGS="-m32"
+ ;;
ppc64)
- CPU_CFLAGS="-m64 -mbig-endian" ;;
+ host_arch=ppc64
+ linux_arch=powerpc
+ CPU_CFLAGS="-m64 -mbig-endian"
+ ;;
ppc64le)
- cpu="ppc64"
- CPU_CFLAGS="-m64 -mlittle-endian" ;;
+ cpu=ppc64
+ host_arch=ppc64
+ linux_arch=powerpc
+ CPU_CFLAGS="-m64 -mlittle-endian"
+ ;;
+
+ riscv32 | riscv64)
+ host_arch=riscv
+ linux_arch=riscv
+ ;;
s390)
- CPU_CFLAGS="-m31" ;;
+ linux_arch=s390
+ CPU_CFLAGS="-m31"
+ ;;
s390x)
- CPU_CFLAGS="-m64" ;;
+ host_arch=s390x
+ linux_arch=s390
+ CPU_CFLAGS="-m64"
+ ;;
sparc|sun4[cdmuv])
- cpu="sparc"
- CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
+ cpu=sparc
+ CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
+ ;;
sparc64)
- CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
+ host_arch=sparc64
+ CPU_CFLAGS="-m64 -mcpu=ultrasparc"
+ ;;
+
+ x32)
+ cpu="x86_64"
+ host_arch=x86_64
+ linux_arch=x86
+ CPU_CFLAGS="-mx32"
+ ;;
+ x86_64|amd64)
+ cpu="x86_64"
+ host_arch=x86_64
+ linux_arch=x86
+ # ??? Only extremely old AMD cpus do not have cmpxchg16b.
+ # If we truly care, we should simply detect this case at
+ # runtime and generate the fallback to serial emulation.
+ CPU_CFLAGS="-m64 -mcx16"
+ ;;
esac
+if test -n "$host_arch" && {
+ ! test -d "$source_path/linux-user/include/host/$host_arch" ||
+ ! test -d "$source_path/common-user/host/$host_arch"; }; then
+ error_exit "linux-user/include/host/$host_arch does not exist." \
+ "This is a bug in the configure script, please report it."
+fi
+if test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arch"; then
+ error_exit "linux-headers/asm-$linux_arch does not exist." \
+ "This is a bug in the configure script, please report it."
+fi
+
check_py_version() {
# We require python >= 3.7.
# NB: a True python conditional creates a non-zero return code (Failure)
@@ -810,7 +872,7 @@ default_target_list=""
mak_wilds=""
if [ "$linux_user" != no ]; then
- if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$host_arch" ]; then
+ if [ "$targetos" = linux ] && [ -n "$host_arch" ]; then
linux_user=yes
elif [ "$linux_user" = yes ]; then
error_exit "linux-user not supported on this architecture"
@@ -1715,40 +1777,9 @@ echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
echo "CC=$cc" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $config_host_mak
-# use included Linux headers
-if test "$linux" = "yes" ; then
- mkdir -p linux-headers
- case "$cpu" in
- i386|x86_64)
- linux_arch=x86
- ;;
- ppc|ppc64)
- linux_arch=powerpc
- ;;
- s390x)
- linux_arch=s390
- ;;
- aarch64)
- linux_arch=arm64
- ;;
- loongarch*)
- linux_arch=loongarch
- ;;
- mips64)
- linux_arch=mips
- ;;
- riscv32|riscv64)
- linux_arch=riscv
- ;;
- *)
- # For most CPUs the kernel architecture name and QEMU CPU name match.
- linux_arch="$cpu"
- ;;
- esac
- # For non-KVM architectures we will not have asm headers
- if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
- symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
- fi
+# use included Linux headers for KVM architectures
+if test "$linux" = "yes" && test -n "$linux_arch"; then
+ symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
fi
for target in $target_list; do
diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h
deleted file mode 100644
index 4f9e2ab..0000000
--- a/linux-user/include/host/alpha/host-signal.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2003-2005 Fabrice Bellard
- * Copyright (c) 2021 Linaro Limited
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef ALPHA_HOST_SIGNAL_H
-#define ALPHA_HOST_SIGNAL_H
-
-/* The third argument to a SA_SIGINFO handler is ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
- return uc->uc_mcontext.sc_pc;
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
- uc->uc_mcontext.sc_pc = pc;
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
- return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
- uint32_t *pc = (uint32_t *)host_signal_pc(uc);
- uint32_t insn = *pc;
-
- /* XXX: need kernel patch to get write flag faster */
- switch (insn >> 26) {
- case 0x0d: /* stw */
- case 0x0e: /* stb */
- case 0x0f: /* stq_u */
- case 0x24: /* stf */
- case 0x25: /* stg */
- case 0x26: /* sts */
- case 0x27: /* stt */
- case 0x2c: /* stl */
- case 0x2d: /* stq */
- case 0x2e: /* stl_c */
- case 0x2f: /* stq_c */
- return true;
- }
- return false;
-}
-
-#endif
diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h
deleted file mode 100644
index e6d3ec2..0000000
--- a/linux-user/include/host/s390/host-signal.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2003-2005 Fabrice Bellard
- * Copyright (c) 2021 Linaro Limited
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef S390_HOST_SIGNAL_H
-#define S390_HOST_SIGNAL_H
-
-/* The third argument to a SA_SIGINFO handler is ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
- return uc->uc_mcontext.psw.addr;
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
- uc->uc_mcontext.psw.addr = pc;
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
- return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
- uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
-
- /*
- * ??? On linux, the non-rt signal handler has 4 (!) arguments instead
- * of the normal 2 arguments. The 4th argument contains the "Translation-
- * Exception Identification for DAT Exceptions" from the hardware (aka
- * "int_parm_long"), which does in fact contain the is_write value.
- * The rt signal handler, as far as I can tell, does not give this value
- * at all. Not that we could get to it from here even if it were.
- * So fall back to parsing instructions. Treat read-modify-write ones as
- * writes, which is not fully correct, but for tracking self-modifying code
- * this is better than treating them as reads. Checking si_addr page flags
- * might be a viable improvement, albeit a racy one.
- */
- /* ??? This is not even close to complete. */
- switch (pinsn[0] >> 8) {
- case 0x50: /* ST */
- case 0x42: /* STC */
- case 0x40: /* STH */
- case 0x44: /* EX */
- case 0xba: /* CS */
- case 0xbb: /* CDS */
- return true;
- case 0xc4: /* RIL format insns */
- switch (pinsn[0] & 0xf) {
- case 0xf: /* STRL */
- case 0xb: /* STGRL */
- case 0x7: /* STHRL */
- return true;
- }
- break;
- case 0xc6: /* RIL-b format insns */
- switch (pinsn[0] & 0xf) {
- case 0x0: /* EXRL */
- return true;
- }
- break;
- case 0xc8: /* SSF format insns */
- switch (pinsn[0] & 0xf) {
- case 0x2: /* CSST */
- return true;
- }
- break;
- case 0xe3: /* RXY format insns */
- switch (pinsn[2] & 0xff) {
- case 0x50: /* STY */
- case 0x24: /* STG */
- case 0x72: /* STCY */
- case 0x70: /* STHY */
- case 0x8e: /* STPQ */
- case 0x3f: /* STRVH */
- case 0x3e: /* STRV */
- case 0x2f: /* STRVG */
- return true;
- }
- break;
- case 0xe6:
- switch (pinsn[2] & 0xff) {
- case 0x09: /* VSTEBRH */
- case 0x0a: /* VSTEBRG */
- case 0x0b: /* VSTEBRF */
- case 0x0e: /* VSTBR */
- case 0x0f: /* VSTER */
- case 0x3f: /* VSTRLR */
- return true;
- }
- break;
- case 0xe7:
- switch (pinsn[2] & 0xff) {
- case 0x08: /* VSTEB */
- case 0x09: /* VSTEH */
- case 0x0a: /* VSTEG */
- case 0x0b: /* VSTEF */
- case 0x0e: /* VST */
- case 0x1a: /* VSCEG */
- case 0x1b: /* VSCEF */
- case 0x3e: /* VSTM */
- case 0x3f: /* VSTL */
- return true;
- }
- break;
- case 0xeb: /* RSY format insns */
- switch (pinsn[2] & 0xff) {
- case 0x14: /* CSY */
- case 0x30: /* CSG */
- case 0x31: /* CDSY */
- case 0x3e: /* CDSG */
- case 0xe4: /* LANG */
- case 0xe6: /* LAOG */
- case 0xe7: /* LAXG */
- case 0xe8: /* LAAG */
- case 0xea: /* LAALG */
- case 0xf4: /* LAN */
- case 0xf6: /* LAO */
- case 0xf7: /* LAX */
- case 0xfa: /* LAAL */
- case 0xf8: /* LAA */
- return true;
- }
- break;
- }
- return false;
-}
-
-#endif
diff --git a/linux-user/include/host/s390x/host-signal.h b/linux-user/include/host/s390x/host-signal.h
index 0e83f93..e6d3ec2 100644
--- a/linux-user/include/host/s390x/host-signal.h
+++ b/linux-user/include/host/s390x/host-signal.h
@@ -1 +1,138 @@
-#include "../s390/host-signal.h"
+/*
+ * host-signal.h: signal info dependent on the host architecture
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ * Copyright (c) 2021 Linaro Limited
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef S390_HOST_SIGNAL_H
+#define S390_HOST_SIGNAL_H
+
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
+{
+ return uc->uc_mcontext.psw.addr;
+}
+
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.psw.addr = pc;
+}
+
+static inline void *host_signal_mask(host_sigcontext *uc)
+{
+ return &uc->uc_sigmask;
+}
+
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
+{
+ uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
+
+ /*
+ * ??? On linux, the non-rt signal handler has 4 (!) arguments instead
+ * of the normal 2 arguments. The 4th argument contains the "Translation-
+ * Exception Identification for DAT Exceptions" from the hardware (aka
+ * "int_parm_long"), which does in fact contain the is_write value.
+ * The rt signal handler, as far as I can tell, does not give this value
+ * at all. Not that we could get to it from here even if it were.
+ * So fall back to parsing instructions. Treat read-modify-write ones as
+ * writes, which is not fully correct, but for tracking self-modifying code
+ * this is better than treating them as reads. Checking si_addr page flags
+ * might be a viable improvement, albeit a racy one.
+ */
+ /* ??? This is not even close to complete. */
+ switch (pinsn[0] >> 8) {
+ case 0x50: /* ST */
+ case 0x42: /* STC */
+ case 0x40: /* STH */
+ case 0x44: /* EX */
+ case 0xba: /* CS */
+ case 0xbb: /* CDS */
+ return true;
+ case 0xc4: /* RIL format insns */
+ switch (pinsn[0] & 0xf) {
+ case 0xf: /* STRL */
+ case 0xb: /* STGRL */
+ case 0x7: /* STHRL */
+ return true;
+ }
+ break;
+ case 0xc6: /* RIL-b format insns */
+ switch (pinsn[0] & 0xf) {
+ case 0x0: /* EXRL */
+ return true;
+ }
+ break;
+ case 0xc8: /* SSF format insns */
+ switch (pinsn[0] & 0xf) {
+ case 0x2: /* CSST */
+ return true;
+ }
+ break;
+ case 0xe3: /* RXY format insns */
+ switch (pinsn[2] & 0xff) {
+ case 0x50: /* STY */
+ case 0x24: /* STG */
+ case 0x72: /* STCY */
+ case 0x70: /* STHY */
+ case 0x8e: /* STPQ */
+ case 0x3f: /* STRVH */
+ case 0x3e: /* STRV */
+ case 0x2f: /* STRVG */
+ return true;
+ }
+ break;
+ case 0xe6:
+ switch (pinsn[2] & 0xff) {
+ case 0x09: /* VSTEBRH */
+ case 0x0a: /* VSTEBRG */
+ case 0x0b: /* VSTEBRF */
+ case 0x0e: /* VSTBR */
+ case 0x0f: /* VSTER */
+ case 0x3f: /* VSTRLR */
+ return true;
+ }
+ break;
+ case 0xe7:
+ switch (pinsn[2] & 0xff) {
+ case 0x08: /* VSTEB */
+ case 0x09: /* VSTEH */
+ case 0x0a: /* VSTEG */
+ case 0x0b: /* VSTEF */
+ case 0x0e: /* VST */
+ case 0x1a: /* VSCEG */
+ case 0x1b: /* VSCEF */
+ case 0x3e: /* VSTM */
+ case 0x3f: /* VSTL */
+ return true;
+ }
+ break;
+ case 0xeb: /* RSY format insns */
+ switch (pinsn[2] & 0xff) {
+ case 0x14: /* CSY */
+ case 0x30: /* CSG */
+ case 0x31: /* CDSY */
+ case 0x3e: /* CDSG */
+ case 0xe4: /* LANG */
+ case 0xe6: /* LAOG */
+ case 0xe7: /* LAXG */
+ case 0xe8: /* LAAG */
+ case 0xea: /* LAALG */
+ case 0xf4: /* LAN */
+ case 0xf6: /* LAO */
+ case 0xf7: /* LAX */
+ case 0xfa: /* LAAL */
+ case 0xf8: /* LAA */
+ return true;
+ }
+ break;
+ }
+ return false;
+}
+
+#endif
diff --git a/linux-user/include/host/x32/host-signal.h b/linux-user/include/host/x32/host-signal.h
deleted file mode 100644
index 2680059..0000000
--- a/linux-user/include/host/x32/host-signal.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../x86_64/host-signal.h"