Skip to content

Commit

Permalink
Merge tag 'pull-omnibus-111023-1' of https://gitlab.com/stsquad/qemu
Browse files Browse the repository at this point in the history
…into staging

testing, gdbstub and plugin updates

  - enable more sbsa-ref tests in avocado
  - add swtpm to the package lists
  - reduce avocado noise in gitlab by limiting tests
  - make docker engine choice driven by configure and enable override
  - remove unneeded gcc suffix on some cross compilers
  - fix some NULL returns in gdbstub
  - improve locking in execlog plugin
  - introduce the GDBFeature structure
  - consistently set gdb_core_xml_file
  - use cleaner escaping for gdb xml
  - drop ancient gdb_has_xml() test
  - disable multi-instruction GUSA emulation when plugins enabled
  - fix some coverity issues in plugins

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmUmVJkACgkQ+9DbCVqe
# KkTfNggAiS02FcL3faGjAN9+60xhvEQ3DJjI473hjvFWu0bSkQTjObcQqGc+V7Cw
# 9yNtnxOOWB6KdAU8At7HlVqiUXeyTCJB7Att5/UgNUZj63j+cs7PXb4p7cVCcJOc
# 17zni22tnmCBcC8wZaz0yj68jaftL3hz1QNUZOmv6CBt42q0+/4g1WKfaJ+w+SbK
# T7cJEiMDObm8qeNAAXpDLB+9v3bRDxMZ8hFJ3p3CatQC8jbDrkuH7RrVPHDWiWQx
# w0uXpUHlZEOVX23v6+iIoeb8YQW2bZI9UsfeyIHJlENaVgyL200LHgLvvAE4Qd63
# dCtfQUZzj4t9sfoL4XgxaB7G4qtXTg==
# =7PLI
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 11 Oct 2023 03:54:01 EDT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* tag 'pull-omnibus-111023-1' of https://gitlab.com/stsquad/qemu: (25 commits)
  contrib/plugins: fix coverity warning in hotblocks
  contrib/plugins: fix coverity warning in lockstep
  contrib/plugins: fix coverity warning in cache
  plugins: Set final instruction count in plugin_gen_tb_end
  target/sh4: Disable decode_gusa when plugins enabled
  accel/tcg: Add plugin_enabled to DisasContextBase
  gdbstub: Replace gdb_regs with an array
  gdbstub: Remove gdb_has_xml variable
  target/ppc: Remove references to gdb_has_xml
  target/arm: Remove references to gdb_has_xml
  gdbstub: Use g_markup_printf_escaped()
  hw/core/cpu: Return static value with gdb_arch_name()
  target/arm: Move the reference to arm-core.xml
  gdbstub: Introduce GDBFeature structure
  contrib/plugins: Use GRWLock in execlog
  plugins: Check if vCPU is realized
  gdbstub: Fix target.xml response
  gdbstub: Fix target_xml initialization
  configure: remove gcc version suffixes
  configure: allow user to override docker engine
  ...

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Oct 11, 2023
2 parents 4874793 + 5b982f3 commit a51e512
Show file tree
Hide file tree
Showing 50 changed files with 305 additions and 274 deletions.
15 changes: 11 additions & 4 deletions .gitlab-ci.d/buildtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ avocado-system-alpine:
variables:
IMAGE: alpine
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:avr arch:loongarch64 arch:mips64 arch:mipsel

build-system-ubuntu:
extends:
Expand All @@ -40,8 +41,7 @@ build-system-ubuntu:
variables:
IMAGE: ubuntu2204
CONFIGURE_ARGS: --enable-docs
TARGETS: alpha-softmmu cris-softmmu hppa-softmmu
microblazeel-softmmu mips64el-softmmu
TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu
MAKE_CHECK_ARGS: check-build

check-system-ubuntu:
Expand All @@ -61,6 +61,7 @@ avocado-system-ubuntu:
variables:
IMAGE: ubuntu2204
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:alpha arch:microblaze arch:mips64el

build-system-debian:
extends:
Expand All @@ -72,7 +73,7 @@ build-system-debian:
IMAGE: debian-amd64
CONFIGURE_ARGS: --with-coroutine=sigaltstack
TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu
sparc-softmmu xtensaeb-softmmu
sparc-softmmu xtensa-softmmu
MAKE_CHECK_ARGS: check-build

check-system-debian:
Expand All @@ -92,6 +93,7 @@ avocado-system-debian:
variables:
IMAGE: debian-amd64
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:arm arch:i386 arch:riscv64 arch:sh4 arch:sparc arch:xtensa

crash-test-debian:
extends: .native_test_job_template
Expand All @@ -114,7 +116,7 @@ build-system-fedora:
variables:
IMAGE: fedora
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs
TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu
TARGETS: microblaze-softmmu mips-softmmu
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
MAKE_CHECK_ARGS: check-build

Expand All @@ -135,6 +137,8 @@ avocado-system-fedora:
variables:
IMAGE: fedora
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:microblaze arch:mips arch:xtensa arch:m68k
arch:riscv32 arch:ppc arch:sparc64

