aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2024-01-04 19:55:19 +0000
committerPeter Maydell <peter.maydell@linaro.org>2024-01-04 19:55:20 +0000
commit05470c3979d5485003e129ff4b0c2ef98af91d86 (patch)
tree62455044099aebd9c5333f4491e7e588101d10ac
parentd328fef93ae757a0dd65ed786a4086e27952eef3 (diff)
parentf705c1f25d9a075534f8279048082af4ce2066bf (diff)
downloadqemu-05470c3979d5485003e129ff4b0c2ef98af91d86.zip
qemu-05470c3979d5485003e129ff4b0c2ef98af91d86.tar.gz
qemu-05470c3979d5485003e129ff4b0c2ef98af91d86.tar.bz2
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* configure: use a native non-cross compiler for linux-user * meson: cleanups * target/i386: miscellaneous cleanups and optimizations * target/i386: implement CMPccXADD * target/i386: the sgx_epc_get_section stub is reachable * esp: check for NULL result from scsi_device_find() # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmWRImYUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroNd7AgAgcyJGiMfUkXqhefplpm06RDXQIa8 # FuoJqPb21lO75DQKfaFRAc4xGLagjJROMJGHMm9HvMu2VlwvOydkQlfFRspENxQ/ # 5XzGdb/X0A7HA/mwUfnMB1AZx0Vs32VI5IBSc6acc9fmgeZ84XQEoM3KBQHUik7X # mSkE4eltR9gJ+4IaGo4voZtK+YoVD8nEcuqmnKihSPWizev0FsZ49aNMtaYa9qC/ # Xs3kiQd/zPibHDHJu0ulFsNZgxtUcvlLHTCf8gO4dHWxCFLXGubMush83McpRtNB # Qoh6cTLH+PBXfrxMR3zmTZMNvo8Euls3s07Y8TkNP4vdIIE/kMeMDW1wJw== # =mq30 # -----END PGP SIGNATURE----- # gpg: Signature made Sun 31 Dec 2023 08:12:22 GMT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # 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: (46 commits) meson.build: report graphics backends separately configure, meson: rename targetos to host_os meson: rename config_all meson: remove CONFIG_ALL meson: remove config_targetos meson: remove CONFIG_POSIX and CONFIG_WIN32 from config_targetos meson: remove OS definitions from config_targetos meson: always probe u2f and canokey if the option is enabled meson: move subdirs to "Collect sources" section meson: move config-host.h definitions together meson: move CFI detection code with other compiler flags meson: keep subprojects together meson: move accelerator dependency checks together meson: move option validation together meson: move program checks together meson: add more sections to main meson.build configure: unify again the case arms in probe_target_compiler configure: remove unnecessary subshell Makefile: clean qemu-iotests output meson: use version_compare() to compare version ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--Makefile1
-rw-r--r--accel/tcg/meson.build4
-rw-r--r--backends/meson.build10
-rw-r--r--block/meson.build11
-rw-r--r--bsd-user/meson.build2
-rw-r--r--chardev/meson.build28
-rwxr-xr-xconfigure159
-rw-r--r--contrib/ivshmem-client/meson.build2
-rw-r--r--contrib/ivshmem-server/meson.build2
-rw-r--r--contrib/vhost-user-blk/meson.build2
-rw-r--r--contrib/vhost-user-input/meson.build2
-rw-r--r--contrib/vhost-user-scsi/meson.build2
-rw-r--r--docs/devel/build-system.rst15
-rw-r--r--docs/devel/kconfig.rst2
-rw-r--r--fsdev/meson.build6
-rw-r--r--gdbstub/meson.build4
-rw-r--r--hw/9pfs/meson.build7
-rw-r--r--hw/acpi/meson.build5
-rw-r--r--hw/cxl/meson.build2
-rw-r--r--hw/display/meson.build8
-rw-r--r--hw/i386/sgx-stub.c2
-rw-r--r--hw/mem/meson.build1
-rw-r--r--hw/mips/meson.build2
-rw-r--r--hw/net/meson.build2
-rw-r--r--hw/pci-bridge/meson.build2
-rw-r--r--hw/pci/meson.build1
-rw-r--r--hw/ppc/meson.build8
-rw-r--r--hw/remote/meson.build1
-rw-r--r--hw/scsi/esp.c9
-rw-r--r--hw/smbios/meson.build5
-rw-r--r--hw/usb/meson.build8
-rw-r--r--hw/virtio/meson.build2
-rw-r--r--meson.build943
-rw-r--r--meson_options.txt2
-rw-r--r--net/can/meson.build4
-rw-r--r--net/meson.build10
-rw-r--r--plugins/meson.build4
-rw-r--r--qga/meson.build50
-rw-r--r--scsi/meson.build8
-rw-r--r--storage-daemon/meson.build2
-rw-r--r--system/meson.build4
-rw-r--r--target/arm/meson.build2
-rw-r--r--target/i386/cpu.c2
-rw-r--r--target/i386/cpu.h5
-rw-r--r--target/i386/tcg/cc_helper.c6
-rw-r--r--target/i386/tcg/decode-new.c.inc152
-rw-r--r--target/i386/tcg/decode-new.h29
-rw-r--r--target/i386/tcg/emit.c.inc220
-rw-r--r--target/i386/tcg/excp_helper.c7
-rw-r--r--target/i386/tcg/fpu_helper.c10
-rw-r--r--target/i386/tcg/helper-tcg.h3
-rw-r--r--target/i386/tcg/int_helper.c8
-rw-r--r--target/i386/tcg/misc_helper.c4
-rw-r--r--target/i386/tcg/seg_helper.c8
-rw-r--r--target/i386/tcg/translate.c160
-rw-r--r--target/mips/meson.build2
-rw-r--r--tcg/meson.build2
-rw-r--r--tests/bench/meson.build6
-rw-r--r--tests/fp/meson.build4
-rw-r--r--tests/meson.build4
-rw-r--r--tests/plugin/meson.build2
-rw-r--r--tests/qemu-iotests/meson.build2
-rw-r--r--tests/qtest/meson.build20
-rw-r--r--tests/tcg/i386/Makefile.target2
-rw-r--r--tests/tcg/i386/test-flags.c37
-rw-r--r--tests/unit/meson.build8
-rw-r--r--ui/dbus-display1.xml10
-rw-r--r--ui/meson.build17
-rw-r--r--util/meson.build58
69 files changed, 1186 insertions, 948 deletions
diff --git a/Makefile b/Makefile
index 676a4a5..8f36990 100644
--- a/Makefile
+++ b/Makefile
@@ -202,6 +202,7 @@ clean: recurse-clean
! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
-exec rm {} +
rm -f TAGS cscope.* *~ */*~
+ @$(MAKE) -Ctests/qemu-iotests clean
VERSION = $(shell cat $(SRC_PATH)/VERSION)
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 8783edd..d25638d 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -17,7 +17,9 @@ if get_option('plugins')
tcg_ss.add(files('plugin-gen.c'))
endif
tcg_ss.add(when: libdw, if_true: files('debuginfo.c'))
-tcg_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c'))
+if host_os == 'linux'
+ tcg_ss.add(files('perf.c'))
+endif
specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
diff --git a/backends/meson.build b/backends/meson.build
index 9a5cea4..8b2b111 100644
--- a/backends/meson.build
+++ b/backends/meson.build
@@ -10,9 +10,13 @@ system_ss.add([files(
'confidential-guest-support.c',
), numa])
-system_ss.add(when: 'CONFIG_POSIX', if_true: files('rng-random.c'))
-system_ss.add(when: 'CONFIG_POSIX', if_true: files('hostmem-file.c'))
-system_ss.add(when: 'CONFIG_LINUX', if_true: files('hostmem-memfd.c'))
+if host_os != 'windows'
+ system_ss.add(files('rng-random.c'))
+ system_ss.add(files('hostmem-file.c'))
+endif
+if host_os == 'linux'
+ system_ss.add(files('hostmem-memfd.c'))
+endif
if keyutils.found()
system_ss.add(keyutils, files('cryptodev-lkcf.c'))
endif
diff --git a/block/meson.build b/block/meson.build
index 59ff6d3..e1f03fd 100644
--- a/block/meson.build
+++ b/block/meson.build
@@ -88,10 +88,15 @@ if get_option('parallels').allowed()
block_ss.add(files('parallels.c', 'parallels-ext.c'))
endif
-block_ss.add(when: 'CONFIG_WIN32', if_true: files('file-win32.c', 'win32-aio.c'))
-block_ss.add(when: 'CONFIG_POSIX', if_true: [files('file-posix.c'), coref, iokit])
+if host_os == 'windows'
+ block_ss.add(files('file-win32.c', 'win32-aio.c'))
+else
+ block_ss.add(files('file-posix.c'), coref, iokit)
+endif
block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c'))
-block_ss.add(when: 'CONFIG_LINUX', if_true: files('nvme.c'))
+if host_os == 'linux'
+ block_ss.add(files('nvme.c'))
+endif
if get_option('replication').allowed()
block_ss.add(files('replication.c'))
endif
diff --git a/bsd-user/meson.build b/bsd-user/meson.build
index c6bfd3b..39bad0a 100644
--- a/bsd-user/meson.build
+++ b/bsd-user/meson.build
@@ -24,6 +24,6 @@ kvm = cc.find_library('kvm', required: true)
bsd_user_ss.add(elf, procstat, kvm)
# Pull in the OS-specific build glue, if any
-subdir(targetos)
+subdir(host_os)
specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
diff --git a/chardev/meson.build b/chardev/meson.build
index 6d56ad3..c80337d 100644
--- a/chardev/meson.build
+++ b/chardev/meson.build
@@ -12,21 +12,23 @@ chardev_ss.add(files(
'char-udp.c',
'char.c',
))
-chardev_ss.add(when: 'CONFIG_POSIX', if_true: [files(
- 'char-fd.c',
- 'char-pty.c',
-), util])
-if targetos in ['linux', 'gnu/kfreebsd', 'freebsd', 'dragonfly']
- chardev_ss.add(files('char-parallel.c'))
+if host_os == 'windows'
+ chardev_ss.add(files(
+ 'char-console.c',
+ 'char-win-stdio.c',
+ 'char-win.c',
+ ))
+else
+ chardev_ss.add(files(
+ 'char-fd.c',
+ 'char-pty.c',
+ ), util)
+ if host_os in ['linux', 'gnu/kfreebsd', 'freebsd', 'dragonfly']
+ chardev_ss.add(files('char-parallel.c'))
+ endif
endif
-chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(
- 'char-console.c',
- 'char-win-stdio.c',
- 'char-win.c',
-))
-
-chardev_ss = chardev_ss.apply(config_targetos, strict: false)
+chardev_ss = chardev_ss.apply({})
system_ss.add(files(
'char-hmp-cmds.c',
diff --git a/configure b/configure
index bdda912..21ab9a6 100755
--- a/configure
+++ b/configure
@@ -334,30 +334,30 @@ EOF
}
if check_define __linux__ ; then
- targetos=linux
+ host_os=linux
elif check_define _WIN32 ; then
- targetos=windows
+ host_os=windows
elif check_define __OpenBSD__ ; then
- targetos=openbsd
+ host_os=openbsd
elif check_define __sun__ ; then
- targetos=sunos
+ host_os=sunos
elif check_define __HAIKU__ ; then
- targetos=haiku
+ host_os=haiku
elif check_define __FreeBSD__ ; then
- targetos=freebsd
+ host_os=freebsd
elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
- targetos=gnu/kfreebsd
+ host_os=gnu/kfreebsd
elif check_define __DragonFly__ ; then
- targetos=dragonfly
+ host_os=dragonfly
elif check_define __NetBSD__; then
- targetos=netbsd
+ host_os=netbsd
elif check_define __APPLE__; then
- targetos=darwin
+ host_os=darwin
else
# This is a fatal error, but don't report it yet, because we
# might be going to just print the --help text, or it might
# be the result of a missing compiler.
- targetos=bogus
+ host_os=bogus
fi
if test ! -z "$cpu" ; then
@@ -573,13 +573,13 @@ do
fi
done
-if test "$targetos" = "windows" ; then
+if test "$host_os" = "windows" ; then
EXESUF=".exe"
fi
meson_option_build_array() {
printf '['
- (if test "$targetos" = windows; then
+ (if test "$host_os" = windows; then
IFS=\;
else
IFS=:
@@ -802,7 +802,7 @@ mak_wilds=""
if [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; then
if [ "$linux_user" != no ]; then
- if [ "$targetos" = linux ]; then
+ if [ "$host_os" = linux ]; then
linux_user=yes
elif [ "$linux_user" = yes ]; then
error_exit "linux-user not supported on this architecture"
@@ -813,9 +813,9 @@ if [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; the
fi
if [ "$bsd_user" != no ]; then
if [ "$bsd_user" = "" ]; then
- test $targetos = freebsd && bsd_user=yes
+ test $host_os = freebsd && bsd_user=yes
fi
- if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
+ if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$host_os" ]; then
error_exit "bsd-user not supported on this host OS"
fi
if [ "$bsd_user" = "yes" ]; then
@@ -998,7 +998,7 @@ if test -z "$ninja"; then
fi
fi
-if test "$targetos" = "bogus"; then
+if test "$host_os" = "bogus"; then
# Now that we know that we're not printing the help and that
# the compiler works (so the results of the check_defines we used
# to identify the OS are reliable), if we didn't recognize the
@@ -1007,7 +1007,7 @@ if test "$targetos" = "bogus"; then
fi
# test for any invalid configuration combinations
-if test "$targetos" = "windows" && ! has "$dlltool"; then
+if test "$host_os" = "windows" && ! has "$dlltool"; then
if test "$plugins" = "yes"; then
error_exit "TCG plugins requires dlltool to build on Windows platforms"
fi
@@ -1041,7 +1041,7 @@ static THREAD int tls_var;
int main(void) { return tls_var; }
EOF
-if test "$targetos" = windows || test "$targetos" = haiku; then
+if test "$host_os" = windows || test "$host_os" = haiku; then
if test "$pie" = "yes"; then
error_exit "PIE not available due to missing OS support"
fi
@@ -1231,6 +1231,7 @@ probe_target_compiler() {
got_cross_cc=no
container_image=
container_hosts=
+ container_cross_prefix=
container_cross_cc=
container_cross_ar=
container_cross_as=
@@ -1272,16 +1273,33 @@ probe_target_compiler() {
test "$container" != no || continue
test "$host" = "$cpu" || continue
case $target_arch in
+ # debian-all-test-cross architectures
+
+ hppa|m68k|mips|riscv64|sparc64)
+ container_image=debian-all-test-cross
+ ;;
+ mips64)
+ container_image=debian-all-test-cross
+ container_cross_prefix=mips64-linux-gnuabi64-
+ ;;
+ ppc|ppc64|ppc64le)
+ container_image=debian-all-test-cross
+ container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
+ ;;
+
+ # debian-legacy-test-cross architectures (need Debian 11)
+ # - libc6.1-dev-alpha-cross: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1054412
+ # - sh4-linux-user: binaries don't run with bookworm compiler
+
+ alpha|sh4)
+ container_image=debian-legacy-test-cross
+ ;;
+
+ # architectures with individual containers
+
aarch64)
# We don't have any bigendian build tools so we only use this for AArch64
container_image=debian-arm64-cross
- container_cross_prefix=aarch64-linux-gnu-
- container_cross_cc=${container_cross_prefix}gcc
- ;;
- alpha)
- container_image=debian-legacy-test-cross
- container_cross_prefix=alpha-linux-gnu-
- container_cross_cc=${container_cross_prefix}gcc
;;
arm)
# We don't have any bigendian build tools so we only use this for ARM
@@ -1290,18 +1308,11 @@ probe_target_compiler() {
;;
cris)
container_image=fedora-cris-cross
- container_cross_prefix=cris-linux-gnu-
;;
hexagon)
- container_image=debian-hexagon-cross
container_cross_prefix=hexagon-unknown-linux-musl-
container_cross_cc=${container_cross_prefix}clang
;;
- hppa)
- container_image=debian-all-test-cross
- container_cross_prefix=hppa-linux-gnu-
- container_cross_cc=${container_cross_prefix}gcc
- ;;
i386)
container_image=debian-i686-cross
container_cross_prefix=i686-linux-gnu-
@@ -1310,59 +1321,19 @@ probe_target_compiler() {
container_image=debian-loongarch-cross
container_cross_prefix=loongarch64-unknown-linux-gnu-
;;
- m68k)
- container_image=debian-all-test-cross
- container_cross_prefix=m68k-linux-gnu-
- container_cross_cc=${container_cross_prefix}gcc
- ;;
microblaze)
- container_image=debian-microblaze-cross
container_cross_prefix=microblaze-linux-musl-
;;
mips64el)
container_image=debian-mips64el-cross
container_cross_prefix=mips64el-linux-gnuabi64-
;;
- mips64)
- container_image=debian-all-test-cross
- container_cross_prefix=mips64-linux-gnuabi64-
- ;;
- mips)
- container_image=debian-all-test-cross
- container_cross_prefix=mips-linux-gnu-
- ;;
- nios2)
- container_image=debian-nios2-cross
- container_cross_prefix=nios2-linux-gnu-
- ;;
- ppc)
- container_image=debian-all-test-cross
- container_cross_prefix=powerpc-linux-gnu-
- container_cross_cc=${container_cross_prefix}gcc
- ;;
- ppc64|ppc64le)
- container_image=debian-all-test-cross
- container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
- ;;
- riscv64)
- container_image=debian-all-test-cross
- container_cross_prefix=riscv64-linux-gnu-
- ;;
- sh4)
- container_image=debian-legacy-test-cross
- container_cross_prefix=sh4-linux-gnu-
- ;;
- sparc64)
- container_image=debian-all-test-cross
- container_cross_prefix=sparc64-linux-gnu-
- ;;
tricore)
container_image=debian-tricore-cross
container_cross_prefix=tricore-
;;
x86_64)
container_image=debian-amd64-cross
- container_cross_prefix=x86_64-linux-gnu-
;;
xtensa*)
container_image=debian-xtensa-cross
@@ -1370,12 +1341,10 @@ probe_target_compiler() {
# default to the dc232b cpu
container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
;;
- *)
- # Debian and GNU architecture names usually match
- container_image=debian-$target_arch-cross
- container_cross_prefix=$target_arch-linux-gnu-
- ;;
esac
+ # Debian and GNU architecture names usually match
+ : ${container_image:=debian-$target_arch-cross}
+ : ${container_cross_prefix:=$target_arch-linux-gnu-}
: ${container_cross_cc:=${container_cross_prefix}gcc}
: ${container_cross_ar:=${container_cross_prefix}ar}
: ${container_cross_as:=${container_cross_prefix}as}
@@ -1387,8 +1356,8 @@ probe_target_compiler() {
done
try=cross
- # For softmmu/roms we might be able to use the host compiler
- if [ "${1%softmmu}" != "$1" ]; then
+ # For softmmu/roms also look for a bi-endian or multilib-enabled host compiler
+ if [ "${1%softmmu}" != "$1" ] || test "$target_arch" = "$cpu"; then
case "$target_arch:$cpu" in
aarch64_be:aarch64 | \
armeb:arm | \
@@ -1559,7 +1528,7 @@ LINKS="$LINKS pc-bios/s390-ccw/Makefile"
LINKS="$LINKS pc-bios/vof/Makefile"
LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
LINKS="$LINKS tests/avocado tests/data"
-LINKS="$LINKS tests/qemu-iotests/check"
+LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
LINKS="$LINKS python"
LINKS="$LINKS contrib/plugins/Makefile "
for f in $LINKS ; do
@@ -1572,8 +1541,8 @@ echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
# Mac OS X ships with a broken assembler
if have_target i386-softmmu x86_64-softmmu && \
- test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
- test "$targetos" != "haiku" && \
+ test "$host_os" != "darwin" && test "$host_os" != "sunos" && \
+ test "$host_os" != "haiku" && \
probe_target_compiler i386-softmmu; then
subdirs="$subdirs pc-bios/optionrom"
config_mak=pc-bios/optionrom/config.mak
@@ -1637,7 +1606,7 @@ echo "NINJA=$ninja" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $config_host_mak
# use included Linux headers for KVM architectures
-if test "$targetos" = "linux" && test -n "$linux_arch"; then
+if test "$host_os" = "linux" && test -n "$linux_arch"; then
symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
fi
@@ -1660,21 +1629,20 @@ echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
-if test "$targetos" = windows; then
+if test "$host_os" = windows; then
echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
fi
-if test "$targetos" = darwin; then
+if test "$host_os" = darwin; then
echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
fi
-if test "$targetos" = windows; then
+if test "$host_os" = windows; then
echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
fi
# tests/tcg configuration
-(config_host_mak=tests/tcg/config-host.mak
mkdir -p tests/tcg
-echo "# Automatically generated by configure - do not modify" > $config_host_mak
-echo "SRC_PATH=$source_path" >> $config_host_mak
+echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak
+echo "SRC_PATH=$source_path" >> tests/tcg/$config_host_mak
tcg_tests_targets=
for target in $target_list; do
@@ -1717,9 +1685,8 @@ for target in $target_list; do
done
if test "$tcg" = "enabled"; then
- echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
+ echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> $config_host_mak
fi
-)
if test "$skip_meson" = no; then
cross="config-meson.cross.new"
@@ -1748,7 +1715,7 @@ if test "$skip_meson" = no; then
echo "# environment defaults, can still be overridden on " >> $cross
echo "# the command line" >> $cross
if test -e "$source_path/.git" && \
- { test "$targetos" = linux || test "$targetos" = "windows"; }; then
+ { test "$host_os" = linux || test "$host_os" = "windows"; }; then
echo 'werror = true' >> $cross
fi
echo "[project options]" >> $cross
@@ -1785,7 +1752,7 @@ if test "$skip_meson" = no; then
echo "windmc = [$(meson_quote $windmc)]" >> $cross
if test "$cross_compile" = "yes"; then
echo "[host_machine]" >> $cross
- echo "system = '$targetos'" >> $cross
+ echo "system = '$host_os'" >> $cross
case "$cpu" in
i386)
echo "cpu_family = 'x86'" >> $cross
@@ -1811,8 +1778,8 @@ if test "$skip_meson" = no; then
fi
mv $cross config-meson.cross
meson_add_machine_file config-meson.cross
- if test -f "$source_path/configs/meson/$targetos.txt"; then
- meson_add_machine_file $source_path/configs/meson/$targetos.txt
+ if test -f "$source_path/configs/meson/$host_os.txt"; then
+ meson_add_machine_file $source_path/configs/meson/$host_os.txt
fi
rm -rf meson-private meson-info meson-logs
diff --git a/contrib/ivshmem-client/meson.build b/contrib/ivshmem-client/meson.build
index ce8dcca..3c8b09a 100644
--- a/contrib/ivshmem-client/meson.build
+++ b/contrib/ivshmem-client/meson.build
@@ -1,4 +1,4 @@
executable('ivshmem-client', files('ivshmem-client.c', 'main.c'), genh,
dependencies: glib,
- build_by_default: targetos == 'linux',
+ build_by_default: host_os == 'linux',
install: false)
diff --git a/contrib/ivshmem-server/meson.build b/contrib/ivshmem-server/meson.build
index c6c3c82..1c8fea6 100644
--- a/contrib/ivshmem-server/meson.build
+++ b/contrib/ivshmem-server/meson.build
@@ -1,4 +1,4 @@
executable('ivshmem-server', files('ivshmem-server.c', 'main.c'), genh,
dependencies: [qemuutil, rt],
- build_by_default: targetos == 'linux',
+ build_by_default: host_os == 'linux',
install: false)
diff --git a/contrib/vhost-user-blk/meson.build b/contrib/vhost-user-blk/meson.build
index dcb9e2f..ac1eece 100644
--- a/contrib/vhost-user-blk/meson.build
+++ b/contrib/vhost-user-blk/meson.build
@@ -1,4 +1,4 @@
executable('vhost-user-blk', files('vhost-user-blk.c'),
dependencies: [qemuutil, vhost_user],
- build_by_default: targetos == 'linux',
+ build_by_default: host_os == 'linux',
install: false)
diff --git a/contrib/vhost-user-input/meson.build b/contrib/vhost-user-input/meson.build
index 21a9ed4..840d866 100644
--- a/contrib/vhost-user-input/meson.build
+++ b/contrib/vhost-user-input/meson.build
@@ -1,4 +1,4 @@
executable('vhost-user-input', files('main.c'),
dependencies: [qemuutil, vhost_user],
- build_by_default: targetos == 'linux',
+ build_by_default: host_os == 'linux',
install: false)
diff --git a/contrib/vhost-user-scsi/meson.build b/contrib/vhost-user-scsi/meson.build
index cc893f6..44be048 100644
--- a/contrib/vhost-user-scsi/meson.build
+++ b/contrib/vhost-user-scsi/meson.build
@@ -1,6 +1,6 @@
if libiscsi.found()
executable('vhost-user-scsi', files('vhost-user-scsi.c'),
dependencies: [qemuutil, libiscsi, vhost_user],
- build_by_default: targetos == 'linux',
+ build_by_default: host_os == 'linux',
install: false)
endif
diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst
index 43d6005..09caf2f 100644
--- a/docs/devel/build-system.rst
+++ b/docs/devel/build-system.rst
@@ -256,21 +256,6 @@ Target-independent emulator sourcesets:
``system_ss`` only in system emulators, ``user_ss`` only in user-mode
emulators.
- Target-independent sourcesets must exercise particular care when using
- ``if_false`` rules. The ``if_false`` rule will be used correctly when linking
- emulator binaries; however, when *compiling* target-independent files
- into .o files, Meson may need to pick *both* the ``if_true`` and
- ``if_false`` sides to cater for targets that want either side. To
- achieve that, you can add a special rule using the ``CONFIG_ALL``
- symbol::
-
- # Some targets have CONFIG_ACPI, some don't, so this is not enough
- system_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi.c'),
- if_false: files('acpi-stub.c'))
-
- # This is required as well:
- system_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c'))
-
Target-dependent emulator sourcesets:
In the target-dependent set lives CPU emulation, some device emulation and
much glue code. This sometimes also has to be compiled multiple times,
diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
index 73f52de..ccb9a46 100644
--- a/docs/devel/kconfig.rst
+++ b/docs/devel/kconfig.rst
@@ -316,6 +316,6 @@ variable::
host_kconfig = \
(have_tpm ? ['CONFIG_TPM=y'] : []) + \
- (targetos == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
+ (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
(have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
...
diff --git a/fsdev/meson.build b/fsdev/meson.build
index 1bec065..e20d725 100644
--- a/fsdev/meson.build
+++ b/fsdev/meson.build
@@ -1,13 +1,13 @@
fsdev_ss = ss.source_set()
fsdev_ss.add(files('qemu-fsdev-opts.c', 'qemu-fsdev-throttle.c'))
-fsdev_ss.add(when: 'CONFIG_ALL', if_true: files('qemu-fsdev-dummy.c'))
fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files(
'9p-iov-marshal.c',
'9p-marshal.c',
'qemu-fsdev.c',
), if_false: files('qemu-fsdev-dummy.c'))
-system_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss)
-system_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss)
+if host_os in ['linux', 'darwin']
+ system_ss.add_all(fsdev_ss)
+endif
if have_virtfs_proxy_helper
executable('virtfs-proxy-helper',
diff --git a/gdbstub/meson.build b/gdbstub/meson.build
index e5bccba..da5721d 100644
--- a/gdbstub/meson.build
+++ b/gdbstub/meson.build
@@ -14,8 +14,8 @@ gdb_system_ss = ss.source_set()
gdb_user_ss.add(files('gdbstub.c', 'user.c'))
gdb_system_ss.add(files('gdbstub.c', 'system.c'))
-gdb_user_ss = gdb_user_ss.apply(config_targetos, strict: false)
-gdb_system_ss = gdb_system_ss.apply(config_targetos, strict: false)
+gdb_user_ss = gdb_user_ss.apply({})
+gdb_system_ss = gdb_system_ss.apply({})
libgdb_user = static_library('gdb_user',
gdb_user_ss.sources() + genh,
diff --git a/hw/9pfs/meson.build b/hw/9pfs/meson.build
index 2944ea6..f1b62fa 100644
--- a/hw/9pfs/meson.build
+++ b/hw/9pfs/meson.build
@@ -13,8 +13,11 @@ fs_ss.add(files(
'coth.c',
'coxattr.c',
))
-fs_ss.add(when: 'CONFIG_LINUX', if_true: files('9p-util-linux.c'))
-fs_ss.add(when: 'CONFIG_DARWIN', if_true: files('9p-util-darwin.c'))
+if host_os == 'darwin'
+ fs_ss.add(files('9p-util-darwin.c'))
+elif host_os == 'linux'
+ fs_ss.add(files('9p-util-linux.c'))
+endif
fs_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-9p-backend.c'))
system_ss.add_all(when: 'CONFIG_FSDEV_9P', if_true: fs_ss)
diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build
index fc1b952..5441c9b 100644
--- a/hw/acpi/meson.build
+++ b/hw/acpi/meson.build
@@ -33,9 +33,4 @@ endif
system_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c', 'acpi_interface.c'))
system_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_false: files('pci-bridge-stub.c'))
system_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss)
-system_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c',
- 'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c',
- 'acpi-mem-hotplug-stub.c', 'acpi-cpu-hotplug-stub.c',
- 'acpi-pci-hotplug-stub.c', 'acpi-nvdimm-stub.c',
- 'cxl-stub.c', 'pci-bridge-stub.c'))
system_ss.add(files('acpi-qmp-cmds.c'))
diff --git a/hw/cxl/meson.build b/hw/cxl/meson.build
index ea0aebf..3e375f6 100644
--- a/hw/cxl/meson.build
+++ b/hw/cxl/meson.build
@@ -11,5 +11,3 @@ system_ss.add(when: 'CONFIG_CXL',
if_false: files(
'cxl-host-stubs.c',
))
-
-system_ss.add(when: 'CONFIG_ALL', if_true: files('cxl-host-stubs.c'))
diff --git a/hw/display/meson.build b/hw/display/meson.build
index 344dfe3..f93a69f 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -69,8 +69,11 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
virtio_gpu_ss = ss.source_set()
virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman])
- virtio_gpu_ss.add(when: 'CONFIG_LINUX', if_true: files('virtio-gpu-udmabuf.c'),
- if_false: files('virtio-gpu-udmabuf-stubs.c'))
+ if host_os == 'linux'
+ virtio_gpu_ss.add(files('virtio-gpu-udmabuf.c'))
+ else
+ virtio_gpu_ss.add(files('virtio-gpu-udmabuf-stubs.c'))
+ endif
virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
@@ -140,5 +143,4 @@ endif
system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_lcdc.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-vga-stub.c'))
modules += { 'hw-display': hw_display_modules }
diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c
index 26833eb..16b1dfd 100644
--- a/hw/i386/sgx-stub.c
+++ b/hw/i386/sgx-stub.c
@@ -34,5 +34,5 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)
bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
{
- g_assert_not_reached();
+ return true;
}
diff --git a/hw/mem/meson.build b/hw/mem/meson.build
index ec26ef5..faee1fe 100644
--- a/hw/mem/meson.build
+++ b/hw/mem/meson.build
@@ -5,7 +5,6 @@ mem_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_mc.c'))
mem_ss.add(when: 'CONFIG_NVDIMM', if_true: files('nvdimm.c'))
mem_ss.add(when: 'CONFIG_CXL_MEM_DEVICE', if_true: files('cxl_type3.c'))
system_ss.add(when: 'CONFIG_CXL_MEM_DEVICE', if_false: files('cxl_type3_stubs.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('cxl_type3_stubs.c'))
system_ss.add_all(when: 'CONFIG_MEM_DEVICE', if_true: mem_ss)
diff --git a/hw/mips/meson.build b/hw/mips/meson.build
index 900613f..f06d88f 100644
--- a/hw/mips/meson.build
+++ b/hw/mips/meson.build
@@ -5,7 +5,7 @@ mips_ss.add(when: 'CONFIG_LOONGSON3V', if_true: files('loongson3_bootp.c', 'loon
mips_ss.add(when: 'CONFIG_MALTA', if_true: files('malta.c'))
mips_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('cps.c'))
-if 'CONFIG_TCG' in config_all
+if 'CONFIG_TCG' in config_all_accel
mips_ss.add(when: 'CONFIG_JAZZ', if_true: files('jazz.c'))
mips_ss.add(when: 'CONFIG_MIPSSIM', if_true: files('mipssim.c'))
mips_ss.add(when: 'CONFIG_FULOONG', if_true: files('fuloong2e.c'))
diff --git a/hw/net/meson.build b/hw/net/meson.build
index f64651c..9afceb0 100644
--- a/hw/net/meson.build
+++ b/hw/net/meson.build
@@ -50,7 +50,6 @@ specific_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-net.c'))
if have_vhost_net
system_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost_net.c'), if_false: files('vhost_net-stub.c'))
- system_ss.add(when: 'CONFIG_ALL', if_true: files('vhost_net-stub.c'))
else
system_ss.add(files('vhost_net-stub.c'))
endif
@@ -69,7 +68,6 @@ system_ss.add(when: 'CONFIG_ROCKER', if_true: files(
'rocker/rocker_of_dpa.c',
'rocker/rocker_world.c',
), if_false: files('rocker/qmp-norocker.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('rocker/qmp-norocker.c'))
system_ss.add(files('rocker/rocker-hmp-cmds.c'))
subdir('can')
diff --git a/hw/pci-bridge/meson.build b/hw/pci-bridge/meson.build
index 6d5ad9f..f2a6043 100644
--- a/hw/pci-bridge/meson.build
+++ b/hw/pci-bridge/meson.build
@@ -13,5 +13,3 @@ pci_ss.add(when: 'CONFIG_CXL', if_true: files('cxl_root_port.c', 'cxl_upstream.c
pci_ss.add(when: 'CONFIG_SIMBA', if_true: files('simba.c'))
system_ss.add_all(when: 'CONFIG_PCI', if_true: pci_ss)
-
-system_ss.add(when: 'CONFIG_ALL', if_true: files('pci_expander_bridge_stubs.c'))
diff --git a/hw/pci/meson.build b/hw/pci/meson.build
index b185545..b9c34b2 100644
--- a/hw/pci/meson.build
+++ b/hw/pci/meson.build
@@ -20,4 +20,3 @@ system_ss.add(when: 'CONFIG_PCI_EXPRESS', if_true: files('pcie_port.c', 'pcie_ho
system_ss.add_all(when: 'CONFIG_PCI', if_true: pci_ss)
system_ss.add(when: 'CONFIG_PCI', if_false: files('pci-stub.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('pci-stub.c'))
diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build
index ea44856..eba3406 100644
--- a/hw/ppc/meson.build
+++ b/hw/ppc/meson.build
@@ -34,9 +34,11 @@ ppc_ss.add(when: ['CONFIG_PSERIES', 'CONFIG_TCG'], if_true: files(
'spapr_softmmu.c',
))
ppc_ss.add(when: 'CONFIG_SPAPR_RNG', if_true: files('spapr_rng.c'))
-ppc_ss.add(when: ['CONFIG_PSERIES', 'CONFIG_LINUX'], if_true: files(
- 'spapr_pci_vfio.c',
-))
+if host_os == 'linux'
+ ppc_ss.add(when: 'CONFIG_PSERIES', if_true: files(
+ 'spapr_pci_vfio.c',
+ ))
+endif
# IBM PowerNV
ppc_ss.add(when: 'CONFIG_POWERNV', if_true: files(
diff --git a/hw/remote/meson.build b/hw/remote/meson.build
index a3aa29a..41eb497 100644
--- a/hw/remote/meson.build
+++ b/hw/remote/meson.build
@@ -11,7 +11,6 @@ remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('iommu.c'))
remote_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_true: libvfio_user_dep)
remote_ss.add(when: 'CONFIG_VFIO_USER_SERVER', if_true: files('vfio-user-obj.c'),
if_false: files('vfio-user-obj-stub.c'))
-remote_ss.add(when: 'CONFIG_ALL', if_true: files('vfio-user-obj-stub.c'))
specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('memory.c'))
specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('proxy-memory-listener.c'))
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index ff90572..3a1c9f7 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -292,6 +292,15 @@ static void do_command_phase(ESPState *s)
esp_fifo_pop_buf(&s->cmdfifo, buf, cmdlen);
current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, s->lun);
+ if (!current_lun) {
+ /* No such drive */
+ s->rregs[ESP_RSTAT] = 0;
+ s->rregs[ESP_RINTR] = INTR_DC;
+ s->rregs[ESP_RSEQ] = SEQ_0;
+ esp_raise_irq(s);
+ return;
+ }
+
s->current_req = scsi_req_new(current_lun, 0, s->lun, buf, cmdlen, s);
datalen = scsi_req_enqueue(s->current_req);
s->ti_size = datalen;
diff --git a/hw/smbios/meson.build b/hw/smbios/meson.build
index 6eeae4b..7046967 100644
--- a/hw/smbios/meson.build
+++ b/hw/smbios/meson.build
@@ -6,8 +6,3 @@ smbios_ss.add(when: 'CONFIG_IPMI',
system_ss.add_all(when: 'CONFIG_SMBIOS', if_true: smbios_ss)
system_ss.add(when: 'CONFIG_SMBIOS', if_false: files('smbios-stub.c'))
-
-system_ss.add(when: 'CONFIG_ALL', if_true: files(
- 'smbios-stub.c',
- 'smbios_type_38-stub.c',
-))
diff --git a/hw/usb/meson.build b/hw/usb/meson.build
index e94149e..2c13c52 100644
--- a/hw/usb/meson.build
+++ b/hw/usb/meson.build
@@ -44,7 +44,9 @@ system_ss.add(when: 'CONFIG_USB_STORAGE_UAS', if_true: files('dev-uas.c'))
system_ss.add(when: 'CONFIG_USB_AUDIO', if_true: files('dev-audio.c'))
system_ss.add(when: 'CONFIG_USB_SERIAL', if_true: files('dev-serial.c'))
system_ss.add(when: 'CONFIG_USB_NETWORK', if_true: files('dev-network.c'))
-system_ss.add(when: ['CONFIG_POSIX', 'CONFIG_USB_STORAGE_MTP'], if_true: files('dev-mtp.c'))
+if host_os != 'windows'
+ system_ss.add(when: 'CONFIG_USB_STORAGE_MTP', if_true: files('dev-mtp.c'))
+endif
# smartcard
system_ss.add(when: 'CONFIG_USB_SMARTCARD', if_true: files('dev-smartcard-reader.c'))
@@ -58,7 +60,9 @@ endif
# U2F
system_ss.add(when: 'CONFIG_USB_U2F', if_true: files('u2f.c'))
-system_ss.add(when: ['CONFIG_LINUX', 'CONFIG_USB_U2F'], if_true: [libudev, files('u2f-passthru.c')])
+if host_os == 'linux'
+ system_ss.add(when: 'CONFIG_USB_U2F', if_true: [libudev, files('u2f-passthru.c')])
+endif
if u2f.found()
system_ss.add(when: 'CONFIG_USB_U2F', if_true: [u2f, files('u2f-emulated.c')])
endif
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index c0055a7..c8c1001 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -74,8 +74,6 @@ specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
system_ss.add_all(when: 'CONFIG_VIRTIO', if_true: system_virtio_ss)
system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
system_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
-system_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c'))
system_ss.add(files('virtio-hmp-cmds.c'))
specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: specific_virtio_ss)
diff --git a/meson.build b/meson.build
index 6c77d96..5a25827 100644
--- a/meson.build
+++ b/meson.build
@@ -9,27 +9,18 @@ add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
+####################
+# Global variables #
+####################
+
not_found = dependency('', required: false)
keyval = import('keyval')
ss = import('sourceset')
fs = import('fs')
-targetos = host_machine.system()
-sh = find_program('sh')
+host_os = host_machine.system()
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
-cc = meson.get_compiler('c')
-all_languages = ['c']
-if targetos == 'windows' and add_languages('cpp', required: false, native: false)
- all_languages += ['cpp']
- cxx = meson.get_compiler('cpp')
-endif
-if targetos == 'darwin' and \
- add_languages('objc', required: get_option('cocoa'), native: false)
- all_languages += ['objc']
- objc = meson.get_compiler('objc')
-endif
-
# Temporary directory used for files created while
# configure runs. Since it is in the build directory
# we can safely blow away any previous version of it
@@ -49,7 +40,6 @@ qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
qemu_desktopdir = get_option('datadir') / 'applications'
qemu_icondir = get_option('datadir') / 'icons'
-config_host_data = configuration_data()
genh = []
qapi_trace_events = []
@@ -61,6 +51,127 @@ supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64'
cpu = host_machine.cpu_family()
target_dirs = config_host['TARGET_DIRS'].split()
+
+############
+# Programs #
+############
+
+sh = find_program('sh')
+python = import('python').find_installation()
+
+cc = meson.get_compiler('c')
+all_languages = ['c']
+if host_os == 'windows' and add_languages('cpp', required: false, native: false)
+ all_languages += ['cpp']
+ cxx = meson.get_compiler('cpp')
+endif
+if host_os == 'darwin' and \
+ add_languages('objc', required: get_option('cocoa'), native: false)
+ all_languages += ['objc']
+ objc = meson.get_compiler('objc')
+endif
+
+dtrace = not_found
+stap = not_found
+if 'dtrace' in get_option('trace_backends')
+ dtrace = find_program('dtrace', required: true)
+ stap = find_program('stap', required: false)
+ if stap.found()
+ # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
+ # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
+ # instead. QEMU --enable-modules depends on this because the SystemTap
+ # semaphores are linked into the main binary and not the module's shared
+ # object.
+ add_global_arguments('-DSTAP_SDT_V2',
+ native: false, language: all_languages)
+ endif
+endif
+
+if get_option('iasl') == ''
+ iasl = find_program('iasl', required: false)
+else
+ iasl = find_program(get_option('iasl'), required: true)
+endif
+
+edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
+unpack_edk2_blobs = false
+foreach target : edk2_targets
+ if target in target_dirs
+ bzip2 = find_program('bzip2', required: get_option('install_blobs'))
+ unpack_edk2_blobs = bzip2.found()
+ break
+ endif
+endforeach
+
+#####################
+# Option validation #
+#####################
+
+# Fuzzing
+if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
+ not cc.links('''
+ #include <stdint.h>
+ #include <sys/types.h>
+ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
+ ''',
+ args: ['-Werror', '-fsanitize=fuzzer'])
+ error('Your compiler does not support -fsanitize=fuzzer')
+endif
+
+# Tracing backends
+if 'ftrace' in get_option('trace_backends') and host_os != 'linux'
+ error('ftrace is supported only on Linux')
+endif
+if 'syslog' in get_option('trace_backends') and not cc.compiles('''
+ #include <syslog.h>
+ int main(void) {
+ openlog("qemu", LOG_PID, LOG_DAEMON);
+ syslog(LOG_INFO, "configure");
+ return 0;
+ }''')
+ error('syslog is not supported on this system')
+endif
+
+# Miscellaneous Linux-only features
+get_option('mpath') \
+ .require(host_os == 'linux', error_message: 'Multipath is supported only on Linux')
+
+multiprocess_allowed = get_option('multiprocess') \
+ .require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
+ .allowed()
+
+vfio_user_server_allowed = get_option('vfio_user_server') \
+ .require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \
+ .allowed()
+
+have_tpm = get_option('tpm') \
+ .require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
+ .allowed()
+
+# vhost
+have_vhost_user = get_option('vhost_user') \
+ .disable_auto_if(host_os != 'linux') \
+ .require(host_os != 'windows',
+ error_message: 'vhost-user is not available on Windows').allowed()
+have_vhost_vdpa = get_option('vhost_vdpa') \
+ .require(host_os == 'linux',
+ error_message: 'vhost-vdpa is only available on Linux').allowed()
+have_vhost_kernel = get_option('vhost_kernel') \
+ .require(host_os == 'linux',
+ error_message: 'vhost-kernel is only available on Linux').allowed()
+have_vhost_user_crypto = get_option('vhost_crypto') \
+ .require(have_vhost_user,
+ error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
+
+have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
+
+have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
+have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
+have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
+have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
+
+# type of binaries to build
have_linux_user = false
have_bsd_user = false
have_system = false
@@ -70,23 +181,27 @@ foreach target : target_dirs
have_system = have_system or target.endswith('-softmmu')
endforeach
have_user = have_linux_user or have_bsd_user
+
have_tools = get_option('tools') \
.disable_auto_if(not have_system) \
.allowed()
have_ga = get_option('guest_agent') \
.disable_auto_if(not have_system and not have_tools) \
- .require(targetos in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
+ .require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
error_message: 'unsupported OS for QEMU guest agent') \
.allowed()
+have_block = have_system or have_tools
+
enable_modules = get_option('modules') \
- .require(targetos != 'windows',
+ .require(host_os != 'windows',
error_message: 'Modules are not available for Windows') \
.require(not get_option('prefer_static'),
error_message: 'Modules are incompatible with static linking') \
.allowed()
-have_block = have_system or have_tools
-python = import('python').find_installation()
+#######################################
+# Variables for host and accelerators #
+#######################################
if cpu not in supported_cpus
host_arch = 'unknown'
@@ -117,12 +232,6 @@ elif cpu in ['riscv64']
else
kvm_targets = []
endif
-
-kvm_targets_c = '""'
-if get_option('kvm').allowed() and targetos == 'linux'
- kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
-endif
-config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
accelerator_targets = { 'CONFIG_KVM': kvm_targets }
if cpu in ['x86', 'x86_64']
@@ -151,42 +260,10 @@ endif
modular_tcg = []
# Darwin does not support references to thread-local variables in modules
-if targetos != 'darwin'
+if host_os != 'darwin'
modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
endif
-edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
-unpack_edk2_blobs = false
-foreach target : edk2_targets
- if target in target_dirs
- bzip2 = find_program('bzip2', required: get_option('install_blobs'))
- unpack_edk2_blobs = bzip2.found()
- break
- endif
-endforeach
-
-dtrace = not_found
-stap = not_found
-if 'dtrace' in get_option('trace_backends')
- dtrace = find_program('dtrace', required: true)
- stap = find_program('stap', required: false)
- if stap.found()
- # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
- # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
- # instead. QEMU --enable-modules depends on this because the SystemTap
- # semaphores are linked into the main binary and not the module's shared
- # object.
- add_global_arguments('-DSTAP_SDT_V2',
- native: false, language: all_languages)
- endif
-endif
-
-if get_option('iasl') == ''
- iasl = find_program('iasl', required: false)
-else
- iasl = find_program(get_option('iasl'), required: true)
-endif
-
##################
# Compiler flags #
##################
@@ -223,18 +300,18 @@ qemu_common_flags = [
qemu_cflags = []
qemu_ldflags = []
-if targetos == 'darwin'
+if host_os == 'darwin'
# Disable attempts to use ObjectiveC features in os/object.h since they
# won't work when we're compiling with gcc as a C compiler.
if compiler.get_id() == 'gcc'
qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0'
endif
-elif targetos == 'sunos'
+elif host_os == 'sunos'
# needed for CMSG_ macros in sys/socket.h
qemu_common_flags += '-D_XOPEN_SOURCE=600'
# needed for TIOCWIN* defines in termios.h
qemu_common_flags += '-D__EXTENSIONS__'
-elif targetos == 'haiku'
+elif host_os == 'haiku'
qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
endif
@@ -318,10 +395,10 @@ ucontext_probe = '''
# For POSIX prefer ucontext, but it's not always possible. The fallback
# is sigcontext.
supported_backends = []
-if targetos == 'windows'
+if host_os == 'windows'
supported_backends += ['windows']
else
- if targetos != 'darwin' and cc.links(ucontext_probe)
+ if host_os != 'darwin' and cc.links(ucontext_probe)
supported_backends += ['ucontext']
endif
supported_backends += ['sigaltstack']
@@ -392,13 +469,13 @@ endif
# The combination is known as "full relro", because .got.plt is read-only too.
qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
-if targetos == 'windows'
+if host_os == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va')
endif
# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
-if targetos != 'sunos' and not get_option('tsan')
+if host_os != 'sunos' and not get_option('tsan')
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--warn-common')
endif
@@ -433,6 +510,46 @@ if get_option('fuzzing')
endif
endif
+if get_option('cfi')
+ cfi_flags=[]
+ # Check for dependency on LTO
+ if not get_option('b_lto')
+ error('Selected Control-Flow Integrity but LTO is disabled')
+ endif
+ if enable_modules
+ error('Selected Control-Flow Integrity is not compatible with modules')
+ endif
+ # Check for cfi flags. CFI requires LTO so we can't use
+ # get_supported_arguments, but need a more complex "compiles" which allows
+ # custom arguments
+ if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall'] )
+ cfi_flags += '-fsanitize=cfi-icall'
+ else
+ error('-fsanitize=cfi-icall is not supported by the compiler')
+ endif
+ if cc.compiles('int main () { return 0; }',
+ name: '-fsanitize-cfi-icall-generalize-pointers',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fsanitize-cfi-icall-generalize-pointers'] )
+ cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
+ else
+ error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
+ endif
+ if get_option('cfi_debug')
+ if cc.compiles('int main () { return 0; }',
+ name: '-fno-sanitize-trap=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fno-sanitize-trap=cfi-icall'] )
+ cfi_flags += '-fno-sanitize-trap=cfi-icall'
+ else
+ error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
+ endif
+ endif
+ add_global_arguments(cfi_flags, native: false, language: all_languages)
+ add_global_link_arguments(cfi_flags, native: false, language: all_languages)
+endif
+
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
@@ -468,7 +585,7 @@ warn_flags = [
'-Wshadow=local',
]
-if targetos != 'darwin'
+if host_os != 'darwin'
warn_flags += ['-Wthread-safety']
endif
@@ -488,7 +605,7 @@ if 'objc' in all_languages
# Note sanitizer flags are not applied to Objective-C sources!
add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc')
endif
-if targetos == 'linux'
+if host_os == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
'-isystem', 'linux-headers',
language: all_languages)
@@ -518,75 +635,10 @@ if sparse.found()
'-Wno-non-pointer-null'])
endif
-###########################################
-# Target-specific checks and dependencies #
-###########################################
-
-# Fuzzing
-if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
- not cc.links('''
- #include <stdint.h>
- #include <sys/types.h>
- int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
- int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
- ''',
- args: ['-Werror', '-fsanitize=fuzzer'])
- error('Your compiler does not support -fsanitize=fuzzer')
-endif
-
-# Tracing backends
-if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
- error('ftrace is supported only on Linux')
-endif
-if 'syslog' in get_option('trace_backends') and not cc.compiles('''
- #include <syslog.h>
- int main(void) {
- openlog("qemu", LOG_PID, LOG_DAEMON);
- syslog(LOG_INFO, "configure");
- return 0;
- }''')
- error('syslog is not supported on this system')
-endif
-
-# Miscellaneous Linux-only features
-get_option('mpath') \
- .require(targetos == 'linux', error_message: 'Multipath is supported only on Linux')
-
-multiprocess_allowed = get_option('multiprocess') \
- .require(targetos == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
- .allowed()
-
-vfio_user_server_allowed = get_option('vfio_user_server') \
- .require(targetos == 'linux', error_message: 'vfio-user server is supported only on Linux') \
- .allowed()
-
-have_tpm = get_option('tpm') \
- .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
- .allowed()
-
-# vhost
-have_vhost_user = get_option('vhost_user') \
- .disable_auto_if(targetos != 'linux') \
- .require(targetos != 'windows',
- error_message: 'vhost-user is not available on Windows').allowed()
-have_vhost_vdpa = get_option('vhost_vdpa') \
- .require(targetos == 'linux',
- error_message: 'vhost-vdpa is only available on Linux').allowed()
-have_vhost_kernel = get_option('vhost_kernel') \
- .require(targetos == 'linux',
- error_message: 'vhost-kernel is only available on Linux').allowed()
-have_vhost_user_crypto = get_option('vhost_crypto') \
- .require(have_vhost_user,
- error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
-
-have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
-
-have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
-have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
-have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
-have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
+#####################################
+# Host-specific libraries and flags #
+#####################################
-# Target-specific libraries and flags
libm = cc.find_library('m', required: false)
threads = dependency('threads')
util = cc.find_library('util', required: false)
@@ -596,13 +648,11 @@ version_res = []
coref = []
iokit = []
emulator_link_args = []
-nvmm =not_found
-hvf = not_found
midl = not_found
widl = not_found
pathcch = not_found
host_dsosuf = '.so'
-if targetos == 'windows'
+if host_os == 'windows'
midl = find_program('midl', required: false)
widl = find_program('widl', required: false)
pathcch = cc.find_library('pathcch')
@@ -614,31 +664,34 @@ if targetos == 'windows'
depend_files: files('pc-bios/qemu-nsis.ico'),
include_directories: include_directories('.'))
host_dsosuf = '.dll'
-elif targetos == 'darwin'
+elif host_os == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
host_dsosuf = '.dylib'
-elif targetos == 'sunos'
+elif host_os == 'sunos'
socket = [cc.find_library('socket'),
cc.find_library('nsl'),
cc.find_library('resolv')]
-elif targetos == 'haiku'
+elif host_os == 'haiku'
socket = [cc.find_library('posix_error_mapper'),
cc.find_library('network'),
cc.find_library('bsd')]
-elif targetos == 'openbsd'
+elif host_os == 'openbsd'
if get_option('tcg').allowed() and target_dirs.length() > 0
# Disable OpenBSD W^X if available
emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
endif
endif
-# Target-specific configuration of accelerators
+###############################################
+# Host-specific configuration of accelerators #
+###############################################
+
accelerators = []
-if get_option('kvm').allowed() and targetos == 'linux'
+if get_option('kvm').allowed() and host_os == 'linux'
accelerators += 'CONFIG_KVM'
endif
-if get_option('whpx').allowed() and targetos == 'windows'
+if get_option('whpx').allowed() and host_os == 'windows'
if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
error('WHPX requires 64-bit host')
elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \
@@ -646,6 +699,8 @@ if get_option('whpx').allowed() and targetos == 'windows'
accelerators += 'CONFIG_WHPX'
endif
endif
+
+hvf = not_found
if get_option('hvf').allowed()
hvf = dependency('appleframeworks', modules: 'Hypervisor',
required: get_option('hvf'))
@@ -653,7 +708,9 @@ if get_option('hvf').allowed()
accelerators += 'CONFIG_HVF'
endif
endif
-if targetos == 'netbsd'
+
+nvmm = not_found
+if host_os == 'netbsd'
nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
accelerators += 'CONFIG_NVMM'
@@ -700,6 +757,85 @@ if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
error('WHPX not available on this platform')
endif
+xen = not_found
+if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
+ xencontrol = dependency('xencontrol', required: false,
+ method: 'pkg-config')
+ if xencontrol.found()
+ xen_pc = declare_dependency(version: xencontrol.version(),
+ dependencies: [
+ xencontrol,
+ # disabler: true makes xen_pc.found() return false if any is not found
+ dependency('xenstore', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xenforeignmemory', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xengnttab', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xenevtchn', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xendevicemodel', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ # optional, no "disabler: true"
+ dependency('xentoolcore', required: false,
+ method: 'pkg-config')])
+ if xen_pc.found()
+ xen = xen_pc
+ endif
+ endif
+ if not xen.found()
+ xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
+ xen_libs = {
+ '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
+ '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
+ '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ }
+ xen_deps = {}
+ foreach ver: xen_tests
+ # cache the various library tests to avoid polluting the logs
+ xen_test_deps = []
+ foreach l: xen_libs[ver]
+ if l not in xen_deps
+ xen_deps += { l: cc.find_library(l, required: false) }
+ endif
+ xen_test_deps += xen_deps[l]
+ endforeach
+
+ # Use -D to pick just one of the test programs in scripts/xen-detect.c
+ xen_version = ver.split('.')
+ xen_ctrl_version = xen_version[0] + \
+ ('0' + xen_version[1]).substring(-2) + \
+ ('0' + xen_version[2]).substring(-2)
+ if cc.links(files('scripts/xen-detect.c'),
+ args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
+ dependencies: xen_test_deps)
+ xen = declare_dependency(version: ver, dependencies: xen_test_deps)
+ break
+ endif
+ endforeach
+ endif
+ if xen.found()
+ accelerators += 'CONFIG_XEN'
+ elif get_option('xen').enabled()
+ error('could not compile and link Xen test program')
+ endif
+endif
+have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
+ .require(xen.found(),
+ error_message: 'Xen PCI passthrough requested but Xen not enabled') \
+ .require(host_os == 'linux',
+ error_message: 'Xen PCI passthrough not available on this platform') \
+ .require(cpu == 'x86' or cpu == 'x86_64',
+ error_message: 'Xen PCI passthrough not available on this platform') \
+ .allowed()
+
################
# Dependencies #
################
@@ -722,7 +858,7 @@ endif
# This workaround is required due to a bug in pkg-config file for glib as it
# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
-if targetos == 'windows' and get_option('prefer_static')
+if host_os == 'windows' and get_option('prefer_static')
glib_cflags += ['-DGLIB_STATIC_COMPILATION']
endif
@@ -983,12 +1119,12 @@ if vde.found() and not cc.links('''
endif
pulse = not_found
-if not get_option('pa').auto() or (targetos == 'linux' and have_system)
+if not get_option('pa').auto() or (host_os == 'linux' and have_system)
pulse = dependency('libpulse', required: get_option('pa'),
method: 'pkg-config')
endif
alsa = not_found
-if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
+if not get_option('alsa').auto() or (host_os == 'linux' and have_system)
alsa = dependency('alsa', required: get_option('alsa'),
method: 'pkg-config')
endif
@@ -998,7 +1134,7 @@ if not get_option('jack').auto() or have_system
method: 'pkg-config')
endif
pipewire = not_found
-if not get_option('pipewire').auto() or (targetos == 'linux' and have_system)
+if not get_option('pipewire').auto() or (host_os == 'linux' and have_system)
pipewire = dependency('libpipewire-0.3', version: '>=0.3.60',
required: get_option('pipewire'),
method: 'pkg-config')
@@ -1043,17 +1179,11 @@ if not get_option('zstd').auto() or have_block
endif
virgl = not_found
-have_vhost_user_gpu = have_tools and targetos == 'linux' and pixman.found()
+have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found()
if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
virgl = dependency('virglrenderer',
method: 'pkg-config',
required: get_option('virglrenderer'))
- if virgl.found()
- config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
- cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
- prefix: '#include <virglrenderer.h>',
- dependencies: virgl))
- endif
endif
rutabaga = not_found
if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
@@ -1074,7 +1204,7 @@ if not get_option('curl').auto() or have_block
required: get_option('curl'))
endif
libudev = not_found
-if targetos == 'linux' and (have_system or have_tools)
+if host_os == 'linux' and (have_system or have_tools)
libudev = dependency('libudev',
method: 'pkg-config',
required: get_option('libudev'))
@@ -1082,7 +1212,7 @@ endif
mpathlibs = [libudev]
mpathpersist = not_found
-if targetos == 'linux' and have_tools and get_option('mpath').allowed()
+if host_os == 'linux' and have_tools and get_option('mpath').allowed()
mpath_test_source = '''
#include <libudev.h>
#include <mpath_persist.h>
@@ -1153,7 +1283,7 @@ if have_system and get_option('curses').allowed()
return 0;
}'''
- curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
+ curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
curses = dependency(curses_dep_list,
required: false,
method: 'pkg-config')
@@ -1170,13 +1300,13 @@ if have_system and get_option('curses').allowed()
endif
if not curses.found()
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
- if targetos != 'windows' and not has_curses_h
+ if host_os != 'windows' and not has_curses_h
message('Trying with /usr/include/ncursesw')
curses_compile_args += ['-I/usr/include/ncursesw']
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
endif
if has_curses_h
- curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
+ curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
foreach curses_libname : curses_libname_list
libcurses = cc.find_library(curses_libname,
required: false)
@@ -1399,7 +1529,7 @@ oss = not_found
if get_option('oss').allowed() and have_system
if not cc.has_header('sys/soundcard.h')
# not found
- elif targetos == 'netbsd'
+ elif host_os == 'netbsd'
oss = cc.find_library('ossaudio', required: get_option('oss'))
else
oss = declare_dependency()
@@ -1412,7 +1542,7 @@ if get_option('oss').allowed() and have_system
endif
endif
dsound = not_found
-if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
+if not get_option('dsound').auto() or (host_os == 'windows' and have_system)
if cc.has_header('dsound.h')
dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
endif
@@ -1425,7 +1555,7 @@ if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
endif
coreaudio = not_found
-if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
+if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system)
coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
required: get_option('coreaudio'))
endif
@@ -1519,6 +1649,25 @@ if not gnutls_crypto.found()
endif
endif
+capstone = not_found
+if not get_option('capstone').auto() or have_system or have_user
+ capstone = dependency('capstone', version: '>=3.0.5',
+ method: 'pkg-config',
+ required: get_option('capstone'))
+
+ # Some versions of capstone have broken pkg-config file
+ # that reports a wrong -I path, causing the #include to
+ # fail later. If the system has such a broken version
+ # do not use it.
+ if capstone.found() and not cc.compiles('#include <capstone.h>',
+ dependencies: [capstone])
+ capstone = not_found
+ if get_option('capstone').enabled()
+ error('capstone requested, but it does not appear to work')
+ endif
+ endif
+endif
+
gmp = dependency('gmp', required: false, method: 'pkg-config')
if nettle.found() and gmp.found()
hogweed = dependency('hogweed', version: '>=3.4',
@@ -1673,98 +1822,18 @@ if not get_option('rdma').auto() or have_system
endforeach
endif
-xen = not_found
-if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
- xencontrol = dependency('xencontrol', required: false,
- method: 'pkg-config')
- if xencontrol.found()
- xen_pc = declare_dependency(version: xencontrol.version(),
- dependencies: [
- xencontrol,
- # disabler: true makes xen_pc.found() return false if any is not found
- dependency('xenstore', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xenforeignmemory', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xengnttab', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xenevtchn', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xendevicemodel', required: false,
- method: 'pkg-config',
- disabler: true),
- # optional, no "disabler: true"
- dependency('xentoolcore', required: false,
- method: 'pkg-config')])
- if xen_pc.found()
- xen = xen_pc
- endif
- endif
- if not xen.found()
- xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
- xen_libs = {
- '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
- '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
- '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- }
- xen_deps = {}
- foreach ver: xen_tests
- # cache the various library tests to avoid polluting the logs
- xen_test_deps = []
- foreach l: xen_libs[ver]
- if l not in xen_deps
- xen_deps += { l: cc.find_library(l, required: false) }
- endif
- xen_test_deps += xen_deps[l]
- endforeach
-
- # Use -D to pick just one of the test programs in scripts/xen-detect.c
- xen_version = ver.split('.')
- xen_ctrl_version = xen_version[0] + \
- ('0' + xen_version[1]).substring(-2) + \
- ('0' + xen_version[2]).substring(-2)
- if cc.links(files('scripts/xen-detect.c'),
- args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
- dependencies: xen_test_deps)
- xen = declare_dependency(version: ver, dependencies: xen_test_deps)
- break
- endif
- endforeach
- endif
- if xen.found()
- accelerators += 'CONFIG_XEN'
- elif get_option('xen').enabled()
- error('could not compile and link Xen test program')
- endif
-endif
-have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
- .require(xen.found(),
- error_message: 'Xen PCI passthrough requested but Xen not enabled') \
- .require(targetos == 'linux',
- error_message: 'Xen PCI passthrough not available on this platform') \
- .require(cpu == 'x86' or cpu == 'x86_64',
- error_message: 'Xen PCI passthrough not available on this platform') \
- .allowed()
-
-
cacard = not_found
if not get_option('smartcard').auto() or have_system
cacard = dependency('libcacard', required: get_option('smartcard'),
version: '>=2.5.1', method: 'pkg-config')
endif
u2f = not_found
-if have_system
+if not get_option('u2f').auto() or have_system
u2f = dependency('u2f-emu', required: get_option('u2f'),
method: 'pkg-config')
endif
canokey = not_found
-if have_system
+if not get_option('canokey').auto() or have_system
canokey = dependency('canokey-qemu', required: get_option('canokey'),
method: 'pkg-config')
endif
@@ -1841,7 +1910,7 @@ has_statx = cc.has_header_symbol('sys/stat.h', 'STATX_BASIC_STATS', prefix: gnu_
has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix)
have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
- .require(targetos == 'linux',
+ .require(host_os == 'linux',
error_message: 'vhost_user_blk_server requires linux') \
.require(have_vhost_user,
error_message: 'vhost_user_blk_server requires vhost-user support') \
@@ -1869,18 +1938,18 @@ if get_option('fuse_lseek').allowed()
endif
endif
-have_libvduse = (targetos == 'linux')
+have_libvduse = (host_os == 'linux')
if get_option('libvduse').enabled()
- if targetos != 'linux'
+ if host_os != 'linux'
error('libvduse requires linux')
endif
elif get_option('libvduse').disabled()
have_libvduse = false
endif
-have_vduse_blk_export = (have_libvduse and targetos == 'linux')
+have_vduse_blk_export = (have_libvduse and host_os == 'linux')
if get_option('vduse_blk_export').enabled()
- if targetos != 'linux'
+ if host_os != 'linux'
error('vduse_blk_export requires linux')
elif not have_libvduse
error('vduse_blk_export requires libvduse support')
@@ -1926,6 +1995,8 @@ endif
# config-host.h #
#################
+config_host_data = configuration_data()
+
audio_drivers_selected = []
if have_system
audio_drivers_available = {
@@ -1946,7 +2017,7 @@ if have_system
# Default to native drivers first, OSS second, SDL third
audio_drivers_priority = \
[ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
- (targetos == 'linux' ? [] : [ 'sdl' ])
+ (host_os == 'linux' ? [] : [ 'sdl' ])
audio_drivers_default = []
foreach k: audio_drivers_priority
if audio_drivers_available[k]
@@ -1967,47 +2038,7 @@ endif
config_host_data.set('CONFIG_AUDIO_DRIVERS',
'"' + '", "'.join(audio_drivers_selected) + '", ')
-if get_option('cfi')
- cfi_flags=[]
- # Check for dependency on LTO
- if not get_option('b_lto')
- error('Selected Control-Flow Integrity but LTO is disabled')
- endif
- if enable_modules
- error('Selected Control-Flow Integrity is not compatible with modules')
- endif
- # Check for cfi flags. CFI requires LTO so we can't use
- # get_supported_arguments, but need a more complex "compiles" which allows
- # custom arguments
- if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall'] )
- cfi_flags += '-fsanitize=cfi-icall'
- else
- error('-fsanitize=cfi-icall is not supported by the compiler')
- endif
- if cc.compiles('int main () { return 0; }',
- name: '-fsanitize-cfi-icall-generalize-pointers',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fsanitize-cfi-icall-generalize-pointers'] )
- cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
- else
- error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
- endif
- if get_option('cfi_debug')
- if cc.compiles('int main () { return 0; }',
- name: '-fno-sanitize-trap=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fno-sanitize-trap=cfi-icall'] )
- cfi_flags += '-fno-sanitize-trap=cfi-icall'
- else
- error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
- endif
- endif
- add_global_arguments(cfi_flags, native: false, language: all_languages)
- add_global_link_arguments(cfi_flags, native: false, language: all_languages)
-endif
-
-have_host_block_device = (targetos != 'darwin' or
+have_host_block_device = (host_os != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
dbus_display = get_option('dbus_display') \
@@ -2018,17 +2049,17 @@ dbus_display = get_option('dbus_display') \
.allowed()
have_virtfs = get_option('virtfs') \
- .require(targetos == 'linux' or targetos == 'darwin',
+ .require(host_os == 'linux' or host_os == 'darwin',
error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
- .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'),
+ .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'),
error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
- .require(targetos == 'darwin' or libattr.found(),
+ .require(host_os == 'darwin' or libattr.found(),
error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \
.disable_auto_if(not have_tools and not have_system) \
.allowed()
have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \
- .require(targetos != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
+ .require(host_os != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
.require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \
.disable_auto_if(not have_tools) \
.require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \
@@ -2083,18 +2114,24 @@ if enable_modules
endif
have_slirp_smbd = get_option('slirp_smbd') \
- .require(targetos != 'windows', error_message: 'Host smbd not supported on this platform.') \
+ .require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \
.allowed()
if have_slirp_smbd
smbd_path = get_option('smbd')
if smbd_path == ''
- smbd_path = (targetos == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
+ smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
endif
config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
endif
config_host_data.set('HOST_' + host_arch.to_upper(), 1)
+kvm_targets_c = '""'
+if get_option('kvm').allowed() and host_os == 'linux'
+ kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
+endif
+config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
+
if get_option('module_upgrades') and not enable_modules
error('Cannot enable module-upgrades as modules are not enabled')
endif
@@ -2103,15 +2140,16 @@ config_host_data.set('CONFIG_MODULE_UPGRADES', get_option('module_upgrades'))
config_host_data.set('CONFIG_ATTR', libattr.found())
config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
config_host_data.set('CONFIG_BRLAPI', brlapi.found())
-config_host_data.set('CONFIG_BSD', targetos in bsd_oses)
+config_host_data.set('CONFIG_BSD', host_os in bsd_oses)
+config_host_data.set('CONFIG_CAPSTONE', capstone.found())
config_host_data.set('CONFIG_COCOA', cocoa.found())
-config_host_data.set('CONFIG_DARWIN', targetos == 'darwin')
+config_host_data.set('CONFIG_DARWIN', host_os == 'darwin')
config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
config_host_data.set('CONFIG_LIBUDEV', libudev.found())
-config_host_data.set('CONFIG_LINUX', targetos == 'linux')
-config_host_data.set('CONFIG_POSIX', targetos != 'windows')
-config_host_data.set('CONFIG_WIN32', targetos == 'windows')
+config_host_data.set('CONFIG_LINUX', host_os == 'linux')
+config_host_data.set('CONFIG_POSIX', host_os != 'windows')
+config_host_data.set('CONFIG_WIN32', host_os == 'windows')
config_host_data.set('CONFIG_LZO', lzo.found())
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
config_host_data.set('CONFIG_BLKIO', blkio.found())
@@ -2167,8 +2205,9 @@ if seccomp.found()
config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc)
endif
config_host_data.set('CONFIG_PIXMAN', pixman.found())
+config_host_data.set('CONFIG_SLIRP', slirp.found())
config_host_data.set('CONFIG_SNAPPY', snappy.found())
-config_host_data.set('CONFIG_SOLARIS', targetos == 'sunos')
+config_host_data.set('CONFIG_SOLARIS', host_os == 'sunos')
if get_option('tcg').allowed()
config_host_data.set('CONFIG_TCG', 1)
config_host_data.set('CONFIG_TCG_INTERPRETER', tcg_arch == 'tci')
@@ -2192,6 +2231,12 @@ config_host_data.set('CONFIG_PNG', png.found())
config_host_data.set('CONFIG_VNC', vnc.found())
config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
config_host_data.set('CONFIG_VNC_SASL', sasl.found())
+if virgl.found()
+ config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
+ cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
+ prefix: '#include <virglrenderer.h>',
+ dependencies: virgl))
+endif
config_host_data.set('CONFIG_VIRTFS', have_virtfs)
config_host_data.set('CONFIG_VTE', vte.found())
config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
@@ -2263,7 +2308,7 @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
-if targetos == 'windows'
+if host_os == 'windows'
config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h'))
endif
@@ -2645,7 +2690,7 @@ config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles('''
int main(void) { return 0; }'''))
have_keyring = get_option('keyring') \
- .require(targetos == 'linux', error_message: 'keyring is only available on Linux') \
+ .require(host_os == 'linux', error_message: 'keyring is only available on Linux') \
.require(cc.compiles('''
#include <errno.h>
#include <asm/unistd.h>
@@ -2754,9 +2799,9 @@ endif
if get_option('membarrier').disabled()
have_membarrier = false
-elif targetos == 'windows'
+elif host_os == 'windows'
have_membarrier = true
-elif targetos == 'linux'
+elif host_os == 'linux'
have_membarrier = cc.compiles('''
#include <linux/membarrier.h>
#include <sys/syscall.h>
@@ -2793,7 +2838,7 @@ config_host_data.set('CONFIG_AF_VSOCK', cc.has_header_symbol(
have_vss = false
have_vss_sdk = false # old xp/2003 SDK
-if targetos == 'windows' and 'cpp' in all_languages
+if host_os == 'windows' and 'cpp' in all_languages
have_vss = cxx.compiles('''
#define __MIDL_user_allocate_free_DEFINED__
#include <vss.h>
@@ -2804,7 +2849,7 @@ config_host_data.set('HAVE_VSS_SDK', have_vss_sdk)
# Older versions of MinGW do not import _lock_file and _unlock_file properly.
# This was fixed for v6.0.0 with commit b48e3ac8969d.
-if targetos == 'windows'
+if host_os == 'windows'
config_host_data.set('HAVE__LOCK_FILE', cc.links('''
#include <stdio.h>
int main(void) {
@@ -2814,7 +2859,7 @@ if targetos == 'windows'
}''', name: '_lock_file and _unlock_file'))
endif
-if targetos == 'windows'
+if host_os == 'windows'
mingw_has_setjmp_longjmp = cc.links('''
#include <setjmp.h>
int main(void) {
@@ -2840,21 +2885,9 @@ endif
########################
minikconf = find_program('scripts/minikconf.py')
-config_targetos = {
- (targetos == 'windows' ? 'CONFIG_WIN32' : 'CONFIG_POSIX'): 'y'
-}
-if targetos == 'darwin'
- config_targetos += {'CONFIG_DARWIN': 'y'}
-elif targetos == 'linux'
- config_targetos += {'CONFIG_LINUX': 'y'}
-endif
-if targetos in bsd_oses
- config_targetos += {'CONFIG_BSD': 'y'}
-endif
-config_all = {}
+config_all_accel = {}
config_all_devices = {}
-config_all_disas = {}
config_devices_mak_list = []
config_devices_h = {}
config_target_h = {}
@@ -2896,7 +2929,7 @@ host_kconfig = \
(have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
(have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
(have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
- (targetos == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
+ (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
(have_pvrdma ? ['CONFIG_PVRDMA=y'] : []) + \
(multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \
(vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \
@@ -2910,7 +2943,7 @@ fdt_required = []
foreach target : target_dirs
config_target = { 'TARGET_NAME': target.split('-')[0] }
if target.endswith('linux-user')
- if targetos != 'linux'
+ if host_os != 'linux'
if default_targets
continue
endif
@@ -2918,7 +2951,7 @@ foreach target : target_dirs
endif
config_target += { 'CONFIG_LINUX_USER': 'y' }
elif target.endswith('bsd-user')
- if targetos not in bsd_oses
+ if host_os not in bsd_oses
if default_targets
continue
endif
@@ -2941,7 +2974,7 @@ foreach target : target_dirs
foreach sym: accelerators
if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
config_target += { sym: 'y' }
- config_all += { sym: 'y' }
+ config_all_accel += { sym: 'y' }
if target in modular_tcg
config_target += { 'CONFIG_TCG_MODULAR': 'y' }
else
@@ -2980,7 +3013,6 @@ foreach target : target_dirs
if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
foreach sym: v
config_target += { sym: 'y' }
- config_all_disas += { sym: 'y' }
endforeach
endif
endforeach
@@ -3039,25 +3071,6 @@ foreach target : target_dirs
endforeach
target_dirs = actual_target_dirs
-# This configuration is used to build files that are shared by
-# multiple binaries, and then extracted out of the "common"
-# static_library target.
-#
-# We do not use all_sources()/all_dependencies(), because it would
-# build literally all source files, including devices only used by
-# targets that are not built for this compilation. The CONFIG_ALL
-# pseudo symbol replaces it.
-
-config_all += config_all_devices
-config_all += config_targetos
-config_all += config_all_disas
-config_all += {
- 'CONFIG_XEN': xen.found(),
- 'CONFIG_SYSTEM_ONLY': have_system,
- 'CONFIG_USER_ONLY': have_user,
- 'CONFIG_ALL': true,
-}
-
target_configs_h = []
foreach target: target_dirs
target_configs_h += config_target_h[target]
@@ -3070,28 +3083,9 @@ genh += custom_target('config-poison.h',
command: [find_program('scripts/make-config-poison.sh'),
target_configs_h])
-##############
-# Submodules #
-##############
-
-capstone = not_found
-if not get_option('capstone').auto() or have_system or have_user
- capstone = dependency('capstone', version: '>=3.0.5',
- method: 'pkg-config',
- required: get_option('capstone'))
-
- # Some versions of capstone have broken pkg-config file
- # that reports a wrong -I path, causing the #include to
- # fail later. If the system has such a broken version
- # do not use it.
- if capstone.found() and not cc.compiles('#include <capstone.h>',
- dependencies: [capstone])
- capstone = not_found
- if get_option('capstone').enabled()
- error('capstone requested, but it does not appear to work')
- endif
- endif
-endif
+###############
+# Subprojects #
+###############
libvfio_user_dep = not_found
if have_system and vfio_user_server_allowed
@@ -3135,9 +3129,19 @@ else
fdt_opt = 'disabled'
endif
-config_host_data.set('CONFIG_CAPSTONE', capstone.found())
config_host_data.set('CONFIG_FDT', fdt.found())
-config_host_data.set('CONFIG_SLIRP', slirp.found())
+
+vhost_user = not_found
+if host_os == 'linux' and have_vhost_user
+ libvhost_user = subproject('libvhost-user')
+ vhost_user = libvhost_user.get_variable('vhost_user_dep')
+endif
+
+libvduse = not_found
+if have_libvduse
+ libvduse_proj = subproject('libvduse')
+ libvduse = libvduse_proj.get_variable('libvduse_dep')
+endif
#####################
# Generated sources #
@@ -3221,39 +3225,6 @@ foreach d : hx_headers
endforeach
genh += hxdep
-###################
-# Collect sources #
-###################
-
-authz_ss = ss.source_set()
-blockdev_ss = ss.source_set()
-block_ss = ss.source_set()
-chardev_ss = ss.source_set()
-common_ss = ss.source_set()
-crypto_ss = ss.source_set()
-hwcore_ss = ss.source_set()
-io_ss = ss.source_set()
-qmp_ss = ss.source_set()
-qom_ss = ss.source_set()
-system_ss = ss.source_set()
-specific_fuzz_ss = ss.source_set()
-specific_ss = ss.source_set()
-stub_ss = ss.source_set()
-trace_ss = ss.source_set()
-user_ss = ss.source_set()
-util_ss = ss.source_set()
-
-# accel modules
-qtest_module_ss = ss.source_set()
-tcg_module_ss = ss.source_set()
-
-modules = {}
-target_modules = {}
-hw_arch = {}
-target_arch = {}
-target_system_arch = {}
-target_user_arch = {}
-
###############
# Trace files #
###############
@@ -3368,17 +3339,38 @@ if have_system or have_user
]
endif
-vhost_user = not_found
-if targetos == 'linux' and have_vhost_user
- libvhost_user = subproject('libvhost-user')
- vhost_user = libvhost_user.get_variable('vhost_user_dep')
-endif
+###################
+# Collect sources #
+###################
-libvduse = not_found
-if have_libvduse
- libvduse_proj = subproject('libvduse')
- libvduse = libvduse_proj.get_variable('libvduse_dep')
-endif
+authz_ss = ss.source_set()
+blockdev_ss = ss.source_set()
+block_ss = ss.source_set()
+chardev_ss = ss.source_set()
+common_ss = ss.source_set()
+crypto_ss = ss.source_set()
+hwcore_ss = ss.source_set()
+io_ss = ss.source_set()
+qmp_ss = ss.source_set()
+qom_ss = ss.source_set()
+system_ss = ss.source_set()
+specific_fuzz_ss = ss.source_set()
+specific_ss = ss.source_set()
+stub_ss = ss.source_set()
+trace_ss = ss.source_set()
+user_ss = ss.source_set()
+util_ss = ss.source_set()
+
+# accel modules
+qtest_module_ss = ss.source_set()
+tcg_module_ss = ss.source_set()
+
+modules = {}
+target_modules = {}
+hw_arch = {}
+target_arch = {}
+target_system_arch = {}
+target_user_arch = {}
# NOTE: the trace/ subdirectory needs the qapi_trace_events variable
# that is filled in by qapi/.
@@ -3399,7 +3391,7 @@ if enable_modules
modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
endif
-qom_ss = qom_ss.apply(config_targetos, strict: false)
+qom_ss = qom_ss.apply({})
libqom = static_library('qom', qom_ss.sources() + genh,
dependencies: [qom_ss.dependencies()],
name_suffix: 'fa',
@@ -3414,10 +3406,10 @@ event_loop_base = static_library('event-loop-base',
event_loop_base = declare_dependency(link_whole: event_loop_base,
dependencies: [qom])
-stub_ss = stub_ss.apply(config_all, strict: false)
+stub_ss = stub_ss.apply({})
util_ss.add_all(trace_ss)
-util_ss = util_ss.apply(config_all, strict: false)
+util_ss = util_ss.apply({})
libqemuutil = static_library('qemuutil',
build_by_default: false,
sources: util_ss.sources() + stub_ss.sources() + genh,
@@ -3464,8 +3456,11 @@ if have_block
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
# os-win32.c does not
- blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
- system_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
+ if host_os == 'windows'
+ system_ss.add(files('os-win32.c'))
+ else
+ blockdev_ss.add(files('os-posix.c'))
+ endif
endif
common_ss.add(files('cpu-common.c'))
@@ -3524,9 +3519,9 @@ specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
target_modules += { 'accel' : { 'qtest': qtest_module_ss,
'tcg': tcg_real_module_ss }}
-########################
-# Library dependencies #
-########################
+##############################################
+# Internal static_libraries and dependencies #
+##############################################
modinfo_collect = find_program('scripts/modinfo-collect.py')
modinfo_generate = find_program('scripts/modinfo-generate.py')
@@ -3541,7 +3536,7 @@ foreach d, list : modules
foreach m, module_ss : list
if enable_modules
- module_ss = module_ss.apply(config_all, strict: false)
+ module_ss = module_ss.apply(config_all_devices, strict: false)
sl = static_library(d + '-' + m, [genh, module_ss.sources()],
dependencies: [modulecommon, module_ss.dependencies()], pic: true)
if d == 'block'
@@ -3577,7 +3572,6 @@ foreach d, list : target_modules
foreach target : target_dirs
if target.endswith('-softmmu')
config_target = config_target_mak[target]
- config_target += config_targetos
target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
c_args = ['-DNEED_CPU_H',
'-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
@@ -3638,7 +3632,7 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
capture: true,
command: [undefsym, nm, '@INPUT@'])
-authz_ss = authz_ss.apply(config_targetos, strict: false)
+authz_ss = authz_ss.apply({})
libauthz = static_library('authz', authz_ss.sources() + genh,
dependencies: [authz_ss.dependencies()],
name_suffix: 'fa',
@@ -3647,7 +3641,7 @@ libauthz = static_library('authz', authz_ss.sources() + genh,
authz = declare_dependency(link_whole: libauthz,
dependencies: qom)
-crypto_ss = crypto_ss.apply(config_targetos, strict: false)
+crypto_ss = crypto_ss.apply({})
libcrypto = static_library('crypto', crypto_ss.sources() + genh,
dependencies: [crypto_ss.dependencies()],
name_suffix: 'fa',
@@ -3656,7 +3650,7 @@ libcrypto = static_library('crypto', crypto_ss.sources() + genh,
crypto = declare_dependency(link_whole: libcrypto,
dependencies: [authz, qom])
-io_ss = io_ss.apply(config_targetos, strict: false)
+io_ss = io_ss.apply({})
libio = static_library('io', io_ss.sources() + genh,
dependencies: [io_ss.dependencies()],
link_with: libqemuutil,
@@ -3672,7 +3666,7 @@ migration = declare_dependency(link_with: libmigration,
dependencies: [zlib, qom, io])
system_ss.add(migration)
-block_ss = block_ss.apply(config_targetos, strict: false)
+block_ss = block_ss.apply({})
libblock = static_library('block', block_ss.sources() + genh,
dependencies: block_ss.dependencies(),
link_depends: block_syms,
@@ -3683,7 +3677,7 @@ block = declare_dependency(link_whole: [libblock],
link_args: '@block.syms',
dependencies: [crypto, io])
-blockdev_ss = blockdev_ss.apply(config_targetos, strict: false)
+blockdev_ss = blockdev_ss.apply({})
libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
dependencies: blockdev_ss.dependencies(),
name_suffix: 'fa',
@@ -3692,7 +3686,7 @@ libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
blockdev = declare_dependency(link_whole: [libblockdev],
dependencies: [block, event_loop_base])
-qmp_ss = qmp_ss.apply(config_targetos, strict: false)
+qmp_ss = qmp_ss.apply({})
libqmp = static_library('qmp', qmp_ss.sources() + genh,
dependencies: qmp_ss.dependencies(),
name_suffix: 'fa',
@@ -3707,7 +3701,7 @@ libchardev = static_library('chardev', chardev_ss.sources() + genh,
chardev = declare_dependency(link_whole: libchardev)
-hwcore_ss = hwcore_ss.apply(config_targetos, strict: false)
+hwcore_ss = hwcore_ss.apply({})
libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
name_suffix: 'fa',
build_by_default: false)
@@ -3737,18 +3731,20 @@ common_ss.add(qom, qemuutil)
common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss])
common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
-common_all = common_ss.apply(config_all, strict: false)
+# Note that this library is never used directly (only through extract_objects)
+# and is not built by default; therefore, source files not used by the build
+# configuration will be in build.ninja, but are never built by default.
common_all = static_library('common',
build_by_default: false,
- sources: common_all.sources() + genh,
+ sources: common_ss.all_sources() + genh,
include_directories: common_user_inc,
implicit_include_directories: false,
- dependencies: common_all.dependencies(),
+ dependencies: common_ss.all_dependencies(),
name_suffix: 'fa')
feature_to_c = find_program('scripts/feature_to_c.py')
-if targetos == 'darwin'
+if host_os == 'darwin'
entitlement = find_program('scripts/entitlement.sh')
endif
@@ -3764,9 +3760,8 @@ foreach target : target_dirs
'-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
link_args = emulator_link_args
- config_target += config_targetos
target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
- if targetos == 'linux'
+ if host_os == 'linux'
target_inc += include_directories('linux-headers', is_system: true)
endif
if target.endswith('-softmmu')
@@ -3796,7 +3791,7 @@ foreach target : target_dirs
endif
if 'CONFIG_BSD_USER' in config_target
base_dir = 'bsd-user'
- target_inc += include_directories('bsd-user/' / targetos)
+ target_inc += include_directories('bsd-user/' / host_os)
target_inc += include_directories('bsd-user/host/' / host_arch)
dir = base_dir / abi
arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
@@ -3853,7 +3848,7 @@ foreach target : target_dirs
'sources': files('system/main.c'),
'dependencies': []
}]
- if targetos == 'windows' and (sdl.found() or gtk.found())
+ if host_os == 'windows' and (sdl.found() or gtk.found())
execs += [{
'name': 'qemu-system-' + target_name + 'w',
'win_subsystem': 'windows',
@@ -3880,7 +3875,7 @@ foreach target : target_dirs
endif
foreach exe: execs
exe_name = exe['name']
- if targetos == 'darwin'
+ if host_os == 'darwin'
exe_name += '-unsigned'
endif
@@ -3893,7 +3888,7 @@ foreach target : target_dirs
link_args: link_args,
win_subsystem: exe['win_subsystem'])
- if targetos == 'darwin'
+ if host_os == 'darwin'
icon = 'pc-bios/qemu.rsrc'
build_input = [emulator, files(icon)]
install_input = [
@@ -3949,7 +3944,7 @@ endforeach
if get_option('plugins')
install_headers('include/qemu/qemu-plugin.h')
- if targetos == 'windows'
+ if host_os == 'windows'
# On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer,
# so that plugin authors can compile against it.
install_data(win32_qemu_plugin_api_lib, install_dir: 'lib')
@@ -3990,7 +3985,7 @@ if have_tools
subdir('contrib/vhost-user-scsi')
endif
- if targetos == 'linux'
+ if host_os == 'linux'
executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
dependencies: [qemuutil, libcap_ng],
install: true,
@@ -4057,7 +4052,7 @@ summary(summary_info, bool_yn: true, section: 'Build environment')
# Directories
summary_info += {'Install prefix': get_option('prefix')}
summary_info += {'BIOS directory': qemu_datadir}
-pathsep = targetos == 'windows' ? ';' : ':'
+pathsep = host_os == 'windows' ? ';' : ':'
summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))}
summary_info += {'binary directory': get_option('prefix') / get_option('bindir')}
summary_info += {'library directory': get_option('prefix') / get_option('libdir')}
@@ -4065,7 +4060,7 @@ summary_info += {'module directory': qemu_moddir}
summary_info += {'libexec directory': get_option('prefix') / get_option('libexecdir')}
summary_info += {'include directory': get_option('prefix') / get_option('includedir')}
summary_info += {'config directory': get_option('prefix') / get_option('sysconfdir')}
-if targetos != 'windows'
+if host_os != 'windows'
summary_info += {'local state directory': get_option('prefix') / get_option('localstatedir')}
summary_info += {'Manual directory': get_option('prefix') / get_option('mandir')}
else
@@ -4088,7 +4083,7 @@ if config_host.has_key('GDB')
endif
summary_info += {'iasl': iasl}
summary_info += {'genisoimage': config_host['GENISOIMAGE']}
-if targetos == 'windows' and have_ga
+if host_os == 'windows' and have_ga
summary_info += {'wixl': wixl}
endif
if slirp.found() and have_system
@@ -4186,7 +4181,7 @@ if get_option('cfi')
endif
summary_info += {'strip binaries': get_option('strip')}
summary_info += {'sparse': sparse}
-summary_info += {'mingw32 support': targetos == 'windows'}
+summary_info += {'mingw32 support': host_os == 'windows'}
summary(summary_info, bool_yn: true, section: 'Compilation')
# snarf the cross-compilation information for tests
@@ -4209,18 +4204,18 @@ endif
# Targets and accelerators
summary_info = {}
if have_system
- summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
- summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
- summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
- summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
+ summary_info += {'KVM support': config_all_accel.has_key('CONFIG_KVM')}
+ summary_info += {'HVF support': config_all_accel.has_key('CONFIG_HVF')}
+ summary_info += {'WHPX support': config_all_accel.has_key('CONFIG_WHPX')}
+ summary_info += {'NVMM support': config_all_accel.has_key('CONFIG_NVMM')}
summary_info += {'Xen support': xen.found()}
if xen.found()
summary_info += {'xen ctrl version': xen.version()}
endif
- summary_info += {'Xen emulation': config_all.has_key('CONFIG_XEN_EMU')}
+ summary_info += {'Xen emulation': config_all_devices.has_key('CONFIG_XEN_EMU')}
endif
-summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
-if config_all.has_key('CONFIG_TCG')
+summary_info += {'TCG support': config_all_accel.has_key('CONFIG_TCG')}
+if config_all_accel.has_key('CONFIG_TCG')
if get_option('tcg_interpreter')
summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
else
@@ -4285,7 +4280,7 @@ summary(summary_info, bool_yn: true, section: 'Crypto')
# UI
summary_info = {}
-if targetos == 'darwin'
+if host_os == 'darwin'
summary_info += {'Cocoa support': cocoa}
endif
summary_info += {'SDL support': sdl}
@@ -4307,17 +4302,23 @@ summary_info += {'curses support': curses}
summary_info += {'brlapi support': brlapi}
summary(summary_info, bool_yn: true, section: 'User interface')
+# Graphics backends
+summary_info = {}
+summary_info += {'VirGL support': virgl}
+summary_info += {'Rutabaga support': rutabaga}
+summary(summary_info, bool_yn: true, section: 'Graphics backends')
+
# Audio backends
summary_info = {}
-if targetos not in ['darwin', 'haiku', 'windows']
+if host_os not in ['darwin', 'haiku', 'windows']
summary_info += {'OSS support': oss}
summary_info += {'sndio support': sndio}
-elif targetos == 'darwin'
+elif host_os == 'darwin'
summary_info += {'CoreAudio support': coreaudio}
-elif targetos == 'windows'
+elif host_os == 'windows'
summary_info += {'DirectSound support': dsound}
endif
-if targetos == 'linux'
+if host_os == 'linux'
summary_info += {'ALSA support': alsa}
summary_info += {'PulseAudio support': pulse}
endif
@@ -4327,7 +4328,7 @@ summary(summary_info, bool_yn: true, section: 'Audio backends')
# Network backends
summary_info = {}
-if targetos == 'darwin'
+if host_os == 'darwin'
summary_info += {'vmnet.framework support': vmnet}
endif
summary_info += {'AF_XDP support': libxdp}
@@ -4342,8 +4343,6 @@ summary_info = {}
summary_info += {'libtasn1': tasn1}
summary_info += {'PAM': pam}
summary_info += {'iconv support': iconv}
-summary_info += {'virgl support': virgl}
-summary_info += {'rutabaga support': rutabaga}
summary_info += {'blkio support': blkio}
summary_info += {'curl support': curl}
summary_info += {'Multipath support': mpathpersist}
@@ -4364,7 +4363,7 @@ summary_info += {'OpenGL support (epoxy)': opengl}
summary_info += {'GBM': gbm}
summary_info += {'libiscsi support': libiscsi}
summary_info += {'libnfs support': libnfs}
-if targetos == 'windows'
+if host_os == 'windows'
if have_ga
summary_info += {'QGA VSS support': have_qga_vss}
endif
@@ -4406,20 +4405,20 @@ if host_arch == 'unknown'
endif
endif
-if not supported_oses.contains(targetos)
+if not supported_oses.contains(host_os)
message()
warning('UNSUPPORTED HOST OS')
message()
- message('Support for host OS ' + targetos + 'is not currently maintained.')
+ message('Support for host OS ' + host_os + 'is not currently maintained.')
message('configure has succeeded and you can continue to build, but')
message('the QEMU project does not guarantee that QEMU will compile or')
message('work on this operating system. You can help by volunteering')
message('to maintain it and providing a build host for our continuous')
message('integration setup. This will ensure that future versions of QEMU')
- message('will keep working on ' + targetos + '.')
+ message('will keep working on ' + host_os + '.')
endif
-if host_arch == 'unknown' or not supported_oses.contains(targetos)
+if host_arch == 'unknown' or not supported_oses.contains(host_os)
message()
message('If you want to help supporting QEMU on this platform, please')
message('contact the developers at qemu-devel@nongnu.org.')
@@ -4433,8 +4432,8 @@ if get_option('relocatable') and \
warning('bindir not included within prefix, the installation will not be relocatable.')
actually_reloc = false
endif
-if not actually_reloc and (targetos == 'windows' or get_option('relocatable'))
- if targetos == 'windows'
+if not actually_reloc and (host_os == 'windows' or get_option('relocatable'))
+ if host_os == 'windows'
message()
warning('Windows installs should usually be relocatable.')
endif
diff --git a/meson_options.txt b/meson_options.txt
index c9baeda..0a99a05 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -101,7 +101,7 @@ option('cfi_debug', type: 'boolean', value: false,
description: 'Verbose errors in case of CFI violation')
option('multiprocess', type: 'feature', value: 'auto',
description: 'Out of process device emulation support')
-option('relocatable', type : 'boolean', value : 'true',
+option('relocatable', type : 'boolean', value : true,
description: 'toggle relocatable install')
option('vfio_user_server', type: 'feature', value: 'disabled',
description: 'vfio-user server support')
diff --git a/net/can/meson.build b/net/can/meson.build
index 45693c8..af3b279 100644
--- a/net/can/meson.build
+++ b/net/can/meson.build
@@ -1,5 +1,7 @@
can_ss = ss.source_set()
can_ss.add(files('can_core.c', 'can_host.c'))
-can_ss.add(when: 'CONFIG_LINUX', if_true: files('can_socketcan.c'))
+if host_os == 'linux'
+ can_ss.add(files('can_socketcan.c'))
+endif
system_ss.add_all(when: 'CONFIG_CAN_BUS', if_true: can_ss)
diff --git a/net/meson.build b/net/meson.build
index ce99bd4..9432a58 100644
--- a/net/meson.build
+++ b/net/meson.build
@@ -41,23 +41,21 @@ system_ss.add(when: libxdp, if_true: files('af-xdp.c'))
if have_vhost_net_user
system_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-user.c'), if_false: files('vhost-user-stub.c'))
- system_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-user-stub.c'))
endif
-if targetos == 'windows'
+if host_os == 'windows'
system_ss.add(files('tap-win32.c'))
-elif targetos == 'linux'
+elif host_os == 'linux'
system_ss.add(files('tap.c', 'tap-linux.c'))
-elif targetos in bsd_oses
+elif host_os in bsd_oses
system_ss.add(files('tap.c', 'tap-bsd.c'))
-elif targetos == 'sunos'
+elif host_os == 'sunos'
system_ss.add(files('tap.c', 'tap-solaris.c'))
else
system_ss.add(files('tap.c', 'tap-stub.c'))
endif
if have_vhost_net_vdpa
system_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('vhost-vdpa.c'), if_false: files('vhost-vdpa-stub.c'))
- system_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-vdpa-stub.c'))
endif
vmnet_files = files(
diff --git a/plugins/meson.build b/plugins/meson.build
index 6b2d7a9..51b4350 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,7 +1,7 @@
plugin_ldflags = []
# Modules need more symbols than just those in plugins/qemu-plugins.symbols
if not enable_modules
- if targetos == 'darwin'
+ if host_os == 'darwin'
configure_file(
input: files('qemu-plugins.symbols'),
output: 'qemu-plugins-ld64.symbols',
@@ -14,7 +14,7 @@ if not enable_modules
endif
if get_option('plugins')
- if targetos == 'windows'
+ if host_os == 'windows'
dlltool = find_program('dlltool', required: true)
# Generate a .lib file for plugins to link against.
diff --git a/qga/meson.build b/qga/meson.build
index ff7a849..1c3d2a3 100644
--- a/qga/meson.build
+++ b/qga/meson.build
@@ -7,7 +7,7 @@ if not have_ga
endif
have_qga_vss = get_option('qga_vss') \
- .require(targetos == 'windows',
+ .require(host_os == 'windows',
error_message: 'VSS support requires Windows') \
.require('cpp' in all_languages,
error_message: 'VSS support requires a C++ compiler') \
@@ -67,29 +67,31 @@ qga_ss.add(files(
'main.c',
'cutils.c',
))
-qga_ss.add(when: 'CONFIG_POSIX', if_true: files(
- 'channel-posix.c',
- 'commands-posix.c',
- 'commands-posix-ssh.c',
-))
-qga_ss.add(when: 'CONFIG_LINUX', if_true: files(
- 'commands-linux.c',
-))
-qga_ss.add(when: 'CONFIG_BSD', if_true: files(
- 'commands-bsd.c',
-))
-qga_ss.add(when: 'CONFIG_WIN32', if_true: files(
- 'channel-win32.c',
- 'commands-win32.c',
- 'service-win32.c',
- 'vss-win32.c'
-))
+if host_os == 'windows'
+ qga_ss.add(files(
+ 'channel-win32.c',
+ 'commands-win32.c',
+ 'service-win32.c',
+ 'vss-win32.c'
+ ))
+else
+ qga_ss.add(files(
+ 'channel-posix.c',
+ 'commands-posix.c',
+ 'commands-posix-ssh.c',
+ ))
+ if host_os == 'linux'
+ qga_ss.add(files('commands-linux.c'))
+ elif host_os in bsd_oses
+ qga_ss.add(files('commands-bsd.c'))
+ endif
+endif
-qga_ss = qga_ss.apply(config_targetos, strict: false)
+qga_ss = qga_ss.apply({})
gen_tlb = []
qga_libs = []
-if targetos == 'windows'
+if host_os == 'windows'
qga_libs += ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwininet', '-liphlpapi', '-lnetapi32',
'-lsetupapi', '-lcfgmgr32']
if have_qga_vss
@@ -99,7 +101,7 @@ if targetos == 'windows'
endif
qga_objs = []
-if targetos == 'windows'
+if host_os == 'windows'
windmc = find_program('windmc', required: true)
windres = find_program('windres', required: true)
@@ -121,7 +123,7 @@ qga = executable('qemu-ga', qga_ss.sources() + qga_objs,
install: true)
all_qga += qga
-if targetos == 'windows'
+if host_os == 'windows'
qemu_ga_msi_arch = {
'x86': ['-D', 'Arch=32'],
'x86_64': ['-a', 'x64', '-D', 'Arch=64']
@@ -140,7 +142,7 @@ if targetos == 'windows'
qemu_ga_msi_vss = ['-D', 'InstallVss']
deps += qga_vss
endif
- if glib.version() < '2.73.2'
+ if glib.version().version_compare('<2.73.2')
libpcre = 'libpcre1'
else
libpcre = 'libpcre2'
@@ -183,7 +185,7 @@ test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
# the leak detector in build-oss-fuzz Gitlab CI test. we should re-enable
# this when an alternative is implemented or when the underlying glib
# issue is identified/fix
-#if targetos != 'windows'
+#if host_os != 'windows'
if false
srcs = [files('commands-posix-ssh.c')]
i = 0
diff --git a/scsi/meson.build b/scsi/meson.build
index 53f3a1f..cdb91e1 100644
--- a/scsi/meson.build
+++ b/scsi/meson.build
@@ -1,4 +1,6 @@
block_ss.add(files('utils.c'))
-block_ss.add(when: 'CONFIG_LINUX',
- if_true: files('pr-manager.c', 'pr-manager-helper.c'),
- if_false: files('pr-manager-stub.c'))
+if host_os == 'linux'
+ block_ss.add(files('pr-manager.c', 'pr-manager-helper.c'))
+else
+ block_ss.add(files('pr-manager-stub.c'))
+endif
diff --git a/storage-daemon/meson.build b/storage-daemon/meson.build
index 5e90cd3..46267b6 100644
--- a/storage-daemon/meson.build
+++ b/storage-daemon/meson.build
@@ -5,7 +5,7 @@ qsd_ss.add(blockdev, chardev, qmp, qom, qemuutil, gnutls)
subdir('qapi')
if have_tools
- qsd_ss = qsd_ss.apply(config_targetos, strict: false)
+ qsd_ss = qsd_ss.apply({})
qsd = executable('qemu-storage-daemon',
qsd_ss.sources(),
dependencies: qsd_ss.dependencies(),
diff --git a/system/meson.build b/system/meson.build
index 3a64dd8..25e2117 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -33,4 +33,6 @@ endif
system_ss.add(when: seccomp, if_true: files('qemu-seccomp.c'))
system_ss.add(when: fdt, if_true: files('device_tree.c'))
-system_ss.add(when: 'CONFIG_LINUX', if_true: files('async-teardown.c'))
+if host_os == 'linux'
+ system_ss.add(files('async-teardown.c'))
+endif
diff --git a/target/arm/meson.build b/target/arm/meson.build
index d6c3902..46b5a21 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -28,7 +28,7 @@ arm_system_ss.add(files(
subdir('hvf')
-if 'CONFIG_TCG' in config_all
+if 'CONFIG_TCG' in config_all_accel
subdir('tcg')
else
arm_ss.add(files('tcg-stubs.c'))
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 95d5f16..fd47ee7 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -738,7 +738,7 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1,
#define TCG_7_0_EDX_FEATURES (CPUID_7_0_EDX_FSRM | CPUID_7_0_EDX_KERNEL_FEATURES)
#define TCG_7_1_EAX_FEATURES (CPUID_7_1_EAX_FZRM | CPUID_7_1_EAX_FSRS | \
- CPUID_7_1_EAX_FSRC)
+ CPUID_7_1_EAX_FSRC | CPUID_7_1_EAX_CMPCCXADD)
#define TCG_7_1_EDX_FEATURES 0
#define TCG_7_2_EDX_FEATURES 0
#define TCG_APM_FEATURES 0
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index ef987f3..7f0786e 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1285,6 +1285,7 @@ typedef enum {
CC_OP_NB,
} CCOp;
+QEMU_BUILD_BUG_ON(CC_OP_NB >= 128);
typedef struct SegmentCache {
uint32_t selector;
@@ -2344,13 +2345,13 @@ void cpu_x86_inject_mce(Monitor *mon, X86CPU *cpu, int bank,
uint64_t status, uint64_t mcg_status, uint64_t addr,
uint64_t misc, int flags);
-uint32_t cpu_cc_compute_all(CPUX86State *env1, int op);
+uint32_t cpu_cc_compute_all(CPUX86State *env1);
static inline uint32_t cpu_compute_eflags(CPUX86State *env)
{
uint32_t eflags = env->eflags;
if (tcg_enabled()) {
- eflags |= cpu_cc_compute_all(env, CC_OP) | (env->df & DF_MASK);
+ eflags |= cpu_cc_compute_all(env) | (env->df & DF_MASK);
}
return eflags;
}
diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c
index c310bd8..f76e9cb 100644
--- a/target/i386/tcg/cc_helper.c
+++ b/target/i386/tcg/cc_helper.c
@@ -220,9 +220,9 @@ target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,
}
}
-uint32_t cpu_cc_compute_all(CPUX86State *env, int op)
+uint32_t cpu_cc_compute_all(CPUX86State *env)
{
- return helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, op);
+ return helper_cc_compute_all(CC_DST, CC_SRC, CC_SRC2, CC_OP);
}
target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1,
@@ -335,7 +335,7 @@ target_ulong helper_read_eflags(CPUX86State *env)
{
uint32_t eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
eflags |= (env->df & DF_MASK);
eflags |= env->eflags & ~(VM_MASK | RF_MASK);
return eflags;
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index 2bdbb1b..426c459 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -26,6 +26,13 @@
* size (X86_SIZE_*) codes used in the manual. There are a few differences
* though.
*
+ * Operand sizes
+ * -------------
+ *
+ * The manual lists d64 ("cannot encode 32-bit size in 64-bit mode") and f64
+ * ("cannot encode 16-bit or 32-bit size in 64-bit mode") as modifiers of the
+ * "v" or "z" sizes. The decoder simply makes them separate operand sizes.
+ *
* Vector operands
* ---------------
*
@@ -44,6 +51,11 @@
* if the difference is expressed via prefixes. Individual instructions
* are separated by prefix in the generator functions.
*
+ * There is a custom size "xh" used to address half of a SSE/AVX operand.
+ * This points to a 64-bit operand for SSE operations, 128-bit operand
+ * for 256-bit AVX operands, etc. It is used for conversion operations
+ * such as VCVTPH2PS or VCVTSS2SD.
+ *
* There are a couple cases in which instructions (e.g. MOVD) write the
* whole XMM or MM register but are established incorrectly in the manual
* as "d" or "q". These have to be fixed for the decoder to work correctly.
@@ -139,10 +151,13 @@
#define cpuid(feat) .cpuid = X86_FEAT_##feat,
#define xchg .special = X86_SPECIAL_Locked,
+#define lock .special = X86_SPECIAL_HasLock,
#define mmx .special = X86_SPECIAL_MMX,
-#define zext0 .special = X86_SPECIAL_ZExtOp0,
-#define zext2 .special = X86_SPECIAL_ZExtOp2,
+#define op0_Rd .special = X86_SPECIAL_Op0_Rd,
+#define op2_Ry .special = X86_SPECIAL_Op2_Ry,
#define avx_movx .special = X86_SPECIAL_AVXExtMov,
+#define sextT0 .special = X86_SPECIAL_SExtT0,
+#define zextT0 .special = X86_SPECIAL_ZExtT0,
#define vex1 .vex_class = 1,
#define vex1_rep3 .vex_class = 1, .vex_special = X86_VEX_REPScalar,
@@ -523,6 +538,28 @@ static const X86OpEntry opcodes_0F38_00toEF[240] = {
[0xdd] = X86_OP_ENTRY3(VAESENCLAST, V,x, H,x, W,x, vex4 cpuid(AES) p_66),
[0xde] = X86_OP_ENTRY3(VAESDEC, V,x, H,x, W,x, vex4 cpuid(AES) p_66),
[0xdf] = X86_OP_ENTRY3(VAESDECLAST, V,x, H,x, W,x, vex4 cpuid(AES) p_66),
+
+ /*
+ * REG selects srcdest2 operand, VEX.vvvv selects src3. VEX class not found
+ * in manual, assumed to be 13 from the VEX.L0 constraint.
+ */
+ [0xe0] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe1] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe2] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe3] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe4] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe5] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe6] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe7] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+
+ [0xe8] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xe9] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xea] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xeb] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xec] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xed] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xee] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
+ [0xef] = X86_OP_ENTRY3(CMPccXADD, M,y, G,y, B,y, vex13 xchg chk(o64) cpuid(CMPCCXADD) p_66),
};
/* five rows for no prefix, 66, F3, F2, 66+F2 */
@@ -558,8 +595,8 @@ static const X86OpEntry opcodes_0F38_F0toFF[16][5] = {
[5] = {
X86_OP_ENTRY3(BZHI, G,y, E,y, B,y, vex13 cpuid(BMI1)),
{},
- X86_OP_ENTRY3(PEXT, G,y, B,y, E,y, vex13 cpuid(BMI2)),
- X86_OP_ENTRY3(PDEP, G,y, B,y, E,y, vex13 cpuid(BMI2)),
+ X86_OP_ENTRY3(PEXT, G,y, B,y, E,y, vex13 zextT0 cpuid(BMI2)),
+ X86_OP_ENTRY3(PDEP, G,y, B,y, E,y, vex13 zextT0 cpuid(BMI2)),
{},
},
[6] = {
@@ -570,10 +607,10 @@ static const X86OpEntry opcodes_0F38_F0toFF[16][5] = {
{},
},
[7] = {
- X86_OP_ENTRY3(BEXTR, G,y, E,y, B,y, vex13 cpuid(BMI1)),
+ X86_OP_ENTRY3(BEXTR, G,y, E,y, B,y, vex13 zextT0 cpuid(BMI1)),
X86_OP_ENTRY3(SHLX, G,y, E,y, B,y, vex13 cpuid(BMI1)),
- X86_OP_ENTRY3(SARX, G,y, E,y, B,y, vex13 cpuid(BMI1)),
- X86_OP_ENTRY3(SHRX, G,y, E,y, B,y, vex13 cpuid(BMI1)),
+ X86_OP_ENTRY3(SARX, G,y, E,y, B,y, vex13 sextT0 cpuid(BMI1)),
+ X86_OP_ENTRY3(SHRX, G,y, E,y, B,y, vex13 zextT0 cpuid(BMI1)),
{},
},
};
@@ -619,13 +656,13 @@ static const X86OpEntry opcodes_0F3A[256] = {
[0x05] = X86_OP_ENTRY3(VPERMILPD_i, V,x, W,x, I,b, vex6 chk(W0) cpuid(AVX) p_66),
[0x06] = X86_OP_ENTRY4(VPERM2x128, V,qq, H,qq, W,qq, vex6 chk(W0) cpuid(AVX) p_66),
- [0x14] = X86_OP_ENTRY3(PEXTRB, E,b, V,dq, I,b, vex5 cpuid(SSE41) zext0 p_66),
- [0x15] = X86_OP_ENTRY3(PEXTRW, E,w, V,dq, I,b, vex5 cpuid(SSE41) zext0 p_66),
+ [0x14] = X86_OP_ENTRY3(PEXTRB, E,b, V,dq, I,b, vex5 cpuid(SSE41) op0_Rd p_66),
+ [0x15] = X86_OP_ENTRY3(PEXTRW, E,w, V,dq, I,b, vex5 cpuid(SSE41) op0_Rd p_66),
[0x16] = X86_OP_ENTRY3(PEXTR, E,y, V,dq, I,b, vex5 cpuid(SSE41) p_66),
[0x17] = X86_OP_ENTRY3(VEXTRACTPS, E,d, V,dq, I,b, vex5 cpuid(SSE41) p_66),
[0x1d] = X86_OP_ENTRY3(VCVTPS2PH, W,xh, V,x, I,b, vex11 chk(W0) cpuid(F16C) p_66),
- [0x20] = X86_OP_ENTRY4(PINSRB, V,dq, H,dq, E,b, vex5 cpuid(SSE41) zext2 p_66),
+ [0x20] = X86_OP_ENTRY4(PINSRB, V,dq, H,dq, E,b, vex5 cpuid(SSE41) op2_Ry p_66),
[0x21] = X86_OP_GROUP0(VINSERTPS),
[0x22] = X86_OP_ENTRY4(PINSR, V,dq, H,dq, E,y, vex5 cpuid(SSE41) p_66),
@@ -1091,10 +1128,6 @@ static int decode_modrm(DisasContext *s, CPUX86State *env, X86DecodedInsn *decod
{
int modrm = get_modrm(s, env);
if ((modrm >> 6) == 3) {
- if (s->prefix & PREFIX_LOCK) {
- decode->e.gen = gen_illegal;
- return 0xff;
- }
op->n = (modrm & 7);
if (type != X86_TYPE_Q && type != X86_TYPE_N) {
op->n |= REX_B(s);
@@ -1201,6 +1234,8 @@ static bool decode_op(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode,
case X86_TYPE_None: /* Implicit or absent */
case X86_TYPE_A: /* Implicit */
case X86_TYPE_F: /* EFLAGS/RFLAGS */
+ case X86_TYPE_X: /* string source */
+ case X86_TYPE_Y: /* string destination */
break;
case X86_TYPE_B: /* VEX.vvvv selects a GPR */
@@ -1316,43 +1351,15 @@ static bool decode_op(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode,
}
case X86_TYPE_I: /* Immediate */
- op->unit = X86_OP_IMM;
- decode->immediate = insn_get_signed(env, s, op->ot);
- break;
-
case X86_TYPE_J: /* Relative offset for a jump */
op->unit = X86_OP_IMM;
decode->immediate = insn_get_signed(env, s, op->ot);
- decode->immediate += s->pc - s->cs_base;
- if (s->dflag == MO_16) {
- decode->immediate &= 0xffff;
- } else if (!CODE64(s)) {
- decode->immediate &= 0xffffffffu;
- }
break;
case X86_TYPE_L: /* The upper 4 bits of the immediate select a 128-bit register */
op->n = insn_get(env, s, op->ot) >> 4;
break;
- case X86_TYPE_X: /* string source */
- op->n = -1;
- decode->mem = (AddressParts) {
- .def_seg = R_DS,
- .base = R_ESI,
- .index = -1,
- };
- break;
-
- case X86_TYPE_Y: /* string destination */
- op->n = -1;
- decode->mem = (AddressParts) {
- .def_seg = R_ES,
- .base = R_EDI,
- .index = -1,
- };
- break;
-
case X86_TYPE_2op:
*op = decode->op[0];
break;
@@ -1518,6 +1525,9 @@ static bool has_cpuid_feature(DisasContext *s, X86CPUIDFeature cpuid)
return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_AVX2);
case X86_FEAT_SHA_NI:
return (s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_SHA_NI);
+
+ case X86_FEAT_CMPCCXADD:
+ return (s->cpuid_7_1_eax_features & CPUID_7_1_EAX_CMPCCXADD);
}
g_assert_not_reached();
}
@@ -1677,6 +1687,7 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
bool first = true;
X86DecodedInsn decode;
X86DecodeFunc decode_func = decode_root;
+ uint8_t cc_live;
s->has_modrm = false;
@@ -1830,6 +1841,7 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
}
memset(&decode, 0, sizeof(decode));
+ decode.cc_op = -1;
decode.b = b;
if (!decode_insn(s, env, decode_func, &decode)) {
goto illegal_op;
@@ -1869,19 +1881,22 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
if (decode.op[0].has_ea) {
s->prefix |= PREFIX_LOCK;
}
+ decode.e.special = X86_SPECIAL_HasLock;
+ /* fallthrough */
+ case X86_SPECIAL_HasLock:
break;
- case X86_SPECIAL_ZExtOp0:
+ case X86_SPECIAL_Op0_Rd:
assert(decode.op[0].unit == X86_OP_INT);
if (!decode.op[0].has_ea) {
decode.op[0].ot = MO_32;
}
break;
- case X86_SPECIAL_ZExtOp2:
+ case X86_SPECIAL_Op2_Ry:
assert(decode.op[2].unit == X86_OP_INT);
if (!decode.op[2].has_ea) {
- decode.op[2].ot = MO_32;
+ decode.op[2].ot = s->dflag == MO_16 ? MO_32 : s->dflag;
}
break;
@@ -1893,10 +1908,22 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
}
break;
+ case X86_SPECIAL_SExtT0:
+ case X86_SPECIAL_ZExtT0:
+ /* Handled in gen_load. */
+ assert(decode.op[1].unit == X86_OP_INT);
+ break;
+
default:
break;
}
+ if (s->prefix & PREFIX_LOCK) {
+ if (decode.e.special != X86_SPECIAL_HasLock || !decode.op[0].has_ea) {
+ goto illegal_op;
+ }
+ }
+
if (!validate_vex(s, &decode)) {
return;
}
@@ -1940,9 +1967,6 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
gen_load_ea(s, &decode.mem, decode.e.vex_class == 12);
}
if (s->prefix & PREFIX_LOCK) {
- if (decode.op[0].unit != X86_OP_INT || !decode.op[0].has_ea) {
- goto illegal_op;
- }
gen_load(s, &decode, 2, s->T1);
decode.e.gen(s, env, &decode);
} else {
@@ -1956,6 +1980,38 @@ static void disas_insn_new(DisasContext *s, CPUState *cpu, int b)
decode.e.gen(s, env, &decode);
gen_writeback(s, &decode, 0, s->T0);
}
+
+ /*
+ * Write back flags after last memory access. Some newer ALU instructions, as
+ * well as SSE instructions, write flags in the gen_* function, but that can
+ * cause incorrect tracking of CC_OP for instructions that write to both memory
+ * and flags.
+ */
+ if (decode.cc_op != -1) {
+ if (decode.cc_dst) {
+ tcg_gen_mov_tl(cpu_cc_dst, decode.cc_dst);
+ }
+ if (decode.cc_src) {
+ tcg_gen_mov_tl(cpu_cc_src, decode.cc_src);
+ }
+ if (decode.cc_src2) {
+ tcg_gen_mov_tl(cpu_cc_src2, decode.cc_src2);
+ }
+ if (decode.cc_op == CC_OP_DYNAMIC) {
+ tcg_gen_mov_i32(cpu_cc_op, decode.cc_op_dynamic);
+ }
+ set_cc_op(s, decode.cc_op);
+ cc_live = cc_op_live[decode.cc_op];
+ } else {
+ cc_live = 0;
+ }
+ if (decode.cc_op != CC_OP_DYNAMIC) {
+ assert(!decode.cc_op_dynamic);
+ assert(!!decode.cc_dst == !!(cc_live & USES_CC_DST));
+ assert(!!decode.cc_src == !!(cc_live & USES_CC_SRC));
+ assert(!!decode.cc_src2 == !!(cc_live & USES_CC_SRC2));
+ }
+
return;
gp_fault:
gen_exception_gpf(s);
diff --git a/target/i386/tcg/decode-new.h b/target/i386/tcg/decode-new.h
index e6c904a..15e6bfe 100644
--- a/target/i386/tcg/decode-new.h
+++ b/target/i386/tcg/decode-new.h
@@ -104,6 +104,7 @@ typedef enum X86CPUIDFeature {
X86_FEAT_AVX2,
X86_FEAT_BMI1,
X86_FEAT_BMI2,
+ X86_FEAT_CMPCCXADD,
X86_FEAT_F16C,
X86_FEAT_FMA,
X86_FEAT_MOVBE,
@@ -158,15 +159,27 @@ typedef enum X86InsnCheck {
typedef enum X86InsnSpecial {
X86_SPECIAL_None,
+ /* Accepts LOCK prefix; LOCKed operations do not load or writeback operand 0 */
+ X86_SPECIAL_HasLock,
+
/* Always locked if it has a memory operand (XCHG) */
X86_SPECIAL_Locked,
/*
- * Register operand 0/2 is zero extended to 32 bits. Rd/Mb or Rd/Mw
- * in the manual.
+ * Rd/Mb or Rd/Mw in the manual: register operand 0 is treated as 32 bits
+ * (and writeback zero-extends it to 64 bits if applicable). PREFIX_DATA
+ * does not trigger 16-bit writeback and, as a side effect, high-byte
+ * registers are never used.
+ */
+ X86_SPECIAL_Op0_Rd,
+
+ /*
+ * Ry/Mb in the manual (PINSRB). However, the high bits are never used by
+ * the instruction in either the register or memory cases; the *real* effect
+ * of this modifier is that high-byte registers are never used, even without
+ * a REX prefix. Therefore, PINSRW does not need it despite having Ry/Mw.
*/
- X86_SPECIAL_ZExtOp0,
- X86_SPECIAL_ZExtOp2,
+ X86_SPECIAL_Op2_Ry,
/*
* Register operand 2 is extended to full width, while a memory operand
@@ -179,6 +192,10 @@ typedef enum X86InsnSpecial {
* become P/P/Q/N, and size "x" becomes "q".
*/
X86_SPECIAL_MMX,
+
+ /* When loaded into s->T0, register operand 1 is zero/sign extended. */
+ X86_SPECIAL_SExtT0,
+ X86_SPECIAL_ZExtT0,
} X86InsnSpecial;
/*
@@ -267,6 +284,10 @@ struct X86DecodedInsn {
target_ulong immediate;
AddressParts mem;
+ TCGv cc_dst, cc_src, cc_src2;
+ TCGv_i32 cc_op_dynamic;
+ int8_t cc_op;
+
uint8_t b;
};
diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 82da548..6bcf88e 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -55,11 +55,6 @@ static void gen_NM_exception(DisasContext *s)
gen_exception(s, EXCP07_PREX);
}
-static void gen_illegal(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
-{
- gen_illegal_opcode(s);
-}
-
static void gen_load_ea(DisasContext *s, AddressParts *mem, bool is_vsib)
{
TCGv ea = gen_lea_modrm_1(s, *mem, is_vsib);
@@ -237,9 +232,30 @@ static void gen_load(DisasContext *s, X86DecodedInsn *decode, int opn, TCGv v)
break;
case X86_OP_INT:
if (op->has_ea) {
- gen_op_ld_v(s, op->ot, v, s->A0);
+ if (v == s->T0 && decode->e.special == X86_SPECIAL_SExtT0) {
+ gen_op_ld_v(s, op->ot | MO_SIGN, v, s->A0);
+ } else {
+ gen_op_ld_v(s, op->ot, v, s->A0);
+ }
+
+ } else if (op->ot == MO_8 && byte_reg_is_xH(s, op->n)) {
+ if (v == s->T0 && decode->e.special == X86_SPECIAL_SExtT0) {
+ tcg_gen_sextract_tl(v, cpu_regs[op->n - 4], 8, 8);
+ } else {
+ tcg_gen_extract_tl(v, cpu_regs[op->n - 4], 8, 8);
+ }
+
+ } else if (op->ot < MO_TL && v == s->T0 &&
+ (decode->e.special == X86_SPECIAL_SExtT0 ||
+ decode->e.special == X86_SPECIAL_ZExtT0)) {
+ if (decode->e.special == X86_SPECIAL_SExtT0) {
+ tcg_gen_ext_tl(v, cpu_regs[op->n], op->ot | MO_SIGN);
+ } else {
+ tcg_gen_ext_tl(v, cpu_regs[op->n], op->ot);
+ }
+
} else {
- gen_op_mov_v_reg(s, op->ot, v, op->n);
+ tcg_gen_mov_tl(v, cpu_regs[op->n]);
}
break;
case X86_OP_IMM:
@@ -323,6 +339,19 @@ static inline int vector_len(DisasContext *s, X86DecodedInsn *decode)
return s->vex_l ? 32 : 16;
}
+static void prepare_update1_cc(X86DecodedInsn *decode, DisasContext *s, CCOp op)
+{
+ decode->cc_dst = s->T0;
+ decode->cc_op = op;
+}
+
+static void prepare_update2_cc(X86DecodedInsn *decode, DisasContext *s, CCOp op)
+{
+ decode->cc_src = s->T1;
+ decode->cc_dst = s->T0;
+ decode->cc_op = op;
+}
+
static void gen_store_sse(DisasContext *s, X86DecodedInsn *decode, int src_ofs)
{
MemOp ot = decode->op[0].ot;
@@ -1011,6 +1040,7 @@ static void gen_##uname(DisasContext *s, CPUX86State *env, X86DecodedInsn *decod
VSIB_AVX(VPGATHERD, vpgatherd)
VSIB_AVX(VPGATHERQ, vpgatherq)
+/* ADCX/ADOX do not have memory operands and can use set_cc_op. */
static void gen_ADCOX(DisasContext *s, CPUX86State *env, MemOp ot, int cc_op)
{
int opposite_cc_op;
@@ -1073,8 +1103,7 @@ static void gen_ANDN(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
MemOp ot = decode->op[0].ot;
tcg_gen_andc_tl(s->T0, s->T1, s->T0);
- gen_op_update1_cc(s);
- set_cc_op(s, CC_OP_LOGICB + ot);
+ prepare_update1_cc(decode, s, CC_OP_LOGICB + ot);
}
static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
@@ -1089,9 +1118,6 @@ static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
* Shifts larger than operand size get zeros.
*/
tcg_gen_ext8u_tl(s->A0, s->T1);
- if (TARGET_LONG_BITS == 64 && ot == MO_32) {
- tcg_gen_ext32u_tl(s->T0, s->T0);
- }
tcg_gen_shr_tl(s->T0, s->T0, s->A0);
tcg_gen_movcond_tl(TCG_COND_LEU, s->T0, s->A0, bound, s->T0, zero);
@@ -1105,10 +1131,10 @@ static void gen_BEXTR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
tcg_gen_movcond_tl(TCG_COND_LEU, s->T1, s->A0, bound, s->T1, zero);
tcg_gen_andc_tl(s->T0, s->T0, s->T1);
- gen_op_update1_cc(s);
- set_cc_op(s, CC_OP_LOGICB + ot);
+ prepare_update1_cc(decode, s, CC_OP_LOGICB + ot);
}
+/* BLSI do not have memory operands and can use set_cc_op. */
static void gen_BLSI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
MemOp ot = decode->op[0].ot;
@@ -1120,6 +1146,7 @@ static void gen_BLSI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
set_cc_op(s, CC_OP_BMILGB + ot);
}
+/* BLSMSK do not have memory operands and can use set_cc_op. */
static void gen_BLSMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
MemOp ot = decode->op[0].ot;
@@ -1131,6 +1158,7 @@ static void gen_BLSMSK(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode
set_cc_op(s, CC_OP_BMILGB + ot);
}
+/* BLSR do not have memory operands and can use set_cc_op. */
static void gen_BLSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
MemOp ot = decode->op[0].ot;
@@ -1151,18 +1179,119 @@ static void gen_BZHI(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
tcg_gen_ext8u_tl(s->T1, s->T1);
+ tcg_gen_shl_tl(s->A0, mone, s->T1);
+ tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->T1, bound, s->A0, zero);
+ tcg_gen_andc_tl(s->T0, s->T0, s->A0);
/*
* Note that since we're using BMILG (in order to get O
* cleared) we need to store the inverse into C.
*/
- tcg_gen_setcond_tl(TCG_COND_LEU, cpu_cc_src, s->T1, bound);
+ tcg_gen_setcond_tl(TCG_COND_LEU, s->T1, s->T1, bound);
+ prepare_update2_cc(decode, s, CC_OP_BMILGB + ot);
+}
+
+static void gen_CMPccXADD(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
+{
+ TCGLabel *label_top = gen_new_label();
+ TCGLabel *label_bottom = gen_new_label();
+ TCGv oldv = tcg_temp_new();
+ TCGv newv = tcg_temp_new();
+ TCGv cmpv = tcg_temp_new();
+ TCGCond cond;
+
+ TCGv cmp_lhs, cmp_rhs;
+ MemOp ot, ot_full;
+
+ int jcc_op = (decode->b >> 1) & 7;
+ static const TCGCond cond_table[8] = {
+ [JCC_O] = TCG_COND_LT, /* test sign bit by comparing against 0 */
+ [JCC_B] = TCG_COND_LTU,
+ [JCC_Z] = TCG_COND_EQ,
+ [JCC_BE] = TCG_COND_LEU,
+ [JCC_S] = TCG_COND_LT, /* test sign bit by comparing against 0 */
+ [JCC_P] = TCG_COND_EQ, /* even parity - tests low bit of popcount */
+ [JCC_L] = TCG_COND_LT,
+ [JCC_LE] = TCG_COND_LE,
+ };
- tcg_gen_shl_tl(s->A0, mone, s->T1);
- tcg_gen_movcond_tl(TCG_COND_LEU, s->A0, s->T1, bound, s->A0, zero);
- tcg_gen_andc_tl(s->T0, s->T0, s->A0);
+ cond = cond_table[jcc_op];
+ if (decode->b & 1) {
+ cond = tcg_invert_cond(cond);
+ }
- gen_op_update1_cc(s);
- set_cc_op(s, CC_OP_BMILGB + ot);
+ ot = decode->op[0].ot;
+ ot_full = ot | MO_LE;
+ if (jcc_op >= JCC_S) {
+ /*
+ * Sign-extend values before subtracting for S, P (zero/sign extension
+ * does not matter there) L, LE and their inverses.
+ */
+ ot_full |= MO_SIGN;
+ }
+
+ /*
+ * cmpv will be moved to cc_src *after* cpu_regs[] is written back, so use
+ * tcg_gen_ext_tl instead of gen_ext_tl.
+ */
+ tcg_gen_ext_tl(cmpv, cpu_regs[decode->op[1].n], ot_full);
+
+ /*
+ * Cmpxchg loop starts here.
+ * - s->T1: addition operand (from decoder)
+ * - s->A0: dest address (from decoder)
+ * - s->cc_srcT: memory operand (lhs for comparison)
+ * - cmpv: rhs for comparison
+ */
+ gen_set_label(label_top);
+ gen_op_ld_v(s, ot_full, s->cc_srcT, s->A0);
+ tcg_gen_sub_tl(s->T0, s->cc_srcT, cmpv);
+
+ /* Compute the comparison result by hand, to avoid clobbering cc_*. */
+ switch (jcc_op) {
+ case JCC_O:
+ /* (src1 ^ src2) & (src1 ^ dst). newv is only used here for a moment */
+ tcg_gen_xor_tl(newv, s->cc_srcT, s->T0);
+ tcg_gen_xor_tl(s->tmp0, s->cc_srcT, cmpv);
+ tcg_gen_and_tl(s->tmp0, s->tmp0, newv);
+ tcg_gen_sextract_tl(s->tmp0, s->tmp0, 0, 8 << ot);
+ cmp_lhs = s->tmp0, cmp_rhs = tcg_constant_tl(0);
+ break;
+
+ case JCC_P:
+ tcg_gen_ext8u_tl(s->tmp0, s->T0);
+ tcg_gen_ctpop_tl(s->tmp0, s->tmp0);
+ tcg_gen_andi_tl(s->tmp0, s->tmp0, 1);
+ cmp_lhs = s->tmp0, cmp_rhs = tcg_constant_tl(0);
+ break;
+
+ case JCC_S:
+ tcg_gen_sextract_tl(s->tmp0, s->T0, 0, 8 << ot);
+ cmp_lhs = s->tmp0, cmp_rhs = tcg_constant_tl(0);
+ break;
+
+ default:
+ cmp_lhs = s->cc_srcT, cmp_rhs = cmpv;
+ break;
+ }
+
+ /* Compute new value: if condition does not hold, just store back s->cc_srcT */
+ tcg_gen_add_tl(newv, s->cc_srcT, s->T1);
+ tcg_gen_movcond_tl(cond, newv, cmp_lhs, cmp_rhs, newv, s->cc_srcT);
+ tcg_gen_atomic_cmpxchg_tl(oldv, s->A0, s->cc_srcT, newv, s->mem_index, ot_full);
+
+ /* Exit unconditionally if cmpxchg succeeded. */
+ tcg_gen_brcond_tl(TCG_COND_EQ, oldv, s->cc_srcT, label_bottom);
+
+ /* Try again if there was actually a store to make. */
+ tcg_gen_brcond_tl(cond, cmp_lhs, cmp_rhs, label_top);
+ gen_set_label(label_bottom);
+
+ /* Store old value to registers only after a successful store. */
+ gen_writeback(s, decode, 1, s->cc_srcT);
+
+ decode->cc_dst = s->T0;
+ decode->cc_src = cmpv;
+ decode->cc_op = CC_OP_SUBB + ot;
}
static void gen_CRC32(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
@@ -1242,9 +1371,7 @@ static void gen_LDMXCSR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decod
static void gen_MASKMOV(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
- tcg_gen_mov_tl(s->A0, cpu_regs[R_EDI]);
- gen_extu(s->aflag, s->A0);
- gen_add_A0_ds_seg(s);
+ gen_lea_v_seg(s, s->aflag, cpu_regs[R_EDI], R_DS, s->override);
if (s->prefix & PREFIX_DATA) {
gen_helper_maskmov_xmm(tcg_env, OP_PTR1, OP_PTR2, s->A0);
@@ -1355,7 +1482,8 @@ static void gen_MULX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
/* low part of result in VEX.vvvv, high in MODRM */
switch (ot) {
- default:
+ case MO_32:
+#ifdef TARGET_X86_64
tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0);
tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T1);
tcg_gen_mulu2_i32(s->tmp2_i32, s->tmp3_i32,
@@ -1363,13 +1491,15 @@ static void gen_MULX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
tcg_gen_extu_i32_tl(cpu_regs[s->vex_v], s->tmp2_i32);
tcg_gen_extu_i32_tl(s->T0, s->tmp3_i32);
break;
-#ifdef TARGET_X86_64
+
case MO_64:
- tcg_gen_mulu2_i64(cpu_regs[s->vex_v], s->T0, s->T0, s->T1);
- break;
#endif
- }
+ tcg_gen_mulu2_tl(cpu_regs[s->vex_v], s->T0, s->T0, s->T1);
+ break;
+ default:
+ g_assert_not_reached();
+ }
}
static void gen_PALIGNR(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
@@ -1432,19 +1562,11 @@ static void gen_PCMPISTRM(DisasContext *s, CPUX86State *env, X86DecodedInsn *dec
static void gen_PDEP(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
- MemOp ot = decode->op[1].ot;
- if (ot < MO_64) {
- tcg_gen_ext32u_tl(s->T0, s->T0);
- }
gen_helper_pdep(s->T0, s->T0, s->T1);
}
static void gen_PEXT(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
- MemOp ot = decode->op[1].ot;
- if (ot < MO_64) {
- tcg_gen_ext32u_tl(s->T0, s->T0);
- }
gen_helper_pext(s->T0, s->T0, s->T1);
}
@@ -1772,14 +1894,24 @@ static void gen_PSLLDQ_i(DisasContext *s, CPUX86State *env, X86DecodedInsn *deco
static void gen_RORX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
{
MemOp ot = decode->op[0].ot;
- int b = decode->immediate;
+ int mask = ot == MO_64 ? 63 : 31;
+ int b = decode->immediate & mask;
- if (ot == MO_64) {
- tcg_gen_rotri_tl(s->T0, s->T0, b & 63);
- } else {
+ switch (ot) {
+ case MO_32:
+#ifdef TARGET_X86_64
tcg_gen_trunc_tl_i32(s->tmp2_i32, s->T0);
- tcg_gen_rotri_i32(s->tmp2_i32, s->tmp2_i32, b & 31);
+ tcg_gen_rotri_i32(s->tmp2_i32, s->tmp2_i32, b);
tcg_gen_extu_i32_tl(s->T0, s->tmp2_i32);
+ break;
+
+ case MO_64:
+#endif
+ tcg_gen_rotri_tl(s->T0, s->T0, b);
+ break;
+
+ default:
+ g_assert_not_reached();
}
}
@@ -1790,9 +1922,6 @@ static void gen_SARX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
mask = ot == MO_64 ? 63 : 31;
tcg_gen_andi_tl(s->T1, s->T1, mask);
- if (ot != MO_64) {
- tcg_gen_ext32s_tl(s->T0, s->T0);
- }
tcg_gen_sar_tl(s->T0, s->T0, s->T1);
}
@@ -1867,9 +1996,6 @@ static void gen_SHRX(DisasContext *s, CPUX86State *env, X86DecodedInsn *decode)
mask = ot == MO_64 ? 63 : 31;
tcg_gen_andi_tl(s->T1, s->T1, mask);
- if (ot != MO_64) {
- tcg_gen_ext32u_tl(s->T0, s->T0);
- }
tcg_gen_shr_tl(s->T0, s->T0, s->T1);
}
diff --git a/target/i386/tcg/excp_helper.c b/target/i386/tcg/excp_helper.c
index 7c3c8dc..65e37ae 100644
--- a/target/i386/tcg/excp_helper.c
+++ b/target/i386/tcg/excp_helper.c
@@ -28,7 +28,7 @@
G_NORETURN void helper_raise_interrupt(CPUX86State *env, int intno,
int next_eip_addend)
{
- raise_interrupt(env, intno, 1, 0, next_eip_addend);
+ raise_interrupt(env, intno, next_eip_addend);
}
G_NORETURN void helper_raise_exception(CPUX86State *env, int exception_index)
@@ -112,10 +112,9 @@ void raise_interrupt2(CPUX86State *env, int intno,
/* shortcuts to generate exceptions */
-G_NORETURN void raise_interrupt(CPUX86State *env, int intno, int is_int,
- int error_code, int next_eip_addend)
+G_NORETURN void raise_interrupt(CPUX86State *env, int intno, int next_eip_addend)
{
- raise_interrupt2(env, intno, is_int, error_code, next_eip_addend, 0);
+ raise_interrupt2(env, intno, 1, 0, next_eip_addend, 0);
}
G_NORETURN void raise_exception_err(CPUX86State *env, int exception_index,
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index 4430d3d..4b965a5 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -484,9 +484,8 @@ void helper_fcomi_ST0_FT0(CPUX86State *env)
FloatRelation ret;
ret = floatx80_compare(ST0, FT0, &env->fp_status);
- eflags = cpu_cc_compute_all(env, CC_OP);
- eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
- CC_SRC = eflags;
+ eflags = cpu_cc_compute_all(env) & ~(CC_Z | CC_P | CC_C);
+ CC_SRC = eflags | fcomi_ccval[ret + 1];
merge_exception_flags(env, old_flags);
}
@@ -497,9 +496,8 @@ void helper_fucomi_ST0_FT0(CPUX86State *env)
FloatRelation ret;
ret = floatx80_compare_quiet(ST0, FT0, &env->fp_status);
- eflags = cpu_cc_compute_all(env, CC_OP);
- eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
- CC_SRC = eflags;
+ eflags = cpu_cc_compute_all(env) & ~(CC_Z | CC_P | CC_C);
+ CC_SRC = eflags | fcomi_ccval[ret + 1];
merge_exception_flags(env, old_flags);
}
diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h
index cd17233..ce34b73 100644
--- a/target/i386/tcg/helper-tcg.h
+++ b/target/i386/tcg/helper-tcg.h
@@ -65,8 +65,7 @@ G_NORETURN void raise_exception_err(CPUX86State *env, int exception_index,
int error_code);
G_NORETURN void raise_exception_err_ra(CPUX86State *env, int exception_index,
int error_code, uintptr_t retaddr);
-G_NORETURN void raise_interrupt(CPUX86State *nenv, int intno, int is_int,
- int error_code, int next_eip_addend);
+G_NORETURN void raise_interrupt(CPUX86State *nenv, int intno, int next_eip_addend);
G_NORETURN void handle_unaligned_access(CPUX86State *env, vaddr vaddr,
MMUAccessType access_type,
uintptr_t retaddr);
diff --git a/target/i386/tcg/int_helper.c b/target/i386/tcg/int_helper.c
index 05418f1..ab85dc5 100644
--- a/target/i386/tcg/int_helper.c
+++ b/target/i386/tcg/int_helper.c
@@ -190,7 +190,7 @@ void helper_aaa(CPUX86State *env)
int al, ah, af;
int eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
af = eflags & CC_A;
al = env->regs[R_EAX] & 0xff;
ah = (env->regs[R_EAX] >> 8) & 0xff;
@@ -214,7 +214,7 @@ void helper_aas(CPUX86State *env)
int al, ah, af;
int eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
af = eflags & CC_A;
al = env->regs[R_EAX] & 0xff;
ah = (env->regs[R_EAX] >> 8) & 0xff;
@@ -237,7 +237,7 @@ void helper_daa(CPUX86State *env)
int old_al, al, af, cf;
int eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
cf = eflags & CC_C;
af = eflags & CC_A;
old_al = al = env->regs[R_EAX] & 0xff;
@@ -264,7 +264,7 @@ void helper_das(CPUX86State *env)
int al, al1, af, cf;
int eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
cf = eflags & CC_C;
af = eflags & CC_A;
al = env->regs[R_EAX] & 0xff;
diff --git a/target/i386/tcg/misc_helper.c b/target/i386/tcg/misc_helper.c
index babff06..b0f0f7b 100644
--- a/target/i386/tcg/misc_helper.c
+++ b/target/i386/tcg/misc_helper.c
@@ -41,9 +41,9 @@ void helper_into(CPUX86State *env, int next_eip_addend)
{
int eflags;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
if (eflags & CC_O) {
- raise_interrupt(env, EXCP04_INTO, 1, 0, next_eip_addend);
+ raise_interrupt(env, EXCP04_INTO, next_eip_addend);
}
}
diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c
index eb29a1f..34ccabd 100644
--- a/target/i386/tcg/seg_helper.c
+++ b/target/i386/tcg/seg_helper.c
@@ -2230,7 +2230,7 @@ target_ulong helper_lsl(CPUX86State *env, target_ulong selector1)
int rpl, dpl, cpl, type;
selector = selector1 & 0xffff;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
if ((selector & 0xfffc) == 0) {
goto fail;
}
@@ -2277,7 +2277,7 @@ target_ulong helper_lar(CPUX86State *env, target_ulong selector1)
int rpl, dpl, cpl, type;
selector = selector1 & 0xffff;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
if ((selector & 0xfffc) == 0) {
goto fail;
}
@@ -2326,7 +2326,7 @@ void helper_verr(CPUX86State *env, target_ulong selector1)
int rpl, dpl, cpl;
selector = selector1 & 0xffff;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
if ((selector & 0xfffc) == 0) {
goto fail;
}
@@ -2364,7 +2364,7 @@ void helper_verw(CPUX86State *env, target_ulong selector1)
int rpl, dpl, cpl;
selector = selector1 & 0xffff;
- eflags = cpu_cc_compute_all(env, CC_OP);
+ eflags = cpu_cc_compute_all(env);
if ((selector & 0xfffc) == 0) {
goto fail;
}
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 037bc47..e1eb82a 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -122,6 +122,7 @@ typedef struct DisasContext {
int cpuid_ext3_features;
int cpuid_7_0_ebx_features;
int cpuid_7_0_ecx_features;
+ int cpuid_7_1_eax_features;
int cpuid_xsave_features;
/* TCG local temps */
@@ -522,9 +523,9 @@ void gen_op_add_reg_im(DisasContext *s, MemOp size, int reg, int32_t val)
gen_op_mov_reg_v(s, size, reg, s->tmp0);
}
-static inline void gen_op_add_reg_T0(DisasContext *s, MemOp size, int reg)
+static inline void gen_op_add_reg(DisasContext *s, MemOp size, int reg, TCGv val)
{
- tcg_gen_add_tl(s->tmp0, cpu_regs[reg], s->T0);
+ tcg_gen_add_tl(s->tmp0, cpu_regs[reg], val);
gen_op_mov_reg_v(s, size, reg, s->tmp0);
}
@@ -635,17 +636,17 @@ static TCGv eip_cur_tl(DisasContext *s)
}
}
-/* Compute SEG:REG into A0. SEG is selected from the override segment
+/* Compute SEG:REG into DEST. SEG is selected from the override segment
(OVR_SEG) and the default segment (DEF_SEG). OVR_SEG may be -1 to
indicate no override. */
-static void gen_lea_v_seg(DisasContext *s, MemOp aflag, TCGv a0,
- int def_seg, int ovr_seg)
+static void gen_lea_v_seg_dest(DisasContext *s, MemOp aflag, TCGv dest, TCGv a0,
+ int def_seg, int ovr_seg)
{
switch (aflag) {
#ifdef TARGET_X86_64
case MO_64:
if (ovr_seg < 0) {
- tcg_gen_mov_tl(s->A0, a0);
+ tcg_gen_mov_tl(dest, a0);
return;
}
break;
@@ -656,14 +657,14 @@ static void gen_lea_v_seg(DisasContext *s, MemOp aflag, TCGv a0,
ovr_seg = def_seg;
}
if (ovr_seg < 0) {
- tcg_gen_ext32u_tl(s->A0, a0);
+ tcg_gen_ext32u_tl(dest, a0);
return;
}
break;
case MO_16:
/* 16 bit address */
- tcg_gen_ext16u_tl(s->A0, a0);
- a0 = s->A0;
+ tcg_gen_ext16u_tl(dest, a0);
+ a0 = dest;
if (ovr_seg < 0) {
if (ADDSEG(s)) {
ovr_seg = def_seg;
@@ -680,17 +681,23 @@ static void gen_lea_v_seg(DisasContext *s, MemOp aflag, TCGv a0,
TCGv seg = cpu_seg_base[ovr_seg];
if (aflag == MO_64) {
- tcg_gen_add_tl(s->A0, a0, seg);
+ tcg_gen_add_tl(dest, a0, seg);
} else if (CODE64(s)) {
- tcg_gen_ext32u_tl(s->A0, a0);
- tcg_gen_add_tl(s->A0, s->A0, seg);
+ tcg_gen_ext32u_tl(dest, a0);
+ tcg_gen_add_tl(dest, dest, seg);
} else {
- tcg_gen_add_tl(s->A0, a0, seg);
- tcg_gen_ext32u_tl(s->A0, s->A0);
+ tcg_gen_add_tl(dest, a0, seg);
+ tcg_gen_ext32u_tl(dest, dest);
}
}
}
+static void gen_lea_v_seg(DisasContext *s, MemOp aflag, TCGv a0,
+ int def_seg, int ovr_seg)
+{
+ gen_lea_v_seg_dest(s, aflag, s->A0, a0, def_seg, ovr_seg);
+}
+
static inline void gen_string_movl_A0_ESI(DisasContext *s)
{
gen_lea_v_seg(s, s->aflag, cpu_regs[R_ESI], R_DS, s->override);
@@ -701,10 +708,12 @@ static inline void gen_string_movl_A0_EDI(DisasContext *s)
gen_lea_v_seg(s, s->aflag, cpu_regs[R_EDI], R_ES, -1);
}
-static inline void gen_op_movl_T0_Dshift(DisasContext *s, MemOp ot)
+static inline TCGv gen_compute_Dshift(DisasContext *s, MemOp ot)
{
- tcg_gen_ld32s_tl(s->T0, tcg_env, offsetof(CPUX86State, df));
- tcg_gen_shli_tl(s->T0, s->T0, ot);
+ TCGv dshift = tcg_temp_new();
+ tcg_gen_ld32s_tl(dshift, tcg_env, offsetof(CPUX86State, df));
+ tcg_gen_shli_tl(dshift, dshift, ot);
+ return dshift;
};
static TCGv gen_ext_tl(TCGv dst, TCGv src, MemOp size, bool sign)
@@ -712,6 +721,9 @@ static TCGv gen_ext_tl(TCGv dst, TCGv src, MemOp size, bool sign)
if (size == MO_TL) {
return src;
}
+ if (!dst) {
+ dst = tcg_temp_new();
+ }
tcg_gen_ext_tl(dst, src, size | (sign ? MO_SIGN : 0));
return dst;
}
@@ -728,9 +740,9 @@ static void gen_exts(MemOp ot, TCGv reg)
static void gen_op_j_ecx(DisasContext *s, TCGCond cond, TCGLabel *label1)
{
- tcg_gen_mov_tl(s->tmp0, cpu_regs[R_ECX]);
- gen_extu(s->aflag, s->tmp0);
- tcg_gen_brcondi_tl(cond, s->tmp0, 0, label1);
+ TCGv tmp = gen_ext_tl(NULL, cpu_regs[R_ECX], s->aflag, false);
+
+ tcg_gen_brcondi_tl(cond, tmp, 0, label1);
}
static inline void gen_op_jz_ecx(DisasContext *s, TCGLabel *label1)
@@ -812,13 +824,16 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCGv_i32 port,
static void gen_movs(DisasContext *s, MemOp ot)
{
+ TCGv dshift;
+
gen_string_movl_A0_ESI(s);
gen_op_ld_v(s, ot, s->T0, s->A0);
gen_string_movl_A0_EDI(s);
gen_op_st_v(s, ot, s->T0, s->A0);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_ESI);
- gen_op_add_reg_T0(s, s->aflag, R_EDI);
+
+ dshift = gen_compute_Dshift(s, ot);
+ gen_op_add_reg(s, s->aflag, R_ESI, dshift);
+ gen_op_add_reg(s, s->aflag, R_EDI, dshift);
}
static void gen_op_update1_cc(DisasContext *s)
@@ -851,22 +866,22 @@ static void gen_op_update_neg_cc(DisasContext *s)
tcg_gen_movi_tl(s->cc_srcT, 0);
}
-/* compute all eflags to cc_src */
-static void gen_compute_eflags(DisasContext *s)
+/* compute all eflags to reg */
+static void gen_mov_eflags(DisasContext *s, TCGv reg)
{
- TCGv zero, dst, src1, src2;
+ TCGv dst, src1, src2;
+ TCGv_i32 cc_op;
int live, dead;
if (s->cc_op == CC_OP_EFLAGS) {
+ tcg_gen_mov_tl(reg, cpu_cc_src);
return;
}
if (s->cc_op == CC_OP_CLR) {
- tcg_gen_movi_tl(cpu_cc_src, CC_Z | CC_P);
- set_cc_op(s, CC_OP_EFLAGS);
+ tcg_gen_movi_tl(reg, CC_Z | CC_P);
return;
}
- zero = NULL;
dst = cpu_cc_dst;
src1 = cpu_cc_src;
src2 = cpu_cc_src2;
@@ -875,7 +890,7 @@ static void gen_compute_eflags(DisasContext *s)
live = cc_op_live[s->cc_op] & ~USES_CC_SRCT;
dead = live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2);
if (dead) {
- zero = tcg_constant_tl(0);
+ TCGv zero = tcg_constant_tl(0);
if (dead & USES_CC_DST) {
dst = zero;
}
@@ -887,8 +902,18 @@ static void gen_compute_eflags(DisasContext *s)
}
}
- gen_update_cc_op(s);
- gen_helper_cc_compute_all(cpu_cc_src, dst, src1, src2, cpu_cc_op);
+ if (s->cc_op != CC_OP_DYNAMIC) {
+ cc_op = tcg_constant_i32(s->cc_op);
+ } else {
+ cc_op = cpu_cc_op;
+ }
+ gen_helper_cc_compute_all(reg, dst, src1, src2, cc_op);
+}
+
+/* compute all eflags to cc_src */
+static void gen_compute_eflags(DisasContext *s)
+{
+ gen_mov_eflags(s, cpu_cc_src);
set_cc_op(s, CC_OP_EFLAGS);
}
@@ -1020,6 +1045,9 @@ static CCPrepare gen_prepare_eflags_o(DisasContext *s, TCGv reg)
case CC_OP_CLR:
case CC_OP_POPCNT:
return (CCPrepare) { .cond = TCG_COND_NEVER, .mask = -1 };
+ case CC_OP_MULB ... CC_OP_MULQ:
+ return (CCPrepare) { .cond = TCG_COND_NE,
+ .reg = cpu_cc_src, .mask = -1 };
default:
gen_compute_eflags(s);
return (CCPrepare) { .cond = TCG_COND_NE, .reg = cpu_cc_src,
@@ -1126,10 +1154,9 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg)
if (reg == cpu_cc_src) {
reg = s->tmp0;
}
- tcg_gen_shri_tl(reg, cpu_cc_src, 4); /* CC_O -> CC_S */
- tcg_gen_xor_tl(reg, reg, cpu_cc_src);
+ tcg_gen_addi_tl(reg, cpu_cc_src, CC_O - CC_S);
cc = (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
- .mask = CC_S };
+ .mask = CC_O };
break;
default:
case JCC_LE:
@@ -1137,10 +1164,9 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg)
if (reg == cpu_cc_src) {
reg = s->tmp0;
}
- tcg_gen_shri_tl(reg, cpu_cc_src, 4); /* CC_O -> CC_S */
- tcg_gen_xor_tl(reg, reg, cpu_cc_src);
+ tcg_gen_addi_tl(reg, cpu_cc_src, CC_O - CC_S);
cc = (CCPrepare) { .cond = TCG_COND_NE, .reg = reg,
- .mask = CC_S | CC_Z };
+ .mask = CC_O | CC_Z };
break;
}
break;
@@ -1239,11 +1265,9 @@ static TCGLabel *gen_jz_ecx_string(DisasContext *s)
static void gen_stos(DisasContext *s, MemOp ot)
{
- gen_op_mov_v_reg(s, MO_32, s->T0, R_EAX);
gen_string_movl_A0_EDI(s);
gen_op_st_v(s, ot, s->T0, s->A0);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_EDI);
+ gen_op_add_reg(s, s->aflag, R_EDI, gen_compute_Dshift(s, ot));
}
static void gen_lods(DisasContext *s, MemOp ot)
@@ -1251,28 +1275,33 @@ static void gen_lods(DisasContext *s, MemOp ot)
gen_string_movl_A0_ESI(s);
gen_op_ld_v(s, ot, s->T0, s->A0);
gen_op_mov_reg_v(s, ot, R_EAX, s->T0);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_ESI);
+ gen_op_add_reg(s, s->aflag, R_ESI, gen_compute_Dshift(s, ot));
}
static void gen_scas(DisasContext *s, MemOp ot)
{
gen_string_movl_A0_EDI(s);
gen_op_ld_v(s, ot, s->T1, s->A0);
- gen_op(s, OP_CMPL, ot, R_EAX);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_EDI);
+ tcg_gen_mov_tl(cpu_cc_src, s->T1);
+ tcg_gen_mov_tl(s->cc_srcT, s->T0);
+ tcg_gen_sub_tl(cpu_cc_dst, s->T0, s->T1);
+ set_cc_op(s, CC_OP_SUBB + ot);
+
+ gen_op_add_reg(s, s->aflag, R_EDI, gen_compute_Dshift(s, ot));
}
static void gen_cmps(DisasContext *s, MemOp ot)
{
+ TCGv dshift;
+
gen_string_movl_A0_EDI(s);
gen_op_ld_v(s, ot, s->T1, s->A0);
gen_string_movl_A0_ESI(s);
gen_op(s, OP_CMPL, ot, OR_TMP0);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_ESI);
- gen_op_add_reg_T0(s, s->aflag, R_EDI);
+
+ dshift = gen_compute_Dshift(s, ot);
+ gen_op_add_reg(s, s->aflag, R_ESI, dshift);
+ gen_op_add_reg(s, s->aflag, R_EDI, dshift);
}
static void gen_bpt_io(DisasContext *s, TCGv_i32 t_port, int ot)
@@ -1300,8 +1329,7 @@ static void gen_ins(DisasContext *s, MemOp ot)
tcg_gen_andi_i32(s->tmp2_i32, s->tmp2_i32, 0xffff);
gen_helper_in_func(ot, s->T0, s->tmp2_i32);
gen_op_st_v(s, ot, s->T0, s->A0);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_EDI);
+ gen_op_add_reg(s, s->aflag, R_EDI, gen_compute_Dshift(s, ot));
gen_bpt_io(s, s->tmp2_i32, ot);
}
@@ -1314,8 +1342,7 @@ static void gen_outs(DisasContext *s, MemOp ot)
tcg_gen_andi_i32(s->tmp2_i32, s->tmp2_i32, 0xffff);
tcg_gen_trunc_tl_i32(s->tmp3_i32, s->T0);
gen_helper_out_func(ot, s->tmp2_i32, s->tmp3_i32);
- gen_op_movl_T0_Dshift(s, ot);
- gen_op_add_reg_T0(s, s->aflag, R_ESI);
+ gen_op_add_reg(s, s->aflag, R_ESI, gen_compute_Dshift(s, ot));
gen_bpt_io(s, s->tmp2_i32, ot);
}
@@ -2474,14 +2501,10 @@ static void gen_jcc(DisasContext *s, int b, int diff)
gen_jmp_rel(s, s->dflag, diff, 0);
}
-static void gen_cmovcc1(CPUX86State *env, DisasContext *s, MemOp ot, int b,
- int modrm, int reg)
+static void gen_cmovcc1(DisasContext *s, int b, TCGv dest, TCGv src)
{
- CCPrepare cc;
+ CCPrepare cc = gen_prepare_cc(s, b, s->T1);
- gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
-
- cc = gen_prepare_cc(s, b, s->T1);
if (cc.mask != -1) {
TCGv t0 = tcg_temp_new();
tcg_gen_andi_tl(t0, cc.reg, cc.mask);
@@ -2491,9 +2514,7 @@ static void gen_cmovcc1(CPUX86State *env, DisasContext *s, MemOp ot, int b,
cc.reg2 = tcg_constant_tl(cc.imm);
}
- tcg_gen_movcond_tl(cc.cond, s->T0, cc.reg, cc.reg2,
- s->T0, cpu_regs[reg]);
- gen_op_mov_reg_v(s, ot, reg, s->T0);
+ tcg_gen_movcond_tl(cc.cond, dest, cc.reg, cc.reg2, src, dest);
}
static inline void gen_op_movl_T0_seg(DisasContext *s, X86Seg seg_reg)
@@ -2560,7 +2581,7 @@ static void gen_push_v(DisasContext *s, TCGv val)
if (!CODE64(s)) {
if (ADDSEG(s)) {
- new_esp = s->tmp4;
+ new_esp = tcg_temp_new();
tcg_gen_mov_tl(new_esp, s->A0);
}
gen_lea_v_seg(s, a_ot, s->A0, R_SS, -1);
@@ -2575,8 +2596,8 @@ static MemOp gen_pop_T0(DisasContext *s)
{
MemOp d_ot = mo_pushpop(s, s->dflag);
- gen_lea_v_seg(s, mo_stacksize(s), cpu_regs[R_ESP], R_SS, -1);
- gen_op_ld_v(s, d_ot, s->T0, s->A0);
+ gen_lea_v_seg_dest(s, mo_stacksize(s), s->T0, cpu_regs[R_ESP], R_SS, -1);
+ gen_op_ld_v(s, d_ot, s->T0, s->T0);
return d_ot;
}
@@ -4182,7 +4203,6 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
tcg_gen_mov_tl(s->A0, cpu_regs[R_EBX]);
tcg_gen_ext8u_tl(s->T0, cpu_regs[R_EAX]);
tcg_gen_add_tl(s->A0, s->A0, s->T0);
- gen_extu(s->aflag, s->A0);
gen_add_A0_ds_seg(s);
gen_op_ld_v(s, MO_8, s->T0, s->A0);
gen_op_mov_reg_v(s, MO_8, R_EAX, s->T0);
@@ -4930,6 +4950,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
case 0xaa: /* stosS */
case 0xab:
ot = mo_b_d(b, dflag);
+ gen_op_mov_v_reg(s, MO_32, s->T0, R_EAX);
if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) {
gen_repz_stos(s, ot);
} else {
@@ -4948,6 +4969,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
case 0xae: /* scasS */
case 0xaf:
ot = mo_b_d(b, dflag);
+ gen_op_mov_v_reg(s, MO_32, s->T0, R_EAX);
if (prefixes & PREFIX_REPNZ) {
gen_repz_scas(s, ot, 1);
} else if (prefixes & PREFIX_REPZ) {
@@ -5201,7 +5223,9 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
ot = dflag;
modrm = x86_ldub_code(env, s);
reg = ((modrm >> 3) & 7) | REX_R(s);
- gen_cmovcc1(env, s, ot, b, modrm, reg);
+ gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
+ gen_cmovcc1(s, b ^ 1, s->T0, cpu_regs[reg]);
+ gen_op_mov_reg_v(s, ot, reg, s->T0);
break;
/************************/
@@ -5834,7 +5858,6 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
gen_update_cc_op(s);
gen_update_eip_cur(s);
tcg_gen_mov_tl(s->A0, cpu_regs[R_EAX]);
- gen_extu(s->aflag, s->A0);
gen_add_A0_ds_seg(s);
gen_helper_monitor(tcg_env, s->A0);
break;
@@ -6941,6 +6964,7 @@ static void i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu)
dc->cpuid_ext3_features = env->features[FEAT_8000_0001_ECX];
dc->cpuid_7_0_ebx_features = env->features[FEAT_7_0_EBX];
dc->cpuid_7_0_ecx_features = env->features[FEAT_7_0_ECX];
+ dc->cpuid_7_1_eax_features = env->features[FEAT_7_1_EAX];
dc->cpuid_xsave_features = env->features[FEAT_XSAVE];
dc->jmp_opt = !((cflags & CF_NO_GOTO_TB) ||
(flags & (HF_TF_MASK | HF_INHIBIT_IRQ_MASK)));
diff --git a/target/mips/meson.build b/target/mips/meson.build
index e57ef24..a26d1e1 100644
--- a/target/mips/meson.build
+++ b/target/mips/meson.build
@@ -12,7 +12,7 @@ if have_system
subdir('sysemu')
endif
-if 'CONFIG_TCG' in config_all
+if 'CONFIG_TCG' in config_all_accel
subdir('tcg')
endif
diff --git a/tcg/meson.build b/tcg/meson.build
index 895a11d..5afdec1 100644
--- a/tcg/meson.build
+++ b/tcg/meson.build
@@ -22,7 +22,7 @@ if get_option('tcg_interpreter')
tcg_ss.add(files('tci.c'))
endif
-tcg_ss = tcg_ss.apply(config_targetos, strict: false)
+tcg_ss = tcg_ss.apply({})
libtcg_user = static_library('tcg_user',
tcg_ss.sources() + genh,
diff --git a/tests/bench/meson.build b/tests/bench/meson.build
index 3c799db..7e76338 100644
--- a/tests/bench/meson.build
+++ b/tests/bench/meson.build
@@ -3,9 +3,9 @@ qht_bench = executable('qht-bench',
sources: 'qht-bench.c',
dependencies: [qemuutil])
-qtree_bench = executable('qtree-bench',
- sources: 'qtree-bench.c',
- dependencies: [qemuutil])
+executable('qtree-bench',
+ sources: 'qtree-bench.c',
+ dependencies: [qemuutil])
executable('atomic_add-bench',
sources: files('atomic_add-bench.c'),
diff --git a/tests/fp/meson.build b/tests/fp/meson.build
index cbc1739..4ab89aa 100644
--- a/tests/fp/meson.build
+++ b/tests/fp/meson.build
@@ -1,9 +1,9 @@
-if 'CONFIG_TCG' not in config_all
+if 'CONFIG_TCG' not in config_all_accel
subdir_done()
endif
# There are namespace pollution issues on Windows, due to osdep.h
# bringing in Windows headers that define a FLOAT128 type.
-if targetos == 'windows'
+if host_os == 'windows'
subdir_done()
endif
diff --git a/tests/meson.build b/tests/meson.build
index 9996a29..0a6f96f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -68,7 +68,7 @@ test_deps = {
'test-qht-par': qht_bench,
}
-if have_tools and have_vhost_user and targetos == 'linux'
+if have_tools and have_vhost_user and host_os == 'linux'
executable('vhost-user-bridge',
sources: files('vhost-user-bridge.c'),
dependencies: [qemuutil, vhost_user])
@@ -76,7 +76,7 @@ endif
subdir('decode')
-if 'CONFIG_TCG' in config_all
+if 'CONFIG_TCG' in config_all_accel
subdir('fp')
endif
diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build
index 28a929d..e18183a 100644
--- a/tests/plugin/meson.build
+++ b/tests/plugin/meson.build
@@ -1,7 +1,7 @@
t = []
if get_option('plugins')
foreach i : ['bb', 'empty', 'insn', 'mem', 'syscall']
- if targetos == 'windows'
+ if host_os == 'windows'
t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c',
include_directories: '../../include/qemu',
link_depends: [win32_qemu_plugin_api_lib],
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
index 53847cb..fad340a 100644
--- a/tests/qemu-iotests/meson.build
+++ b/tests/qemu-iotests/meson.build
@@ -1,4 +1,4 @@
-if not have_tools or targetos == 'windows'
+if not have_tools or host_os == 'windows'
subdir_done()
endif
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 47dabf9..f25bffc 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -38,8 +38,8 @@ qtests_cxl = \
# for the availability of the default NICs in the tests
qtests_filter = \
(get_option('default_devices') and slirp.found() ? ['test-netfilter'] : []) + \
- (get_option('default_devices') and targetos != 'windows' ? ['test-filter-mirror'] : []) + \
- (get_option('default_devices') and targetos != 'windows' ? ['test-filter-redirector'] : [])
+ (get_option('default_devices') and host_os != 'windows' ? ['test-filter-mirror'] : []) + \
+ (get_option('default_devices') and host_os != 'windows' ? ['test-filter-redirector'] : [])
qtests_i386 = \
(slirp.found() ? ['pxe-test'] : []) + \
@@ -48,7 +48,7 @@ qtests_i386 = \
(config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
(config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) + \
(config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) + \
- (targetos == 'linux' and \
+ (host_os == 'linux' and \
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') and
config_all_devices.has_key('CONFIG_IPMI_EXTERN') ? ['ipmi-bt-test'] : []) + \
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
@@ -74,7 +74,7 @@ qtests_i386 = \
(config_all_devices.has_key('CONFIG_SB16') ? ['fuzz-sb16-test'] : []) + \
(config_all_devices.has_key('CONFIG_SDHCI_PCI') ? ['fuzz-sdcard-test'] : []) + \
(config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) + \
- (targetos != 'windows' and \
+ (host_os != 'windows' and \
config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) + \
(config_all_devices.has_key('CONFIG_PCIE_PORT') and \
config_all_devices.has_key('CONFIG_VIRTIO_NET') and \
@@ -155,8 +155,8 @@ qtests_ppc = \
qtests_filter + \
(config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
(config_all_devices.has_key('CONFIG_M48T59') ? ['m48t59-test'] : []) + \
- (config_all.has_key('CONFIG_TCG') ? ['prom-env-test'] : []) + \
- (config_all.has_key('CONFIG_TCG') ? ['boot-serial-test'] : []) + \
+ (config_all_accel.has_key('CONFIG_TCG') ? ['prom-env-test'] : []) + \
+ (config_all_accel.has_key('CONFIG_TCG') ? ['boot-serial-test'] : []) + \
['boot-order-test']
qtests_ppc64 = \
@@ -213,12 +213,12 @@ qtests_arm = \
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
qtests_aarch64 = \
(cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
- (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
+ (config_all_accel.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
(config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', 'xlnx-versal-trng-test'] : []) + \
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
- (config_all.has_key('CONFIG_TCG') and \
+ (config_all_accel.has_key('CONFIG_TCG') and \
config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
['arm-cpu-features',
'numa-test',
@@ -277,7 +277,7 @@ if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
qos_test_ss.add(files('virtio-serial-test.c'))
endif
-if targetos != 'windows'
+if host_os != 'windows'
qos_test_ss.add(files('e1000e-test.c'))
endif
if have_virtfs
@@ -310,7 +310,7 @@ qtests = {
'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
'migration-test': migration_files,
'pxe-test': files('boot-sector.c'),
- 'qos-test': [chardev, io, qos_test_ss.apply(config_targetos, strict: false).sources()],
+ 'qos-test': [chardev, io, qos_test_ss.apply({}).sources()],
'tpm-crb-swtpm-test': [io, tpmemu_files],
'tpm-crb-test': [io, tpmemu_files],
'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'],
diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target
index 3dec7c6..9906f9e 100644
--- a/tests/tcg/i386/Makefile.target
+++ b/tests/tcg/i386/Makefile.target
@@ -13,7 +13,7 @@ config-cc.mak: Makefile
I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
ALL_X86_TESTS=$(I386_SRCS:.c=)
-SKIP_I386_TESTS=test-i386-ssse3 test-avx test-3dnow test-mmx
+SKIP_I386_TESTS=test-i386-ssse3 test-avx test-3dnow test-mmx test-flags
X86_64_TESTS:=$(filter test-i386-adcox test-i386-bmi2 $(SKIP_I386_TESTS), $(ALL_X86_TESTS))
test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse
diff --git a/tests/tcg/i386/test-flags.c b/tests/tcg/i386/test-flags.c
new file mode 100644
index 0000000..c379e29
--- /dev/null
+++ b/tests/tcg/i386/test-flags.c
@@ -0,0 +1,37 @@
+#define _GNU_SOURCE
+#include <sys/mman.h>
+#include <signal.h>
+#include <stdio.h>
+#include <assert.h>
+
+volatile unsigned long flags;
+volatile unsigned long flags_after;
+int *addr;
+
+void sigsegv(int sig, siginfo_t *info, ucontext_t *uc)
+{
+ flags = uc->uc_mcontext.gregs[REG_EFL];
+ mprotect(addr, 4096, PROT_READ|PROT_WRITE);
+}
+
+int main()
+{
+ struct sigaction sa = { .sa_handler = (void *)sigsegv, .sa_flags = SA_SIGINFO };
+ sigaction(SIGSEGV, &sa, NULL);
+
+ /* fault in the page then protect it */
+ addr = mmap (NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
+ *addr = 0x1234;
+ mprotect(addr, 4096, PROT_READ);
+
+ asm("# set flags to all ones \n"
+ "mov $-1, %%eax \n"
+ "movq addr, %%rdi \n"
+ "sahf \n"
+ "sub %%eax, (%%rdi) \n"
+ "pushf \n"
+ "pop flags_after(%%rip) \n" : : : "eax", "edi", "memory");
+
+ /* OF can have any value before the SUB instruction. */
+ assert((flags & 0xff) == 0xd7 && (flags_after & 0x8ff) == 0x17);
+}
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index a05d471..69f9c05 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -100,7 +100,7 @@ if have_block
}
if gnutls.found() and \
tasn1.found() and \
- targetos != 'windows'
+ host_os != 'windows'
tests += {
'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c',
tasn1, crypto, gnutls],
@@ -115,7 +115,7 @@ if have_block
if xts == 'private'
tests += {'test-crypto-xts': [crypto, io]}
endif
- if targetos != 'windows'
+ if host_os != 'windows'
tests += {
'test-image-locking': [testblock],
'test-nested-aio-poll': [testblock],
@@ -150,7 +150,7 @@ if have_system
# are not runnable under TSan due to a known issue.
# https://github.com/google/sanitizers/issues/1116
if not get_option('tsan')
- if targetos != 'windows'
+ if host_os != 'windows'
tests += {
'test-char': ['socket-helpers.c', qom, io, chardev]
}
@@ -162,7 +162,7 @@ if have_system
endif
endif
-if have_ga and targetos == 'linux'
+if have_ga and host_os == 'linux'
tests += {'test-qga': ['../qtest/libqmp.c']}
test_deps += {'test-qga': qga}
endif
diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml
index f0e2fac..ce35d64 100644
--- a/ui/dbus-display1.xml
+++ b/ui/dbus-display1.xml
@@ -71,7 +71,7 @@
:dbus:iface:`org.qemu.Display1.Listener` interface.
-->
<method name="RegisterListener">
- <?if $(env.TARGETOS) == windows?>
+ <?if $(env.HOST_OS) == windows?>
<arg type="ay" name="listener" direction="in">
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
@@ -370,7 +370,7 @@
</arg>
</method>
- <?if $(env.TARGETOS) != windows?>
+ <?if $(env.HOST_OS) != windows?>
<!--
ScanoutDMABUF:
@dmabuf: the DMABUF file descriptor.
@@ -694,7 +694,7 @@
:dbus:iface:`org.qemu.Display1.AudioOutListener` interface.
-->
<method name="RegisterOutListener">
- <?if $(env.TARGETOS) == windows?>
+ <?if $(env.HOST_OS) == windows?>
<arg type="ay" name="listener" direction="in">
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
@@ -715,7 +715,7 @@
:dbus:iface:`org.qemu.Display1.AudioInListener` interface.
-->
<method name="RegisterInListener">
- <?if $(env.TARGETOS) == windows?>
+ <?if $(env.HOST_OS) == windows?>
<arg type="ay" name="listener" direction="in">
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
@@ -976,7 +976,7 @@
The current handler, if any, will be replaced.
-->
<method name="Register">
- <?if $(env.TARGETOS) == windows?>
+ <?if $(env.HOST_OS) == windows?>
<arg type="ay" name="listener" direction="in">
<annotation name="org.gtk.GDBus.C.ForceGVariant" value="true"/>
</arg>
diff --git a/ui/meson.build b/ui/meson.build
index 0ccb338..376e0d7 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -25,10 +25,9 @@ endif
system_ss.add([spice_headers, files('spice-module.c')])
system_ss.add(when: spice_protocol, if_true: files('vdagent.c'))
-system_ss.add(when: 'CONFIG_LINUX', if_true: files(
- 'input-linux.c',
- 'udmabuf.c',
-))
+if host_os == 'linux'
+ system_ss.add(files('input-linux.c', 'udmabuf.c'))
+endif
system_ss.add(when: cocoa, if_true: files('cocoa.m'))
vnc_ss = ss.source_set()
@@ -76,7 +75,7 @@ endif
if dbus_display
dbus_ss = ss.source_set()
env = environment()
- env.set('TARGETOS', targetos)
+ env.set('HOST_OS', host_os)
xml = custom_target('dbus-display preprocess',
input: 'dbus-display1.xml',
output: 'dbus-display1.xml',
@@ -106,7 +105,9 @@ if dbus_display
endif
if gtk.found()
- system_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c'))
+ if host_os == 'windows'
+ system_ss.add(files('win32-kbd-hook.c'))
+ endif
gtk_ss = ss.source_set()
gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
@@ -120,7 +121,9 @@ if gtk.found()
endif
if sdl.found()
- system_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c'))
+ if host_os == 'windows'
+ system_ss.add(files('win32-kbd-hook.c'))
+ endif
sdl_ss = ss.source_set()
sdl_ss.add(sdl, sdl_image, pixman, glib, files(
diff --git a/util/meson.build b/util/meson.build
index 174c133..af3bf56 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -3,28 +3,31 @@ util_ss.add(files('thread-context.c'), numa)
if not config_host_data.get('CONFIG_ATOMIC64')
util_ss.add(files('atomic64.c'))
endif
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('aio-posix.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('fdmon-poll.c'))
-if config_host_data.get('CONFIG_EPOLL_CREATE1')
- util_ss.add(files('fdmon-epoll.c'))
+if host_os != 'windows'
+ util_ss.add(files('aio-posix.c'))
+ util_ss.add(files('fdmon-poll.c'))
+ if config_host_data.get('CONFIG_EPOLL_CREATE1')
+ util_ss.add(files('fdmon-epoll.c'))
+ endif
+ util_ss.add(files('compatfd.c'))
+ util_ss.add(files('event_notifier-posix.c'))
+ util_ss.add(files('mmap-alloc.c'))
+ freebsd_dep = []
+ if host_os == 'freebsd'
+ freebsd_dep = util
+ endif
+ util_ss.add(files('oslib-posix.c'), freebsd_dep)
+ util_ss.add(files('qemu-thread-posix.c'))
+ util_ss.add(files('memfd.c'))
+ util_ss.add(files('drm.c'))
+else
+ util_ss.add(files('aio-win32.c'))
+ util_ss.add(files('event_notifier-win32.c'))
+ util_ss.add(files('oslib-win32.c'))
+ util_ss.add(files('qemu-thread-win32.c'))
+ util_ss.add(winmm, pathcch)
endif
util_ss.add(when: linux_io_uring, if_true: files('fdmon-io_uring.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('compatfd.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('event_notifier-posix.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('mmap-alloc.c'))
-freebsd_dep = []
-if targetos == 'freebsd'
- freebsd_dep = util
-endif
-util_ss.add(when: 'CONFIG_POSIX', if_true: [files('oslib-posix.c'), freebsd_dep])
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('qemu-thread-posix.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('memfd.c'))
-util_ss.add(when: 'CONFIG_WIN32', if_true: files('aio-win32.c'))
-util_ss.add(when: 'CONFIG_WIN32', if_true: files('event_notifier-win32.c'))
-util_ss.add(when: 'CONFIG_WIN32', if_true: files('oslib-win32.c'))
-util_ss.add(when: 'CONFIG_WIN32', if_true: files('qemu-thread-win32.c'))
-util_ss.add(when: 'CONFIG_WIN32', if_true: winmm)
-util_ss.add(when: 'CONFIG_WIN32', if_true: pathcch)
if glib_has_gslice
util_ss.add(files('qtree.c'))
endif
@@ -56,7 +59,6 @@ util_ss.add(files('reserved-region.c'))
util_ss.add(files('stats64.c'))
util_ss.add(files('systemd.c'))
util_ss.add(files('transactions.c'))
-util_ss.add(when: 'CONFIG_POSIX', if_true: files('drm.c'))
util_ss.add(files('guest-random.c'))
util_ss.add(files('yank.c'))
util_ss.add(files('int128.c'))
@@ -71,7 +73,9 @@ endif
if have_system
util_ss.add(files('crc-ccitt.c'))
util_ss.add(when: gio, if_true: files('dbus.c'))
- util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c'))
+ if host_os == 'linux'
+ util_ss.add(files('userfaultfd.c'))
+ endif
endif
if have_block or have_ga
@@ -92,9 +96,6 @@ if have_block
util_ss.add(files('iova-tree.c'))
util_ss.add(files('iov.c', 'uri.c'))
util_ss.add(files('nvdimm-utils.c'))
- util_ss.add(when: 'CONFIG_LINUX', if_true: [
- files('vhost-user-server.c'), vhost_user
- ])
util_ss.add(files('block-helpers.c'))
util_ss.add(files('qemu-coroutine-sleep.c'))
util_ss.add(files('qemu-co-shared-resource.c'))
@@ -107,8 +108,11 @@ if have_block
else
util_ss.add(files('filemonitor-stub.c'))
endif
- util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))
- util_ss.add(when: 'CONFIG_LINUX', if_true: files('chardev_open.c'))
+ if host_os == 'linux'
+ util_ss.add(files('vhost-user-server.c'), vhost_user)
+ util_ss.add(files('vfio-helpers.c'))
+ util_ss.add(files('chardev_open.c'))
+ endif
endif
if cpu == 'aarch64'