Skip to contentSkip to conversation

testing and plugin updates

PATCH Superseded Alex Bennée 6 participants 40 messages Jan 24, 2022 – Feb 2, 2022

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover testing and plugin updates

Hi,

Here is the usual accumulation of testing patches along with some updates for TCG plugins. Aside from a few more tricks for some of the plugins I've also fixed a bug and done some tidying up of the gcov behaviour. I've included one patch to test the stxp behaviour but I'll drop it before any PR so no need to review that one. Of the rest quite a few could still do with some review:

- plugins: move reset of plugin data to tb_start
- target/i386: use CPU_LOG_INT for IRQ servicing
- tests/plugins: add instruction matching to libinsn.so
- tests/plugin: allow libinsn.so per-CPU counts
- .gitignore: add .gcov pattern
- Makefile: also remove .gcno files when cleaning
- tests/qtest: enable more vhost-user tests by default
- tests/Makefile.include: clean-up old code

Alex Bennée (13):
tests/Makefile.include: clean-up old code tests/qtest: enable more vhost-user tests by default
Makefile: also remove .gcno files when cleaning .gitignore: add .gcov pattern
plugins: stxp test case from Aaron (!upstream)
docs: remove references to TCG tracing
tracing: remove TCG memory access tracing
tracing: remove the trace-tcg includes from the build
tracing: excise the tcg related from tracetool tests/plugin: allow libinsn.so per-CPU counts tests/plugins: add instruction matching to libinsn.so target/i386: use CPU_LOG_INT for IRQ servicing
plugins: move reset of plugin data to tb_start

Ivanov Arkady (2):
plugins: add helper functions for coverage plugins contrib/plugins: add a drcov plugin

Michael Tokarev (1):
drop libxml2 checks since libxml is not actually used (for parallels)

Philippe Mathieu-Daudé (6):
MAINTAINERS: Cover lcitool submodule with build test / automation
gitmodules: Correct libvirt-ci submodule URL tests/lcitool: Include local qemu.yml when refreshing cirrus-ci files tests/lcitool: Refresh submodule and remove libxml2
tests: Manually remove libxml2 on MSYS2 runners tests/lcitool: Install libibumad to cover RDMA on Debian based distros

 docs/about/removed-features.rst               |  13 ++
 docs/devel/tracing.rst                        |  85 ---------
 Makefile                                      |   3 +-
 meson.build                                   |  10 --
 accel/tcg/atomic_template.h                   |  12 --
 include/exec/helper-gen.h                     |   2 -
 include/exec/helper-proto.h                   |   1 -
 include/exec/helper-tcg.h                     |   1 -
 include/qemu/qemu-plugin.h                    |  34 ++++
 include/trace-tcg.h                           |   6 -
 accel/tcg/cputlb.c                            |   2 -
 accel/tcg/plugin-gen.c                        |  29 ++--
 accel/tcg/user-exec.c                         |  14 --
 contrib/plugins/drcov.c                       | 163 ++++++++++++++++++
 contrib/plugins/stxp-plugin.c                 |  50 ++++++
 plugins/api.c                                 |  46 +++++
 target/i386/tcg/sysemu/seg_helper.c           |   4 +-
 tcg/tcg-op.c                                  |   5 -
 tests/plugin/insn.c                           | 125 +++++++++++++-
 tests/qtest/vhost-user-test.c                 |  21 +--
 tests/tcg/aarch64/stxp.c                      |  28 +++
 accel/tcg/atomic_common.c.inc                 |  20 ---
 .cirrus.yml                                   |   1 -
 .gitignore                                    |   1 +
 .gitlab-ci.d/cirrus/freebsd-12.vars           |   2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars           |   2 +-
 .gitlab-ci.d/cirrus/macos-11.vars             |   2 +-
 .gitlab-ci.d/windows.yml                      |   2 -
 .gitmodules                                   |   2 +-
 MAINTAINERS                                   |   1 +
 block/meson.build                             |   3 +-
 contrib/plugins/Makefile                      |   2 +
 meson_options.txt                             |   2 -
 plugins/qemu-plugins.symbols                  |   4 +
 scripts/checkpatch.pl                         |   1 -
 .../ci/org.centos/stream/8/x86_64/configure   |   1 -
 scripts/coverity-scan/coverity-scan.docker    |   1 -
 scripts/coverity-scan/run-coverity-scan       |   2 +-
 scripts/meson-buildoptions.sh                 |   3 -
 scripts/tracetool/__init__.py                 |  41 +----
 scripts/tracetool/format/tcg_h.py             |  83 ---------
 scripts/tracetool/format/tcg_helper_c.py      |  79 ---------
 scripts/tracetool/format/tcg_helper_h.py      |  48 ------
 .../tracetool/format/tcg_helper_wrapper_h.py  |  70 --------
 scripts/tracetool/vcpu.py                     |  14 +-
 tests/Makefile.include                        |   4 -
 tests/docker/dockerfiles/alpine.docker        |   4 +-
 tests/docker/dockerfiles/centos8.docker       |   4 +-
 tests/docker/dockerfiles/fedora.docker        |   4 +-
 tests/docker/dockerfiles/opensuse-leap.docker |   3 +-
 tests/docker/dockerfiles/ubuntu1804.docker    |   4 +-
 tests/docker/dockerfiles/ubuntu2004.docker    |   4 +-
 tests/lcitool/libvirt-ci                      |   2 +-
 tests/lcitool/projects/qemu.yml               |   2 +-
 tests/lcitool/refresh                         |   2 +-
 tests/tcg/aarch64/Makefile.target             |   3 +
 trace-events                                  |  14 --
 trace/meson.build                             |  14 --
 58 files changed, 515 insertions(+), 590 deletions(-)
 delete mode 100644 include/trace-tcg.h
 create mode 100644 contrib/plugins/drcov.c
 create mode 100644 contrib/plugins/stxp-plugin.c
 create mode 100644 tests/tcg/aarch64/stxp.c
 delete mode 100644 scripts/tracetool/format/tcg_h.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_c.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_h.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_wrapper_h.py
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/22 tests/Makefile.include: clean-up old code

This is no longer needed since 5516623020 ("meson: convert migration directory to Meson")

---
 tests/Makefile.include | 4 ----
 1 file changed, 4 deletions(-)
tests/Makefile.include +0 -4
index 3aba622400..47cc7bc40c 100644
@@ -34,10 +34,6 @@ endif
 ifneq ($(wildcard config-host.mak),)
 export SRC_PATH
 
-# Get the list of all supported sysemu targets
-SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
-   $(wildcard $(SRC_PATH)/configs/*-softmmu.mak)))
-
 SPEED = quick
 
 # Build up our target list from the filtered list of ninja targets
Signature · 1 line
2.30.2
#3 lore raw

PATCH 2/22 tests/qtest: enable more vhost-user tests by default

In reply to Alex Bennée

If this starts causing failures again we should probably fix that.

---
 tests/qtest/vhost-user-test.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
tests/qtest/vhost-user-test.c +9 -12
index 3d6337fb5c..2a4568cd7d 100644
@@ -995,20 +995,17 @@ static void register_vhost_user_test(void)
                  "virtio-net",
                  test_migrate, &opts);
 
-    /* keeps failing on build-system since Aug 15 2017 */
-    if (getenv("QTEST_VHOST_USER_FIXME")) {
-        opts.before = vhost_user_test_setup_reconnect;
-        qos_add_test("vhost-user/reconnect", "virtio-net",
-                     test_reconnect, &opts);
+    opts.before = vhost_user_test_setup_reconnect;
+    qos_add_test("vhost-user/reconnect", "virtio-net",
+                 test_reconnect, &opts);
 
-        opts.before = vhost_user_test_setup_connect_fail;
-        qos_add_test("vhost-user/connect-fail", "virtio-net",
-                     test_vhost_user_started, &opts);
+    opts.before = vhost_user_test_setup_connect_fail;
+    qos_add_test("vhost-user/connect-fail", "virtio-net",
+                 test_vhost_user_started, &opts);
 
-        opts.before = vhost_user_test_setup_flags_mismatch;
-        qos_add_test("vhost-user/flags-mismatch", "virtio-net",
-                     test_vhost_user_started, &opts);
-    }
+    opts.before = vhost_user_test_setup_flags_mismatch;
+    qos_add_test("vhost-user/flags-mismatch", "virtio-net",
+                 test_vhost_user_started, &opts);
 
     opts.before = vhost_user_test_setup_multiqueue;
     opts.edge.extra_device_opts = "mq=on";
Signature · 1 line
2.30.2
Tested-by on v1 2/22
#4 lore raw

Re: [PATCH v1 02/22] tests/qtest: enable more vhost-user tests by default

Quoted 7 lines · Alex Bennée

If this starts causing failures again we should probably fix that.

---
  tests/qtest/vhost-user-test.c | 21 +++++++++------------
  1 file changed, 9 insertions(+), 12 deletions(-)

Works for me, too:

#5 lore raw

PATCH 3/22 Makefile: also remove .gcno files when cleaning

In reply to Alex Bennée

Left over .gcno files from old builds can really confuse gcov and the user expects a clean slate after "make clean". Make clean mean clean.

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index db9a788601..65e0d2dd4e 100644
@@ -206,7 +206,8 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
 clean: recurse-clean
 	-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
 	-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist || :
-	find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
+	find . \( -name '*.so' -o -name '*.dll' -o \
+	 	  -name '*.[oda]' -o -name '*.gcno' \) -type f \
 		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
 		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
 		-exec rm {} +
Signature · 1 line
2.30.2
#6 lore raw

Re: [PATCH v1 03/22] Makefile: also remove .gcno files when cleaning

Quoted 13 lines · Alex Bennée

Left over .gcno files from old builds can really confuse gcov and the user expects a clean slate after "make clean". Make clean mean clean.

---
  Makefile | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +0 -0
index db9a788601..65e0d2dd4e 100644

Makefile recurse-clean: $(addsuffix /clean, $(ROM_DIRS)) · line 210

Quoted 6 lines
Makefile +2 -1
@@ -206,7 +206,8 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
  clean: recurse-clean
  	-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
  	-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist || :
-	find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
+	find . \( -name '*.so' -o -name '*.dll' -o \
+	 	  -name '*.[oda]' -o -name '*.gcno' \) -type f \

My git complains here:

.git/rebase-apply/patch:15: space before tab in indent.

	 	  -name '*.[oda]' -o -name '*.gcno' \) -type f \

warning: 1 line adds whitespace errors.

Please remove the space before the tab.

Thomas

#7 lore raw

PATCH 4/22 .gitignore: add .gcov pattern

In reply to Alex Bennée

The gcovr tool is very messy and can leave a lot of crap in the source tree even when using build directories.

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)
.gitignore +1 -0
index eb2553026c..9726a778b3 100644
@@ -15,3 +15,4 @@ GTAGS
 *.depend_raw
 *.swp
 *.patch
+*.gcov
Signature · 1 line
2.30.2
#9 lore raw

PATCH 5/22 MAINTAINERS: Cover lcitool submodule with build test / automation

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

lcitool is used by build test / automation, we want maintainers to get notified if the submodule is updated.

Message-Id: <[email protected]>

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index e4b3a4bcdf..6d5539d46f 100644
@@ -3579,6 +3579,7 @@ F: .travis.yml
 F: scripts/ci/
 F: tests/docker/
 F: tests/vm/
+F: tests/lcitool/
 F: scripts/archive-source.sh
 W: https://gitlab.com/qemu-project/qemu/pipelines
 W: https://travis-ci.org/qemu/qemu
Signature · 1 line
2.30.2
#10 lore raw

PATCH 6/22 gitmodules: Correct libvirt-ci submodule URL

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Correct the libvirt-ci repository URL to avoid this warning when cloning / refreshing the submodule:

warning: redirecting to https://gitlab.com/libvirt/libvirt-ci.git/

Fixes 4ebb040f1fd ("tests: integrate lcitool for generating build env manifests")

Message-Id: <[email protected]>

---
 .gitmodules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitmodules +1 -1
index 84425d87e2..f4b6a9b401 100644
@@ -66,4 +66,4 @@
 	url = https://gitlab.com/qemu-project/vbootrom.git
 [submodule "tests/lcitool/libvirt-ci"]
 	path = tests/lcitool/libvirt-ci
-	url = http://gitlab.com/libvirt/libvirt-ci
+	url = https://gitlab.com/libvirt/libvirt-ci.git
Signature · 1 line
2.30.2
#11 lore raw

PATCH 7/22 tests/lcitool: Include local qemu.yml when refreshing cirrus-ci files

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

The script only include the local qemu.yml for Dockerfiles. Since we want to keep the Cirrus-CI generated files in sync, also use the --data-dir option in generate_cirrus().

