Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge tag 'pull-tcg-20230620' of https://gitlab.com/rth7680/qemu into…
… staging

tcg: Define _CALL_AIX for clang on ppc64
accel/tcg: Build fix for macos catalina
accel/tcg: Handle MO_ATOM_WITHIN16 in do_st16_leN
accel/tcg: Restrict SavedIOTLB to system emulation
accel/tcg: Use generic 'helper-proto-common.h' header
plugins: Remove unused 'exec/helper-proto.h' header
*: Check for CONFIG_USER_ONLY instead of CONFIG_SOFTMMU

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmSRYmIdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8zbAgAlX4GcShS1OU1BDRe
# b0HHHj1fFBB/9yk8f/5WuQb2snYS+pcZCez9XeT175ugovXSOz+shvmFrbRPvpfj
# q8C88CIKCJRsXnhWqKWOKDqgTttu2WNXOvCe0eCZbUoGQ9K1seMvUBq6T50fNv2H
# fXeHtLSu/+jiHIN3+woJqdgrkp0cko2rrpnwIpjuIsY1iz/J/VKEHmnv7Ah+GsRs
# OTYnR7iN6uhBXVll14r3UCylbgdEz58sSSEi3dYYfaTRuijDwOzM0evhk6+5XzHP
# DYwGdbtDE5HJOrCLiKegk80Gh6v1XVZQWnn9PdiN1eJcQsWNT9mYV9/4IsCVrsF4
# 8r5KUg==
# =JmjK
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 20 Jun 2023 10:25:06 AM CEST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-tcg-20230620' of https://gitlab.com/rth7680/qemu:
  cputlb: Restrict SavedIOTLB to system emulation
  exec/cpu-defs: Check for SOFTMMU instead of !USER_ONLY
  accel/tcg/cpu-exec: Use generic 'helper-proto-common.h' header
  plugins: Remove unused 'exec/helper-proto.h' header
  meson: Replace softmmu_ss -> system_ss
  meson: Replace CONFIG_SOFTMMU -> CONFIG_SYSTEM_ONLY
  meson: Alias CONFIG_SOFTMMU -> CONFIG_SYSTEM_ONLY
  accel/tcg: Check for USER_ONLY definition instead of SOFTMMU one
  hw/core/cpu: Check for USER_ONLY definition instead of SOFTMMU one
  target/ppc: Check for USER_ONLY definition instead of SOFTMMU one
  target/m68k: Check for USER_ONLY definition instead of SOFTMMU one
  target/tricore: Remove pointless CONFIG_SOFTMMU guard
  target/i386: Simplify i386_tr_init_disas_context()
  tcg/ppc: Define _CALL_AIX for clang on ppc64(be)
  accel/tcg: Handle MO_ATOM_WITHIN16 in do_st16_leN
  host/include/x86_64: Use __m128i for "x" constraints

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jun 20, 2023
2 parents 48ab886 + d7ee93e commit cab35c7
Show file tree
Hide file tree
Showing 125 changed files with 872 additions and 862 deletions.
4 changes: 2 additions & 2 deletions accel/meson.build
@@ -1,5 +1,5 @@
specific_ss.add(files('accel-common.c', 'accel-blocker.c'))
softmmu_ss.add(files('accel-softmmu.c'))
system_ss.add(files('accel-softmmu.c'))
user_ss.add(files('accel-user.c'))

subdir('tcg')
Expand All @@ -12,4 +12,4 @@ if have_system
endif

