October maintainer omnibus pre-PR (tests, gdbstub, plugins)
Subsystems (2)
cover October maintainer omnibus pre-PR (tests, gdbstub, plugins)
Hi,
This wraps up my current testing, gdbstub and plugin trees in an attempt to do my part to reduce the qemu-devel fire hose. It is pretty much the same as the September tree except:
- dropped RFC patches
- dropped CRIS deprecation patches
- dropped makefile dependency tweaks
- tweaked RUNC as per Paolo's suggestion
- used later version of Marcin's sbsa-ref changes
- added a FLAKY_TEST removal
- added tags as appropriate
Now I'm using the pre-PR subject to give people a last chance to object before I roll a proper pull request later this week.
The following still could do with review:
contrib/plugins: fix coverity warning in hotblocks contrib/plugins: fix coverity warning in lockstep contrib/plugins: fix coverity warning in cache
configure: remove gcc version suffixes
configure: allow user to override docker engine tests/docker: make docker engine choice entirely configure driven tests/avocado: remove flaky test marking for test_sbsaref_edk2_firmware
Akihiko Odaki (12):
gdbstub: Fix target_xml initialization
gdbstub: Fix target.xml response
plugins: Check if vCPU is realized contrib/plugins: Use GRWLock in execlog
gdbstub: Introduce GDBFeature structure target/arm: Move the reference to arm-core.xml hw/core/cpu: Return static value with gdb_arch_name()
gdbstub: Use g_markup_printf_escaped() target/arm: Remove references to gdb_has_xml target/ppc: Remove references to gdb_has_xml
gdbstub: Remove gdb_has_xml variable
gdbstub: Replace gdb_regs with an array
Alex Bennée (9):
tests/avocado: remove flaky test marking for
test_sbsaref_edk2_firmware
tests/lcitool: add swtpm to the package list
gitlab: shuffle some targets and reduce avocado noise tests/docker: make docker engine choice entirely configure driven
configure: allow user to override docker engine
configure: remove gcc version suffixes contrib/plugins: fix coverity warning in cache contrib/plugins: fix coverity warning in lockstep contrib/plugins: fix coverity warning in hotblocks
Marcin Juszkiewicz (1):
tests/avocado: update firmware to enable OpenBSD test on sbsa-ref
Matt Borgerson (1):
plugins: Set final instruction count in plugin_gen_tb_end
Richard Henderson (2):
accel/tcg: Add plugin_enabled to DisasContextBase target/sh4: Disable decode_gusa when plugins enabled
MAINTAINERS | 2 +- configure | 13 ++- meson.build | 2 +- gdbstub/internals.h | 2 - include/exec/gdbstub.h | 17 ++-- include/exec/plugin-gen.h | 4 +- include/exec/translator.h | 2 + include/hw/core/cpu.h | 4 +- target/ppc/internal.h | 2 +- accel/tcg/plugin-gen.c | 6 +- accel/tcg/translator.c | 3 +- contrib/plugins/cache.c | 18 ++-- contrib/plugins/execlog.c | 16 ++-- contrib/plugins/hotblocks.c | 2 +- contrib/plugins/lockstep.c | 13 ++- gdbstub/gdbstub.c | 95 +++++++++---------- gdbstub/softmmu.c | 2 +- plugins/core.c | 2 +- stubs/gdbstub.c | 6 +- target/arm/cpu.c | 9 +- target/arm/cpu64.c | 4 +- target/arm/gdbstub.c | 32 +------ target/i386/cpu.c | 6 +- target/loongarch/cpu.c | 8 +- target/ppc/gdbstub.c | 24 +---- target/riscv/cpu.c | 6 +- target/s390x/cpu.c | 4 +- target/sh4/translate.c | 41 +++++--- target/tricore/cpu.c | 4 +- .gitlab-ci.d/buildtest.yml | 15 ++- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- scripts/feature_to_c.py | 48 ++++++++++ scripts/feature_to_c.sh | 69 -------------- tests/avocado/machine_aarch64_sbsaref.py | 71 +++++++++++--- tests/docker/Makefile.include | 9 +- tests/docker/dockerfiles/alpine.docker | 1 + tests/docker/dockerfiles/centos8.docker | 1 + .../dockerfiles/debian-amd64-cross.docker | 1 + tests/docker/dockerfiles/debian-amd64.docker | 1 + .../dockerfiles/debian-arm64-cross.docker | 1 + .../dockerfiles/debian-armhf-cross.docker | 1 + .../dockerfiles/debian-ppc64el-cross.docker | 1 + .../dockerfiles/debian-s390x-cross.docker | 1 + .../dockerfiles/fedora-win32-cross.docker | 1 + .../dockerfiles/fedora-win64-cross.docker | 1 + tests/docker/dockerfiles/fedora.docker | 1 + tests/docker/dockerfiles/opensuse-leap.docker | 1 + tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/libvirt-ci | 2 +- tests/lcitool/projects/qemu.yml | 1 + 50 files changed, 305 insertions(+), 274 deletions(-) create mode 100755 scripts/feature_to_c.py delete mode 100644 scripts/feature_to_c.sh
Signature · 1 line
2.39.2
PATCH 1/25 tests/avocado: update firmware to enable OpenBSD test on sbsa-ref
From: Marcin Juszkiewicz <[email protected]>
Update prebuilt firmware images:
- Neoverse V1/N2 cpu support
- non-secure EL2 virtual timer
- XHCI controller in DSDT
With those changes we can now run OpenBSD as part of sbsa-ref tests.
Message-Id: <[email protected]>
--- tests/avocado/machine_aarch64_sbsaref.py | 70 ++++++++++++++++++++---- 1 file changed, 60 insertions(+), 10 deletions(-)
tests/avocado/machine_aarch64_sbsaref.py +60 -10
@@ -28,33 +28,33 @@ def fetch_firmware(self): """ Flash volumes generated using: - - Fedora GNU Toolchain version 13.1.1 20230511 (Red Hat 13.1.1-2) + - Fedora GNU Toolchain version 13.2.1 20230728 (Red Hat 13.2.1-1) - Trusted Firmware-A - https://github.com/ARM-software/arm-trusted-firmware/tree/c0d8ee38 + https://github.com/ARM-software/arm-trusted-firmware/tree/7c3ff62d - Tianocore EDK II https://github.com/tianocore/edk2/tree/0f9283429dd4 - https://github.com/tianocore/edk2-non-osi/tree/f0bb00937ad6 - https://github.com/tianocore/edk2-platforms/tree/7880b92e2a04 + https://github.com/tianocore/edk2/tree/ad1c0394b177 + https://github.com/tianocore/edk2-platforms/tree/d03a60523a60 """ # Secure BootRom (TF-A code) fs0_xz_url = ( - "https://fileserver.linaro.org/s/HrYMCjP7MEccjRP/" + "https://fileserver.linaro.org/s/rE43RJyTfxPtBkc/" "download/SBSA_FLASH0.fd.xz" ) - fs0_xz_hash = "447eff64a90b84ce47703c6ec41fbfc25befaaea" + fs0_xz_hash = "cdb8e4ffdaaa79292b7b465693f9e5fae6b7062d" tar_xz_path = self.fetch_asset(fs0_xz_url, asset_hash=fs0_xz_hash) archive.extract(tar_xz_path, self.workdir) fs0_path = os.path.join(self.workdir, "SBSA_FLASH0.fd") # Non-secure rom (UEFI and EFI variables) fs1_xz_url = ( - "https://fileserver.linaro.org/s/t8foNnMPz74DZZy/" + "https://fileserver.linaro.org/s/AGWPDXbcqJTKS4R/" "download/SBSA_FLASH1.fd.xz" ) - fs1_xz_hash = "13a9a262953787c7fc5a9155dfaa26e703631e02" + fs1_xz_hash = "411155ae6984334714dff08d5d628178e790c875" tar_xz_path = self.fetch_asset(fs1_xz_url, asset_hash=fs1_xz_hash) archive.extract(tar_xz_path, self.workdir) fs1_path = os.path.join(self.workdir, "SBSA_FLASH1.fd")
@@ -144,7 +144,7 @@ def test_sbsaref_alpine_linux_cortex_a57(self): def test_sbsaref_alpine_linux_neoverse_n1(self): """ - :avocado: tags=cpu:max + :avocado: tags=cpu:neoverse-n1 """ self.boot_alpine_linux("neoverse-n1")
@@ -152,4 +152,54 @@ def test_sbsaref_alpine_linux_max(self): """ :avocado: tags=cpu:max """ - self.boot_alpine_linux("max,pauth-impdef=on") + self.boot_alpine_linux("max") + + + # This tests the whole boot chain from EFI to Userspace + # We only boot a whole OS for the current top level CPU and GIC + # Other test profiles should use more minimal boots + def boot_openbsd73(self, cpu): + self.fetch_firmware() + + img_url = ( + "https://cdn.openbsd.org/pub/OpenBSD/7.3/arm64/miniroot73.img" + ) + + img_hash = "7fc2c75401d6f01fbfa25f4953f72ad7d7c18650056d30755c44b9c129b707e5" + img_path = self.fetch_asset(img_url, algorithm="sha256", asset_hash=img_hash) + + self.vm.set_console() + self.vm.add_args( + "-cpu", + cpu, + "-drive", + f"file={img_path},format=raw", + "-device", + "virtio-rng-pci,rng=rng0", + "-object", + "rng-random,id=rng0,filename=/dev/urandom", + ) + + self.vm.launch() + wait_for_console_pattern(self, + "Welcome to the OpenBSD/arm64" + " 7.3 installation program.") + + def test_sbsaref_openbsd73_cortex_a57(self): + """ + :avocado: tags=cpu:cortex-a57 + """ + self.boot_openbsd73("cortex-a57") + + def test_sbsaref_openbsd73_neoverse_n1(self): + """ + :avocado: tags=cpu:neoverse-n1 + """ + self.boot_openbsd73("neoverse-n1") + + def test_sbsaref_openbsd73_max(self): + """ + :avocado: tags=cpu:max + """ + self.boot_openbsd73("max") +
Signature · 1 line
2.39.2
PATCH 2/25 tests/avocado: remove flaky test marking for test_sbsaref_edk2_firmware
In reply to Alex BennéeAfter testing locally I decided to revert a5754847e0 (tests/avocado: Disable the test_sbsaref_edk2_firmware by default) as the test seems pretty stable:
env QEMU_TEST_FLAKY_TESTS=1 retry.py -n 50 -c -- \
./tests/venv/bin/avocado run \
./tests/avocado/machine_aarch64_sbsaref.py:Aarch64SbsarefMachine.test_sbsaref_edk2_firmwareyields:
Results summary:
0: 50 times (100.00%), avg time 2.064 (0.04 varience/0.19 deviation) Ran command 50 times, 50 passes
Maybe f0ec14c78c (tests/avocado: Fix console data loss) has made it more reliable?
--- tests/avocado/machine_aarch64_sbsaref.py | 1 - 1 file changed, 1 deletion(-)
tests/avocado/machine_aarch64_sbsaref.py +0 -1
@@ -75,7 +75,6 @@ def fetch_firmware(self): "sbsa-ref", ) - @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is not reliable') def test_sbsaref_edk2_firmware(self): """ :avocado: tags=cpu:cortex-a57
Signature · 1 line
2.39.2
Re: [PATCH 02/25] tests/avocado: remove flaky test marking for test_sbsaref_edk2_firmware
Quoted 14 lines · Alex Bennée
After testing locally I decided to revert
a5754847e0(tests/avocado: Disable thetest_sbsaref_edk2_firmwareby default) as the test seems pretty stable:env QEMU_TEST_FLAKY_TESTS=1 retry.py -n 50 -c -- \ ./tests/venv/bin/avocado run \ ./tests/avocado/machine_aarch64_sbsaref.py:Aarch64SbsarefMachine.test_sbsaref_edk2_firmwareyields:
Results summary:
0: 50 times (100.00%), avg time 2.064 (0.04 varience/0.19 deviation) Ran command 50 times, 50 passes
Quoted 8 lines
Maybe
f0ec14c78c(tests/avocado: Fix console data loss) has made it more reliable?Signed-off-by Alex Bennée <[email protected]>Cc Thomas Huth <[email protected]>--- tests/avocado/machine_aarch64_sbsaref.py | 1 - 1 file changed, 1 deletion(-)
PATCH 3/25 tests/lcitool: add swtpm to the package list
In reply to Alex BennéeWe need this to test some TPM stuff.
Message-Id: <[email protected]>
--- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- tests/docker/dockerfiles/alpine.docker | 1 + tests/docker/dockerfiles/centos8.docker | 1 + tests/docker/dockerfiles/debian-amd64-cross.docker | 1 + tests/docker/dockerfiles/debian-amd64.docker | 1 + tests/docker/dockerfiles/debian-arm64-cross.docker | 1 + tests/docker/dockerfiles/debian-armhf-cross.docker | 1 + tests/docker/dockerfiles/debian-ppc64el-cross.docker | 1 + tests/docker/dockerfiles/debian-s390x-cross.docker | 1 + tests/docker/dockerfiles/fedora-win32-cross.docker | 1 + tests/docker/dockerfiles/fedora-win64-cross.docker | 1 + tests/docker/dockerfiles/fedora.docker | 1 + tests/docker/dockerfiles/opensuse-leap.docker | 1 + tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/libvirt-ci | 2 +- tests/lcitool/projects/qemu.yml | 1 + 16 files changed, 16 insertions(+), 2 deletions(-)
.gitlab-ci.d/cirrus/macos-12.vars +1 -1
@@ -11,6 +11,6 @@ MAKE='/opt/homebrew/bin/gmake' NINJA='/opt/homebrew/bin/ninja' PACKAGING_COMMAND='brew' PIP3='/opt/homebrew/bin/pip3' -PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol tesseract usbredir vde vte3 xorriso zlib zstd' +PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol swtpm tesseract usbredir vde vte3 xorriso zlib zstd' PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli' PYTHON='/opt/homebrew/bin/python3'
tests/docker/dockerfiles/alpine.docker +1 -0
@@ -100,6 +100,7 @@ RUN apk update && \ sparse \ spice-dev \ spice-protocol \ + swtpm \ tar \ tesseract-ocr \ usbredir-dev \
tests/docker/dockerfiles/centos8.docker +1 -0
@@ -107,6 +107,7 @@ RUN dnf distro-sync -y && \ socat \ spice-protocol \ spice-server-devel \ + swtpm \ systemd-devel \ systemtap-sdt-devel \ tar \
tests/docker/dockerfiles/debian-amd64-cross.docker +1 -0
@@ -55,6 +55,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \
tests/docker/dockerfiles/debian-amd64.docker +1 -0
@@ -124,6 +124,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ systemtap-sdt-dev \ tar \ tesseract-ocr \
tests/docker/dockerfiles/debian-arm64-cross.docker +1 -0
@@ -55,6 +55,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \
tests/docker/dockerfiles/debian-armhf-cross.docker +1 -0
@@ -55,6 +55,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \
tests/docker/dockerfiles/debian-ppc64el-cross.docker +1 -0
@@ -55,6 +55,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \
tests/docker/dockerfiles/debian-s390x-cross.docker +1 -0
@@ -55,6 +55,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ tar \ tesseract-ocr \ tesseract-ocr-eng \
tests/docker/dockerfiles/fedora-win32-cross.docker +1 -0
@@ -55,6 +55,7 @@ exec "$@"\n' > /usr/bin/nosync && \ socat \ sparse \ spice-protocol \ + swtpm \ tar \ tesseract \ tesseract-langpack-eng \
tests/docker/dockerfiles/fedora-win64-cross.docker +1 -0
@@ -55,6 +55,7 @@ exec "$@"\n' > /usr/bin/nosync && \ socat \ sparse \ spice-protocol \ + swtpm \ tar \ tesseract \ tesseract-langpack-eng \
tests/docker/dockerfiles/fedora.docker +1 -0
@@ -118,6 +118,7 @@ exec "$@"\n' > /usr/bin/nosync && \ sparse \ spice-protocol \ spice-server-devel \ + swtpm \ systemd-devel \ systemtap-sdt-devel \ tar \
tests/docker/dockerfiles/opensuse-leap.docker +1 -0
@@ -100,6 +100,7 @@ RUN zypper update -y && \ socat \ sparse \ spice-protocol-devel \ + swtpm \ systemd-devel \ systemtap-sdt-devel \ tar \
tests/docker/dockerfiles/ubuntu2204.docker +1 -0
@@ -124,6 +124,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ sed \ socat \ sparse \ + swtpm \ systemtap-sdt-dev \ tar \ tesseract-ocr \
tests/lcitool/libvirt-ci +1 -1
@@ -1 +1 @@ -Subproject commit e3ed1e5da101943e53d8d89424e17b22120743f5 +Subproject commit 36bc517161c45ead20224d47f2dc4fa428af6724
tests/lcitool/projects/qemu.yml +1 -0
@@ -110,6 +110,7 @@ packages: - spice-protocol - spice-server - ssh-client + - swtpm - systemd - tar - tesseract
Signature · 1 line
2.39.2
Re: [PATCH 03/25] tests/lcitool: add swtpm to the package list
Quoted 15 lines · Alex Bennée
We need this to test some TPM stuff.
Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>--- .gitlab-ci.d/cirrus/macos-12.vars | 2 +- tests/docker/dockerfiles/alpine.docker | 1 + tests/docker/dockerfiles/centos8.docker | 1 + tests/docker/dockerfiles/debian-amd64-cross.docker | 1 + tests/docker/dockerfiles/debian-amd64.docker | 1 + tests/docker/dockerfiles/debian-arm64-cross.docker | 1 + tests/docker/dockerfiles/debian-armhf-cross.docker | 1 + tests/docker/dockerfiles/debian-ppc64el-cross.docker | 1 + tests/docker/dockerfiles/debian-s390x-cross.docker | 1 +
Quoted 8 lines
tests/docker/dockerfiles/fedora-win32-cross.docker | 1 + tests/docker/dockerfiles/fedora-win64-cross.docker | 1 + tests/docker/dockerfiles/fedora.docker | 1 + tests/docker/dockerfiles/opensuse-leap.docker | 1 + tests/docker/dockerfiles/ubuntu2204.docker | 1 + tests/lcitool/libvirt-ci | 2 +- tests/lcitool/projects/qemu.yml | 1 + 16 files changed, 16 insertions(+), 2 deletions(-)
PATCH 4/25 gitlab: shuffle some targets and reduce avocado noise
In reply to Alex BennéeWe move a couple of targets out of the avocado runs because there are no tests to run. Tricore already has some coverage. The cris target only really has check-tcg tests but its getting harder to find anything that packages the compiler.
To reduce the noise of CANCEL messages we also set AVOCADO_TAGS appropriately so we filter down the number of tests we attempt.
---
v2
- minor commit reword, no longer attempt to keep cris going
--- .gitlab-ci.d/buildtest.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
.gitlab-ci.d/buildtest.yml +11 -4
@@ -30,6 +30,7 @@ avocado-system-alpine: variables: IMAGE: alpine MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:avr arch:loongarch64 arch:mips64 arch:mipsel build-system-ubuntu: extends:
@@ -40,8 +41,7 @@ build-system-ubuntu: variables: IMAGE: ubuntu2204 CONFIGURE_ARGS: --enable-docs - TARGETS: alpha-softmmu cris-softmmu hppa-softmmu - microblazeel-softmmu mips64el-softmmu + TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu MAKE_CHECK_ARGS: check-build check-system-ubuntu:
@@ -61,6 +61,7 @@ avocado-system-ubuntu: variables: IMAGE: ubuntu2204 MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:alpha arch:microblaze arch:mips64el build-system-debian: extends:
@@ -72,7 +73,7 @@ build-system-debian: IMAGE: debian-amd64 CONFIGURE_ARGS: --with-coroutine=sigaltstack TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu - sparc-softmmu xtensaeb-softmmu + sparc-softmmu xtensa-softmmu MAKE_CHECK_ARGS: check-build check-system-debian:
@@ -92,6 +93,7 @@ avocado-system-debian: variables: IMAGE: debian-amd64 MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:arm arch:i386 arch:riscv64 arch:sh4 arch:sparc arch:xtensa crash-test-debian: extends: .native_test_job_template
@@ -114,7 +116,7 @@ build-system-fedora: variables: IMAGE: fedora CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs - TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu + TARGETS: microblaze-softmmu mips-softmmu xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu MAKE_CHECK_ARGS: check-build
@@ -135,6 +137,8 @@ avocado-system-fedora: variables: IMAGE: fedora MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:microblaze arch:mips arch:xtensa arch:m68k + arch:riscv32 arch:ppc arch:sparc64 crash-test-fedora: extends: .native_test_job_template
@@ -180,6 +184,8 @@ avocado-system-centos: variables: IMAGE: centos8 MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:ppc64 arch:or1k arch:390x arch:x86_64 arch:rx + arch:sh4 arch:nios2 build-system-opensuse: extends:
@@ -209,6 +215,7 @@ avocado-system-opensuse: variables: IMAGE: opensuse-leap MAKE_CHECK_ARGS: check-avocado + AVOCADO_TAGS: arch:s390x arch:x86_64 arch:aarch64 # This jobs explicitly disable TCG (--disable-tcg), KVM is detected by
Signature · 1 line
2.39.2
PATCH 5/25 tests/docker: make docker engine choice entirely configure driven
In reply to Alex BennéeSince 0b1a649047 (tests/docker: use direct RUNC call to build containers) we ended up with the potential for the remaining docker.py script calls to deviate from the direct RUNC calls. Fix this by dropping the use of ENGINE in the makefile and rely entirely on what we detect at configure time.
We also tweak the RUNC detection so podman users can still run things from the source tree.
---
v2
- add RUNC stanza suggested by Paolo
--- configure | 1 - tests/docker/Makefile.include | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-)
configure +0 -1
@@ -1694,7 +1694,6 @@ if test -n "$gdb_bin"; then fi if test "$container" != no; then - echo "ENGINE=$container" >> $config_host_mak echo "RUNC=$runc" >> $config_host_mak fi echo "SUBDIRS=$subdirs" >> $config_host_mak
tests/docker/Makefile.include +3 -6
@@ -16,9 +16,8 @@ DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu endif DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY)) -RUNC ?= docker -ENGINE ?= auto -DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE) +RUNC ?= $(if $(shell command -v docker), docker, podman) +DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(RUNC) CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$) DOCKER_SRC_COPY := $(BUILD_DIR)/docker-src.$(CUR_TIME)
@@ -158,7 +157,7 @@ $(foreach i,$(filter-out $(DOCKER_PARTIAL_IMAGES),$(DOCKER_IMAGES)), \ ) docker: - @echo 'Build QEMU and run tests inside Docker or Podman containers' + @echo 'Build QEMU and run tests inside $(RUNC) containers' @echo @echo 'Available targets:' @echo
@@ -198,8 +197,6 @@ docker: @echo ' EXECUTABLE=<path> Include executable in image.' @echo ' EXTRA_FILES="<path> [... <path>]"' @echo ' Include extra files in image.' - @echo ' ENGINE=auto/docker/podman' - @echo ' Specify which container engine to run.' @echo ' REGISTRY=url Cache builds from registry (default:$(DOCKER_REGISTRY))' docker-help: docker
Signature · 1 line
2.39.2
Re: [PATCH 05/25] tests/docker: make docker engine choice entirely configure driven
Quoted 11 lines · Alex Bennée
Since
0b1a649047(tests/docker: use direct RUNC call to build containers) we ended up with the potential for the remainingdocker.pyscript calls to deviate from the direct RUNC calls. Fix this by dropping the use of ENGINE in the makefile and rely entirely on what we detect at configure time.We also tweak the RUNC detection so podman users can still run things from the source tree.
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 59 lines
---
v2
- add RUNC stanza suggested by Paolo--- configure | 1 - tests/docker/Makefile.include | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-)configure +0
-1@@ -1694,7 +1694,6 @@ if test -n "$gdb_bin"; then fi if test "$container" != no; then - echo "ENGINE=$container" >> $config_host_mak echo "RUNC=$runc" >> $config_host_mak fi echo "SUBDIRS=$subdirs" >> $config_host_maktests/docker/Makefile.include +3
-7@@ -16,9 +16,8 @@ DOCKER_DEFAULT_REGISTRY := registry.gitlab.com/qemu-project/qemu endif DOCKER_REGISTRY := $(if $(REGISTRY),$(REGISTRY),$(DOCKER_DEFAULT_REGISTRY)) -RUNC ?= docker -ENGINE ?= auto -DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE) +RUNC ?= $(if $(shell command -v docker), docker, podman) +DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(RUNC) CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$) DOCKER_SRC_COPY := $(BUILD_DIR)/docker-src.$(CUR_TIME)@@ -158,7 +157,7 @@ $(foreach i,$(filter-out $(DOCKER_PARTIAL_IMAGES),$(DOCKER_IMAGES)), \ ) docker: - @echo 'Build QEMU and run tests inside Docker or Podman containers' + @echo 'Build QEMU and run tests inside $(RUNC) containers' @echo @echo 'Available targets:' @echo@@ -198,8 +197,6 @@ docker: @echo ' EXECUTABLE=<path> Include executable in image.' @echo ' EXTRA_FILES="<path> [... <path>]"' @echo ' Include extra files in image.' - @echo ' ENGINE=auto/docker/podman' - @echo ' Specify which container engine to run.' @echo ' REGISTRY=url Cache builds from registry (default:$(DOCKER_REGISTRY))' docker-help: docker --2.39.2
PATCH 6/25 configure: allow user to override docker engine
In reply to Alex BennéeIf you have both engines installed but one is broken you are stuck with the automagic. Allow the user to override the engine for this case.
--- configure | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
configure +6 -2
@@ -180,6 +180,7 @@ fi # some defaults, based on the host environment # default parameters +container_engine="auto" cpu="" cross_compile="no" cross_prefix=""
@@ -787,6 +788,8 @@ for opt do ;; --disable-containers) use_containers="no" ;; + --container-engine=*) container_engine="$optarg" + ;; --gdb=*) gdb_bin="$optarg" ;; # everything else has the same name in configure and meson
@@ -921,6 +924,7 @@ Advanced options (experts only): --enable-plugins enable plugins via shared library loading --disable-containers don't use containers for cross-building + --container-engine=TYPE which container engine to use [$container_engine] --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] EOF meson_options_help
@@ -1195,14 +1199,14 @@ fi container="no" runc="" if test $use_containers = "yes" && (has "docker" || has "podman"); then - case $($python "$source_path"/tests/docker/docker.py probe) in + case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in *docker) container=docker ;; podman) container=podman ;; no) container=no ;; esac if test "$container" != "no"; then docker_py="$python $source_path/tests/docker/docker.py --engine $container" - runc=$($python "$source_path"/tests/docker/docker.py probe) + runc=$container fi fi
Signature · 1 line
2.39.2
Re: [PATCH 06/25] configure: allow user to override docker engine
Quoted 6 lines · Alex Bennée
If you have both engines installed but one is broken you are stuck with the automagic. Allow the user to override the engine for this case.
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 54 lines
--- configure | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)configure +6
-3@@ -180,6 +180,7 @@ fi # some defaults, based on the host environment # default parameters +container_engine="auto" cpu="" cross_compile="no" cross_prefix=""@@ -787,6 +788,8 @@ for opt do ;; --disable-containers) use_containers="no" ;; + --container-engine=*) container_engine="$optarg" + ;; --gdb=*) gdb_bin="$optarg" ;; # everything else has the same name in configure and meson@@ -921,6 +924,7 @@ Advanced options (experts only): --enable-plugins enable plugins via shared library loading --disable-containers don't use containers for cross-building + --container-engine=TYPE which container engine to use [$container_engine] --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] EOF meson_options_help@@ -1195,14 +1199,14 @@ fi container="no" runc="" if test $use_containers = "yes" && (has "docker" || has "podman"); then - case $($python "$source_path"/tests/docker/docker.py probe) in + case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in *docker) container=docker ;; podman) container=podman ;; no) container=no ;; esac if test "$container" != "no"; then docker_py="$python $source_path/tests/docker/docker.py --engine $container" - runc=$($python "$source_path"/tests/docker/docker.py probe) + runc=$container fi fi --2.39.2
PATCH 7/25 configure: remove gcc version suffixes
In reply to Alex BennéeThe modern packaging of cross GCC's doesn't need the explicit version number at the end.
--- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
@@ -1334,7 +1334,7 @@ probe_target_compiler() { # We don't have any bigendian build tools so we only use this for AArch64 container_image=debian-arm64-cross container_cross_prefix=aarch64-linux-gnu- - container_cross_cc=${container_cross_prefix}gcc-10 + container_cross_cc=${container_cross_prefix}gcc ;; alpha) container_image=debian-alpha-cross
@@ -1397,7 +1397,7 @@ probe_target_compiler() { ppc) container_image=debian-powerpc-test-cross container_cross_prefix=powerpc-linux-gnu- - container_cross_cc=${container_cross_prefix}gcc-10 + container_cross_cc=${container_cross_prefix}gcc ;; ppc64|ppc64le) container_image=debian-powerpc-test-cross
Signature · 1 line
2.39.2
Re: [PATCH 07/25] configure: remove gcc version suffixes
Quoted 7 lines · Alex Bennée
The modern packaging of cross GCC's doesn't need the explicit version number at the end.
Signed-off-by Alex Bennée <[email protected]>--- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 8/25 gdbstub: Fix target_xml initialization
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
target_xml is no longer a fixed-length array but a pointer to a variable-length memory.
Message-Id: <[email protected]>
--- gdbstub/softmmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gdbstub/softmmu.c +1 -1
@@ -292,7 +292,7 @@ static int find_cpu_clusters(Object *child, void *opaque)assert (cluster->cluster_id !=UINT32_MAX ); process->pid = cluster->cluster_id +1 ; process->attached = false; - process->target_xml[0 ] ='\0' ; + process->target_xml =NULL ;return 0 ; }
Signature · 1 line
2.39.2
Re: [PATCH 08/25] gdbstub: Fix target_xml initialization
Quoted 11 lines · Alex Bennée
From: Akihiko Odaki <[email protected]>
target_xmlis no longer a fixed-length array but a pointer to a variable-length memory.Fixes 56e534bd11 ("gdbstub: refactor get_feature_xml")Signed-off-by Akihiko Odaki <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 21 lines
--- gdbstub/softmmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)gdbstub/softmmu.c +1
-2@@ -292,7 +292,7 @@ static int find_cpu_clusters(Object *child, void *opaque)assert (cluster->cluster_id !=UINT32_MAX ); process->pid = cluster->cluster_id +1 ; process->attached = false; - process->target_xml[0 ] ='\0' ; + process->target_xml =NULL ;return 0 ; } --2.39.2
PATCH 9/25 gdbstub: Fix target.xml response
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
It was failing to return target.xml after the first request.
Message-Id: <[email protected]>
--- gdbstub/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gdbstub/gdbstub.c +1 -1
@@ -396,8 +396,8 @@ static const char *get_feature_xml(const char *p, const char **newp,g_string_append (xml,"</target>" ); process->target_xml =g_string_free (xml, false); -return process->target_xml; } +return process->target_xml; }/* Is it dynamically generated by the target? */ if (cc->gdb_get_dynamic_xml) {
Signature · 1 line
2.39.2
PATCH 10/25 plugins: Check if vCPU is realized
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
The created member of CPUState tells if the vCPU thread is started, and will be always false for the user space emulation that manages threads independently. Use the realized member of DeviceState, which is valid for both of the system and user space emulation.
Message-Id: <[email protected]>
--- plugins/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
plugins/core.c +1 -1
@@ -64,7 +64,7 @@ static void plugin_cpu_update__locked(gpointer k, gpointer v, gpointer udata)CPUState *cpu =container_of (k, CPUState, cpu_index);run_on_cpu_data mask =RUN_ON_CPU_HOST_ULONG (*plugin.mask); -if (cpu->created) { +if (DEVICE (cpu)->realized) {async_run_on_cpu (cpu, plugin_cpu_update__async, mask); }else {plugin_cpu_update__async (cpu, mask);
Signature · 1 line
2.39.2
PATCH 11/25 contrib/plugins: Use GRWLock in execlog
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
execlog had the following comment:
Quoted 4 lines
As we could have multiple threads trying to do this we need to serialise the expansion under a lock. Threads accessing already created entries can continue without issue even if the ptr array gets reallocated during resize.
However, when the ptr array gets reallocated, the other threads may have a stale reference to the old buffer. This results in use-after-free.
Use GRWLock to properly fix this issue.
Message-Id: <[email protected]>
--- contrib/plugins/execlog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
contrib/plugins/execlog.c +10 -6
@@ -19,7 +19,7 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;/* Store last executed instruction on each vCPU as a GString */ static GPtrArray *last_exec; -static GMutex expand_array_lock; +static GRWLock expand_array_lock;static GPtrArray *imatches;static GArray *amatches;
@@ -28,18 +28,16 @@ static GArray *amatches;* Expand last_exec array. * * As we could have multiple threads trying to do this we need to -* serialise the expansion under a lock. Threads accessing already -* created entries can continue without issue even if the ptr array -* gets reallocated during resize. +* serialise the expansion under a lock. */ static void expand_last_exec (int cpu_index) { -g_mutex_lock (&expand_array_lock); +g_rw_lock_writer_lock (&expand_array_lock);while (cpu_index >= last_exec->len) {GString *s =g_string_new (NULL );g_ptr_array_add (last_exec, s); } -g_mutex_unlock (&expand_array_lock); +g_rw_lock_writer_unlock (&expand_array_lock); }/**
@@ -51,8 +49,10 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info,GString *s;/* Find vCPU in array */ +g_rw_lock_reader_lock (&expand_array_lock);g_assert (cpu_index < last_exec->len); s =g_ptr_array_index (last_exec, cpu_index); +g_rw_lock_reader_unlock (&expand_array_lock);/* Indicate type of memory access */ if (qemu_plugin_mem_is_store (info)) {
@@ -80,10 +80,14 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata)GString *s;/* Find or create vCPU in array */ +g_rw_lock_reader_lock (&expand_array_lock);if (cpu_index >= last_exec->len) { +g_rw_lock_reader_unlock (&expand_array_lock);expand_last_exec (cpu_index); +g_rw_lock_reader_lock (&expand_array_lock); } s =g_ptr_array_index (last_exec, cpu_index); +g_rw_lock_reader_unlock (&expand_array_lock);/* Print previous instruction in cache */ if (s->len) {
Signature · 1 line
2.39.2
PATCH 12/25 gdbstub: Introduce GDBFeature structure
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
Before this change, the information from a XML file was stored in an array that is not descriptive. Introduce a dedicated structure type to make it easier to understand and to extend with more fields.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 +- meson.build | 2 +- include/exec/gdbstub.h | 9 ++++-- gdbstub/gdbstub.c | 6 ++-- stubs/gdbstub.c | 6 ++-- scripts/feature_to_c.py | 48 ++++++++++++++++++++++++++++ scripts/feature_to_c.sh | 69 ----------------------------------------- 7 files changed, 63 insertions(+), 79 deletions(-) create mode 100755 scripts/feature_to_c.py delete mode 100644 scripts/feature_to_c.sh
MAINTAINERS +1 -1
@@ -2836,7 +2836,7 @@ F: include/exec/gdbstub.h F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ -F: scripts/feature_to_c.sh +F: scripts/feature_to_c.py F: scripts/probe-gdb-support.py Memory API
meson.build +1 -1
@@ -3693,7 +3693,7 @@ common_all = static_library('common', dependencies: common_all.dependencies(), name_suffix: 'fa') -feature_to_c = find_program('scripts/feature_to_c.sh') +feature_to_c = find_program('scripts/feature_to_c.py') if targetos == 'darwin' entitlement = find_program('scripts/entitlement.sh')
include/exec/gdbstub.h +7 -2
@@ -10,6 +10,11 @@#define GDB_WATCHPOINT_READ 3#define GDB_WATCHPOINT_ACCESS 4 +typedef struct GDBFeature { +const char *xmlname; +const char *xml; +}GDBFeature ; +/* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb )(CPUArchState *env,GByteArray *buf,int reg);
@@ -48,7 +53,7 @@ void gdb_set_stop_cpu(CPUState *cpu);*/ bool gdb_has_xml (void ); -/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ -extern const char *const xml_builtin[][2 ]; +/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ +extern const GDBFeature gdb_static_features[];#endif
gdbstub/gdbstub.c +3 -3
@@ -408,11 +408,11 @@ static const char *get_feature_xml(const char *p, const char **newp, } }/* Is it one of the encoded gdb-xml/ files? */ -for (int i =0 ; xml_builtin[i][0 ]; i++) { -const char *name = xml_builtin[i][0 ]; +for (int i =0 ; gdb_static_features[i].xmlname; i++) { +const char *name = gdb_static_features[i].xmlname;if ((strncmp (name, p, len) ==0 ) &&strlen (name) == len) { -return xml_builtin[i][1 ]; +return gdb_static_features[i].xml; } }
stubs/gdbstub.c +3 -3
@@ -1,6 +1,6 @@#include "qemu/osdep.h" -#include "exec/gdbstub.h" /* xml_builtin */ +#include "exec/gdbstub.h" /* gdb_static_features */ -const char *const xml_builtin[][2 ] = { - {NULL ,NULL } +const GDBFeature gdb_static_features[] = { + {NULL } };
scripts/feature_to_c.py new file +48 -0
48 lines not on this page · raw message
scripts/feature_to_c.sh deleted +0 -69
69 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH 13/25 target/arm: Move the reference to arm-core.xml
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
Some subclasses overwrite gdb_core_xml_file member but others don't. Always initialize the member in the subclasses for consistency.
This especially helps for AArch64; in a following change, the file specified by gdb_core_xml_file is always looked up even if it's going to be overwritten later. Looking up arm-core.xml results in an error as it will not be embedded in the AArch64 build.
Message-Id: <[email protected]>
--- target/arm/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target/arm/cpu.c +2 -1
@@ -2392,7 +2392,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->sysemu_ops = &arm_sysemu_ops;#endif cc->gdb_num_core_regs =26 ; - cc->gdb_core_xml_file ="arm-core.xml" ; cc->gdb_arch_name = arm_gdb_arch_name; cc->gdb_get_dynamic_xml = arm_gdb_get_dynamic_xml; cc->gdb_stop_before_watchpoint = true;
@@ -2414,8 +2413,10 @@ static void arm_cpu_instance_init(Object *obj)static void cpu_register_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc); +CPUClass *cc =CPU_CLASS (acc); acc->info = data; + cc->gdb_core_xml_file ="arm-core.xml" ; }void arm_cpu_register (const ARMCPUInfo *info)
Signature · 1 line
2.39.2
PATCH 14/25 hw/core/cpu: Return static value with gdb_arch_name()
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
All implementations of gdb_arch_name() returns dynamic duplicates of static strings. It's also unlikely that there will be an implementation of gdb_arch_name() that returns a truly dynamic value due to the nature of the function returning a well-known identifiers. Qualify the value gdb_arch_name() with const and make all of its implementations return static strings.
Message-Id: <[email protected]>
--- include/hw/core/cpu.h | 2 +- target/ppc/internal.h | 2 +- gdbstub/gdbstub.c | 3 +-- target/arm/cpu.c | 6 +++--- target/arm/cpu64.c | 4 ++-- target/i386/cpu.c | 6 +++--- target/loongarch/cpu.c | 8 ++++---- target/ppc/gdbstub.c | 6 +++--- target/riscv/cpu.c | 6 +++--- target/s390x/cpu.c | 4 ++-- target/tricore/cpu.c | 4 ++-- 11 files changed, 25 insertions(+), 26 deletions(-)
include/hw/core/cpu.h +1 -1
@@ -165,7 +165,7 @@ struct CPUClass {vaddr (*gdb_adjust_breakpoint)(CPUState *cpu,vaddr addr);const char *gdb_core_xml_file; - gchar * (*gdb_arch_name)(CPUState *cpu); +const gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);void (*disas_set_info)(CPUState *cpu,disassemble_info *info);
target/ppc/internal.h +1 -1
@@ -221,7 +221,7 @@ void destroy_ppc_opcodes(PowerPCCPU *cpu);/* gdbstub.c */ void ppc_gdb_init (CPUState *cs,PowerPCCPUClass *ppc); -gchar *ppc_gdb_arch_name (CPUState *cs); +const gchar *ppc_gdb_arch_name (CPUState *cs);/** * prot_for_access_type:
gdbstub/gdbstub.c +1 -2
@@ -380,10 +380,9 @@ static const char *get_feature_xml(const char *p, const char **newp, "<target>");if (cc->gdb_arch_name) { - g_autofree gchar *arch = cc->gdb_arch_name(cpu);g_string_append_printf (xml,"<architecture>%s</architecture>" , - arch); + cc->gdb_arch_name (cpu)); }g_string_append (xml,"<xi:include href=\"" );g_string_append (xml, cc->gdb_core_xml_file);
target/arm/cpu.c +3 -3
@@ -2319,15 +2319,15 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; -static gchar *arm_gdb_arch_name (CPUState *cs) +static const gchar *arm_gdb_arch_name (CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;if (arm_feature (env,ARM_FEATURE_IWMMXT )) { -return g_strdup ("iwmmxt" ); +return "iwmmxt" ; } -return g_strdup ("arm" ); +return "arm" ; }#ifndef CONFIG_USER_ONLY
target/arm/cpu64.c +2 -2
@@ -781,9 +781,9 @@ static void aarch64_cpu_finalizefn(Object *obj) { } -static gchar *aarch64_gdb_arch_name (CPUState *cs) +static const gchar *aarch64_gdb_arch_name (CPUState *cs) { -return g_strdup ("aarch64" ); +return "aarch64" ; }static void aarch64_cpu_class_init (ObjectClass *oc,void *data)
target/i386/cpu.c +3 -3
@@ -5915,12 +5915,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)memset (&env->user_features,0 ,sizeof (env->user_features)); } -static gchar *x86_gdb_arch_name (CPUState *cs) +static const gchar *x86_gdb_arch_name (CPUState *cs) {#ifdef TARGET_X86_64 -return g_strdup ("i386:x86-64" ); +return "i386:x86-64" ;#else -return g_strdup ("i386" ); +return "i386" ;#endif }
target/loongarch/cpu.c +4 -4
@@ -766,9 +766,9 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)#endif } -static gchar *loongarch32_gdb_arch_name (CPUState *cs) +static const gchar *loongarch32_gdb_arch_name (CPUState *cs) { -return g_strdup ("loongarch32" ); +return "loongarch32" ; }static void loongarch32_cpu_class_init (ObjectClass *c,void *data)
@@ -780,9 +780,9 @@ static void loongarch32_cpu_class_init(ObjectClass *c, void *data) cc->gdb_arch_name = loongarch32_gdb_arch_name; } -static gchar *loongarch64_gdb_arch_name (CPUState *cs) +static const gchar *loongarch64_gdb_arch_name (CPUState *cs) { -return g_strdup ("loongarch64" ); +return "loongarch64" ; }static void loongarch64_cpu_class_init (ObjectClass *c,void *data)
target/ppc/gdbstub.c +3 -3
@@ -589,12 +589,12 @@ static int gdb_set_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n)return 0 ; } -gchar *ppc_gdb_arch_name (CPUState *cs) +const gchar *ppc_gdb_arch_name (CPUState *cs) {#if defined(TARGET_PPC64 ) -return g_strdup ("powerpc:common64" ); +return "powerpc:common64" ;#else -return g_strdup ("powerpc:common" ); +return "powerpc:common" ;#endif }
target/riscv/cpu.c +3 -3
@@ -2004,17 +2004,17 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static gchar *riscv_gdb_arch_name (CPUState *cs) +static const gchar *riscv_gdb_arch_name (CPUState *cs) {RISCVCPU *cpu =RISCV_CPU (cs);CPURISCVState *env = &cpu->env;switch (riscv_cpu_mxl (env)) {case MXL_RV32 : -return g_strdup ("riscv:rv32" ); +return "riscv:rv32" ;case MXL_RV64 :case MXL_RV128 : -return g_strdup ("riscv:rv64" ); +return "riscv:rv64" ;default :g_assert_not_reached (); }
target/s390x/cpu.c +2 -2
@@ -282,9 +282,9 @@ static void s390_cpu_initfn(Object *obj)#endif } -static gchar *s390_gdb_arch_name (CPUState *cs) +static const gchar *s390_gdb_arch_name (CPUState *cs) { -return g_strdup ("s390:64-bit" ); +return "s390:64-bit" ; }static Property s390x_cpu_properties[] = {
target/tricore/cpu.c +2 -2
@@ -29,9 +29,9 @@ static inline void set_feature(CPUTriCoreState *env, int feature) env->features |=1ULL << feature; } -static gchar *tricore_gdb_arch_name (CPUState *cs) +static const gchar *tricore_gdb_arch_name (CPUState *cs) { -return g_strdup ("tricore" ); +return "tricore" ; }static void tricore_cpu_set_pc (CPUState *cs,vaddr value)
Signature · 1 line
2.39.2
Re: [PATCH 14/25] hw/core/cpu: Return static value with gdb_arch_name()
Quoted 10 lines · Alex Bennée
From: Akihiko Odaki <[email protected]>
All implementations of
gdb_arch_name()returns dynamic duplicates of static strings. It's also unlikely that there will be an implementation ofgdb_arch_name()that returns a truly dynamic value due to the nature of the function returning a well-known identifiers. Qualify the valuegdb_arch_name()with const and make all of its implementations return static strings.
Quoted 4 lines
Signed-off-by Akihiko Odaki <[email protected]>Reviewed-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 224 lines
--- include/hw/core/cpu.h | 2 +- target/ppc/internal.h | 2 +- gdbstub/gdbstub.c | 3 +-- target/arm/cpu.c | 6 +++--- target/arm/cpu64.c | 4 ++-- target/i386/cpu.c | 6 +++--- target/loongarch/cpu.c | 8 ++++---- target/ppc/gdbstub.c | 6 +++--- target/riscv/cpu.c | 6 +++--- target/s390x/cpu.c | 4 ++-- target/tricore/cpu.c | 4 ++-- 11 files changed, 25 insertions(+), 26 deletions(-)include/hw/core/cpu.h +1
-1@@ -165,7 +165,7 @@ struct CPUClass {vaddr (*gdb_adjust_breakpoint)(CPUState *cpu,vaddr addr);const char *gdb_core_xml_file; - gchar * (*gdb_arch_name)(CPUState *cpu); +const gchar * (*gdb_arch_name)(CPUState *cpu);const char * (*gdb_get_dynamic_xml)(CPUState *cpu,const char *xmlname);void (*disas_set_info)(CPUState *cpu,disassemble_info *info);target/ppc/internal.h +1
-1@@ -221,7 +221,7 @@ void destroy_ppc_opcodes(PowerPCCPU *cpu);/* gdbstub.c */ void ppc_gdb_init (CPUState *cs,PowerPCCPUClass *ppc); -gchar *ppc_gdb_arch_name (CPUState *cs); +const gchar *ppc_gdb_arch_name (CPUState *cs);/** * prot_for_access_type: gdbstub/gdbstub.c +1
-2@@ -380,10 +380,9 @@ static const char *get_feature_xml(const char *p, const char **newp, "<target>");if (cc->gdb_arch_name) { - g_autofree gchar *arch = cc->gdb_arch_name(cpu);g_string_append_printf (xml,"<architecture>%s</architecture>" , - arch); + cc->gdb_arch_name (cpu)); }g_string_append (xml,"<xi:include href=\"" );g_string_append (xml, cc->gdb_core_xml_file);target/arm/cpu.c +3
-3@@ -2319,15 +2319,15 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; -static gchar *arm_gdb_arch_name (CPUState *cs) +static const gchar *arm_gdb_arch_name (CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;if (arm_feature (env,ARM_FEATURE_IWMMXT )) { -return g_strdup ("iwmmxt" ); +return "iwmmxt" ; } -return g_strdup ("arm" ); +return "arm" ; }#ifndef CONFIG_USER_ONLY target/arm/cpu64.c +2
-2@@ -781,9 +781,9 @@ static void aarch64_cpu_finalizefn(Object *obj) { } -static gchar *aarch64_gdb_arch_name (CPUState *cs) +static const gchar *aarch64_gdb_arch_name (CPUState *cs) { -return g_strdup ("aarch64" ); +return "aarch64" ; }static void aarch64_cpu_class_init (ObjectClass *oc,void *data)target/i386/cpu.c +3
-3@@ -5915,12 +5915,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)memset (&env->user_features,0 ,sizeof (env->user_features)); } -static gchar *x86_gdb_arch_name (CPUState *cs) +static const gchar *x86_gdb_arch_name (CPUState *cs) {#ifdef TARGET_X86_64 -return g_strdup ("i386:x86-64" ); +return "i386:x86-64" ;#else -return g_strdup ("i386" ); +return "i386" ;#endif }target/loongarch/cpu.c +4
-4@@ -766,9 +766,9 @@ static void loongarch_cpu_class_init(ObjectClass *c, void *data)#endif } -static gchar *loongarch32_gdb_arch_name (CPUState *cs) +static const gchar *loongarch32_gdb_arch_name (CPUState *cs) { -return g_strdup ("loongarch32" ); +return "loongarch32" ; }static void loongarch32_cpu_class_init (ObjectClass *c,void *data)@@ -780,9 +780,9 @@ static void loongarch32_cpu_class_init(ObjectClass *c, void *data) cc->gdb_arch_name = loongarch32_gdb_arch_name; } -static gchar *loongarch64_gdb_arch_name (CPUState *cs) +static const gchar *loongarch64_gdb_arch_name (CPUState *cs) { -return g_strdup ("loongarch64" ); +return "loongarch64" ; }static void loongarch64_cpu_class_init (ObjectClass *c,void *data)target/ppc/gdbstub.c +3
-3@@ -589,12 +589,12 @@ static int gdb_set_vsx_reg(CPUPPCState *env, uint8_t *mem_buf, int n)return 0 ; } -gchar *ppc_gdb_arch_name (CPUState *cs) +const gchar *ppc_gdb_arch_name (CPUState *cs) {#if defined(TARGET_PPC64 ) -return g_strdup ("powerpc:common64" ); +return "powerpc:common64" ;#else -return g_strdup ("powerpc:common" ); +return "powerpc:common" ;#endif }target/riscv/cpu.c +3
-3@@ -2004,17 +2004,17 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static gchar *riscv_gdb_arch_name (CPUState *cs) +static const gchar *riscv_gdb_arch_name (CPUState *cs) {RISCVCPU *cpu =RISCV_CPU (cs);CPURISCVState *env = &cpu->env;switch (riscv_cpu_mxl (env)) {case MXL_RV32 : -return g_strdup ("riscv:rv32" ); +return "riscv:rv32" ;case MXL_RV64 :case MXL_RV128 : -return g_strdup ("riscv:rv64" ); +return "riscv:rv64" ;default :g_assert_not_reached (); }target/s390x/cpu.c +2
-2@@ -282,9 +282,9 @@ static void s390_cpu_initfn(Object *obj)#endif } -static gchar *s390_gdb_arch_name (CPUState *cs) +static const gchar *s390_gdb_arch_name (CPUState *cs) { -return g_strdup ("s390:64-bit" ); +return "s390:64-bit" ; }static Property s390x_cpu_properties[] = {target/tricore/cpu.c +2
-3@@ -29,9 +29,9 @@ static inline void set_feature(CPUTriCoreState *env, int feature) env->features |=1ULL << feature; } -static gchar *tricore_gdb_arch_name (CPUState *cs) +static const gchar *tricore_gdb_arch_name (CPUState *cs) { -return g_strdup ("tricore" ); +return "tricore" ; }static void tricore_cpu_set_pc (CPUState *cs,vaddr value) --2.39.2
PATCH 15/25 gdbstub: Use g_markup_printf_escaped()
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
g_markup_printf_escaped() is a safer alternative to simple printf() as it automatically escapes values.
Message-Id: <[email protected]>
--- gdbstub/gdbstub.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
gdbstub/gdbstub.c +21 -15
@@ -373,28 +373,34 @@ static const char *get_feature_xml(const char *p, const char **newp,if (strncmp (p,"target.xml" , len) ==0 ) {if (!process->target_xml) {GDBRegisterState *r; -GString *xml =g_string_new ("<?xml version=\"1.0\"?>" ); +g_autoptr (GPtrArray) xml =g_ptr_array_new_with_free_func (g_free); -g_string_append (xml, -"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" -"<target>" ); +g_ptr_array_add ( + xml, +g_strdup ("<?xml version=\"1.0\"?>" +"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" +"<target>" ));if (cc->gdb_arch_name) { -g_string_append_printf (xml, -"<architecture>%s</architecture>" , - cc->gdb_arch_name (cpu)); +g_ptr_array_add ( + xml, +g_markup_printf_escaped ("<architecture>%s</architecture>" , + cc->gdb_arch_name (cpu))); } -g_string_append (xml,"<xi:include href=\"" ); -g_string_append (xml, cc->gdb_core_xml_file); -g_string_append (xml,"\"/>" ); +g_ptr_array_add ( + xml, +g_markup_printf_escaped ("<xi:include href=\"%s\"/>" , + cc->gdb_core_xml_file));for (r = cpu->gdb_regs; r; r = r->next) { -g_string_append (xml,"<xi:include href=\"" ); -g_string_append (xml, r->xml); -g_string_append (xml,"\"/>" ); +g_ptr_array_add ( + xml, +g_markup_printf_escaped ("<xi:include href=\"%s\"/>" , + r->xml)); } -g_string_append (xml,"</target>" ); +g_ptr_array_add (xml,g_strdup ("</target>" )); +g_ptr_array_add (xml,NULL ); - process->target_xml =g_string_free (xml, false); + process->target_xml =g_strjoinv (NULL , (void *)xml->pdata); }return process->target_xml; }
Signature · 1 line
2.39.2
PATCH 16/25 target/arm: Remove references to gdb_has_xml
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support.
Message-Id: <[email protected]>
--- target/arm/gdbstub.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-)
target/arm/gdbstub.c +2 -30
@@ -46,21 +46,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)/* Core integer register. */ return gdb_get_reg32 (mem_buf, env->regs[n]); } -if (n <24 ) { -/* FPA registers. */ -if (gdb_has_xml ()) { -return 0 ; - } -return gdb_get_zeroes (mem_buf,12 ); - } -switch (n) { -case 24 : -/* FPA status register. */ -if (gdb_has_xml ()) { -return 0 ; - } -return gdb_get_reg32 (mem_buf,0 ); -case 25 : +if (n ==25 ) {/* CPSR, or XPSR for M-profile */ if (arm_feature (env,ARM_FEATURE_M )) {return gdb_get_reg32 (mem_buf,xpsr_read (env));
@@ -100,21 +86,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->regs[n] = tmp;return 4 ; } -if (n <24 ) {/* 16-23 */ -/* FPA registers (ignored). */ -if (gdb_has_xml ()) { -return 0 ; - } -return 12 ; - } -switch (n) { -case 24 : -/* FPA status register (ignored). */ -if (gdb_has_xml ()) { -return 0 ; - } -return 4 ; -case 25 : +if (n ==25 ) {/* CPSR, or XPSR for M-profile */ if (arm_feature (env,ARM_FEATURE_M )) {/*
Signature · 1 line
2.39.2
Re: [PATCH 16/25] target/arm: Remove references to gdb_has_xml
Quoted 10 lines · Alex Bennée
From: Akihiko Odaki <[email protected]>
GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support.
Signed-off-by Akihiko Odaki <[email protected]>Acked-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 58 lines
--- target/arm/gdbstub.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-)target/arm/gdbstub.c +2
-31@@ -46,21 +46,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)/* Core integer register. */ return gdb_get_reg32 (mem_buf, env->regs[n]); } -if (n <24 ) { -/* FPA registers. */ -if (gdb_has_xml ()) { -return 0 ; - } -return gdb_get_zeroes (mem_buf,12 ); - } -switch (n) { -case 24 : -/* FPA status register. */ -if (gdb_has_xml ()) { -return 0 ; - } -return gdb_get_reg32 (mem_buf,0 ); -case 25 : +if (n ==25 ) {/* CPSR, or XPSR for M-profile */ if (arm_feature (env,ARM_FEATURE_M )) {return gdb_get_reg32 (mem_buf,xpsr_read (env));@@ -100,21 +86,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->regs[n] = tmp;return 4 ; } -if (n <24 ) {/* 16-23 */ -/* FPA registers (ignored). */ -if (gdb_has_xml ()) { -return 0 ; - } -return 12 ; - } -switch (n) { -case 24 : -/* FPA status register (ignored). */ -if (gdb_has_xml ()) { -return 0 ; - } -return 4 ; -case 25 : +if (n ==25 ) {/* CPSR, or XPSR for M-profile */ if (arm_feature (env,ARM_FEATURE_M )) {/* -- 2.39.2
PATCH 17/25 target/ppc: Remove references to gdb_has_xml
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support.
Message-Id: <[email protected]>
--- target/ppc/gdbstub.c | 18 ------------------ 1 file changed, 18 deletions(-)
target/ppc/gdbstub.c +0 -18
@@ -54,12 +54,6 @@ static int ppc_gdb_register_len(int n) case 0 ... 31:/* gprs */ return sizeof (target_ulong); - case 32 ... 63: -/* fprs */ -if (gdb_has_xml ()) { -return 0 ; - } -return 8 ;case 66 :/* cr */ case 69 :
@@ -74,12 +68,6 @@ static int ppc_gdb_register_len(int n)case 68 :/* ctr */ return sizeof (target_ulong); -case 70 : -/* fpscr */ -if (gdb_has_xml ()) { -return 0 ; - } -return sizeof (target_ulong);default :return 0 ; }
@@ -132,9 +120,6 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)if (n <32 ) {/* gprs */ gdb_get_regl (buf, env->gpr[n]); - }else if (n <64 ) { -/* fprs */ -gdb_get_reg64 (buf, *cpu_fpr_ptr (env, n -32 )); }else {switch (n) {case 64 :
@@ -158,9 +143,6 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)case 69 :gdb_get_reg32 (buf,cpu_read_xer (env));break ; -case 70 : -gdb_get_reg32 (buf, env->fpscr); -break ; } } mem_buf = buf->data + buf->len - r;
Signature · 1 line
2.39.2
PATCH 18/25 gdbstub: Remove gdb_has_xml variable
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support.
Message-Id: <[email protected]>
--- gdbstub/internals.h | 2 -- include/exec/gdbstub.h | 8 -------- gdbstub/gdbstub.c | 15 --------------- 3 files changed, 25 deletions(-)
gdbstub/internals.h +0 -2
@@ -32,8 +32,6 @@ enum {typedef struct GDBProcess {uint32_t pid;bool attached; - -/* If gdb sends qXfer:features:read:target.xml this will be populated */ char *target_xml; }GDBProcess ;
include/exec/gdbstub.h +0 -8
@@ -45,14 +45,6 @@ int gdbserver_start(const char *port_or_device);void gdb_set_stop_cpu (CPUState *cpu); -/** -* gdb_has_xml() - report of gdb supports modern target descriptions -* -* This will report true if the gdb negotiated qXfer:features:read -* target descriptions. -*/ -bool gdb_has_xml (void ); -/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ extern const GDBFeature gdb_static_features[];
gdbstub/gdbstub.c +0 -15
@@ -349,11 +349,6 @@ static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) } } -bool gdb_has_xml (void ) -{ -return !!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml; -} -static const char *get_feature_xml (const char *p,const char **newp,GDBProcess *process) {
@@ -1086,11 +1081,6 @@ static void handle_set_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) { -gdb_put_packet ("" ); -return ; - } -if (params->len !=2 ) {gdb_put_packet ("E22" );return ;
@@ -1107,11 +1097,6 @@ static void handle_get_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) { -gdb_put_packet ("" ); -return ; - } -if (!params->len) {gdb_put_packet ("E14" );return ;
Signature · 1 line
2.39.2
Re: [PATCH 18/25] gdbstub: Remove gdb_has_xml variable
Quoted 9 lines · Alex Bennée
From: Akihiko Odaki <[email protected]>
GDB has XML support since 6.7 which was released in 2007. It's time to remove support for old GDB versions without XML support.
Signed-off-by Akihiko Odaki <[email protected]>Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 82 lines
--- gdbstub/internals.h | 2 -- include/exec/gdbstub.h | 8 -------- gdbstub/gdbstub.c | 15 --------------- 3 files changed, 25 deletions(-)gdbstub/internals.h +0
-2@@ -32,8 +32,6 @@ enum {typedef struct GDBProcess {uint32_t pid;bool attached; - -/* If gdb sends qXfer:features:read:target.xml this will be populated */ char *target_xml; }GDBProcess ;include/exec/gdbstub.h +0
-8@@ -45,14 +45,6 @@ int gdbserver_start(const char *port_or_device);void gdb_set_stop_cpu (CPUState *cpu); -/** -* gdb_has_xml() - report of gdb supports modern target descriptions -* -* This will report true if the gdb negotiated qXfer:features:read -* target descriptions. -*/ -bool gdb_has_xml (void ); -/* in gdbstub-xml.c, generated by scripts/feature_to_c.py */ extern const GDBFeature gdb_static_features[];gdbstub/gdbstub.c +0
-16@@ -349,11 +349,6 @@ static CPUState *gdb_get_cpu(uint32_t pid, uint32_t tid) } } -bool gdb_has_xml (void ) -{ -return !!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml; -} -static const char *get_feature_xml (const char *p,const char **newp,GDBProcess *process) {@@ -1086,11 +1081,6 @@ static void handle_set_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) { -gdb_put_packet ("" ); -return ; - } -if (params->len !=2 ) {gdb_put_packet ("E22" );return ;@@ -1107,11 +1097,6 @@ static void handle_get_reg(GArray *params, void *user_ctx) {int reg_size; -if (!gdb_get_cpu_process (gdbserver_state.g_cpu)->target_xml) { -gdb_put_packet ("" ); -return ; - } -if (!params->len) {gdb_put_packet ("E14" );return ; --2.39.2
PATCH 19/25 gdbstub: Replace gdb_regs with an array
In reply to Alex BennéeFrom: Akihiko Odaki <[email protected]>
An array is a more appropriate data structure than a list for gdb_regs since it is initialized only with append operation and read-only after initialization.
Message-Id: <[email protected]>
--- include/hw/core/cpu.h | 2 +- gdbstub/gdbstub.c | 35 +++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-)
include/hw/core/cpu.h +1 -1
@@ -502,7 +502,7 @@ struct CPUState {CPUJumpCache *tb_jmp_cache; -struct GDBRegisterState *gdb_regs; +GArray *gdb_regs;int gdb_num_regs;int gdb_num_g_regs;QTAILQ_ENTRY (CPUState) node;
gdbstub/gdbstub.c +21 -14
@@ -51,7 +51,6 @@ typedef struct GDBRegisterState {gdb_get_reg_cb get_reg;gdb_set_reg_cb set_reg;const char *xml; -struct GDBRegisterState *next; } GDBRegisterState;GDBState gdbserver_state;
@@ -386,7 +385,8 @@ static const char *get_feature_xml(const char *p, const char **newp, xml,g_markup_printf_escaped ("<xi:include href=\"%s\"/>" , cc->gdb_core_xml_file)); -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); g_ptr_array_add( xml, g_markup_printf_escaped("<xi:include href=\"%s\"/>",
@@ -430,7 +430,8 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)return cc->gdb_read_register (cpu, buf, reg); } -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i);if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->get_reg (env, buf, reg - r->base_reg); }
@@ -448,7 +449,8 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)return cc->gdb_write_register (cpu, mem_buf, reg); } -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i);if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->set_reg (env, mem_buf, reg - r->base_reg); }
@@ -461,17 +463,23 @@ void gdb_register_coprocessor(CPUState *cpu, int num_regs, const char *xml, int g_pos) { GDBRegisterState *s; -GDBRegisterState **p; - - p = &cpu->gdb_regs; -while (*p) { -/* Check for duplicates. */ -if (strcmp ((*p)->xml, xml) ==0 ) -return ; - p = &(*p)->next; +guint i; + +if (cpu->gdb_regs) { +for (i =0 ; i < cpu->gdb_regs->len; i++) { +/* Check for duplicates. */ + s = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); +if (strcmp (s->xml, xml) ==0 ) { +return ; + } + } + }else { + cpu->gdb_regs =g_array_new (false, false,sizeof (GDBRegisterState)); + i =0 ; } - s =g_new0 (GDBRegisterState,1 ); +g_array_set_size (cpu->gdb_regs, i +1 ); + s = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; s->num_regs = num_regs; s->get_reg = get_reg;
@@ -480,7 +488,6 @@ void gdb_register_coprocessor(CPUState *cpu,/* Add to end of list. */ cpu->gdb_num_regs += num_regs; - *p = s;if (g_pos) {if (g_pos != s->base_reg) { error_report("Error: Bad gdb register numbering for '%s', "
Signature · 1 line
2.39.2
Re: [PATCH 19/25] gdbstub: Replace gdb_regs with an array
Quoted 11 lines · Alex Bennée
From: Akihiko Odaki <[email protected]>
An array is a more appropriate data structure than a list for
gdb_regssince it is initialized only with append operation and read-only after initialization.Signed-off-by Akihiko Odaki <[email protected]>Message-Id: <[email protected]>
[AJB: fixed a checkpatch violation]Signed-off-by Alex Bennée <[email protected]>
Alistair
Quoted 105 lines
--- include/hw/core/cpu.h | 2 +- gdbstub/gdbstub.c | 35 +++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-)include/hw/core/cpu.h +1
-1@@ -502,7 +502,7 @@ struct CPUState {CPUJumpCache *tb_jmp_cache; -struct GDBRegisterState *gdb_regs; +GArray *gdb_regs;int gdb_num_regs;int gdb_num_g_regs;QTAILQ_ENTRY (CPUState) node;gdbstub/gdbstub.c +21
-15@@ -51,7 +51,6 @@ typedef struct GDBRegisterState {gdb_get_reg_cb get_reg;gdb_set_reg_cb set_reg;const char *xml; -struct GDBRegisterState *next; } GDBRegisterState;GDBState gdbserver_state;@@ -386,7 +385,8 @@ static const char *get_feature_xml(const char *p, const char **newp, xml,g_markup_printf_escaped ("<xi:include href=\"%s\"/>" , cc->gdb_core_xml_file)); -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); g_ptr_array_add( xml, g_markup_printf_escaped("<xi:include href=\"%s\"/>",@@ -430,7 +430,8 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg)return cc->gdb_read_register (cpu, buf, reg); } -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i);if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->get_reg (env, buf, reg - r->base_reg); }@@ -448,7 +449,8 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)return cc->gdb_write_register (cpu, mem_buf, reg); } -for (r = cpu->gdb_regs; r; r = r->next) { +for (guint i =0 ; i < cpu->gdb_regs->len; i++) { + r = &g_array_index (cpu->gdb_regs, GDBRegisterState, i);if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) {return r->set_reg (env, mem_buf, reg - r->base_reg); }@@ -461,17 +463,23 @@ void gdb_register_coprocessor(CPUState *cpu, int num_regs, const char *xml, int g_pos) { GDBRegisterState *s; -GDBRegisterState **p; - - p = &cpu->gdb_regs; -while (*p) { -/* Check for duplicates. */ -if (strcmp ((*p)->xml, xml) ==0 ) -return ; - p = &(*p)->next; +guint i; + +if (cpu->gdb_regs) { +for (i =0 ; i < cpu->gdb_regs->len; i++) { +/* Check for duplicates. */ + s = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); +if (strcmp (s->xml, xml) ==0 ) { +return ; + } + } + }else { + cpu->gdb_regs =g_array_new (false, false,sizeof (GDBRegisterState)); + i =0 ; } - s =g_new0 (GDBRegisterState,1 ); +g_array_set_size (cpu->gdb_regs, i +1 ); + s = &g_array_index (cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; s->num_regs = num_regs; s->get_reg = get_reg;@@ -480,7 +488,6 @@ void gdb_register_coprocessor(CPUState *cpu,/* Add to end of list. */ cpu->gdb_num_regs += num_regs; - *p = s;if (g_pos) {if (g_pos != s->base_reg) { error_report("Error: Bad gdb register numbering for '%s', " --2.39.2
PATCH 20/25 accel/tcg: Add plugin_enabled to DisasContextBase
In reply to Alex BennéeFrom: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- include/exec/translator.h | 2 ++ accel/tcg/translator.c | 1 + 2 files changed, 3 insertions(+)
include/exec/translator.h +2 -0
@@ -73,6 +73,7 @@ typedef enum DisasJumpType {* @max_insns: Maximum number of instructions to be translated in this TB. * @singlestep_enabled: "Hardware" single stepping enabled. * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown. +* @plugin_enabled: TCG plugin enabled in this TB. * * Architecture-agnostic disassembly context. */
@@ -85,6 +86,7 @@ typedef struct DisasContextBase {int max_insns;bool singlestep_enabled;int8_t saved_can_do_io; +bool plugin_enabled;void *host_addr[2 ]; } DisasContextBase;
accel/tcg/translator.c +1 -0
@@ -158,6 +158,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns, }else { plugin_enabled =plugin_gen_tb_start (cpu, db, false); } + db->plugin_enabled = plugin_enabled;while (true) { *max_insns = ++db->num_insns;
Signature · 1 line
2.39.2
PATCH 21/25 target/sh4: Disable decode_gusa when plugins enabled
In reply to Alex BennéeFrom: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
--- target/sh4/translate.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
target/sh4/translate.c +29 -12
@@ -1816,6 +1816,18 @@ static void decode_opc(DisasContext * ctx) }#ifdef CONFIG_USER_ONLY +/* +* Restart with the EXCLUSIVE bit set, within a TB run via +* cpu_exec_step_atomic holding the exclusive lock. +*/ +static void gen_restart_exclusive (DisasContext *ctx) +{ + ctx->envflags |=TB_FLAG_GUSA_EXCLUSIVE ; +gen_save_cpu_state (ctx, false); +gen_helper_exclusive (tcg_env); + ctx->base.is_jmp =DISAS_NORETURN ; +} +/* For uniprocessors, SH4 uses optimistic restartable atomic sequences. Upon an interrupt, a real kernel would simply notice magic values in the registers and reset the PC to the start of the sequence.
@@ -2149,12 +2161,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)qemu_log_mask (LOG_UNIMP ,"Unrecognized gUSA sequence %08x-%08x\n" , pc, pc_end); -/* Restart with the EXCLUSIVE bit set, within a TB run via -cpu_exec_step_atomic holding the exclusive lock. */ - ctx->envflags |=TB_FLAG_GUSA_EXCLUSIVE ; -gen_save_cpu_state (ctx, false); -gen_helper_exclusive (tcg_env); - ctx->base.is_jmp =DISAS_NORETURN ; +gen_restart_exclusive (ctx);/* We're not executing an instruction, but we must report one for the purposes of accounting within the TB. We might as well report the
@@ -2242,12 +2249,22 @@ static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)#ifdef CONFIG_USER_ONLY if (unlikely (ctx->envflags &TB_FLAG_GUSA_MASK ) && !(ctx->envflags &TB_FLAG_GUSA_EXCLUSIVE )) { -/* We're in an gUSA region, and we have not already fallen -back on using an exclusive region. Attempt to parse the -region into a single supported atomic operation. Failure -is handled within the parser by raising an exception to -retry using an exclusive region. */ -decode_gusa (ctx, env); +/* +* We're in an gUSA region, and we have not already fallen +* back on using an exclusive region. Attempt to parse the +* region into a single supported atomic operation. Failure +* is handled within the parser by raising an exception to +* retry using an exclusive region. +* +* Parsing the region in one block conflicts with plugins, +* so always use exclusive mode if plugins enabled. +*/ +if (ctx->base.plugin_enabled) { +gen_restart_exclusive (ctx); + ctx->base.pc_next +=2 ; + }else { +decode_gusa (ctx, env); + }return ; }#endif
Signature · 1 line
2.39.2
PATCH 22/25 plugins: Set final instruction count in plugin_gen_tb_end
In reply to Alex BennéeFrom: Matt Borgerson <[email protected]>
Translation logic may partially decode an instruction, then abort and remove the instruction from the TB. This can happen for example when an instruction spans two pages. In this case, plugins may get an incorrect result when calling qemu_plugin_tb_n_insns to query for the number of instructions in the TB. This patch updates plugin_gen_tb_end to set the final instruction count.
Message-Id: <CADc=-s5RwGViNTR-h5cq3np673W3RRFfhr4vCGJp0EoDUxvhog@mail.gmail.com>
--- include/exec/plugin-gen.h | 4 ++-- accel/tcg/plugin-gen.c | 6 +++++- accel/tcg/translator.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-)
include/exec/plugin-gen.h +2 -2
@@ -20,7 +20,7 @@ struct DisasContextBase;bool plugin_gen_tb_start (CPUState *cpu,const struct DisasContextBase *db,bool supress); -void plugin_gen_tb_end (CPUState *cpu); +void plugin_gen_tb_end (CPUState *cpu,size_t num_insns);void plugin_gen_insn_start (CPUState *cpu,const struct DisasContextBase *db);void plugin_gen_insn_end (void );
@@ -42,7 +42,7 @@ void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db)static inline void plugin_gen_insn_end (void ) { } -static inline void plugin_gen_tb_end (CPUState *cpu) +static inline void plugin_gen_tb_end (CPUState *cpu,size_t num_insns) { }static inline void plugin_gen_disable_mem_helpers (void )
accel/tcg/plugin-gen.c +5 -1
@@ -866,10 +866,14 @@ void plugin_gen_insn_end(void)* do any clean-up here and make sure things are reset in * plugin_gen_tb_start. */ -void plugin_gen_tb_end (CPUState *cpu) +void plugin_gen_tb_end (CPUState *cpu,size_t num_insns) {struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; +/* translator may have removed instructions, update final count */ +g_assert (num_insns <= ptb->n); + ptb->n = num_insns; +/* collect instrumentation requests */ qemu_plugin_tb_trans_cb (cpu, ptb);
accel/tcg/translator.c +1 -1
@@ -210,7 +210,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,gen_tb_end (tb, cflags, icount_start_insn, db->num_insns);if (plugin_enabled) { -plugin_gen_tb_end (cpu); +plugin_gen_tb_end (cpu, db->num_insns); }/* The disas_log hook may use these values rather than recompute. */
Signature · 1 line
2.39.2
PATCH 23/25 contrib/plugins: fix coverity warning in cache
In reply to Alex BennéeCoverity complains that appends_stats_line can be fed a 0 leading to the undefined behaviour of a divide by 0.
--- contrib/plugins/cache.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
contrib/plugins/cache.c +8 -10
@@ -535,15 +535,13 @@ static void caches_free(Cache **caches) } } -static void append_stats_line (GString *line,uint64_t l1_daccess, -uint64_t l1_dmisses,uint64_t l1_iaccess, -uint64_t l1_imisses,uint64_t l2_access, -uint64_t l2_misses) +static void append_stats_line (GString *line, +uint64_t l1_daccess,uint64_t l1_dmisses, +uint64_t l1_iaccess,uint64_t l1_imisses, +uint64_t l2_access,uint64_t l2_misses) { -double l1_dmiss_rate, l1_imiss_rate, l2_miss_rate; - - l1_dmiss_rate = ((double ) l1_dmisses) / (l1_daccess) *100.0 ; - l1_imiss_rate = ((double ) l1_imisses) / (l1_iaccess) *100.0 ; +double l1_dmiss_rate = ((double ) l1_dmisses) / (l1_daccess) *100.0 ; +double l1_imiss_rate = ((double ) l1_imisses) / (l1_iaccess) *100.0 ; g_string_append_printf(line, "%-14" PRIu64 " %-12" PRIu64 " %9.4lf%%" " %-14" PRIu64 " %-12" PRIu64 " %9.4lf%%",
@@ -554,8 +552,8 @@ static void append_stats_line(GString *line, uint64_t l1_daccess, l1_imisses, l1_iaccess ? l1_imiss_rate : 0.0); -if (use_l2) { - l2_miss_rate = ((double ) l2_misses) / (l2_access) *100.0 ; +if (l2_access && l2_misses) { +double l2_miss_rate = ((double ) l2_misses) / (l2_access) *100.0 ; g_string_append_printf(line, " %-12" PRIu64 " %-11" PRIu64 " %10.4lf%%", l2_access,
Signature · 1 line
2.39.2
PATCH 24/25 contrib/plugins: fix coverity warning in lockstep
In reply to Alex BennéeCoverity complains that e don't check for a truncation when copying in the path. Bail if we can't copy the whole path into sockaddr.
--- contrib/plugins/lockstep.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
contrib/plugins/lockstep.c +11 -2
@@ -245,6 +245,7 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)static bool setup_socket (const char *path) {struct sockaddr_un sockaddr; +const gsize pathlen =sizeof (sockaddr.sun_path) -1 ;int fd; fd =socket (AF_UNIX ,SOCK_STREAM ,0 );
@@ -254,7 +255,11 @@ static bool setup_socket(const char *path) } sockaddr.sun_family =AF_UNIX ; -g_strlcpy (sockaddr.sun_path, path,sizeof (sockaddr.sun_path) -1 ); +if (g_strlcpy (sockaddr.sun_path, path, pathlen) >= pathlen) { +perror ("bad path" ); +return false; + } +if (bind (fd, (struct sockaddr *)&sockaddr,sizeof (sockaddr)) <0 ) {perror ("bind socket" );close (fd);
@@ -287,6 +292,7 @@ static bool connect_socket(const char *path) {int fd;struct sockaddr_un sockaddr; +const gsize pathlen =sizeof (sockaddr.sun_path) -1 ; fd =socket (AF_UNIX ,SOCK_STREAM ,0 );if (fd <0 ) {
@@ -295,7 +301,10 @@ static bool connect_socket(const char *path) } sockaddr.sun_family =AF_UNIX ; -g_strlcpy (sockaddr.sun_path, path,sizeof (sockaddr.sun_path) -1 ); +if (g_strlcpy (sockaddr.sun_path, path, pathlen) >= pathlen) { +perror ("bad path" ); +return false; + }if (connect (fd, (struct sockaddr *)&sockaddr,sizeof (sockaddr)) <0 ) {perror ("failed to connect" );
Signature · 1 line
2.39.2
PATCH 25/25 contrib/plugins: fix coverity warning in hotblocks
In reply to Alex BennéeCoverity complains that we have an unbalance use of mutex leading to potential deadlocks.
--- contrib/plugins/hotblocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/plugins/hotblocks.c +1 -1
@@ -69,8 +69,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) }g_list_free (it); -g_mutex_unlock (&lock); } +g_mutex_unlock (&lock);qemu_plugin_outs (report->str); }
Signature · 1 line
2.39.2
Re: [PATCH 25/25] contrib/plugins: fix coverity warning in hotblocks
Quoted 4 lines · Alex Bennée
Coverity complains that we have an unbalance use of mutex leading to potential deadlocks.
Fixes CID 1519048
Quoted 4 lines
Signed-off-by Alex Bennée <[email protected]>--- contrib/plugins/hotblocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)