Fixes c45a540f4bd (".gitlab-ci.d/cirrus: auto-generate variables with lcitool")

Message-Id: <[email protected]>

---
 tests/lcitool/refresh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/lcitool/refresh +1 -1
index 033120e223..25301f2ef0 100755
@@ -62,7 +62,7 @@ def generate_dockerfile(host, target, cross=None, trailer=None):
 
 def generate_cirrus(target, trailer=None):
    filename = Path(src_dir, ".gitlab-ci.d", "cirrus", target + ".vars")
-   cmd = [lcitool_path, "variables", target, "qemu"]
+   cmd = lcitool_cmd + ["variables", target, "qemu"]
    generate(filename, cmd, trailer)
 
 ubuntu1804_skipssh = [
Signature · 1 line
2.30.2
#12 lore raw

PATCH 8/22 drop libxml2 checks since libxml is not actually used (for parallels)

In reply to Alex Bennée

From: Michael Tokarev <[email protected]>

For a long time, we assumed that libxml2 is necessary for parallels block format support (block/parallels*). However, this format actually does not use libxml [*]. Since this is the only user of libxml2 in whole QEMU tree, we can drop all libxml2 checks and dependencies too.

It is even more: --enable-parallels configure option was the only option which was silently ignored when it's (fake) dependency (libxml2) isn't installed.

Drop all mentions of libxml2.

[*] Actually the basis for libxml use were introduced in commit
ed279a06c53 ("configure: add dependency") but the implementation was never merged:
https://lore.kernel.org/qemu-devel/[email protected]/

Message-Id: <[email protected]>

Message-Id: <[email protected]>

---
 meson.build                                     | 6 ------
 block/meson.build                               | 3 +--
 meson_options.txt                               | 2 --
 scripts/checkpatch.pl                           | 1 -
 scripts/ci/org.centos/stream/8/x86_64/configure | 1 -
 scripts/coverity-scan/coverity-scan.docker      | 1 -
 scripts/coverity-scan/run-coverity-scan         | 2 +-
 scripts/meson-buildoptions.sh                   | 3 ---
 8 files changed, 2 insertions(+), 17 deletions(-)
meson.build +0 -6
index 833fd6bc4c..51e3090438 100644
@@ -451,11 +451,6 @@ if not get_option('linux_io_uring').auto() or have_block
                               required: get_option('linux_io_uring'),
                               method: 'pkg-config', kwargs: static_kwargs)
 endif
-libxml2 = not_found
-if not get_option('libxml2').auto() or have_block
-  libxml2 = dependency('libxml-2.0', required: get_option('libxml2'),
-                       method: 'pkg-config', kwargs: static_kwargs)
-endif
 libnfs = not_found
 if not get_option('libnfs').auto() or have_block
   libnfs = dependency('libnfs', version: '>=1.9.3',
@@ -3491,7 +3486,6 @@ summary_info += {'bzip2 support':     libbzip2}
 summary_info += {'lzfse support':     liblzfse}
 summary_info += {'zstd support':      zstd}
 summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
-summary_info += {'libxml2':           libxml2}
 summary_info += {'capstone':          capstone_opt == 'internal' ? capstone_opt : capstone}
 summary_info += {'libpmem support':   libpmem}
 summary_info += {'libdaxctl support': libdaxctl}
block/meson.build +1 -2
index deb73ca389..90dc9983e5 100644
@@ -58,8 +58,7 @@ block_ss.add(when: 'CONFIG_QED', if_true: files(
   'qed-table.c',
   'qed.c',
 ))
-block_ss.add(when: [libxml2, 'CONFIG_PARALLELS'],
-             if_true: files('parallels.c', 'parallels-ext.c'))
+block_ss.add(when: 'CONFIG_PARALLELS', if_true: files('parallels.c', 'parallels-ext.c'))
 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])
 block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c'))
meson_options.txt +0 -2
index 921967eddb..95d527f773 100644
@@ -113,8 +113,6 @@ option('libudev', type : 'feature', value : 'auto',
        description: 'Use libudev to enumerate host devices')
 option('libusb', type : 'feature', value : 'auto',
        description: 'libusb support for USB passthrough')
-option('libxml2', type : 'feature', value : 'auto',
-       description: 'libxml2 support for Parallels image format')
 option('linux_aio', type : 'feature', value : 'auto',
        description: 'Linux AIO support')
 option('linux_io_uring', type : 'feature', value : 'auto',
scripts/checkpatch.pl +0 -1
index 5caa739db4..5e50111060 100755
@@ -307,7 +307,6 @@ our @typeList = (
 	qr{target_(?:u)?long},
 	qr{hwaddr},
         # external libraries
-	qr{xml${Ident}},
 	qr{xen\w+_handle},
 	# Glib definitions
 	qr{gchar},
scripts/ci/org.centos/stream/8/x86_64/configure +0 -1
index e05f2fddcc..9850dd4444 100755
@@ -81,7 +81,6 @@
 --disable-libssh \
 --disable-libudev \
 --disable-libusb \
---disable-libxml2 \
 --disable-linux-aio \
 --disable-linux-io-uring \
 --disable-linux-user \
scripts/coverity-scan/coverity-scan.docker +0 -1
index ecff6ac5b4..6f60a52d23 100644
@@ -59,7 +59,6 @@ ENV PACKAGES \
     libubsan \
     libudev-devel \
     libusbx-devel \
-    libxml2-devel \
     libzstd-devel \
     llvm \
     lzo-devel \
scripts/coverity-scan/run-coverity-scan +1 -1
index 6d443250a9..181bdcb263 100755
@@ -402,7 +402,7 @@ echo "Configuring..."
     --enable-libiscsi --enable-libnfs --enable-seccomp \
     --enable-tpm --enable-libssh --enable-lzo --enable-snappy --enable-bzip2 \
     --enable-numa --enable-rdma --enable-smartcard --enable-virglrenderer \
-    --enable-mpath --enable-libxml2 --enable-glusterfs \
+    --enable-mpath --enable-glusterfs \
     --enable-virtfs --enable-zstd
 
 echo "Running cov-build..."
scripts/meson-buildoptions.sh +0 -3
index a4af02c527..48a454cece 100644
@@ -58,7 +58,6 @@ meson_options_help() {
   printf "%s\n" '  libssh          ssh block device support'
   printf "%s\n" '  libudev         Use libudev to enumerate host devices'
   printf "%s\n" '  libusb          libusb support for USB passthrough'
-  printf "%s\n" '  libxml2         libxml2 support for Parallels image format'
   printf "%s\n" '  linux-aio       Linux AIO support'
   printf "%s\n" '  linux-io-uring  Linux io_uring support'
   printf "%s\n" '  lzfse           lzfse support for DMG images'
@@ -188,8 +187,6 @@ _meson_option_parse() {
     --disable-libudev) printf "%s" -Dlibudev=disabled ;;
     --enable-libusb) printf "%s" -Dlibusb=enabled ;;
     --disable-libusb) printf "%s" -Dlibusb=disabled ;;
-    --enable-libxml2) printf "%s" -Dlibxml2=enabled ;;
-    --disable-libxml2) printf "%s" -Dlibxml2=disabled ;;
     --enable-linux-aio) printf "%s" -Dlinux_aio=enabled ;;
     --disable-linux-aio) printf "%s" -Dlinux_aio=disabled ;;
     --enable-linux-io-uring) printf "%s" -Dlinux_io_uring=enabled ;;
Signature · 1 line
2.30.2
Reviewed-by on v1 8/22
#13 lore raw

Re: [PATCH v1 08/22] drop libxml2 checks since libxml is not actually used (for parallels)

Quoted 20 lines · Alex Bennée

From: Michael Tokarev <[email protected]>

For a long time, we assumed that libxml2 is necessary for parallels block format support (block/parallels*). However, this format actually does not use libxml [*]. Since this is the only user of libxml2 in whole QEMU tree, we can drop all libxml2 checks and dependencies too.

It is even more: --enable-parallels configure option was the only option which was silently ignored when it's (fake) dependency (libxml2) isn't installed.

Drop all mentions of libxml2.

[*] Actually the basis for libxml use were introduced in commit
ed279a06c53 ("configure: add dependency") but the implementation was never merged:
https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 8 lines

Message-Id: <[email protected]>

Message-Id: <[email protected]>