crash-test-fedora:
extends: .native_test_job_template
Expand Down Expand Up @@ -180,6 +184,8 @@ avocado-system-centos:
variables:
IMAGE: centos8
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:ppc64 arch:or1k arch:390x arch:x86_64 arch:rx
arch:sh4 arch:nios2

build-system-opensuse:
extends:
Expand Down Expand Up @@ -209,6 +215,7 @@ avocado-system-opensuse:
variables:
IMAGE: opensuse-leap
MAKE_CHECK_ARGS: check-avocado
AVOCADO_TAGS: arch:s390x arch:x86_64 arch:aarch64


# This jobs explicitly disable TCG (--disable-tcg), KVM is detected by
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.d/cirrus/macos-12.vars
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ MAKE='/opt/homebrew/bin/gmake'
NINJA='/opt/homebrew/bin/ninja'
PACKAGING_COMMAND='brew'
PIP3='/opt/homebrew/bin/pip3'
PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol tesseract usbredir vde vte3 xorriso zlib zstd'
PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol swtpm tesseract usbredir vde vte3 xorriso zlib zstd'
PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli'
PYTHON='/opt/homebrew/bin/python3'
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ F: include/exec/gdbstub.h
F: include/gdbstub/*
F: gdb-xml/
F: tests/tcg/multiarch/gdbstub/
F: scripts/feature_to_c.sh
F: scripts/feature_to_c.py
F: scripts/probe-gdb-support.py

Memory API
Expand Down
6 changes: 5 additions & 1 deletion accel/tcg/plugin-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,14 @@ void plugin_gen_insn_end(void)
* do any clean-up here and make sure things are reset in
* plugin_gen_tb_start.
*/
void plugin_gen_tb_end(CPUState *cpu)
void plugin_gen_tb_end(CPUState *cpu, size_t num_insns)
{
struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb;

/* translator may have removed instructions, update final count */
g_assert(num_insns <= ptb->n);
ptb->n = num_insns;

/* collect instrumentation requests */
qemu_plugin_tb_trans_cb(cpu, ptb);

Expand Down
3 changes: 2 additions & 1 deletion accel/tcg/translator.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
} else {
plugin_enabled = plugin_gen_tb_start(cpu, db, false);
}
db->plugin_enabled = plugin_enabled;

while (true) {
*max_insns = ++db->num_insns;
Expand Down Expand Up @@ -209,7 +210,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
gen_tb_end(tb, cflags, icount_start_insn, db->num_insns);

if (plugin_enabled) {
plugin_gen_tb_end(cpu);
plugin_gen_tb_end(cpu, db->num_insns);
}

/* The disas_log hook may use these values rather than recompute. */
Expand Down
13 changes: 8 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ fi
# some defaults, based on the host environment

# default parameters
container_engine="auto"
cpu=""
cross_compile="no"
cross_prefix=""
Expand Down Expand Up @@ -787,6 +788,8 @@ for opt do
;;
--disable-containers) use_containers="no"
;;
--container-engine=*) container_engine="$optarg"
;;
--gdb=*) gdb_bin="$optarg"
;;
# everything else has the same name in configure and meson
Expand Down Expand Up @@ -921,6 +924,7 @@ Advanced options (experts only):
--enable-plugins
enable plugins via shared library loading
--disable-containers don't use containers for cross-building
--container-engine=TYPE which container engine to use [$container_engine]
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
EOF
meson_options_help
Expand Down Expand Up @@ -1195,14 +1199,14 @@ fi
container="no"
runc=""
if test $use_containers = "yes" && (has "docker" || has "podman"); then
case $($python "$source_path"/tests/docker/docker.py probe) in
case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in
*docker) container=docker ;;
podman) container=podman ;;
no) container=no ;;
esac
if test "$container" != "no"; then
docker_py="$python $source_path/tests/docker/docker.py --engine $container"
runc=$($python "$source_path"/tests/docker/docker.py probe)
runc=$container
fi
fi

Expand Down Expand Up @@ -1330,7 +1334,7 @@ probe_target_compiler() {
# 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-10
container_cross_cc=${container_cross_prefix}gcc
;;
alpha)
container_image=debian-alpha-cross
Expand Down Expand Up @@ -1393,7 +1397,7 @@ probe_target_compiler() {
ppc)
container_image=debian-powerpc-test-cross
container_cross_prefix=powerpc-linux-gnu-
container_cross_cc=${container_cross_prefix}gcc-10
container_cross_cc=${container_cross_prefix}gcc
;;
ppc64|ppc64le)
container_image=debian-powerpc-test-cross
Expand Down Expand Up @@ -1694,7 +1698,6 @@ if test -n "$gdb_bin"; then
fi

if test "$container" != no; then
echo "ENGINE=$container" >> $config_host_mak
echo "RUNC=$runc" >> $config_host_mak
fi
echo "SUBDIRS=$subdirs" >> $config_host_mak
Expand Down
18 changes: 8 additions & 10 deletions contrib/plugins/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,13 @@ static void caches_free(Cache **caches)
}
}