# qtest
softmmu_ss.add(files('dummy-cpus.c'))
system_ss.add(files('dummy-cpus.c'))
2 changes: 1 addition & 1 deletion accel/qtest/meson.build
@@ -1 +1 @@
qtest_module_ss.add(when: ['CONFIG_SOFTMMU'], if_true: files('qtest.c'))
qtest_module_ss.add(when: ['CONFIG_SYSTEM_ONLY'], if_true: files('qtest.c'))
2 changes: 1 addition & 1 deletion accel/stubs/meson.build
Expand Up @@ -4,4 +4,4 @@ sysemu_stubs_ss.add(when: 'CONFIG_XEN', if_false: files('xen-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
sysemu_stubs_ss.add(when: 'CONFIG_TCG', if_false: files('tcg-stub.c'))

specific_ss.add_all(when: ['CONFIG_SOFTMMU'], if_true: sysemu_stubs_ss)
specific_ss.add_all(when: ['CONFIG_SYSTEM_ONLY'], if_true: sysemu_stubs_ss)
6 changes: 3 additions & 3 deletions accel/tcg/cpu-exec.c
Expand Up @@ -38,7 +38,7 @@
#include "sysemu/cpu-timers.h"
#include "exec/replay-core.h"
#include "sysemu/tcg.h"
#include "exec/helper-proto.h"
#include "exec/helper-proto-common.h"
#include "tb-jmp-cache.h"
#include "tb-hash.h"
#include "tb-context.h"
Expand Down Expand Up @@ -566,7 +566,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
cpu_tb_exec(cpu, tb, &tb_exit);
cpu_exec_exit(cpu);
} else {
#ifndef CONFIG_SOFTMMU
#ifdef CONFIG_USER_ONLY
clear_helper_retaddr();
if (have_mmap_lock()) {
mmap_unlock();
Expand Down Expand Up @@ -1023,7 +1023,7 @@ static int cpu_exec_setjmp(CPUState *cpu, SyncClocks *sc)
/* Non-buggy compilers preserve this; assert the correct value. */
g_assert(cpu == current_cpu);

#ifndef CONFIG_SOFTMMU
#ifdef CONFIG_USER_ONLY
clear_helper_retaddr();
if (have_mmap_lock()) {
mmap_unlock();
Expand Down
1 change: 1 addition & 0 deletions accel/tcg/cputlb.c
Expand Up @@ -2727,6 +2727,7 @@ static uint64_t do_st16_leN(CPUArchState *env, MMULookupPageData *p,
* and so neither is atomic.
*/
case MO_ATOM_IFALIGN:
case MO_ATOM_WITHIN16:
case MO_ATOM_NONE:
stq_le_p(p->haddr, int128_getlo(val_le));
return store_bytes_leN(p->haddr + 8, p->size - 8,
Expand Down
6 changes: 3 additions & 3 deletions accel/tcg/internal.h
Expand Up @@ -17,10 +17,10 @@
* memory related structures are protected with mmap_lock.
* In !user-mode we use per-page locks.
*/
#ifdef CONFIG_SOFTMMU
#define assert_memory_lock()
#else
#ifdef CONFIG_USER_ONLY
#define assert_memory_lock() tcg_debug_assert(have_mmap_lock())
#else
#define assert_memory_lock()
#endif

#if defined(CONFIG_SOFTMMU) && defined(CONFIG_DEBUG_TCG)
Expand Down
6 changes: 3 additions & 3 deletions accel/tcg/meson.build
Expand Up @@ -10,18 +10,18 @@ tcg_ss.add(files(
'translator.c',
))
tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c'))
tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c'))
tcg_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_false: files('user-exec-stub.c'))
tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c')])
tcg_ss.add(when: libdw, if_true: files('debuginfo.c'))
tcg_ss.add(when: 'CONFIG_LINUX', if_true: files('perf.c'))
specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)

specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
specific_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
'cputlb.c',
'monitor.c',
))

tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
tcg_module_ss.add(when: ['CONFIG_SYSTEM_ONLY', 'CONFIG_TCG'], if_true: files(
'tcg-accel-ops.c',
'tcg-accel-ops-mttcg.c',
'tcg-accel-ops-icount.c',
Expand Down
8 changes: 4 additions & 4 deletions audio/meson.build
@@ -1,5 +1,5 @@
softmmu_ss.add([spice_headers, files('audio.c')])
softmmu_ss.add(files(
system_ss.add([spice_headers, files('audio.c')])
system_ss.add(files(
'audio-hmp-cmds.c',
'audio_legacy.c',
'mixeng.c',
Expand All @@ -8,8 +8,8 @@ softmmu_ss.add(files(
'wavcapture.c',
))

softmmu_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
softmmu_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))
system_ss.add(when: coreaudio, if_true: files('coreaudio.m'))
system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int.c'))

audio_modules = {}
foreach m : [
Expand Down
20 changes: 10 additions & 10 deletions backends/meson.build
@@ -1,4 +1,4 @@
softmmu_ss.add([files(
system_ss.add([files(
'cryptodev-builtin.c',
'cryptodev-hmp-cmds.c',
'cryptodev.c',
Expand All @@ -10,20 +10,20 @@ softmmu_ss.add([files(
'confidential-guest-support.c',
), numa])

softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files('rng-random.c'))
softmmu_ss.add(when: 'CONFIG_POSIX', if_true: files('hostmem-file.c'))
softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('hostmem-memfd.c'))
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 keyutils.found()
softmmu_ss.add(keyutils, files('cryptodev-lkcf.c'))
system_ss.add(keyutils, files('cryptodev-lkcf.c'))
endif
if have_vhost_user
softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('vhost-user.c'))
system_ss.add(when: 'CONFIG_VIRTIO', if_true: files('vhost-user.c'))
endif
softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c'))
system_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c'))
if have_vhost_user_crypto
softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost-user.c'))
system_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost-user.c'))
endif
softmmu_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
softmmu_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
system_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))

subdir('tpm')
8 changes: 4 additions & 4 deletions backends/tpm/meson.build
@@ -1,6 +1,6 @@
if have_tpm
softmmu_ss.add(files('tpm_backend.c'))
softmmu_ss.add(files('tpm_util.c'))
softmmu_ss.add(when: 'CONFIG_TPM_PASSTHROUGH', if_true: files('tpm_passthrough.c'))
softmmu_ss.add(when: 'CONFIG_TPM_EMULATOR', if_true: files('tpm_emulator.c'))
system_ss.add(files('tpm_backend.c'))
system_ss.add(files('tpm_util.c'))
system_ss.add(when: 'CONFIG_TPM_PASSTHROUGH', if_true: files('tpm_passthrough.c'))
system_ss.add(when: 'CONFIG_TPM_EMULATOR', if_true: files('tpm_emulator.c'))
endif
6 changes: 3 additions & 3 deletions block/meson.build
Expand Up @@ -42,8 +42,8 @@ block_ss.add(files(
'write-threshold.c',
), zstd, zlib, gnutls)

softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
softmmu_ss.add(files('block-ram-registrar.c'))
system_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
system_ss.add(files('block-ram-registrar.c'))

if get_option('qcow1').allowed()
block_ss.add(files('qcow.c'))
Expand Down Expand Up @@ -159,7 +159,7 @@ block_ss.add(block_gen_c)

block_ss.add(files('stream.c'))

softmmu_ss.add(files('qapi-sysemu.c'))
system_ss.add(files('qapi-sysemu.c'))

subdir('export')
subdir('monitor')
Expand Down
2 changes: 1 addition & 1 deletion block/monitor/meson.build
@@ -1,2 +1,2 @@
softmmu_ss.add(files('block-hmp-cmds.c'))
system_ss.add(files('block-hmp-cmds.c'))
block_ss.add(files('bitmap-qmp-cmds.c'))
2 changes: 1 addition & 1 deletion chardev/meson.build
Expand Up @@ -28,7 +28,7 @@ chardev_ss.add(when: 'CONFIG_WIN32', if_true: files(

chardev_ss = chardev_ss.apply(config_host, strict: false)

softmmu_ss.add(files(
system_ss.add(files(
'char-hmp-cmds.c',
'msmouse.c',
'wctablet.c',
Expand Down
2 changes: 1 addition & 1 deletion disas/meson.build
Expand Up @@ -13,5 +13,5 @@ common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('xtensa.c'))
common_ss.add(when: capstone, if_true: [files('capstone.c'), capstone])
common_ss.add(files('disas.c'))

softmmu_ss.add(files('disas-mon.c'))
system_ss.add(files('disas-mon.c'))
specific_ss.add(capstone)
14 changes: 7 additions & 7 deletions docs/devel/build-system.rst
Expand Up @@ -183,9 +183,9 @@ Target-independent emulator sourcesets:
This includes error handling infrastructure, standard data structures,
platform portability wrapper functions, etc.

Target-independent code lives in the ``common_ss``, ``softmmu_ss`` and
Target-independent code lives in the ``common_ss``, ``system_ss`` and
``user_ss`` sourcesets. ``common_ss`` is linked into all emulators,
``softmmu_ss`` only in system emulators, ``user_ss`` only in user-mode
``system_ss`` only in system emulators, ``user_ss`` only in user-mode
emulators.

Target-independent sourcesets must exercise particular care when using
Expand All @@ -197,11 +197,11 @@ Target-independent emulator sourcesets:
symbol::

# Some targets have CONFIG_ACPI, some don't, so this is not enough
softmmu_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi.c'),
system_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi.c'),
if_false: files('acpi-stub.c'))

# This is required as well:
softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c'))
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
Expand Down Expand Up @@ -229,16 +229,16 @@ Target-dependent emulator sourcesets:
for all emulators and for system emulators only. For example::

arm_ss = ss.source_set()
arm_softmmu_ss = ss.source_set()
arm_system_ss = ss.source_set()
...
target_arch += {'arm': arm_ss}
target_softmmu_arch += {'arm': arm_softmmu_ss}
target_softmmu_arch += {'arm': arm_system_ss}

Module sourcesets:
There are two dictionaries for modules: ``modules`` is used for
target-independent modules and ``target_modules`` is used for
target-dependent modules. When modules are disabled the ``module``
source sets are added to ``softmmu_ss`` and the ``target_modules``
source sets are added to ``system_ss`` and the ``target_modules``
source sets are added to ``specific_ss``.

Both dictionaries are nested. One dictionary is created per
Expand Down
4 changes: 2 additions & 2 deletions dump/meson.build
@@ -1,2 +1,2 @@
softmmu_ss.add([files('dump.c', 'dump-hmp-cmds.c'), snappy, lzo])
specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: files('win_dump.c'))
system_ss.add([files('dump.c', 'dump-hmp-cmds.c'), snappy, lzo])
specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: files('win_dump.c'))
2 changes: 1 addition & 1 deletion ebpf/meson.build
@@ -1 +1 @@
softmmu_ss.add(when: libbpf, if_true: files('ebpf_rss.c'), if_false: files('ebpf_rss-stub.c'))
system_ss.add(when: libbpf, if_true: files('ebpf_rss.c'), if_false: files('ebpf_rss-stub.c'))
4 changes: 2 additions & 2 deletions fsdev/meson.build
Expand Up @@ -6,8 +6,8 @@ fsdev_ss.add(when: ['CONFIG_FSDEV_9P'], if_true: files(
'9p-marshal.c',
'qemu-fsdev.c',
), if_false: files('qemu-fsdev-dummy.c'))
softmmu_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss)
softmmu_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss)
system_ss.add_all(when: 'CONFIG_LINUX', if_true: fsdev_ss)
system_ss.add_all(when: 'CONFIG_DARWIN', if_true: fsdev_ss)

if have_virtfs_proxy_helper
executable('virtfs-proxy-helper',
Expand Down
10 changes: 5 additions & 5 deletions gdbstub/meson.build
Expand Up @@ -8,14 +8,14 @@
# cflags so:

gdb_user_ss = ss.source_set()
gdb_softmmu_ss = ss.source_set()
gdb_system_ss = ss.source_set()

# We build two versions of gdbstub, one for each mode
gdb_user_ss.add(files('gdbstub.c', 'user.c'))
gdb_softmmu_ss.add(files('gdbstub.c', 'softmmu.c'))
gdb_system_ss.add(files('gdbstub.c', 'softmmu.c'))

gdb_user_ss = gdb_user_ss.apply(config_host, strict: false)
gdb_softmmu_ss = gdb_softmmu_ss.apply(config_host, strict: false)
gdb_system_ss = gdb_system_ss.apply(config_host, strict: false)

libgdb_user = static_library('gdb_user',
gdb_user_ss.sources() + genh,
Expand All @@ -24,14 +24,14 @@ libgdb_user = static_library('gdb_user',
build_by_default: have_user)

libgdb_softmmu = static_library('gdb_softmmu',
gdb_softmmu_ss.sources() + genh,
gdb_system_ss.sources() + genh,
name_suffix: 'fa',
build_by_default: have_system)

gdb_user = declare_dependency(link_whole: libgdb_user)
user_ss.add(gdb_user)
gdb_softmmu = declare_dependency(link_whole: libgdb_softmmu)
softmmu_ss.add(gdb_softmmu)
system_ss.add(gdb_softmmu)

common_ss.add(files('syscalls.c'))

Expand Down
25 changes: 16 additions & 9 deletions host/include/x86_64/host/atomic128-ldst.h
Expand Up @@ -8,12 +8,19 @@
* atomic primitive is meant to provide.
*/

#ifndef AARCH64_ATOMIC128_LDST_H
#define AARCH64_ATOMIC128_LDST_H
#ifndef X86_64_ATOMIC128_LDST_H
#define X86_64_ATOMIC128_LDST_H

#ifdef CONFIG_INT128_TYPE
#include "host/cpuinfo.h"
#include "tcg/debug-assert.h"
#include <immintrin.h>

typedef union {
__m128i v;
__int128_t i;
Int128 s;
} X86Int128Union;

/*
* Through clang 16, with -mcx16, __atomic_load_n is incorrectly
Expand All @@ -25,21 +32,21 @@

static inline Int128 atomic16_read_ro(const Int128 *ptr)
{
Int128Alias r;
X86Int128Union r;

tcg_debug_assert(HAVE_ATOMIC128_RO);
asm("vmovdqa %1, %0" : "=x" (r.i) : "m" (*ptr));
asm("vmovdqa %1, %0" : "=x" (r.v) : "m" (*ptr));

return r.s;
}

static inline Int128 atomic16_read_rw(Int128 *ptr)
{
__int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
Int128Alias r;
X86Int128Union r;

if (HAVE_ATOMIC128_RO) {
asm("vmovdqa %1, %0" : "=x" (r.i) : "m" (*ptr_align));
asm("vmovdqa %1, %0" : "=x" (r.v) : "m" (*ptr_align));
} else {
r.i = __sync_val_compare_and_swap_16(ptr_align, 0, 0);
}
Expand All @@ -49,10 +56,10 @@ static inline Int128 atomic16_read_rw(Int128 *ptr)
static inline void atomic16_set(Int128 *ptr, Int128 val)
{
__int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
Int128Alias new = { .s = val };
X86Int128Union new = { .s = val };

if (HAVE_ATOMIC128_RO) {
asm("vmovdqa %1, %0" : "=m"(*ptr_align) : "x" (new.i));
asm("vmovdqa %1, %0" : "=m"(*ptr_align) : "x" (new.v));
} else {
__int128_t old;
do {
Expand All @@ -65,4 +72,4 @@ static inline void atomic16_set(Int128 *ptr, Int128 val)
#include "host/include/generic/host/atomic128-ldst.h"
#endif

#endif /* AARCH64_ATOMIC128_LDST_H */
#endif /* X86_64_ATOMIC128_LDST_H */
8 changes: 4 additions & 4 deletions host/include/x86_64/host/load-extract-al16-al8.h
Expand Up @@ -9,7 +9,7 @@
#define X86_64_LOAD_EXTRACT_AL16_AL8_H

#ifdef CONFIG_INT128_TYPE
#include "host/cpuinfo.h"
#include "host/atomic128-ldst.h"

/**
* load_atom_extract_al16_or_al8:
Expand All @@ -26,7 +26,7 @@ load_atom_extract_al16_or_al8(void *pv, int s)
uintptr_t pi = (uintptr_t)pv;
__int128_t *ptr_align = (__int128_t *)(pi & ~7);
int shr = (pi & 7) * 8;
Int128Alias r;
X86Int128Union r;

/*
* ptr_align % 16 is now only 0 or 8.
Expand All @@ -35,9 +35,9 @@ load_atom_extract_al16_or_al8(void *pv, int s)
* when ptr_align % 16 == 0 for 16-byte atomicity.
*/
if ((cpuinfo & CPUINFO_ATOMIC_VMOVDQU) || (pi & 8)) {
asm("vmovdqu %1, %0" : "=x" (r.i) : "m" (*ptr_align));
asm("vmovdqu %1, %0" : "=x" (r.v) : "m" (*ptr_align));
} else {
asm("vmovdqa %1, %0" : "=x" (r.i) : "m" (*ptr_align));
asm("vmovdqa %1, %0" : "=x" (r.v) : "m" (*ptr_align));
}
return int128_getlo(int128_urshift(r.s, shr));
}
Expand Down

0 comments on commit cab35c7

Please sign in to comment.