Parallels format includes xml disk descriptor format, which was never merged to Qemu. Yes, the introduced dependency was premature, sorry for that :(

The implementation of xml part was sent, but only for someone other who want to continue this work, Virtuozzo don't have such plans now:

https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg03601.html

Signature · 2 lines
Best regards,
Vladimir
#14 lore raw

PATCH 9/22 tests/lcitool: Refresh submodule and remove libxml2

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

The previous commit removed all uses of libxml2.

Refresh lcitool submodule, update qemu.yml and refresh the generated files by running:

  $ make lcitool-refresh

Note: This refreshment also removes libudev dependency on Fedora and CentOS due to libvirt-ci commit 18bfaee ("mappings: Improve mapping for libudev"), since "The udev project has been absorbed by the systemd project", and lttng-ust on FreeBSD runners due to libvirt-ci commit 6dd9b6f ("guests: drop lttng-ust from FreeBSD platform").

Message-Id: <[email protected]>

---
 .gitlab-ci.d/cirrus/freebsd-12.vars           | 2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars           | 2 +-
 .gitlab-ci.d/cirrus/macos-11.vars             | 2 +-
 tests/docker/dockerfiles/alpine.docker        | 4 ++--
 tests/docker/dockerfiles/centos8.docker       | 4 +---
 tests/docker/dockerfiles/fedora.docker        | 4 +---
 tests/docker/dockerfiles/opensuse-leap.docker | 3 +--
 tests/docker/dockerfiles/ubuntu1804.docker    | 3 +--
 tests/docker/dockerfiles/ubuntu2004.docker    | 3 +--
 tests/lcitool/libvirt-ci                      | 2 +-
 tests/lcitool/projects/qemu.yml               | 1 -
 11 files changed, 11 insertions(+), 19 deletions(-)
.gitlab-ci.d/cirrus/freebsd-12.vars +1 -1
index 9c52266811..07f313aa3a 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
 NINJA='/usr/local/bin/ninja'
 PACKAGING_COMMAND='pkg'
 PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
.gitlab-ci.d/cirrus/freebsd-13.vars +1 -1
index 7b44dba324..8a648dda1e 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
 NINJA='/usr/local/bin/ninja'
 PACKAGING_COMMAND='pkg'
 PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
.gitlab-ci.d/cirrus/macos-11.vars +1 -1
index 613d1373c2..08183f8793 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
 NINJA='/usr/local/bin/ninja'
 PACKAGING_COMMAND='brew'
 PIP3='/usr/local/bin/pip3'
-PKGS='bash bc bzip2 capstone ccache cpanminus ctags curl dbus diffutils dtc gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb libxml2 llvm lzo make meson ncurses nettle ninja perl pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy sparse spice-protocol tesseract texinfo usbredir vde vte3 zlib zstd'
+PKGS='bash bc bzip2 capstone ccache cpanminus ctags curl dbus diffutils dtc gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson ncurses nettle ninja perl pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy sparse spice-protocol tesseract texinfo usbredir vde vte3 zlib zstd'
 PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme virtualenv'
 PYTHON='/usr/local/bin/python3'
tests/docker/dockerfiles/alpine.docker +2 -2
index eb2251c81c..591af43d60 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile alpine-edge qemu
+#  $ lcitool dockerfile --layers all alpine-edge qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -56,7 +56,6 @@ RUN apk update && \
         libtasn1-dev \
         liburing-dev \
         libusb-dev \
-        libxml2-dev \
         linux-pam-dev \
         llvm11 \
         lttng-ust-dev \
@@ -109,6 +108,7 @@ RUN apk update && \
         zlib-dev \
         zlib-static \
         zstd-dev && \
+    apk list | sort > /packages.txt && \
     mkdir -p /usr/libexec/ccache-wrappers && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/c++ && \
     ln -s /usr/bin/ccache /usr/libexec/ccache-wrappers/cc && \
tests/docker/dockerfiles/centos8.docker +1 -3
index cbb909d02b..3abac7a8b1 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile centos-8 qemu
+#  $ lcitool dockerfile --layers all centos-8 qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -69,10 +69,8 @@ RUN dnf update -y && \
         libssh-devel \
         libtasn1-devel \
         libubsan \
-        libudev-devel \
         liburing-devel \
         libusbx-devel \
-        libxml2-devel \
         libzstd-devel \
         llvm \
         lttng-ust-devel \
tests/docker/dockerfiles/fedora.docker +1 -3
index 60207f3da3..1d01cd9440 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile fedora-35 qemu
+#  $ lcitool dockerfile --layers all fedora-35 qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -77,10 +77,8 @@ exec "$@"' > /usr/bin/nosync && \
         libssh-devel \
         libtasn1-devel \
         libubsan \
-        libudev-devel \
         liburing-devel \
         libusbx-devel \
-        libxml2-devel \
         libzstd-devel \
         llvm \
         lttng-ust-devel \
tests/docker/dockerfiles/opensuse-leap.docker +1 -2
index f57d8cfb29..1b78d8369a 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile opensuse-leap-152 qemu
+#  $ lcitool dockerfile --layers all opensuse-leap-152 qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -71,7 +71,6 @@ RUN zypper update -y && \
            libudev-devel \
            liburing-devel \
            libusb-1_0-devel \
-           libxml2-devel \
            libzstd-devel \
            llvm \
            lttng-ust-devel \
tests/docker/dockerfiles/ubuntu1804.docker +1 -2
index 0ffa3c4d4b..003ee2cfed 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile ubuntu-1804 qemu
+#  $ lcitool dockerfile --layers all ubuntu-1804 qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -89,7 +89,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libvirglrenderer-dev \
             libvte-2.91-dev \
             libxen-dev \
-            libxml2-dev \
             libzstd-dev \
             llvm \
             locales \
tests/docker/dockerfiles/ubuntu2004.docker +1 -2
index 4e562dfdcd..8993d2d9e0 100644
@@ -1,6 +1,6 @@
 # THIS FILE WAS AUTO-GENERATED
 #
-#  $ lcitool dockerfile ubuntu-2004 qemu
+#  $ lcitool dockerfile --layers all ubuntu-2004 qemu
 #
 # https://gitlab.com/libvirt/libvirt-ci
 
@@ -91,7 +91,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libvirglrenderer-dev \
             libvte-2.91-dev \
             libxen-dev \
-            libxml2-dev \
             libzstd-dev \
             llvm \
             locales \
tests/lcitool/libvirt-ci +1 -1
index 29cec2153b..6dd9b6fab1 160000
@@ -1 +1 @@
-Subproject commit 29cec2153b9a4dbb2e66f1cbc9866a4eff519cfd
+Subproject commit 6dd9b6fab1fe081b16bc975485d7a02c81ba5fbe
tests/lcitool/projects/qemu.yml +0 -1
index ed5ab1407a..de51a2f1dd 100644
@@ -63,7 +63,6 @@ packages:
  - liburing
  - libusbx
  - libvdeplug
- - libxml2
  - libzstd
  - llvm
  - lttng-ust
Signature · 1 line
2.30.2
#15 lore raw

Re: [PATCH v1 09/22] tests/lcitool: Refresh submodule and remove libxml2

Quoted 51 lines · Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

The previous commit removed all uses of libxml2.

Refresh lcitool submodule, update qemu.yml and refresh the generated files by running:

   $ make lcitool-refresh

Note: This refreshment also removes libudev dependency on Fedora and CentOS due to libvirt-ci commit 18bfaee ("mappings: Improve mapping for libudev"), since "The udev project has been absorbed by the systemd project", and lttng-ust on FreeBSD runners due to libvirt-ci commit 6dd9b6f ("guests: drop lttng-ust from FreeBSD platform").

Message-Id: <[email protected]>

---
  .gitlab-ci.d/cirrus/freebsd-12.vars           | 2 +-
  .gitlab-ci.d/cirrus/freebsd-13.vars           | 2 +-
  .gitlab-ci.d/cirrus/macos-11.vars             | 2 +-
  tests/docker/dockerfiles/alpine.docker        | 4 ++--
  tests/docker/dockerfiles/centos8.docker       | 4 +---
  tests/docker/dockerfiles/fedora.docker        | 4 +---
  tests/docker/dockerfiles/opensuse-leap.docker | 3 +--
  tests/docker/dockerfiles/ubuntu1804.docker    | 3 +--
  tests/docker/dockerfiles/ubuntu2004.docker    | 3 +--
  tests/lcitool/libvirt-ci                      | 2 +-
  tests/lcitool/projects/qemu.yml               | 1 -
  11 files changed, 11 insertions(+), 19 deletions(-)
.gitlab-ci.d/cirrus/freebsd-12.vars +1 -1
index 9c52266811..07f313aa3a 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
  NINJA='/usr/local/bin/ninja'
  PACKAGING_COMMAND='pkg'
  PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
  PYPI_PKGS=''
  PYTHON='/usr/local/bin/python3'
.gitlab-ci.d/cirrus/freebsd-13.vars +0 -0
index 7b44dba324..8a648dda1e 100644

.gitlab-ci.d/cirrus/freebsd-13.vars MAKE='/usr/local/bin/gmake' · line 14

Quoted 5 lines
.gitlab-ci.d/cirrus/freebsd-13.vars +1 -1
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
  NINJA='/usr/local/bin/ninja'
  PACKAGING_COMMAND='pkg'
  PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'

Seems like this now also added fusefs-libs3 on FreeBSD which causes the build to break:

https://gitlab.com/thuth/qemu/-/jobs/2012083924#L3454

Any ideas how to best fix this?

Thomas

#16 lore raw

Re: [PATCH v1 09/22] tests/lcitool: Refresh submodule and remove libxml2

Quoted 95 lines · Thomas Huth
Quoted 82 lines · Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

The previous commit removed all uses of libxml2.

Refresh lcitool submodule, update qemu.yml and refresh the generated files by running:

   $ make lcitool-refresh

Note: This refreshment also removes libudev dependency on Fedora and CentOS due to libvirt-ci commit 18bfaee ("mappings: Improve mapping for libudev"), since "The udev project has been absorbed by the systemd project", and lttng-ust on FreeBSD runners due to libvirt-ci commit 6dd9b6f ("guests: drop lttng-ust from FreeBSD platform").

Message-Id: <[email protected]>
---
  .gitlab-ci.d/cirrus/freebsd-12.vars           | 2 +- .gitlab-ci.d/cirrus/freebsd-13.vars           | 2 +- .gitlab-ci.d/cirrus/macos-11.vars             | 2 +- tests/docker/dockerfiles/alpine.docker        | 4 ++-- tests/docker/dockerfiles/centos8.docker       | 4 +--- tests/docker/dockerfiles/fedora.docker        | 4 +--- tests/docker/dockerfiles/opensuse-leap.docker | 3 +-- tests/docker/dockerfiles/ubuntu1804.docker    | 3 +-- tests/docker/dockerfiles/ubuntu2004.docker    | 3 +-- tests/lcitool/libvirt-ci                      | 2 +- tests/lcitool/projects/qemu.yml               | 1 -

  11 files changed, 11 insertions(+), 19 deletions(-)
.gitlab-ci.d/cirrus/freebsd-12.vars +0 -0
index 9c52266811..07f313aa3a 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'

  NINJA='/usr/local/bin/ninja'
  PACKAGING_COMMAND='pkg'
  PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
  PYPI_PKGS=''
  PYTHON='/usr/local/bin/python3'

.gitlab-ci.d/cirrus/freebsd-13.vars +0 -0
index 7b44dba324..8a648dda1e 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'

  NINJA='/usr/local/bin/ninja'
  PACKAGING_COMMAND='pkg'
  PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 libxml2 llvm lttng-ust lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'
+PKGS='alsa-lib bash bzip2 ca_root_nss capstone4 ccache

Quoted 8 lines

cdrkit-genisoimage ctags curl cyrus-sasl dbus diffutils dtc fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 libepoxy libffi libgcrypt libjpeg-turbo libnfs libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv p5-Test-Harness perl5 pixman pkgconf png py38-numpy py38-pillow py38-pip py38-sphinx py38-sphinx_rtd_theme py38-virtualenv py38-yaml python3 rpm2cpio sdl2 sdl2_image snappy spice-protocol tesseract texinfo usbredir virglrenderer vte3 zstd'

Seems like this now also added fusefs-libs3 on FreeBSD which causes the build to break:

Quoted 3 lines

 https://gitlab.com/thuth/qemu/-/jobs/2012083924#L3454

Any ideas how to best fix this?

Candidate patch:
https://lore.kernel.org/qemu-devel/[email protected]/

#17 lore raw

PATCH 10/22 tests: Manually remove libxml2 on MSYS2 runners

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

lcitool doesn't support MSYS2 targets, so manually remove this now unnecessary library.

Message-Id: <[email protected]>

---
 .cirrus.yml              | 1 -
 .gitlab-ci.d/windows.yml | 2 --
 2 files changed, 3 deletions(-)
.cirrus.yml +0 -1
index 02c43a074a..7552d70974 100644
@@ -32,7 +32,6 @@ windows_msys2_task:
       mingw-w64-x86_64-libgcrypt
       mingw-w64-x86_64-libpng
       mingw-w64-x86_64-libssh
-      mingw-w64-x86_64-libxml2
       mingw-w64-x86_64-snappy
       mingw-w64-x86_64-libusb
       mingw-w64-x86_64-usbredir
.gitlab-ci.d/windows.yml +0 -2
index 62dd9ed832..1df1630349 100644
@@ -44,7 +44,6 @@ msys2-64bit:
       mingw-w64-x86_64-libssh
       mingw-w64-x86_64-libtasn1
       mingw-w64-x86_64-libusb
-      mingw-w64-x86_64-libxml2
       mingw-w64-x86_64-nettle
       mingw-w64-x86_64-ninja
       mingw-w64-x86_64-pixman
@@ -80,7 +79,6 @@ msys2-32bit:
       mingw-w64-i686-libssh
       mingw-w64-i686-libtasn1
       mingw-w64-i686-libusb
-      mingw-w64-i686-libxml2
       mingw-w64-i686-lzo2
       mingw-w64-i686-ninja
       mingw-w64-i686-pixman
Signature · 1 line
2.30.2
#18 lore raw

PATCH 11/22 tests/lcitool: Install libibumad to cover RDMA on Debian based distros

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

On Debian we also need libibumad to enable RDMA:

  $ ../configure --enable-rdma

ERROR: OpenFabrics librdmacm/libibverbs/libibumad not present.
Your options:
(1) Fast: Install infiniband packages (devel) from your distro.
(2) Cleanest: Install libraries from www.openfabrics.org
(3) Also: Install softiwarp if you don't have RDMA hardware

Add the dependency to lcitool's qemu.yml (where librdmacm and libibverbs are already listed) and refresh the generated files by running:

      $ make lcitool-refresh

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/ubuntu1804.docker | 1 +
 tests/docker/dockerfiles/ubuntu2004.docker | 1 +
 tests/lcitool/projects/qemu.yml            | 1 +
 3 files changed, 3 insertions(+)
tests/docker/dockerfiles/ubuntu1804.docker +1 -0
index 003ee2cfed..699f2dfc6a 100644
@@ -52,6 +52,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libglib2.0-dev \
             libgnutls28-dev \
             libgtk-3-dev \
+            libibumad-dev \
             libibverbs-dev \
             libiscsi-dev \
             libjemalloc-dev \
tests/docker/dockerfiles/ubuntu2004.docker +1 -0
index 8993d2d9e0..87513125b8 100644
@@ -53,6 +53,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
             libglusterfs-dev \
             libgnutls28-dev \
             libgtk-3-dev \
+            libibumad-dev \
             libibverbs-dev \
             libiscsi-dev \
             libjemalloc-dev \
tests/lcitool/projects/qemu.yml +1 -0
index de51a2f1dd..958868a6ee 100644
@@ -43,6 +43,7 @@ packages:
  - libfdt
  - libffi
  - libgcrypt
+ - libibumad
  - libibverbs
  - libiscsi
  - libjemalloc
Signature · 1 line
2.30.2
#19 lore raw

PATCH 12/22 plugins: stxp test case from Aaron (!upstream)

In reply to Alex Bennée

Message-ID: <[email protected]>

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

---
 contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
 tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
 contrib/plugins/Makefile          |  1 +
 tests/tcg/aarch64/Makefile.target |  3 ++
 4 files changed, 82 insertions(+)
 create mode 100644 contrib/plugins/stxp-plugin.c
 create mode 100644 tests/tcg/aarch64/stxp.c
contrib/plugins/stxp-plugin.c new file +50 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("PC 0x%" PRIx64 " accessed memory at 0x%" PRIx64 "\n", pc, va);
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+    size_t n = qemu_plugin_tb_n_insns(tb);
+
+    for (size_t i = 0; i < n; i++) {
+        struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
+        uint64_t pc = qemu_plugin_insn_vaddr(insn);
+
+        qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb, QEMU_PLUGIN_CB_R_REGS, (void *)pc);
+        qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);
+    }
+}
+
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+                        int argc, char **argv)
+{
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    return 0;
+}
tests/tcg/aarch64/stxp.c new file +28 -0
new file mode 100644
index 0000000000..fb8ef6a46d
@@ -0,0 +1,28 @@
+
+
+void stxp_issue_demo(void *arr)
+{
+    asm(".align 8\n\t"
+        "    mov x0, %[in]\n\t"
+        "    mov x18, 0x1000\n\t"
+        "    mov x2, 0x0\n\t"
+        "    mov x3, 0x0\n\t"
+        "loop:\n\t"
+        "    prfm  pstl1strm, [x0]\n\t"
+        "    ldxp  x16, x17, [x0]\n\t"
+        "    stxp  w16, x2, x3, [x0]\n\t"
+        "\n\t"
+        "    subs x18, x18, 1\n\t"
+        "    beq done\n\t"
+        "    b loop\n\t"
+        "done:\n\t"
+        : /* none out */
+        : [in] "r" (arr) /* in */
+        : "x0", "x2", "x3", "x16", "x17", "x18"); /* clobbers */
+}
+
+int main()
+{
+    char arr[16];
+    stxp_issue_demo(&arr);
+}
contrib/plugins/Makefile +1 -0
index 54ac5ccd9f..576ed5875a 100644
@@ -20,6 +20,7 @@ NAMES += howvec
 NAMES += lockstep
 NAMES += hwprofile
 NAMES += cache