static void append_stats_line(GString *line, uint64_t l1_daccess,
uint64_t l1_dmisses, uint64_t l1_iaccess,
uint64_t l1_imisses, uint64_t l2_access,
uint64_t l2_misses)
static void append_stats_line(GString *line,
uint64_t l1_daccess, uint64_t l1_dmisses,
uint64_t l1_iaccess, uint64_t l1_imisses,
uint64_t l2_access, uint64_t l2_misses)
{
double l1_dmiss_rate, l1_imiss_rate, l2_miss_rate;

l1_dmiss_rate = ((double) l1_dmisses) / (l1_daccess) * 100.0;
l1_imiss_rate = ((double) l1_imisses) / (l1_iaccess) * 100.0;
double l1_dmiss_rate = ((double) l1_dmisses) / (l1_daccess) * 100.0;
double l1_imiss_rate = ((double) l1_imisses) / (l1_iaccess) * 100.0;

g_string_append_printf(line, "%-14" PRIu64 " %-12" PRIu64 " %9.4lf%%"
" %-14" PRIu64 " %-12" PRIu64 " %9.4lf%%",
Expand All @@ -554,8 +552,8 @@ static void append_stats_line(GString *line, uint64_t l1_daccess,
l1_imisses,
l1_iaccess ? l1_imiss_rate : 0.0);

if (use_l2) {
l2_miss_rate = ((double) l2_misses) / (l2_access) * 100.0;
if (l2_access && l2_misses) {
double l2_miss_rate = ((double) l2_misses) / (l2_access) * 100.0;
g_string_append_printf(line,
" %-12" PRIu64 " %-11" PRIu64 " %10.4lf%%",
l2_access,
Expand Down
16 changes: 10 additions & 6 deletions contrib/plugins/execlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;

/* Store last executed instruction on each vCPU as a GString */
static GPtrArray *last_exec;
static GMutex expand_array_lock;
static GRWLock expand_array_lock;

static GPtrArray *imatches;
static GArray *amatches;
Expand All @@ -28,18 +28,16 @@ static GArray *amatches;
* Expand last_exec array.
*
* As we could have multiple threads trying to do this we need to
* serialise the expansion under a lock. Threads accessing already
* created entries can continue without issue even if the ptr array
* gets reallocated during resize.
* serialise the expansion under a lock.
*/
static void expand_last_exec(int cpu_index)
{
g_mutex_lock(&expand_array_lock);
g_rw_lock_writer_lock(&expand_array_lock);
while (cpu_index >= last_exec->len) {
GString *s = g_string_new(NULL);
g_ptr_array_add(last_exec, s);
}
g_mutex_unlock(&expand_array_lock);
g_rw_lock_writer_unlock(&expand_array_lock);
}

/**
Expand All @@ -51,8 +49,10 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,
GString *s;

/* Find vCPU in array */
g_rw_lock_reader_lock(&expand_array_lock);
g_assert(cpu_index < last_exec->len);
s = g_ptr_array_index(last_exec, cpu_index);
g_rw_lock_reader_unlock(&expand_array_lock);

/* Indicate type of memory access */
if (qemu_plugin_mem_is_store(info)) {
Expand Down Expand Up @@ -80,10 +80,14 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
GString *s;

/* Find or create vCPU in array */
g_rw_lock_reader_lock(&expand_array_lock);
if (cpu_index >= last_exec->len) {
g_rw_lock_reader_unlock(&expand_array_lock);
expand_last_exec(cpu_index);
g_rw_lock_reader_lock(&expand_array_lock);
}
s = g_ptr_array_index(last_exec, cpu_index);
g_rw_lock_reader_unlock(&expand_array_lock);

/* Print previous instruction in cache */
if (s->len) {
Expand Down
2 changes: 1 addition & 1 deletion contrib/plugins/hotblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
}

g_list_free(it);
g_mutex_unlock(&lock);
}
g_mutex_unlock(&lock);

qemu_plugin_outs(report->str);
}
Expand Down
13 changes: 11 additions & 2 deletions contrib/plugins/lockstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
static bool setup_socket(const char *path)
{
struct sockaddr_un sockaddr;
const gsize pathlen = sizeof(sockaddr.sun_path) - 1;
int fd;

fd = socket(AF_UNIX, SOCK_STREAM, 0);
Expand All @@ -254,7 +255,11 @@ static bool setup_socket(const char *path)
}

sockaddr.sun_family = AF_UNIX;
g_strlcpy(sockaddr.sun_path, path, sizeof(sockaddr.sun_path) - 1);
if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
perror("bad path");
return false;
}

if (bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
perror("bind socket");
close(fd);
Expand Down Expand Up @@ -287,6 +292,7 @@ static bool connect_socket(const char *path)
{
int fd;
struct sockaddr_un sockaddr;
const gsize pathlen = sizeof(sockaddr.sun_path) - 1;

fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
Expand All @@ -295,7 +301,10 @@ static bool connect_socket(const char *path)
}

sockaddr.sun_family = AF_UNIX;
g_strlcpy(sockaddr.sun_path, path, sizeof(sockaddr.sun_path) - 1);
if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
perror("bad path");
return false;
}

if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
perror("failed to connect");
Expand Down

0 comments on commit a51e512

Please sign in to comment.