+NAMES += stxp-plugin
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
tests/tcg/aarch64/Makefile.target +3 -0
index 1d967901bd..54b2e90d00 100644
@@ -72,4 +72,7 @@ endif
 
 endif
 
+# Load/Store exclusive test
+AARCH64_TESTS += stxp
+
 TESTS += $(AARCH64_TESTS)
Signature · 1 line
2.30.2
#20 lore raw

Re: [PATCH v1 12/22] plugins: stxp test case from Aaron (!upstream)

Quoted 37 lines · Alex Bennée

Message-ID: <[email protected]>

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

---
  contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
  tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
  contrib/plugins/Makefile          |  1 +
  tests/tcg/aarch64/Makefile.target |  3 ++
  4 files changed, 82 insertions(+)

create mode 100644 contrib/plugins/stxp-plugin.c create mode 100644 tests/tcg/aarch64/stxp.c

contrib/plugins/stxp-plugin.c new file +15 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+

contrib/plugins/stxp-plugin.c line 25

Quoted 10 lines
contrib/plugins/stxp-plugin.c new file +10 -0
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)

Could you please break the line to avoid checkpatch errors:

ERROR: line over 90 characters
#63: FILE: contrib/plugins/stxp-plugin.c:25:
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)

ERROR: line over 90 characters
#77: FILE: contrib/plugins/stxp-plugin.c:39:
+ qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb, QEMU_PLUGIN_CB_R_REGS, (void *)pc);

ERROR: line over 90 characters
#78: FILE: contrib/plugins/stxp-plugin.c:40:
+ qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);

ERROR: "(foo*)" should be "(foo *)"
#78: FILE: contrib/plugins/stxp-plugin.c:40:
+ qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);

total: 4 errors, 1 warnings, 92 lines checked

Thanks,
Thomas

#21 lore raw

Re: [PATCH v1 12/22] plugins: stxp test case from Aaron (!upstream)

Quoted 66 lines · Thomas Huth
Quoted 37 lines · Alex Bennée

Message-ID: <[email protected]>

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

---
  contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
  tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
  contrib/plugins/Makefile          |  1 +
  tests/tcg/aarch64/Makefile.target |  3 ++
  4 files changed, 82 insertions(+)

create mode 100644 contrib/plugins/stxp-plugin.c create mode 100644 tests/tcg/aarch64/stxp.c

contrib/plugins/stxp-plugin.c new file +15 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+

contrib/plugins/stxp-plugin.c line 25

Quoted 10 lines
contrib/plugins/stxp-plugin.c new file +10 -0
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)

Could you please break the line to avoid checkpatch errors:

ERROR: line over 90 characters
#63: FILE: contrib/plugins/stxp-plugin.c:25:
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)

ERROR: line over 90 characters
#77: FILE: contrib/plugins/stxp-plugin.c:39:
+ qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb,
QEMU_PLUGIN_CB_R_REGS, (void *)pc);

ERROR: line over 90 characters
#78: FILE: contrib/plugins/stxp-plugin.c:40:
+ qemu_plugin_register_vcpu_mem_cb(insn, mem_cb,
QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);

Quoted 6 lines

ERROR: "(foo*)" should be "(foo *)"
#78: FILE: contrib/plugins/stxp-plugin.c:40:
+ qemu_plugin_register_vcpu_mem_cb(insn, mem_cb,
QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);

total: 4 errors, 1 warnings, 92 lines checked

For whatever it's worth, I don't think Alex's intention is to upstream this code.

-Aaron

#22 lore raw

Re: [PATCH v1 12/22] plugins: stxp test case from Aaron (!upstream)

In reply to Alex Bennée
Quoted 7 lines · Alex Bennée

Message-ID: <[email protected]>

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

Is it true that execlog can also reproduce the duplicate loads which are still an outstanding issue?

-Aaron

Quoted 126 lines
---
 contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
 tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
 contrib/plugins/Makefile          |  1 +
 tests/tcg/aarch64/Makefile.target |  3 ++
 4 files changed, 82 insertions(+)
 create mode 100644 contrib/plugins/stxp-plugin.c
 create mode 100644 tests/tcg/aarch64/stxp.c
contrib/plugins/stxp-plugin.c new file +50 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("PC 0x%" PRIx64 " accessed memory at 0x%" PRIx64 "\n", pc, va);
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+    size_t n = qemu_plugin_tb_n_insns(tb);
+
+    for (size_t i = 0; i < n; i++) {
+        struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
+        uint64_t pc = qemu_plugin_insn_vaddr(insn);
+
+        qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb, QEMU_PLUGIN_CB_R_REGS, (void *)pc);
+        qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);
+    }
+}
+
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+                        int argc, char **argv)
+{
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    return 0;
+}
tests/tcg/aarch64/stxp.c new file +28 -0
new file mode 100644
index 0000000000..fb8ef6a46d
@@ -0,0 +1,28 @@
+
+
+void stxp_issue_demo(void *arr)
+{
+    asm(".align 8\n\t"
+        "    mov x0, %[in]\n\t"
+        "    mov x18, 0x1000\n\t"
+        "    mov x2, 0x0\n\t"
+        "    mov x3, 0x0\n\t"
+        "loop:\n\t"
+        "    prfm  pstl1strm, [x0]\n\t"
+        "    ldxp  x16, x17, [x0]\n\t"
+        "    stxp  w16, x2, x3, [x0]\n\t"
+        "\n\t"
+        "    subs x18, x18, 1\n\t"
+        "    beq done\n\t"
+        "    b loop\n\t"
+        "done:\n\t"
+        : /* none out */
+        : [in] "r" (arr) /* in */
+        : "x0", "x2", "x3", "x16", "x17", "x18"); /* clobbers */
+}
+
+int main()
+{
+    char arr[16];
+    stxp_issue_demo(&arr);
+}
contrib/plugins/Makefile +1 -0
index 54ac5ccd9f..576ed5875a 100644
@@ -20,6 +20,7 @@ NAMES += howvec
 NAMES += lockstep
 NAMES += hwprofile
 NAMES += cache
+NAMES += stxp-plugin
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
tests/tcg/aarch64/Makefile.target +3 -0
index 1d967901bd..54b2e90d00 100644
@@ -72,4 +72,7 @@ endif
 
 endif
 
+# Load/Store exclusive test
+AARCH64_TESTS += stxp
+
 TESTS += $(AARCH64_TESTS)
Signature · 1 line
2.30.2
#23 lore raw

Re: [PATCH v1 12/22] plugins: stxp test case from Aaron (!upstream)

Quoted 11 lines · Aaron Lindsay
Quoted 7 lines · Alex Bennée

Message-ID: <[email protected]>

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

Is it true that execlog can also reproduce the duplicate loads which are still an outstanding issue?

Are we still seeing duplicate loads? I thought that had been fixed.

Quoted 129 lines

-Aaron

Quoted 126 lines
---
 contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
 tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
 contrib/plugins/Makefile          |  1 +
 tests/tcg/aarch64/Makefile.target |  3 ++
 4 files changed, 82 insertions(+)
 create mode 100644 contrib/plugins/stxp-plugin.c
 create mode 100644 tests/tcg/aarch64/stxp.c
contrib/plugins/stxp-plugin.c new file +50 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("PC 0x%" PRIx64 " accessed memory at 0x%" PRIx64 "\n", pc, va);
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+    size_t n = qemu_plugin_tb_n_insns(tb);
+
+    for (size_t i = 0; i < n; i++) {
+        struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
+        uint64_t pc = qemu_plugin_insn_vaddr(insn);
+
+        qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb, QEMU_PLUGIN_CB_R_REGS, (void *)pc);
+        qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);
+    }
+}
+
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+                        int argc, char **argv)
+{
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    return 0;
+}
tests/tcg/aarch64/stxp.c new file +28 -0
new file mode 100644
index 0000000000..fb8ef6a46d
@@ -0,0 +1,28 @@
+
+
+void stxp_issue_demo(void *arr)
+{
+    asm(".align 8\n\t"
+        "    mov x0, %[in]\n\t"
+        "    mov x18, 0x1000\n\t"
+        "    mov x2, 0x0\n\t"
+        "    mov x3, 0x0\n\t"
+        "loop:\n\t"
+        "    prfm  pstl1strm, [x0]\n\t"
+        "    ldxp  x16, x17, [x0]\n\t"
+        "    stxp  w16, x2, x3, [x0]\n\t"
+        "\n\t"
+        "    subs x18, x18, 1\n\t"
+        "    beq done\n\t"
+        "    b loop\n\t"
+        "done:\n\t"
+        : /* none out */
+        : [in] "r" (arr) /* in */
+        : "x0", "x2", "x3", "x16", "x17", "x18"); /* clobbers */
+}
+
+int main()
+{
+    char arr[16];
+    stxp_issue_demo(&arr);
+}
contrib/plugins/Makefile +1 -0
index 54ac5ccd9f..576ed5875a 100644
@@ -20,6 +20,7 @@ NAMES += howvec
 NAMES += lockstep
 NAMES += hwprofile
 NAMES += cache
+NAMES += stxp-plugin
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
tests/tcg/aarch64/Makefile.target +3 -0
index 1d967901bd..54b2e90d00 100644
@@ -72,4 +72,7 @@ endif
 
 endif
 
+# Load/Store exclusive test
+AARCH64_TESTS += stxp
+
 TESTS += $(AARCH64_TESTS)
Signature · 1 line
2.30.2
Signature · 1 line
Alex Bennée
#24 lore raw

Re: [PATCH v1 12/22] plugins: stxp test case from Aaron (!upstream)

Quoted 8 lines · Alex Bennée
Quoted 5 lines · Aaron Lindsay
Quoted 4 lines · Alex Bennée

Message-ID: <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

---
[AJB] this was for testing, I think you can show the same stuff with the much more complete execlog now.

Is it true that execlog can also reproduce the duplicate loads which are still an outstanding issue?

Are we still seeing duplicate loads? I thought that had been fixed.

I have not explicitly tested for the duplicate loads on atomics lately (though I have seen some transient behavior related to atomics that I have struggled to reliably reproduce, but I believe that's a different issue). I hadn't seen a subsequent fix come through after the initial fix for stores and assumed it was still an issue. Sorry for my assumption, particularly if I just missed it.

-Aaron

Quoted 130 lines
Quoted 126 lines
Quoted 126 lines
---
 contrib/plugins/stxp-plugin.c     | 50 +++++++++++++++++++++++++++++++
 tests/tcg/aarch64/stxp.c          | 28 +++++++++++++++++
 contrib/plugins/Makefile          |  1 +
 tests/tcg/aarch64/Makefile.target |  3 ++
 4 files changed, 82 insertions(+)
 create mode 100644 contrib/plugins/stxp-plugin.c
 create mode 100644 tests/tcg/aarch64/stxp.c
contrib/plugins/stxp-plugin.c new file +50 -0
new file mode 100644
index 0000000000..432cf8c1ed
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+void qemu_logf(const char *str, ...)
+{
+    char message[1024];
+    va_list args;
+    va_start(args, str);
+    vsnprintf(message, 1023, str, args);
+
+    qemu_plugin_outs(message);
+
+    va_end(args);
+}
+
+void before_insn_cb(unsigned int cpu_index, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("Executing PC: 0x%" PRIx64 "\n", pc);
+}
+
+static void mem_cb(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, uint64_t va, void *udata)
+{
+    uint64_t pc = (uint64_t)udata;
+    qemu_logf("PC 0x%" PRIx64 " accessed memory at 0x%" PRIx64 "\n", pc, va);
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+    size_t n = qemu_plugin_tb_n_insns(tb);
+
+    for (size_t i = 0; i < n; i++) {
+        struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
+        uint64_t pc = qemu_plugin_insn_vaddr(insn);
+
+        qemu_plugin_register_vcpu_insn_exec_cb(insn, before_insn_cb, QEMU_PLUGIN_CB_R_REGS, (void *)pc);
+        qemu_plugin_register_vcpu_mem_cb(insn, mem_cb, QEMU_PLUGIN_CB_NO_REGS, QEMU_PLUGIN_MEM_RW, (void*)pc);
+    }
+}
+
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+                        int argc, char **argv)
+{
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    return 0;
+}
tests/tcg/aarch64/stxp.c new file +28 -0
new file mode 100644
index 0000000000..fb8ef6a46d
@@ -0,0 +1,28 @@
+
+
+void stxp_issue_demo(void *arr)
+{
+    asm(".align 8\n\t"
+        "    mov x0, %[in]\n\t"
+        "    mov x18, 0x1000\n\t"
+        "    mov x2, 0x0\n\t"
+        "    mov x3, 0x0\n\t"
+        "loop:\n\t"
+        "    prfm  pstl1strm, [x0]\n\t"
+        "    ldxp  x16, x17, [x0]\n\t"
+        "    stxp  w16, x2, x3, [x0]\n\t"
+        "\n\t"
+        "    subs x18, x18, 1\n\t"
+        "    beq done\n\t"
+        "    b loop\n\t"
+        "done:\n\t"
+        : /* none out */
+        : [in] "r" (arr) /* in */
+        : "x0", "x2", "x3", "x16", "x17", "x18"); /* clobbers */
+}
+
+int main()
+{
+    char arr[16];
+    stxp_issue_demo(&arr);
+}
contrib/plugins/Makefile +1 -0
index 54ac5ccd9f..576ed5875a 100644
@@ -20,6 +20,7 @@ NAMES += howvec
 NAMES += lockstep
 NAMES += hwprofile
 NAMES += cache
+NAMES += stxp-plugin
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
tests/tcg/aarch64/Makefile.target +3 -0
index 1d967901bd..54b2e90d00 100644
@@ -72,4 +72,7 @@ endif
 
 endif
 
+# Load/Store exclusive test
+AARCH64_TESTS += stxp
+
 TESTS += $(AARCH64_TESTS)
Signature · 1 line
2.30.2
Signature · 1 line
Alex Bennée
#25 lore raw

PATCH 13/22 docs: remove references to TCG tracing

In reply to Alex Bennée

Users wanting this sort of functionality should turn to TCG plugins instead.

---
 docs/about/removed-features.rst | 13 +++++
 docs/devel/tracing.rst          | 85 ---------------------------------
 2 files changed, 13 insertions(+), 85 deletions(-)
docs/about/removed-features.rst +13 -0
index 4c4da20d0f..b0156e0f25 100644
@@ -601,6 +601,19 @@ the upstream Linux kernel in 2018, and it has also been dropped from glibc, so
 there is no new Linux development taking place with this architecture. For
 running the old binaries, you can use older versions of QEMU.
 
+TCG introspection features
+--------------------------
+
+TCG trace-events (since 6.2)
+''''''''''''''''''''''''''''
+
+The ability to add new TCG trace points had bit rotted and as the
+feature can be replicated with TCG plugins it was removed. If
+any user is currently using this feature and needs help with
+converting to using TCG plugins they should contact the qemu-devel
+mailing list.
+
+
 System emulator devices
 -----------------------
 
docs/devel/tracing.rst +0 -85

88 lines not on this page · raw message

Signature · 1 line
2.30.2
#26 lore raw

PATCH 14/22 tracing: remove TCG memory access tracing

In reply to Alex Bennée

If you really want to trace all memory operations TCG plugins gives you a more flexible interface for doing so.

--
v2
- dropped extra line

---
 accel/tcg/atomic_template.h   | 12 ------------
 accel/tcg/cputlb.c            |  2 --
 accel/tcg/user-exec.c         | 14 --------------
 tcg/tcg-op.c                  |  5 -----
 accel/tcg/atomic_common.c.inc | 20 --------------------
 trace-events                  | 14 --------------
 6 files changed, 67 deletions(-)
accel/tcg/atomic_template.h +0 -12
index 2d917b6b1f..fc165031e8 100644
@@ -77,7 +77,6 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
                                          PAGE_READ | PAGE_WRITE, retaddr);
     DATA_TYPE ret;
 
-    atomic_trace_rmw_pre(env, addr, oi);
 #if DATA_SIZE == 16
     ret = atomic16_cmpxchg(haddr, cmpv, newv);
 #else
@@ -97,7 +96,6 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr,
                                          PAGE_READ, retaddr);
     DATA_TYPE val;
 
-    atomic_trace_ld_pre(env, addr, oi);
     val = atomic16_read(haddr);
     ATOMIC_MMU_CLEANUP;
     atomic_trace_ld_post(env, addr, oi);
@@ -110,7 +108,6 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val,
     DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE,
                                          PAGE_WRITE, retaddr);
 
-    atomic_trace_st_pre(env, addr, oi);
     atomic16_set(haddr, val);
     ATOMIC_MMU_CLEANUP;
     atomic_trace_st_post(env, addr, oi);
@@ -124,7 +121,6 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,
                                          PAGE_READ | PAGE_WRITE, retaddr);
     DATA_TYPE ret;
 
-    atomic_trace_rmw_pre(env, addr, oi);
     ret = qatomic_xchg__nocheck(haddr, val);
     ATOMIC_MMU_CLEANUP;
     atomic_trace_rmw_post(env, addr, oi);
@@ -138,7 +134,6 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE,  \
                                          PAGE_READ | PAGE_WRITE, retaddr); \
     DATA_TYPE ret;                                                  \
-    atomic_trace_rmw_pre(env, addr, oi);                            \
     ret = qatomic_##X(haddr, val);                                  \
     ATOMIC_MMU_CLEANUP;                                             \
     atomic_trace_rmw_post(env, addr, oi);                           \
@@ -171,7 +166,6 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     XDATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \
                                           PAGE_READ | PAGE_WRITE, retaddr); \
     XDATA_TYPE cmp, old, new, val = xval;                           \
-    atomic_trace_rmw_pre(env, addr, oi);                            \
     smp_mb();                                                       \
     cmp = qatomic_read__nocheck(haddr);                             \
     do {                                                            \
@@ -216,7 +210,6 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, target_ulong addr,
                                          PAGE_READ | PAGE_WRITE, retaddr);
     DATA_TYPE ret;
 
-    atomic_trace_rmw_pre(env, addr, oi);
 #if DATA_SIZE == 16
     ret = atomic16_cmpxchg(haddr, BSWAP(cmpv), BSWAP(newv));
 #else
@@ -236,7 +229,6 @@ ABI_TYPE ATOMIC_NAME(ld)(CPUArchState *env, target_ulong addr,
                                          PAGE_READ, retaddr);
     DATA_TYPE val;
 
-    atomic_trace_ld_pre(env, addr, oi);
     val = atomic16_read(haddr);
     ATOMIC_MMU_CLEANUP;
     atomic_trace_ld_post(env, addr, oi);
@@ -249,7 +241,6 @@ void ATOMIC_NAME(st)(CPUArchState *env, target_ulong addr, ABI_TYPE val,
     DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE,
                                          PAGE_WRITE, retaddr);
 
-    atomic_trace_st_pre(env, addr, oi);
     val = BSWAP(val);
     atomic16_set(haddr, val);
     ATOMIC_MMU_CLEANUP;
@@ -264,7 +255,6 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, ABI_TYPE val,
                                          PAGE_READ | PAGE_WRITE, retaddr);
     ABI_TYPE ret;
 
-    atomic_trace_rmw_pre(env, addr, oi);
     ret = qatomic_xchg__nocheck(haddr, BSWAP(val));
     ATOMIC_MMU_CLEANUP;
     atomic_trace_rmw_post(env, addr, oi);
@@ -278,7 +268,6 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     DATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE,  \
                                          PAGE_READ | PAGE_WRITE, retaddr); \
     DATA_TYPE ret;                                                  \
-    atomic_trace_rmw_pre(env, addr, oi);                            \
     ret = qatomic_##X(haddr, BSWAP(val));                           \
     ATOMIC_MMU_CLEANUP;                                             \
     atomic_trace_rmw_post(env, addr, oi);                           \
@@ -308,7 +297,6 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr,       \
     XDATA_TYPE *haddr = atomic_mmu_lookup(env, addr, oi, DATA_SIZE, \
                                           PAGE_READ | PAGE_WRITE, retaddr); \
     XDATA_TYPE ldo, ldn, old, new, val = xval;                      \
-    atomic_trace_rmw_pre(env, addr, oi);                            \
     smp_mb();                                                       \
     ldn = qatomic_read__nocheck(haddr);                             \
     do {                                                            \
accel/tcg/cputlb.c +0 -2
index 5e0d0eebc3..82adefe574 100644
@@ -2140,7 +2140,6 @@ static inline uint64_t cpu_load_helper(CPUArchState *env, abi_ptr addr,
 {
     uint64_t ret;
 
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     ret = full_load(env, addr, oi, retaddr);
     qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R);
     return ret;
@@ -2487,7 +2486,6 @@ static inline void cpu_store_helper(CPUArchState *env, target_ulong addr,
                                     uint64_t val, MemOpIdx oi, uintptr_t ra,
                                     FullStoreHelper *full_store)
 {
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     full_store(env, addr, val, oi, ra);
     qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W);
 }
accel/tcg/user-exec.c +0 -14
index 6f5d4933f0..8edf0bbaa1 100644
@@ -250,7 +250,6 @@ uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr,
     uint8_t ret;
 
     validate_memop(oi, MO_UB);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = ldub_p(haddr);
     clear_helper_retaddr();
@@ -265,7 +264,6 @@ uint16_t cpu_ldw_be_mmu(CPUArchState *env, abi_ptr addr,
     uint16_t ret;
 
     validate_memop(oi, MO_BEUW);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = lduw_be_p(haddr);
     clear_helper_retaddr();
@@ -280,7 +278,6 @@ uint32_t cpu_ldl_be_mmu(CPUArchState *env, abi_ptr addr,
     uint32_t ret;
 
     validate_memop(oi, MO_BEUL);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = ldl_be_p(haddr);
     clear_helper_retaddr();
@@ -295,7 +292,6 @@ uint64_t cpu_ldq_be_mmu(CPUArchState *env, abi_ptr addr,
     uint64_t ret;
 
     validate_memop(oi, MO_BEUQ);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = ldq_be_p(haddr);
     clear_helper_retaddr();
@@ -310,7 +306,6 @@ uint16_t cpu_ldw_le_mmu(CPUArchState *env, abi_ptr addr,
     uint16_t ret;
 
     validate_memop(oi, MO_LEUW);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = lduw_le_p(haddr);
     clear_helper_retaddr();
@@ -325,7 +320,6 @@ uint32_t cpu_ldl_le_mmu(CPUArchState *env, abi_ptr addr,
     uint32_t ret;
 
     validate_memop(oi, MO_LEUL);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = ldl_le_p(haddr);
     clear_helper_retaddr();
@@ -340,7 +334,6 @@ uint64_t cpu_ldq_le_mmu(CPUArchState *env, abi_ptr addr,
     uint64_t ret;
 
     validate_memop(oi, MO_LEUQ);
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_LOAD);
     ret = ldq_le_p(haddr);
     clear_helper_retaddr();
@@ -354,7 +347,6 @@ void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val,
     void *haddr;
 
     validate_memop(oi, MO_UB);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stb_p(haddr, val);
     clear_helper_retaddr();
@@ -367,7 +359,6 @@ void cpu_stw_be_mmu(CPUArchState *env, abi_ptr addr, uint16_t val,
     void *haddr;
 
     validate_memop(oi, MO_BEUW);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stw_be_p(haddr, val);
     clear_helper_retaddr();
@@ -380,7 +371,6 @@ void cpu_stl_be_mmu(CPUArchState *env, abi_ptr addr, uint32_t val,
     void *haddr;
 
     validate_memop(oi, MO_BEUL);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stl_be_p(haddr, val);
     clear_helper_retaddr();
@@ -393,7 +383,6 @@ void cpu_stq_be_mmu(CPUArchState *env, abi_ptr addr, uint64_t val,
     void *haddr;
 
     validate_memop(oi, MO_BEUQ);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stq_be_p(haddr, val);
     clear_helper_retaddr();
@@ -406,7 +395,6 @@ void cpu_stw_le_mmu(CPUArchState *env, abi_ptr addr, uint16_t val,
     void *haddr;
 
     validate_memop(oi, MO_LEUW);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stw_le_p(haddr, val);
     clear_helper_retaddr();
@@ -419,7 +407,6 @@ void cpu_stl_le_mmu(CPUArchState *env, abi_ptr addr, uint32_t val,
     void *haddr;
 
     validate_memop(oi, MO_LEUL);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stl_le_p(haddr, val);
     clear_helper_retaddr();
@@ -432,7 +419,6 @@ void cpu_stq_le_mmu(CPUArchState *env, abi_ptr addr, uint64_t val,
     void *haddr;
 
     validate_memop(oi, MO_LEUQ);
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
     haddr = cpu_mmu_lookup(env, addr, oi, ra, MMU_DATA_STORE);
     stq_le_p(haddr, val);
     clear_helper_retaddr();
tcg/tcg-op.c +0 -5
index 61b492d89f..65e1c94c2d 100644
@@ -27,7 +27,6 @@
 #include "tcg/tcg.h"
 #include "tcg/tcg-op.h"
 #include "tcg/tcg-mo.h"
-#include "trace-tcg.h"
 #include "exec/plugin-gen.h"
 
 /* Reduce the number of ifdefs below.  This assumes that all uses of
@@ -2877,7 +2876,6 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)
     tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
     memop = tcg_canonicalize_memop(memop, 0, 0);
     oi = make_memop_idx(memop, idx);
-    trace_guest_ld_before_tcg(tcg_ctx->cpu, cpu_env, addr, oi);
 
     orig_memop = memop;
     if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
@@ -2916,7 +2914,6 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop)
     tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST);
     memop = tcg_canonicalize_memop(memop, 0, 1);
     oi = make_memop_idx(memop, idx);
-    trace_guest_st_before_tcg(tcg_ctx->cpu, cpu_env, addr, oi);
 
     if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
         swap = tcg_temp_new_i32();
@@ -2965,7 +2962,6 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)
     tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
     memop = tcg_canonicalize_memop(memop, 1, 0);
     oi = make_memop_idx(memop, idx);
-    trace_guest_ld_before_tcg(tcg_ctx->cpu, cpu_env, addr, oi);
 
     orig_memop = memop;
     if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
@@ -3013,7 +3009,6 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop)
     tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST);
     memop = tcg_canonicalize_memop(memop, 1, 1);
     oi = make_memop_idx(memop, idx);
-    trace_guest_st_before_tcg(tcg_ctx->cpu, cpu_env, addr, oi);
 
     if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) {
         swap = tcg_temp_new_i64();
accel/tcg/atomic_common.c.inc +0 -20
index 1df1f243e9..6602d7689f 100644
@@ -13,14 +13,6 @@
  * See the COPYING file in the top-level directory.
  */
 
-static void atomic_trace_rmw_pre(CPUArchState *env, target_ulong addr,
-                                 MemOpIdx oi)
-{
-    CPUState *cpu = env_cpu(env);
-
-    trace_guest_rmw_before_exec(cpu, addr, oi);
-}
-
 static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr,
                                   MemOpIdx oi)
 {
@@ -28,24 +20,12 @@ static void atomic_trace_rmw_post(CPUArchState *env, target_ulong addr,
 }
 
 #if HAVE_ATOMIC128
-static void atomic_trace_ld_pre(CPUArchState *env, target_ulong addr,
-                                MemOpIdx oi)
-{
-    trace_guest_ld_before_exec(env_cpu(env), addr, oi);
-}
-
 static void atomic_trace_ld_post(CPUArchState *env, target_ulong addr,
                                  MemOpIdx oi)
 {
     qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R);
 }
 
-static void atomic_trace_st_pre(CPUArchState *env, target_ulong addr,
-                                MemOpIdx oi)
-{
-    trace_guest_st_before_exec(env_cpu(env), addr, oi);
-}
-
 static void atomic_trace_st_post(CPUArchState *env, target_ulong addr,
                                  MemOpIdx oi)
 {
trace-events +0 -14
index a637a61eba..bc71006675 100644
@@ -117,20 +117,6 @@ vcpu guest_cpu_exit(void)
 # Targets: all
 vcpu guest_cpu_reset(void)
 
-# tcg/tcg-op.c
-
-# @vaddr: Access' virtual address.
-# @memopidx: Access' information (see below).
-#
-# Start virtual memory access (before any potential access violation).
-# Does not include memory accesses performed by devices.
-#
-# Mode: user, softmmu
-# Targets: TCG(all)
-vcpu tcg guest_ld_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x"
-vcpu tcg guest_st_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x"
-vcpu tcg guest_rmw_before(TCGv vaddr, uint32_t memopidx) "info=%d", "vaddr=0x%016"PRIx64" memopidx=0x%x"
-
 # include/user/syscall-trace.h
 
 # @num: System call number.
Signature · 1 line
2.30.2
Reviewed-by Philippe Mathieu-Daudé on v1 14/22
#27 lore raw

Re: [PATCH v1 14/22] tracing: remove TCG memory access tracing

Quoted 9 lines · Alex Bennée

If you really want to trace all memory operations TCG plugins gives you a more flexible interface for doing so.

--

git tools need 3 dashes '---' sto split ections.

Quoted 10 lines

v2
- dropped extra line

---
 accel/tcg/atomic_template.h   | 12 ------------
 accel/tcg/cputlb.c            |  2 --
 accel/tcg/user-exec.c         | 14 --------------
 tcg/tcg-op.c                  |  5 -----
 accel/tcg/atomic_common.c.inc | 20 --------------------
 trace-events                  | 14 --------------
 6 files changed, 67 deletions(-)
#28 lore raw

PATCH 15/22 tracing: remove the trace-tcg includes from the build

In reply to Alex Bennée

---
v2
- dropped includes here instead of next patch

---
 include/exec/helper-proto.h | 1 -
 include/exec/helper-tcg.h   | 1 -
 include/trace-tcg.h         | 6 ------
 trace/meson.build           | 1 -
 4 files changed, 9 deletions(-)
 delete mode 100644 include/trace-tcg.h
include/exec/helper-proto.h +0 -1
index ba100793a7..c4b1bda632 100644
@@ -38,7 +38,6 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
 #define IN_HELPER_PROTO
 
 #include "helper.h"
-#include "trace/generated-helpers.h"
 #include "accel/tcg/tcg-runtime.h"
 #include "accel/tcg/plugin-helpers.h"
 
include/exec/helper-tcg.h +0 -1
index 16cd318b83..3933258f1a 100644
@@ -59,7 +59,6 @@
     | dh_typemask(t5, 5) | dh_typemask(t6, 6) | dh_typemask(t7, 7) },
 
 #include "helper.h"
-#include "trace/generated-helpers.h"
 #include "accel/tcg/tcg-runtime.h"
 #include "accel/tcg/plugin-helpers.h"
 
include/trace-tcg.h deleted +0 -6
deleted file mode 100644
index da68608c85..0000000000
@@ -1,6 +0,0 @@
-#ifndef TRACE_TCG_H
-#define TRACE_TCG_H
-
-#include "trace/generated-tcg-tracers.h"
-
-#endif /* TRACE_TCG_H */
trace/meson.build +0 -1
index 573dd699c6..e279e33d4d 100644
@@ -62,7 +62,6 @@ trace_events_all = custom_target('trace-events-all',
                                  install_dir: qemu_datadir)
 
 foreach d : [
-  ['generated-tcg-tracers.h', 'tcg-h'],
   ['generated-helpers.c', 'tcg-helper-c'],
   ['generated-helpers.h', 'tcg-helper-h'],
   ['generated-helpers-wrappers.h', 'tcg-helper-wrapper-h'],
Signature · 1 line
2.30.2
Reviewed-by Philippe Mathieu-Daudé on v1 15/22
#29 lore raw

Re: [PATCH v1 15/22] tracing: remove the trace-tcg includes from the build

Quoted 8 lines · Alex Bennée

---
v2
- dropped includes here instead of next patch

Quoted 7 lines
---
 include/exec/helper-proto.h | 1 -
 include/exec/helper-tcg.h   | 1 -
 include/trace-tcg.h         | 6 ------
 trace/meson.build           | 1 -
 4 files changed, 9 deletions(-)
 delete mode 100644 include/trace-tcg.h
#30 lore raw

PATCH 16/22 tracing: excise the tcg related from tracetool

In reply to Alex Bennée

Now we have no TCG trace events and no longer handle them in the code we can remove the handling from the tracetool to generate them. vcpu tracing is still available although the existing syscall event is an exercise in redundancy (plugins and -strace can also get the information).

---
 meson.build                                   |  4 -
 include/exec/helper-gen.h                     |  2 -
 scripts/tracetool/__init__.py                 | 41 +--------
 scripts/tracetool/format/tcg_h.py             | 83 -------------------
 scripts/tracetool/format/tcg_helper_c.py      | 79 ------------------
 scripts/tracetool/format/tcg_helper_h.py      | 48 -----------
 .../tracetool/format/tcg_helper_wrapper_h.py  | 70 ----------------
 scripts/tracetool/vcpu.py                     | 14 +---
 trace/meson.build                             | 13 ---
 9 files changed, 4 insertions(+), 350 deletions(-)
 delete mode 100644 scripts/tracetool/format/tcg_h.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_c.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_h.py
 delete mode 100644 scripts/tracetool/format/tcg_helper_wrapper_h.py
meson.build +0 -4
index 51e3090438..73533f9eaa 100644
@@ -2355,19 +2355,15 @@ tracetool_depends = files(
   'scripts/tracetool/backend/simple.py',
   'scripts/tracetool/backend/syslog.py',
   'scripts/tracetool/backend/ust.py',
-  'scripts/tracetool/format/tcg_h.py',
   'scripts/tracetool/format/ust_events_c.py',
   'scripts/tracetool/format/ust_events_h.py',
   'scripts/tracetool/format/__init__.py',
   'scripts/tracetool/format/d.py',
-  'scripts/tracetool/format/tcg_helper_c.py',
   'scripts/tracetool/format/simpletrace_stap.py',
   'scripts/tracetool/format/c.py',
   'scripts/tracetool/format/h.py',
-  'scripts/tracetool/format/tcg_helper_h.py',
   'scripts/tracetool/format/log_stap.py',
   'scripts/tracetool/format/stap.py',
-  'scripts/tracetool/format/tcg_helper_wrapper_h.py',
   'scripts/tracetool/__init__.py',
   'scripts/tracetool/transform.py',
   'scripts/tracetool/vcpu.py'
include/exec/helper-gen.h +0 -2
index 1c2e7a8ed3..7b6ca975ef 100644
@@ -79,8 +79,6 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret)          \
 }
 
 #include "helper.h"
-#include "trace/generated-helpers.h"
-#include "trace/generated-helpers-wrappers.h"
 #include "accel/tcg/tcg-runtime.h"
 #include "accel/tcg/plugin-helpers.h"
 
scripts/tracetool/__init__.py +2 -39

65 lines not on this page · raw message

scripts/tracetool/format/tcg_h.py deleted +0 -83

83 lines not on this page · raw message

scripts/tracetool/format/tcg_helper_c.py deleted +0 -79

79 lines not on this page · raw message

scripts/tracetool/format/tcg_helper_h.py deleted +0 -48

48 lines not on this page · raw message

scripts/tracetool/format/tcg_helper_wrapper_h.py deleted +0 -70

70 lines not on this page · raw message

scripts/tracetool/vcpu.py +2 -12
index 868b4cb04c..d232cb1d06 100644
@@ -19,19 +19,9 @@
 def transform_event(event):
     """Transform event to comply with the 'vcpu' property (if present)."""
     if "vcpu" in event.properties:
-        # events with 'tcg-trans' and 'tcg-exec' are auto-generated from
-        # already-patched events
-        assert "tcg-trans" not in event.properties
-        assert "tcg-exec" not in event.properties
-
         event.args = Arguments([("void *", "__cpu"), event.args])
-        if "tcg" in event.properties:
-            fmt = "\"cpu=%p \""
-            event.fmt = [fmt + event.fmt[0],
-                         fmt + event.fmt[1]]
-        else:
-            fmt = "\"cpu=%p \""
-            event.fmt = fmt + event.fmt
+        fmt = "\"cpu=%p \""
+        event.fmt = fmt + event.fmt
     return event
 
 
trace/meson.build +0 -13
index e279e33d4d..298926036a 100644
@@ -61,19 +61,6 @@ trace_events_all = custom_target('trace-events-all',
                                  install: true,
                                  install_dir: qemu_datadir)
 
-foreach d : [
-  ['generated-helpers.c', 'tcg-helper-c'],
-  ['generated-helpers.h', 'tcg-helper-h'],
-  ['generated-helpers-wrappers.h', 'tcg-helper-wrapper-h'],
-]
-  gen = custom_target(d[0],
-                output: d[0],
-                input: meson.project_source_root() / 'trace-events',
-                command: [ tracetool, '--group=root', '--format=@0@'.format(d[1]), '@INPUT@', '@OUTPUT@' ],
-                depend_files: tracetool_depends)
-  specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
-endforeach
-
 if 'ust' in get_option('trace_backends')
   trace_ust_all_h = custom_target('trace-ust-all.h',
                                   output: 'trace-ust-all.h',
Signature · 1 line
2.30.2
#31 lore raw

PATCH 17/22 plugins: add helper functions for coverage plugins

In reply to Alex Bennée

From: Ivanov Arkady <[email protected]>

Which provide information about:
- start_code.
- end_code.
- entry.
- path to the executable binary.

Message-Id: <163491883461.304355.8210754161847179432.stgit@pc-System-Product-Name>

[AJB: reword title, better descriptions, defaults, rm export, fix include]
---
 include/qemu/qemu-plugin.h   | 34 ++++++++++++++++++++++++++
 plugins/api.c                | 46 ++++++++++++++++++++++++++++++++++++
 plugins/qemu-plugins.symbols |  4 ++++
 3 files changed, 84 insertions(+)
include/qemu/qemu-plugin.h +34 -0
index 5f1017201f..535ddbf0ae 100644
@@ -590,4 +590,38 @@ void qemu_plugin_outs(const char *string);
  */
 bool qemu_plugin_bool_parse(const char *name, const char *val, bool *ret);
 
+/**
+ * qemu_plugin_path_to_binary() - path to binary file being executed
+ *
+ * Return a string representing the path to the binary. For user-mode
+ * this is the main executable. For system emulation we currently
+ * return NULL. The user should g_free() the string once no longer
+ * needed.
+ */
+const char *qemu_plugin_path_to_binary(void);
+
+/**
+ * qemu_plugin_start_code() - returns start of text segment
+ *
+ * Returns the nominal start address of the main text segment in
+ * user-mode. Currently returns 0 for system emulation.
+ */
+uint64_t qemu_plugin_start_code(void);
+
+/**
+ * qemu_plugin_end_code() - returns end of text segment
+ *
+ * Returns the nominal end address of the main text segment in
+ * user-mode. Currently returns 0 for system emulation.
+ */
+uint64_t qemu_plugin_end_code(void);
+
+/**
+ * qemu_plugin_entry_code() - returns start address for module
+ *
+ * Returns the nominal entry address of the main text segment in
+ * user-mode. Currently returns 0 for system emulation.
+ */
+uint64_t qemu_plugin_entry_code(void);
+
 #endif /* QEMU_PLUGIN_API_H */
plugins/api.c +46 -0

55 lines not on this page · raw message

plugins/qemu-plugins.symbols +4 -0
index 4834756ba3..71f6c90549 100644
@@ -1,5 +1,7 @@
 {
   qemu_plugin_bool_parse;
+  qemu_plugin_end_code;
+  qemu_plugin_entry_code;
   qemu_plugin_get_hwaddr;
   qemu_plugin_hwaddr_device_name;
   qemu_plugin_hwaddr_is_io;
@@ -17,6 +19,7 @@
   qemu_plugin_n_max_vcpus;
   qemu_plugin_n_vcpus;
   qemu_plugin_outs;
+  qemu_plugin_path_to_binary;
   qemu_plugin_register_atexit_cb;
   qemu_plugin_register_flush_cb;
   qemu_plugin_register_vcpu_exit_cb;
@@ -33,6 +36,7 @@
   qemu_plugin_register_vcpu_tb_exec_inline;
   qemu_plugin_register_vcpu_tb_trans_cb;
   qemu_plugin_reset;
+  qemu_plugin_start_code;
   qemu_plugin_tb_get_insn;
   qemu_plugin_tb_n_insns;
   qemu_plugin_tb_vaddr;
Signature · 1 line
2.30.2
#32 lore raw

PATCH 18/22 contrib/plugins: add a drcov plugin

In reply to Alex Bennée

From: Ivanov Arkady <[email protected]>

This patch adds the ability to generate files in drcov format. Primary goal this script is to have coverage logfiles thatwork in Lighthouse.

Message-Id: <163491884553.304355.13246023070235438959.stgit@pc-System-Product-Name>

[AJB: use g_ptr_array instead of slist]
---
 contrib/plugins/drcov.c  | 163 +++++++++++++++++++++++++++++++++++++++
 contrib/plugins/Makefile |   1 +
 2 files changed, 164 insertions(+)
 create mode 100644 contrib/plugins/drcov.c
contrib/plugins/drcov.c new file +163 -0
new file mode 100644
index 0000000000..b4a855adaf
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2021, Ivanov Arkady <[email protected]>
+ *
+ * Drcov - a DynamoRIO-based tool that collects coverage information
+ * from a binary. Primary goal this script is to have coverage log
+ * files that work in Lighthouse.
+ *
+ * License: GNU GPL, version 2 or later.
+ *   See the COPYING file in the top-level directory.
+ */
+
+#include <inttypes.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <glib.h>
+
+#include <qemu-plugin.h>
+
+QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
+
+static char header[] = "DRCOV VERSION: 2\n"
+                "DRCOV FLAVOR: drcov-64\n"
+                "Module Table: version 2, count 1\n"
+                "Columns: id, base, end, entry, path\n";
+
+static FILE *fp;
+static const char *file_name = "file.drcov.trace";
+static GMutex lock;
+
+typedef struct {
+    uint32_t start;
+    uint16_t size;
+    uint16_t mod_id;
+    bool     exec;
+} bb_entry_t;
+
+/* Translated blocks */
+static GPtrArray *blocks;
+
+static void printf_header(unsigned long count)
+{
+    fprintf(fp, "%s", header);
+    const char *path = qemu_plugin_path_to_binary();
+    uint64_t start_code = qemu_plugin_start_code();
+    uint64_t end_code = qemu_plugin_end_code();
+    uint64_t entry = qemu_plugin_entry_code();
+    fprintf(fp, "0, 0x%lx, 0x%lx, 0x%lx, %s\n",
+            start_code, end_code, entry, path);
+    fprintf(fp, "BB Table: %ld bbs\n", count);
+}
+
+static void printf_char_array32(uint32_t data)
+{
+    const uint8_t *bytes = (const uint8_t *)(&data);
+    fwrite(bytes, sizeof(char), sizeof(data), fp);
+}
+
+static void printf_char_array16(uint16_t data)
+{
+    const uint8_t *bytes = (const uint8_t *)(&data);
+    fwrite(bytes, sizeof(char), sizeof(data), fp);
+}
+
+
+static void printf_el(gpointer data, gpointer user_data)
+{
+    bb_entry_t *bb = (bb_entry_t *)data;
+    if (bb->exec) {
+        printf_char_array32(bb->start);
+        printf_char_array16(bb->size);
+        printf_char_array16(bb->mod_id);
+    }
+    g_free(bb);
+}
+
+static void count_block(gpointer data, gpointer user_data)
+{
+    unsigned long *count = (unsigned long *) user_data;
+    bb_entry_t *bb = (bb_entry_t *)data;
+    if (bb->exec) {
+        *count = *count + 1;
+    }
+}
+
+static void plugin_exit(qemu_plugin_id_t id, void *p)
+{
+    unsigned long count = 0;
+    g_mutex_lock(&lock);
+    g_ptr_array_foreach(blocks, count_block, &count);
+
+    /* Print function */
+    printf_header(count);
+    g_ptr_array_foreach(blocks, printf_el, NULL);
+
+    /* Clear */
+    g_ptr_array_free(blocks, true);
+
+    fclose(fp);
+
+    g_mutex_unlock(&lock);
+}
+
+static void plugin_init(void)
+{
+    fp = fopen(file_name, "wb");
+    blocks = g_ptr_array_sized_new(128);
+}
+
+static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
+{
+    bb_entry_t *bb = (bb_entry_t *) udata;
+
+    g_mutex_lock(&lock);
+    bb->exec = true;
+    g_mutex_unlock(&lock);
+}
+
+static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
+{
+    uint64_t pc = qemu_plugin_tb_vaddr(tb);
+    size_t n = qemu_plugin_tb_n_insns(tb);
+
+    g_mutex_lock(&lock);
+
+    bb_entry_t *bb = g_new0(bb_entry_t, 1);
+    for (int i = 0; i < n; i++) {
+        bb->size += qemu_plugin_insn_size(qemu_plugin_tb_get_insn(tb, i));
+    }
+
+    bb->start = pc;
+    bb->mod_id = 0;
+    bb->exec = false;
+    g_ptr_array_add(blocks, bb);
+
+    g_mutex_unlock(&lock);
+    qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec,
+                                         QEMU_PLUGIN_CB_NO_REGS,
+                                         (void *)bb);
+
+}
+
+QEMU_PLUGIN_EXPORT
+int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
+                        int argc, char **argv)
+{
+    for (int i = 0; i < argc; i++) {
+        g_autofree char **tokens = g_strsplit(argv[i], "=", 2);
+        if (g_strcmp0(tokens[0], "filename") == 0) {
+            file_name = g_strdup(tokens[1]);
+        }
+    }
+
+    plugin_init();
+
+    qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
+    qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
+
+    return 0;
+}
contrib/plugins/Makefile +1 -0
index 576ed5875a..7eed5d51f8 100644
@@ -21,6 +21,7 @@ NAMES += lockstep
 NAMES += hwprofile
 NAMES += cache
 NAMES += stxp-plugin
+NAMES += drcov
 
 SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
 
Signature · 1 line
2.30.2
#33 lore raw

PATCH 19/22 tests/plugin: allow libinsn.so per-CPU counts

In reply to Alex Bennée

We won't go fully flexible but for most system emulation 8 vCPUs resolution should be enough for anybody ;-)

---
 tests/plugin/insn.c | 39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)
tests/plugin/insn.c +31 -8
index d229fdc001..d5a0a08cb4 100644
@@ -16,22 +16,33 @@
 
 QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
 
-static uint64_t insn_count;
+#define MAX_CPUS 8 /* lets not go nuts */
+
+typedef struct {
+    uint64_t last_pc;
+    uint64_t insn_count;
+} InstructionCount;
+
+static InstructionCount counts[MAX_CPUS];
+static uint64_t inline_insn_count;
+
 static bool do_inline;
 static bool do_size;
+static bool do_frequency;
 static GArray *sizes;
 
 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata)
 {
-    static uint64_t last_pc;
+    unsigned int i = cpu_index % MAX_CPUS;
+    InstructionCount *c = &counts[i];
     uint64_t this_pc = GPOINTER_TO_UINT(udata);
-    if (this_pc == last_pc) {
+    if (this_pc == c->last_pc) {
         g_autofree gchar *out = g_strdup_printf("detected repeat execution @ 0x%"
                                                 PRIx64 "\n", this_pc);
         qemu_plugin_outs(out);
     }
-    last_pc = this_pc;
-    insn_count++;
+    c->last_pc = this_pc;
+    c->insn_count++;
 }
 
 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
@@ -44,7 +55,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 
         if (do_inline) {
             qemu_plugin_register_vcpu_insn_exec_inline(
-                insn, QEMU_PLUGIN_INLINE_ADD_U64, &insn_count, 1);
+                insn, QEMU_PLUGIN_INLINE_ADD_U64, &inline_insn_count, 1);
         } else {
             uint64_t vaddr = qemu_plugin_insn_vaddr(insn);
             qemu_plugin_register_vcpu_insn_exec_cb(
@@ -66,9 +77,9 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 static void plugin_exit(qemu_plugin_id_t id, void *p)
 {
     g_autoptr(GString) out = g_string_new(NULL);
+    int i;
 
     if (do_size) {
-        int i;
         for (i = 0; i <= sizes->len; i++) {
             unsigned long *cnt = &g_array_index(sizes, unsigned long, i);
             if (*cnt) {
@@ -76,8 +87,20 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
                                        "len %d bytes: %ld insns\n", i, *cnt);
             }
         }
+    } else if (do_inline) {
+        g_string_append_printf(out, "insns: %" PRIu64 "\n", inline_insn_count);
     } else {
-        g_string_append_printf(out, "insns: %" PRIu64 "\n", insn_count);
+        uint64_t total_insns = 0;
+        for (i = 0; i < MAX_CPUS; i++) {
+            InstructionCount *c = &counts[i];
+            if (c->insn_count) {
+                g_string_append_printf(out, "cpu %d insns: %" PRIu64 "\n",
+                                       i, c->insn_count);
+                total_insns += c->insn_count;
+            }
+        }
+        g_string_append_printf(out, "total insns: %" PRIu64 "\n",
+                               total_insns);
     }
     qemu_plugin_outs(out->str);
 }
Signature · 1 line
2.30.2
#34 lore raw

PATCH 20/22 tests/plugins: add instruction matching to libinsn.so

In reply to Alex Bennée

This adds simple instruction matching to the libinsn.so plugin which is useful for examining the execution distance between instructions. For example to track how often we flush in ARM due to TLB updates:

-plugin ./tests/plugin/libinsn.so,match=tlbi

which leads to output like this:

0xffffffc01018fa00, tlbi aside1is, x0, 339, 32774 match hits, 23822 since last, avg 47279 0xffffffc01018fa00, tlbi aside1is, x0, 340, 32775 match hits, 565051 since last, avg 47295 0xffffffc0101915a4, tlbi vae1is, x0, 155, 32776 match hits, 151135 since last, avg 47298 0xffffffc01018fc60, tlbi vae1is, x4, 224, 32777 match hits, 814 since last, avg 47297

  0xffffffc010194a44, tlbi vale1is, x1,  8835, 32778 match hits, 52027 since last, avg 47297
  0xffffffc010194a44, tlbi vale1is, x1,  8836, 32779 match hits, 8347 since last, avg 47296
  0xffffffc010194a44, tlbi vale1is, x1,  8837, 32780 match hits, 33677 since last, avg 47295

showing we do some sort of TLBI invalidation every 47 thousand instructions.

Cc Vasilev Oleg <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Emilio Cota <[email protected]>
---
 tests/plugin/insn.c | 88 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)
tests/plugin/insn.c +87 -1
index d5a0a08cb4..3f48c86fd7 100644
@@ -28,9 +28,25 @@ static uint64_t inline_insn_count;
 
 static bool do_inline;
 static bool do_size;
-static bool do_frequency;
 static GArray *sizes;
 
+typedef struct {
+    char *match_string;
+    uint64_t hits[MAX_CPUS];
+    uint64_t last_hit[MAX_CPUS];
+    uint64_t total_delta[MAX_CPUS];
+    GPtrArray *history[MAX_CPUS];
+} Match;
+
+static GArray *matches;
+
+typedef struct {
+    Match *match;
+    uint64_t vaddr;
+    uint64_t hits;
+    char *disas;
+} Instruction;
+
 static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata)
 {
     unsigned int i = cpu_index % MAX_CPUS;
@@ -45,6 +61,36 @@ static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata)
     c->insn_count++;
 }
 
+static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *udata)
+{
+    unsigned int i = cpu_index % MAX_CPUS;
+    Instruction *insn = (Instruction *) udata;
+    Match *match = insn->match;
+    g_autoptr(GString) ts = g_string_new("");
+
+    insn->hits++;
+    g_string_append_printf(ts, "0x%" PRIx64 ", %s, % "PRId64,
+                           insn->vaddr, insn->disas, insn->hits);
+
+    uint64_t icount = counts[i].insn_count;
+    uint64_t delta = icount - match->last_hit[i];
+
+    match->hits[i]++;
+    match->total_delta[i] += delta;
+
+    g_string_append_printf(ts,
+                           ", %"PRId64" match hits, %"PRId64
+                           " since last, avg %"PRId64"\n",
+                           match->hits[i], delta,
+                           match->total_delta[i] / match->hits[i]);
+
+    match->last_hit[i] = icount;
+
+    qemu_plugin_outs(ts->str);
+
+    g_ptr_array_add(match->history[i], insn);
+}
+
 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 {
     size_t n = qemu_plugin_tb_n_insns(tb);
@@ -71,6 +117,29 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
             unsigned long *cnt = &g_array_index(sizes, unsigned long, sz);
             (*cnt)++;
         }
+
+        /*
+         * If we are tracking certain instructions we will need more
+         * information about the instruction which we also need to
+         * save if there is a hit.
+         */
+        if (matches) {
+            char *insn_disas = qemu_plugin_insn_disas(insn);
+            int j;
+            for (j = 0; j < matches->len; j++) {
+                Match *m = &g_array_index(matches, Match, j);
+                if (g_str_has_prefix(insn_disas, m->match_string)) {
+                    Instruction *rec = g_new0(Instruction, 1);
+                    rec->disas = g_strdup(insn_disas);
+                    rec->vaddr = qemu_plugin_insn_vaddr(insn);
+                    rec->match = m;
+                    qemu_plugin_register_vcpu_insn_exec_cb(
+                        insn, vcpu_insn_matched_exec_before,
+                        QEMU_PLUGIN_CB_NO_REGS, rec);
+                }
+            }
+            g_free(insn_disas);
+        }
     }
 }
 
@@ -105,6 +174,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *p)
     qemu_plugin_outs(out->str);
 }
 
+
+/* Add a match to the array of matches */
+static void parse_match(char *match)
+{
+    Match new_match = { .match_string = match };
+    int i;
+    for (i = 0; i < MAX_CPUS; i++) {
+        new_match.history[i] = g_ptr_array_new();
+    }
+    if (!matches) {
+        matches = g_array_new(false, true, sizeof(Match));
+    }
+    g_array_append_val(matches, new_match);
+}
+
 QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
                                            const qemu_info_t *info,
                                            int argc, char **argv)
@@ -122,6 +206,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
                 fprintf(stderr, "boolean argument parsing failed: %s\n", opt);
                 return -1;
             }
+        } else if (g_strcmp0(tokens[0], "match") == 0) {
+            parse_match(tokens[1]);
         } else {
             fprintf(stderr, "option parsing failed: %s\n", opt);
             return -1;
Signature · 1 line
2.30.2
#35 lore raw

Re: [PATCH v1 20/22] tests/plugins: add instruction matching to libinsn.so

Quoted 8 lines · Alex Bennée

This adds simple instruction matching to the libinsn.so plugin which is useful for examining the execution distance between instructions. For example to track how often we flush in ARM due to TLB updates:

-plugin ./tests/plugin/libinsn.so,match=tlbi

which leads to output like this:

Quoted 7 lines

0xffffffc01018fa00, tlbi aside1is, x0, 339, 32774 match hits, 23822 since last, avg 47279 0xffffffc01018fa00, tlbi aside1is, x0, 340, 32775 match hits, 565051 since last, avg 47295 0xffffffc0101915a4, tlbi vae1is, x0, 155, 32776 match hits, 151135 since last, avg 47298 0xffffffc01018fc60, tlbi vae1is, x4, 224, 32777 match hits, 814 since last, avg 47297

  0xffffffc010194a44, tlbi vale1is, x1,  8835, 32778 match hits, 52027 since last, avg 47297
  0xffffffc010194a44, tlbi vale1is, x1,  8836, 32779 match hits, 8347 since last, avg 47296
  0xffffffc010194a44, tlbi vale1is, x1,  8837, 32780 match hits, 33677 since last, avg 47295

Just nitpicking the output below.

Quoted 11 lines

showing we do some sort of TLBI invalidation every 47 thousand instructions.

Cc Vasilev Oleg <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Emilio Cota <[email protected]>
---
 tests/plugin/insn.c | 88 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)

tests/plugin/insn.c static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) · line 73

Quoted 10 lines
tests/plugin/insn.c +10 -0
+static void vcpu_insn_matched_exec_before(unsigned int cpu_index, void *udata)
+{
+    unsigned int i = cpu_index % MAX_CPUS;
+    Instruction *insn = (Instruction *) udata;
+    Match *match = insn->match;
+    g_autoptr(GString) ts = g_string_new("");
+
+    insn->hits++;
+    g_string_append_printf(ts, "0x%" PRIx64 ", %s, % "PRId64,
+                           insn->vaddr, insn->disas, insn->hits);

Maybe use something else the ',' to split last arg (hits)? \t or --? Otherwise it seems part of the decoded instr.

tests/plugin/insn.c static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) · line 82

Quoted 9 lines
tests/plugin/insn.c +9 -0
+
+    uint64_t icount = counts[i].insn_count;
+    uint64_t delta = icount - match->last_hit[i];
+
+    match->hits[i]++;
+    match->total_delta[i] += delta;
+
+    g_string_append_printf(ts,
+                           ", %"PRId64" match hits, %"PRId64

Maybe prefix delta with '+'.

Quoted 10 lines
tests/plugin/insn.c +10 -0
+                           " since last, avg %"PRId64"\n",
+                           match->hits[i], delta,
+                           match->total_delta[i] / match->hits[i]);
+
+    match->last_hit[i] = icount;
+
+    qemu_plugin_outs(ts->str);
+
+    g_ptr_array_add(match->history[i], insn);
+}
#36 lore raw

PATCH 21/22 target/i386: use CPU_LOG_INT for IRQ servicing

In reply to Alex Bennée

I think these have been wrong since f193c7979c (do not depend on thunk.h - more log items). Fix them so as not to confuse other debugging.

---
 target/i386/tcg/sysemu/seg_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/tcg/sysemu/seg_helper.c +2 -2
index bf3444c26b..824b9a5a26 100644
@@ -167,7 +167,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
         cs->interrupt_request &= ~(CPU_INTERRUPT_HARD |
                                    CPU_INTERRUPT_VIRQ);
         intno = cpu_get_pic_interrupt(env);
-        qemu_log_mask(CPU_LOG_TB_IN_ASM,
+        qemu_log_mask(CPU_LOG_INT,
                       "Servicing hardware INT=0x%02x\n", intno);
         do_interrupt_x86_hardirq(env, intno, 1);
         break;
@@ -175,7 +175,7 @@ bool x86_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
         cpu_svm_check_intercept_param(env, SVM_EXIT_VINTR, 0, 0);
         intno = x86_ldl_phys(cs, env->vm_vmcb
                              + offsetof(struct vmcb, control.int_vector));
-        qemu_log_mask(CPU_LOG_TB_IN_ASM,
+        qemu_log_mask(CPU_LOG_INT,
                       "Servicing virtual hardware INT=0x%02x\n", intno);
         do_interrupt_x86_hardirq(env, intno, 1);
         cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
Signature · 1 line
2.30.2
Reviewed-by Philippe Mathieu-Daudé on v1 21/22
#37 lore raw

Re: [PATCH v1 21/22] target/i386: use CPU_LOG_INT for IRQ servicing

Quoted 8 lines · Alex Bennée

I think these have been wrong since f193c7979c (do not depend on thunk.h - more log items). Fix them so as not to confuse other debugging.

---
 target/i386/tcg/sysemu/seg_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by on v1 21/22
#38 lore raw

Re: [PATCH v1 21/22] target/i386: use CPU_LOG_INT for IRQ servicing

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

I think these have been wrong since f193c7979c (do not depend on thunk.h - more log items). Fix them so as not to confuse other debugging.

---
  target/i386/tcg/sysemu/seg_helper.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

r~

#39 lore raw

PATCH 22/22 plugins: move reset of plugin data to tb_start

In reply to Alex Bennée

We can't always guarantee we get to the end of a translator loop. Although this can happen for a variety of reasons it does happen more often on x86 system emulation when an instruction spans across to an un-faulted page. This caused confusion of the instruction tracking data resulting in apparent reverse execution (at least from the plugins point of view).

Fix this by moving the reset code to plugin_gen_tb_start so we always start with a clean slate.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/824

---
 accel/tcg/plugin-gen.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)
accel/tcg/plugin-gen.c +18 -11
index 22d95fe1c3..ae70e4a5b0 100644
@@ -854,10 +854,21 @@ static void plugin_gen_inject(const struct qemu_plugin_tb *plugin_tb)
 
 bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool mem_only)
 {
-    struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb;
     bool ret = false;
 
     if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_mask)) {
+        struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb;
+        int i;
+
+        /* reset callbacks */
+        for (i = 0; i < PLUGIN_N_CB_SUBTYPES; i++) {
+            if (ptb->cbs[i]) {
+                g_array_set_size(ptb->cbs[i], 0);
+            }
+        }
+        ptb->n = 0;
+        tcg_ctx->plugin_insn = NULL;
+
         ret = true;
 
         ptb->vaddr = tb->pc;
@@ -904,23 +915,19 @@ void plugin_gen_insn_end(void)
     plugin_gen_empty_callback(PLUGIN_GEN_AFTER_INSN);
 }
 
+/*
+ * There are cases where we never get to finalise a translation - for
+ * example a page fault during translation. As a result we shouldn't
+ * do any clean-up here and make sure things are reset in
+ * plugin_gen_tb_start.
+ */
 void plugin_gen_tb_end(CPUState *cpu)
 {
     struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb;
-    int i;
 
     /* collect instrumentation requests */
     qemu_plugin_tb_trans_cb(cpu, ptb);
 
     /* inject the instrumentation at the appropriate places */
     plugin_gen_inject(ptb);
-
-    /* clean up */
-    for (i = 0; i < PLUGIN_N_CB_SUBTYPES; i++) {
-        if (ptb->cbs[i]) {
-            g_array_set_size(ptb->cbs[i], 0);
-        }
-    }
-    ptb->n = 0;
-    tcg_ctx->plugin_insn = NULL;
 }
Signature · 1 line
2.30.2