random fixes for 8.2 pre-PR (tests, plugins, docs, semihosting)
v2 cover random fixes for 8.2 pre-PR (tests, plugins, docs, semihosting)
I've just been trying to clear some of the bugs against various subsystems. These are mostly testing changes and a minor tweak I found while checking up on semihosting behaviour. Enabling arm-softmmu check-tcg tests expands our testing abilities slightly for the 32 bit side of the family.
For v2
------
- fixed up register test for ppc64/s390x
- added gdbstub doc patch
- review comments for arm-softmmu testing
- changed handling of "native" cross for linux-user
I intend to roll the PR on Wednesday.
The following need still review:
tests/tcg: finesse the registers check for "hidden" regs
configure: don't try a "native" cross for linux-user tests/tcg: enable semiconsole test for Arm
tests/tcg: enable arm softmmu tests
docs/system: clarify limits of using gdbstub in system emulation docs/emulation: expand warning about semihosting tests/tcg: fixup Aarch64 semiconsole test
Alex Bennée (10):
tests/docker: merge debian-native with debian-amd64 tests/tcg: fixup Aarch64 semiconsole test docs/emulation: expand warning about semihosting docs/system: clarify limits of using gdbstub in system emulation hw/core: skip loading debug on all failures
testing: move arm system tests into their own folder tests/tcg: enable arm softmmu tests
tests/tcg: enable semiconsole test for Arm
configure: don't try a "native" cross for linux-user tests/tcg: finesse the registers check for "hidden" regs
Daniel P. Berrangé (1):
tests/docker: replace fedora-i386 with debian-i686
Greg Manning (1):
plugins: fix win plugin tests on cross compile
Philippe Mathieu-Daudé (2):
.gitlab-ci.d/cirrus: Upgrade macOS to 13 (Ventura) target/nios2: Deprecate the Nios II architecture
docs/about/deprecated.rst | 15 +
docs/about/emulation.rst | 5 +-
docs/system/gdb.rst | 13 +-
configure | 27 +-
hw/core/loader.c | 2 +-
hw/nios2/10m50_devboard.c | 1 +
hw/nios2/generic_nommu.c | 1 +
tests/tcg/arm/system/semiconsole.c | 42 +++
.gitlab-ci.d/buildtest.yml | 12 +-
.gitlab-ci.d/cirrus.yml | 6 +-
.../cirrus/{macos-12.vars => macos-13.vars} | 2 +-
.gitlab-ci.d/container-cross.yml | 11 +-
.gitlab-ci.d/containers.yml | 2 +-
.gitlab-ci.d/crossbuilds.yml | 14 +-
contrib/plugins/Makefile | 2 +-
plugins/meson.build | 2 +-
tests/docker/Makefile.include | 3 -
.../dockerfiles/debian-i686-cross.docker | 182 +++++++++++
tests/docker/dockerfiles/debian-native.docker | 54 ----
.../{debian-amd64.docker => debian.docker} | 7 +-
.../dockerfiles/fedora-i386-cross.docker | 40 ---
tests/lcitool/refresh | 18 +-
tests/plugin/meson.build | 3 +-
tests/tcg/aarch64/Makefile.softmmu-target | 5 +-
tests/tcg/arm/Makefile.softmmu-target | 76 ++++-
tests/tcg/arm/system/boot.S | 301 ++++++++++++++++++
tests/tcg/arm/system/kernel.ld | 24 ++
.../tcg/arm/{ => system}/test-armv6m-undef.S | 0
.../tcg/arm/{ => system}/test-armv6m-undef.ld | 0
tests/tcg/multiarch/gdbstub/registers.py | 87 +++--
tests/tcg/ppc64/Makefile.target | 7 -
tests/tcg/s390x/Makefile.target | 4 -
32 files changed, 775 insertions(+), 193 deletions(-)
create mode 100644 tests/tcg/arm/system/semiconsole.c
rename .gitlab-ci.d/cirrus/{macos-12.vars => macos-13.vars} (95%)
create mode 100644 tests/docker/dockerfiles/debian-i686-cross.docker
delete mode 100644 tests/docker/dockerfiles/debian-native.docker
rename tests/docker/dockerfiles/{debian-amd64.docker => debian.docker} (96%)
delete mode 100644 tests/docker/dockerfiles/fedora-i386-cross.docker
create mode 100644 tests/tcg/arm/system/boot.S
create mode 100644 tests/tcg/arm/system/kernel.ld
rename tests/tcg/arm/{ => system}/test-armv6m-undef.S (100%)
rename tests/tcg/arm/{ => system}/test-armv6m-undef.ld (100%)Signature · 1 line
2.39.2
PATCH v2 1/14 tests/docker: replace fedora-i386 with debian-i686
From: Daniel P. Berrangé <[email protected]>
Fedora is gradually killing off i386 packages in its repos, via a death-by-1000-cuts process. Thus Debian looks like a better long term bet for i686 build testing. It has the added advantage that we can generate it via lcitool too.
Message-Id: <[email protected]>
---
v2
- also set correct prefix
--- configure | 4 +- .gitlab-ci.d/container-cross.yml | 11 +- .gitlab-ci.d/crossbuilds.yml | 12 +- .../dockerfiles/debian-i686-cross.docker | 182 ++++++++++++++++++ .../dockerfiles/fedora-i386-cross.docker | 40 ---- tests/lcitool/refresh | 7 + 6 files changed, 203 insertions(+), 53 deletions(-) create mode 100644 tests/docker/dockerfiles/debian-i686-cross.docker delete mode 100644 tests/docker/dockerfiles/fedora-i386-cross.docker
configure +2 -2
@@ -1307,8 +1307,8 @@ probe_target_compiler() { container_cross_cc=${container_cross_prefix}gcc ;; i386) - container_image=fedora-i386-cross - container_cross_prefix= + container_image=debian-i686-cross + container_cross_prefix=i686-linux-gnu- ;; loongarch64) container_image=debian-loongarch-cross
.gitlab-ci.d/container-cross.yml +6 -5
@@ -46,6 +46,12 @@ loongarch-debian-cross-container: variables: NAME: debian-loongarch-cross +i686-debian-cross-container: + extends: .container_job_template + stage: containers + variables: + NAME: debian-i686-cross + mips64el-debian-cross-container: extends: .container_job_template stage: containers
@@ -95,11 +101,6 @@ cris-fedora-cross-container: variables: NAME: fedora-cris-cross -i386-fedora-cross-container: - extends: .container_job_template - variables: - NAME: fedora-i386-cross - win32-fedora-cross-container: extends: .container_job_template variables:
.gitlab-ci.d/crossbuilds.yml +6 -6
@@ -37,25 +37,25 @@ cross-arm64-kvm-only: IMAGE: debian-arm64-cross EXTRA_CONFIGURE_OPTS: --disable-tcg --without-default-features -cross-i386-user: +cross-i686-user: extends: - .cross_user_build_job - .cross_test_artifacts needs: - job: i386-fedora-cross-container + job: i686-debian-cross-container variables: - IMAGE: fedora-i386-cross + IMAGE: debian-i686-cross MAKE_CHECK_ARGS: check -cross-i386-tci: +cross-i686-tci: extends: - .cross_accel_build_job - .cross_test_artifacts timeout: 60m needs: - job: i386-fedora-cross-container + job: i686-debian-cross-container variables: - IMAGE: fedora-i386-cross + IMAGE: debian-i686-cross ACCEL: tcg-interpreter EXTRA_CONFIGURE_OPTS: --target-list=i386-softmmu,i386-linux-user,aarch64-softmmu,aarch64-linux-user,ppc-softmmu,ppc-linux-user --disable-plugins MAKE_CHECK_ARGS: check check-tcg
tests/docker/dockerfiles/debian-i686-cross.docker new file +182 -0
182 lines not on this page · raw message
tests/docker/dockerfiles/fedora-i386-cross.docker deleted +0 -40
@@ -1,40 +0,0 @@ -FROM registry.fedoraproject.org/fedora:34 - -ENV PACKAGES \ - bison \ - bzip2 \ - ccache \ - diffutils \ - flex \ - findutils \ - gcc \ - git \ - libfdt-devel.i686 \ - libffi-devel.i686 \ - libselinux-devel.i686 \ - libtasn1-devel.i686 \ - libzstd-devel.i686 \ - make \ - meson \ - ninja-build \ - glib2-devel.i686 \ - glibc-devel.i686 \ - glibc-static.i686 \ - gnutls-devel.i686 \ - nettle-devel.i686 \ - pcre-devel.i686 \ - pixman-devel.i686 \ - python3-tomli \ - sysprof-capture-devel.i686 \ - zlib-devel.i686 - -ENV QEMU_CONFIGURE_OPTS --cpu=i386 --disable-vhost-user -ENV PKG_CONFIG_LIBDIR /usr/lib/pkgconfig - -RUN dnf update -y && dnf install -y $PACKAGES -RUN rpm -q $PACKAGES | sort > /packages.txt -# As a final step configure the user (if env is defined) -ARG USER -ARG UID -RUN if [ "${USER}" ]; then \ - id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
tests/lcitool/refresh +7 -0
@@ -156,6 +156,13 @@ try: trailer=cross_build("arm-linux-gnueabihf-", "arm-softmmu,arm-linux-user")) + generate_dockerfile("debian-i686-cross", "debian-11", + cross="i686", + trailer=cross_build("x86_64-linux-gnu-", + "x86_64-softmmu," + "x86_64-linux-user," + "i386-softmmu,i386-linux-user")) + generate_dockerfile("debian-mips64el-cross", "debian-11", cross="mips64el", trailer=cross_build("mips64el-linux-gnuabi64-",
Signature · 1 line
2.39.2
PATCH v2 2/14 .gitlab-ci.d/cirrus: Upgrade macOS to 13 (Ventura)
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
macOS 14 "Sonoma" was released on September 2023 [1].
According to QEMU's support policy, we stop supporting the previous major release two years after the the new major release has been published. Replace the macOS 12 (Monterey) testing by macOS 13 (Ventura, released on October 2022, [2]).
Refresh the generated files by running:
$ make lcitool-refresh
[1] https://www.apple.com/newsroom/2023/09/macos-sonoma-is-available-today/
[2] https://www.apple.com/newsroom/2022/10/macos-ventura-is-now-available/
Message-Id: <[email protected]>
---
.gitlab-ci.d/cirrus.yml | 6 +++---
.gitlab-ci.d/cirrus/{macos-12.vars => macos-13.vars} | 2 +-
tests/lcitool/refresh | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
rename .gitlab-ci.d/cirrus/{macos-12.vars => macos-13.vars} (95%).gitlab-ci.d/cirrus.yml +3 -3
@@ -59,13 +59,13 @@ x64-freebsd-13-build: INSTALL_COMMAND: pkg install -y TEST_TARGETS: check -aarch64-macos-12-base-build: +aarch64-macos-13-base-build: extends: .cirrus_build_job variables: - NAME: macos-12 + NAME: macos-13 CIRRUS_VM_INSTANCE_TYPE: macos_instance CIRRUS_VM_IMAGE_SELECTOR: image - CIRRUS_VM_IMAGE_NAME: ghcr.io/cirruslabs/macos-monterey-base:latest + CIRRUS_VM_IMAGE_NAME: ghcr.io/cirruslabs/macos-ventura-base:latest CIRRUS_VM_CPUS: 12 CIRRUS_VM_RAM: 24G UPDATE_COMMAND: brew update
.gitlab-ci.d/cirrus/macos-13.vars renamed from .gitlab-ci.d/cirrus/macos-12.vars +1 -1
@@ -1,6 +1,6 @@ # THIS FILE WAS AUTO-GENERATED # -# $ lcitool variables macos-12 qemu +# $ lcitool variables macos-13 qemu # # https://gitlab.com/libvirt/libvirt-ci
tests/lcitool/refresh +1 -1
@@ -203,7 +203,7 @@ try: # Cirrus packages lists for GitLab # generate_cirrus("freebsd-13") - generate_cirrus("macos-12") + generate_cirrus("macos-13") # # VM packages lists
Signature · 1 line
2.39.2
PATCH v2 3/14 tests/docker: merge debian-native with debian-amd64
In reply to Alex Bennéedebian-native isn't really needed and suffers from the problem of tracking a distros dependencies rather than the projects. With a little surgery we can make the debian-amd64 container architecture neutral and allow people to use it to build a native QEMU.
Rename it so it follows the same non-arch pattern of the other distro containers.
---
.gitlab-ci.d/buildtest.yml | 12 ++---
.gitlab-ci.d/containers.yml | 2 +-
tests/docker/Makefile.include | 3 --
tests/docker/dockerfiles/debian-native.docker | 54 -------------------
.../{debian-amd64.docker => debian.docker} | 7 ++-
tests/lcitool/refresh | 9 ++--
6 files changed, 18 insertions(+), 69 deletions(-)
delete mode 100644 tests/docker/dockerfiles/debian-native.docker
rename tests/docker/dockerfiles/{debian-amd64.docker => debian.docker} (96%).gitlab-ci.d/buildtest.yml +6 -6
@@ -70,7 +70,7 @@ build-system-debian: needs: job: amd64-debian-container variables: - IMAGE: debian-amd64 + IMAGE: debian CONFIGURE_ARGS: --with-coroutine=sigaltstack TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensa-softmmu
@@ -82,7 +82,7 @@ check-system-debian: - job: build-system-debian artifacts: true variables: - IMAGE: debian-amd64 + IMAGE: debian MAKE_CHECK_ARGS: check avocado-system-debian:
@@ -91,7 +91,7 @@ avocado-system-debian: - job: build-system-debian artifacts: true variables: - IMAGE: debian-amd64 + IMAGE: debian MAKE_CHECK_ARGS: check-avocado AVOCADO_TAGS: arch:arm arch:i386 arch:riscv64 arch:sh4 arch:sparc arch:xtensa
@@ -101,7 +101,7 @@ crash-test-debian: - job: build-system-debian artifacts: true variables: - IMAGE: debian-amd64 + IMAGE: debian script: - cd build - make NINJA=":" check-venv
@@ -589,7 +589,7 @@ build-tools-and-docs-debian: # when running on 'master' we use pre-existing container optional: true variables: - IMAGE: debian-amd64 + IMAGE: debian MAKE_CHECK_ARGS: check-unit ctags TAGS cscope CONFIGURE_ARGS: --disable-system --disable-user --enable-docs --enable-tools QEMU_JOB_PUBLISH: 1
@@ -609,7 +609,7 @@ build-tools-and-docs-debian: # of what topic branch they're currently using pages: extends: .base_job_template - image: $CI_REGISTRY_IMAGE/qemu/debian-amd64:$QEMU_CI_CONTAINER_TAG + image: $CI_REGISTRY_IMAGE/qemu/debian:$QEMU_CI_CONTAINER_TAG stage: test needs: - job: build-tools-and-docs-debian
.gitlab-ci.d/containers.yml +1 -1
@@ -11,7 +11,7 @@ amd64-debian-container: extends: .container_job_template stage: containers variables: - NAME: debian-amd64 + NAME: debian amd64-ubuntu2204-container: extends: .container_job_template
tests/docker/Makefile.include +0 -3
@@ -88,9 +88,6 @@ DOCKER_PARTIAL_IMAGES += debian-s390x-cross DOCKER_PARTIAL_IMAGES += fedora endif -# The native build should never use the registry -docker-image-debian-native: DOCKER_REGISTRY= - # alpine has no adduser docker-image-alpine: NOUSER=1
tests/docker/dockerfiles/debian-native.docker deleted +0 -54
54 lines not on this page · raw message
tests/docker/dockerfiles/debian.docker renamed from tests/docker/dockerfiles/debian-amd64.docker +5 -2
@@ -155,10 +155,13 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ apt install -y --no-install-recommends \ cscope\ global\ - linux-headers-amd64 + linux-headers-generic RUN git clone https://github.com/luigirizzo/netmap.git /usr/src/netmap RUN cd /usr/src/netmap && git checkout v11.3 -RUN cd /usr/src/netmap/LINUX && ./configure --no-drivers --no-apps --kernel-dir=$(ls -d /usr/src/linux-headers-*-amd64) && make install +RUN cd /usr/src/netmap/LINUX && \ + ./configure --no-drivers --no-apps \ + --kernel-dir=$(ls -d /usr/src/linux-headers-*-$(dpkg --print-architecture)) \ + && make install ENV QEMU_CONFIGURE_OPTS --enable-netmap # As a final step configure the user (if env is defined) ARG USER
tests/lcitool/refresh +6 -3
@@ -99,10 +99,13 @@ debian12_extras = [ " apt install -y --no-install-recommends \\\n", " cscope\\\n", " global\\\n", - " linux-headers-amd64\n", + " linux-headers-generic\n", "RUN git clone https://github.com/luigirizzo/netmap.git /usr/src/netmap\n", "RUN cd /usr/src/netmap && git checkout v11.3\n", - "RUN cd /usr/src/netmap/LINUX && ./configure --no-drivers --no-apps --kernel-dir=$(ls -d /usr/src/linux-headers-*-amd64) && make install\n", + "RUN cd /usr/src/netmap/LINUX && \\\n", + " ./configure --no-drivers --no-apps \\\n", + " --kernel-dir=$(ls -d /usr/src/linux-headers-*-$(dpkg --print-architecture)) \\\n", + " && make install\n", "ENV QEMU_CONFIGURE_OPTS --enable-netmap\n" ]
@@ -123,7 +126,7 @@ try: # generate_dockerfile("alpine", "alpine-318") generate_dockerfile("centos8", "centos-stream-8") - generate_dockerfile("debian-amd64", "debian-12", + generate_dockerfile("debian", "debian-12", trailer="".join(debian12_extras)) generate_dockerfile("fedora", "fedora-38") generate_dockerfile("opensuse-leap", "opensuse-leap-15")
Signature · 1 line
2.39.2
PATCH v2 4/14 plugins: fix win plugin tests on cross compile
In reply to Alex BennéeFrom: Greg Manning <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1972
Cross compile gcc is more picky about argument order than msys. Changed the meson command to take the (now renamed) libqemu_plugin_api.a as a lib, rather than an object. This puts it in the right place on both native and cross compile gcc commands
Reenable plugins on crossbuilds
Message-Id: <[email protected]>
--- .gitlab-ci.d/crossbuilds.yml | 2 +- contrib/plugins/Makefile | 2 +- plugins/meson.build | 2 +- tests/plugin/meson.build | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-)
.gitlab-ci.d/crossbuilds.yml +1 -1
@@ -165,7 +165,7 @@ cross-win32-system: job: win32-fedora-cross-container variables: IMAGE: fedora-win32-cross - EXTRA_CONFIGURE_OPTS: --enable-fdt=internal --disable-plugins + EXTRA_CONFIGURE_OPTS: --enable-fdt=internal CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu m68k-softmmu microblazeel-softmmu mips64el-softmmu nios2-softmmu artifacts:
contrib/plugins/Makefile +1 -1
@@ -49,7 +49,7 @@ all: $(SONAMES) $(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $< ifeq ($(CONFIG_WIN32),y) -lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/qemu_plugin_api.lib +lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/libqemu_plugin_api.a $(CC) -shared -o $@ $^ $(LDLIBS) else ifeq ($(CONFIG_DARWIN),y) lib%$(SO_SUFFIX): %.o
plugins/meson.build +1 -1
@@ -28,7 +28,7 @@ if get_option('plugins') # then use dlltool to assemble a delaylib. win32_qemu_plugin_api_lib = configure_file( input: win32_plugin_def, - output: 'qemu_plugin_api.lib', + output: 'libqemu_plugin_api.a', command: [dlltool, '--input-def', '@INPUT@', '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe'] )
tests/plugin/meson.build +2 -1
@@ -4,7 +4,8 @@ if get_option('plugins') if targetos == 'windows' t += shared_module(i, files(i + '.c') + '../../contrib/plugins/win32_linker.c', include_directories: '../../include/qemu', - objects: [win32_qemu_plugin_api_lib], + link_depends: [win32_qemu_plugin_api_lib], + link_args: ['-Lplugins', '-lqemu_plugin_api'], dependencies: glib) else
Signature · 1 line
2.39.2
PATCH v2 5/14 target/nios2: Deprecate the Nios II architecture
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
See commit 9ba1caf510 ("MAINTAINERS: Mark the Nios II CPU as orphan"), last contribution from Chris was in 2012 [1] and Marek in 2018 [2].
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
Message-Id: <[email protected]>
--- docs/about/deprecated.rst | 15 +++++++++++++++ hw/nios2/10m50_devboard.c | 1 + hw/nios2/generic_nommu.c | 1 + 3 files changed, 17 insertions(+)
docs/about/deprecated.rst +15 -0
@@ -236,6 +236,16 @@ it. Since all recent x86 hardware from the past >10 years is capable of the 64-bit x86 extensions, a corresponding 64-bit OS should be used instead. +System emulator CPUs +-------------------- + +Nios II CPU (since 8.2) +''''''''''''''''''''''' + +The Nios II architecture is orphan. The ``nios2`` guest CPU support is +deprecated and will be removed in a future version of QEMU. + + System emulator machines ------------------------
@@ -254,6 +264,11 @@ These old machine types are quite neglected nowadays and thus might have various pitfalls with regards to live migration. Use a newer machine type instead. +Nios II ``10m50-ghrd`` and ``nios2-generic-nommu`` machines (since 8.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The Nios II architecture is orphan. + Backend options ---------------
hw/nios2/10m50_devboard.c +1 -0
@@ -160,6 +160,7 @@ static void nios2_10m50_ghrd_class_init(ObjectClass *oc, void *data) mc->desc ="Altera 10M50 GHRD Nios II design" ; mc->init = nios2_10m50_ghrd_init; mc->is_default = true; + mc->deprecation_reason ="Nios II architecture is deprecated" ;object_class_property_add_bool (oc,"vic" , get_vic, set_vic); object_class_property_set_description(oc, "vic",
hw/nios2/generic_nommu.c +1 -0
@@ -95,6 +95,7 @@ static void nios2_generic_nommu_machine_init(struct MachineClass *mc) { mc->desc ="Generic NOMMU Nios II design" ; mc->init = nios2_generic_nommu_init; + mc->deprecation_reason ="Nios II architecture is deprecated" ; }DEFINE_MACHINE ("nios2-generic-nommu" , nios2_generic_nommu_machine_init);
Signature · 1 line
2.39.2
PATCH v2 6/14 tests/tcg: fixup Aarch64 semiconsole test
In reply to Alex BennéeWe need to ensure we squash the serial port if we want to hand craft our muxed input. As a bonus emit the example with a V=1 build to make it easier for people to figure out.
--- tests/tcg/aarch64/Makefile.softmmu-target | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tests/tcg/aarch64/Makefile.softmmu-target +3 -2
@@ -48,10 +48,11 @@ QEMU_BASE_MACHINE=-M virt -cpu max -display none QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel # console test is manual only -QEMU_SEMIHOST=-chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline -run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel +QEMU_SEMIHOST=-serial none -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline +run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel run-semiconsole: semiconsole $(call skip-test, $<, "MANUAL ONLY") + $(if $(V),@printf " %-7s %s %s\n" "TO RUN" $(notdir $(QEMU)) "$(QEMU_OPTS) $<") run-plugin-semiconsole-with-%: semiconsole $(call skip-test, $<, "MANUAL ONLY")
Signature · 1 line
2.39.2
PATCH v2 7/14 docs/emulation: expand warning about semihosting
In reply to Alex BennéeA surprising feature of calls like SYS_READC is this can cause QEMU to indefinitely block as there is no handling for EOF.
Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1963
--- docs/about/emulation.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
docs/about/emulation.rst +3 -2
@@ -129,8 +129,9 @@ causing most hypervisors to trap and fault on them. .. warning:: Semihosting inherently bypasses any isolation there may be between the guest and the host. As a result a program using semihosting can - happily trash your host system. You should only ever run trusted - code with semihosting enabled. + happily trash your host system. Some semihosting calls (e.g. + ``SYS_READC``) can block execution indefinitely. You should only + ever run trusted code with semihosting enabled. Redirection ~~~~~~~~~~~
Signature · 1 line
2.39.2
Re: [PATCH v2 07/14] docs/emulation: expand warning about semihosting
Quoted 15 lines · Alex Bennée
A surprising feature of calls like
SYS_READCis this can cause QEMU to indefinitely block as there is no handling for EOF.Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1963
Signed-off-by Alex Bennée <[email protected]>--- docs/about/emulation.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)docs/about/emulation.rst +0
-0@@ -129,8 +129,9 @@ causing most hypervisors to trap and fault on them. .. warning::
docs/about/emulation.rst causing most hypervisors to trap and fault on them. · line 137
Quoted 10 lines
docs/about/emulation.rst +3
-2Semihosting inherently bypasses any isolation there may be between the guest and the host. As a result a program using semihosting can - happily trash your host system. You should only ever run trusted - code with semihosting enabled. + happily trash your host system. Some semihosting calls (e.g. + ``SYS_READC``) can block execution indefinitely. You should only + ever run trusted code with semihosting enabled. Redirection ~~~~~~~~~~~
r~
PATCH v2 8/14 docs/system: clarify limits of using gdbstub in system emulation
In reply to Alex BennéeIt seems some users will try and use the gdbstub to debug userspace inside a system emulation. While possible clarify the limitations of this approach and direct the users to a less head scratching way of debugging user-space.
Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1274
--- docs/system/gdb.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
docs/system/gdb.rst +12 -1
@@ -60,7 +60,7 @@ As TCG cannot track all memory accesses in user-mode there is no support for watchpoints. Relocating code ---------------- +=============== On modern kernels confusion can be caused by code being relocated by features such as address space layout randomisation. To avoid
@@ -68,6 +68,17 @@ confusion when debugging such things you either need to update gdb's view of where things are in memory or perhaps more trivially disable ASLR when booting the system. +Debugging user-space in system emulation +======================================== + +While technically possible to debug a user-space program running +inside a system image it does present challenges. Kernel preemption +and execution mode changes between kernel and user mode can make it +hard to follow whats going on. Unless you are specifically trying to +debug some interaction between kernel and user-space you are better +off running your guest program with gdb either in the guest or using +a gdbserver exposed via a port to the outside world. + Debugging multicore machines ============================
Signature · 1 line
2.39.2
Re: [PATCH v2 08/14] docs/system: clarify limits of using gdbstub in system emulation
Quoted 10 lines · Alex Bennée
It seems some users will try and use the gdbstub to debug userspace inside a system emulation. While possible clarify the limitations of this approach and direct the users to a less head scratching way of debugging user-space.
Signed-off-by Alex Bennée <[email protected]>Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1274
--- docs/system/gdb.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
r~
Re: [PATCH v2 08/14] docs/system: clarify limits of using gdbstub in system emulation
In reply to Alex BennéeQuoted 10 lines · Alex Bennée
It seems some users will try and use the gdbstub to debug userspace inside a system emulation. While possible clarify the limitations of this approach and direct the users to a less head scratching way of debugging user-space.
Signed-off-by Alex Bennée <[email protected]>Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1274
--- docs/system/gdb.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
Re: [PATCH v2 08/14] docs/system: clarify limits of using gdbstub in system emulation
In reply to Alex BennéeQuoted 26 lines · Alex Bennée
It seems some users will try and use the gdbstub to debug userspace inside a system emulation. While possible clarify the limitations of this approach and direct the users to a less head scratching way of debugging user-space.
Signed-off-by Alex Bennée <[email protected]>Clarifies: https://gitlab.com/qemu-project/qemu/-/issues/1274
--- docs/system/gdb.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)docs/system/gdb.rst +1
-1@@ -60,7 +60,7 @@ As TCG cannot track all memory accesses in user-mode there is no support for watchpoints. Relocating code ---------------- +=============== On modern kernels confusion can be caused by code being relocated by features such as address space layout randomisation. To avoid
docs/system/gdb.rst confusion when debugging such things you either need to update gdb's · line 74
Quoted 7 lines
docs/system/gdb.rst +4
-0@@ -68,6 +68,17 @@ confusion when debugging such things you either need to update gdb's view of where things are in memory or perhaps more trivially disable ASLR when booting the system. +Debugging user-space in system emulation +======================================== + +While technically possible to debug a user-space program running
"While it is"
docs/system/gdb.rst confusion when debugging such things you either need to update gdb's · line 75
Quoted 1 line
docs/system/gdb.rst +1
-0+inside a system image it does present challenges. Kernel preemption
"image, "
docs/system/gdb.rst confusion when debugging such things you either need to update gdb's · line 77
Quoted 2 lines
docs/system/gdb.rst +2
-0+and execution mode changes between kernel and user mode can make it +hard to follow whats going on. Unless you are specifically trying to
"what's"
docs/system/gdb.rst confusion when debugging such things you either need to update gdb's · line 83
Quoted 6 lines
docs/system/gdb.rst +4
-0+debug some interaction between kernel and user-space you are better +off running your guest program with gdb either in the guest or using +a gdbserver exposed via a port to the outside world. + Debugging multicore machines ============================
thanks
-- PMM
PATCH v2 9/14 hw/core: skip loading debug on all failures
In reply to Alex BennéeELF_LOAD_FAILED is one of many negative return codes we can have. Lets treat any positive size_t as a success for loading.
Message-Id: <[email protected]>
--- hw/core/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/loader.c +1 -1
@@ -505,7 +505,7 @@ ssize_t load_elf_ram_sym(const char *filename, clear_lsb, data_swab, as, load_rom, sym_cb); } -if (ret !=ELF_LOAD_FAILED ) { +if (ret >0 ) {debuginfo_report_elf (filename, fd,0 ); }
Signature · 1 line
2.39.2
PATCH v2 10/14 testing: move arm system tests into their own folder
In reply to Alex BennéePrepare for expanding the arm system tests by cleaning up the test directory.
Message-Id: <[email protected]>
---
tests/tcg/arm/Makefile.softmmu-target | 5 ++---
tests/tcg/arm/{ => system}/test-armv6m-undef.S | 0
tests/tcg/arm/{ => system}/test-armv6m-undef.ld | 0
3 files changed, 2 insertions(+), 3 deletions(-)
rename tests/tcg/arm/{ => system}/test-armv6m-undef.S (100%)
rename tests/tcg/arm/{ => system}/test-armv6m-undef.ld (100%)tests/tcg/arm/Makefile.softmmu-target +2 -3
@@ -3,7 +3,7 @@ # ARM SoftMMU tests - included from tests/tcg/Makefile # -ARM_SRC=$(SRC_PATH)/tests/tcg/arm +ARM_SRC=$(SRC_PATH)/tests/tcg/arm/system # Set search path for all sources VPATH += $(ARM_SRC)
@@ -12,7 +12,6 @@ ARM_TESTS=test-armv6m-undef TESTS += $(ARM_TESTS) -CFLAGS+=-Wl,--build-id=none -x assembler-with-cpp LDFLAGS+=-nostdlib -N -static %: %.S %.ld
@@ -20,7 +19,7 @@ LDFLAGS+=-nostdlib -N -static # Specific Test Rules -test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 -mfloat-abi=soft +test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 -mfloat-abi=soft -Wl,--build-id=none -x assembler-with-cpp run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
tests/tcg/arm/system/test-armv6m-undef.S renamed from tests/tcg/arm/test-armv6m-undef.S +0 -0
tests/tcg/arm/system/test-armv6m-undef.ld renamed from tests/tcg/arm/test-armv6m-undef.ld +0 -0
Signature · 1 line
2.39.2
PATCH v2 11/14 tests/tcg: enable arm softmmu tests
In reply to Alex BennéeTo make it easier to test 32 bit Arm softmmu issues implement a basic boot.S so we can build the multiarch tests. Currently CHECK_UNALIGNED is disabled as I haven't got the right magic set for it to work.
Message-Id: <[email protected]>
---
v2
- use endf macro for global function symbols in boot.S
--- tests/tcg/arm/Makefile.softmmu-target | 64 +++++- tests/tcg/arm/system/boot.S | 301 ++++++++++++++++++++++++++ tests/tcg/arm/system/kernel.ld | 24 ++ 3 files changed, 379 insertions(+), 10 deletions(-) create mode 100644 tests/tcg/arm/system/boot.S create mode 100644 tests/tcg/arm/system/kernel.ld
tests/tcg/arm/Makefile.softmmu-target +54 -10
@@ -8,20 +8,64 @@ ARM_SRC=$(SRC_PATH)/tests/tcg/arm/system # Set search path for all sources VPATH += $(ARM_SRC) -ARM_TESTS=test-armv6m-undef +# Specific Test Rules -TESTS += $(ARM_TESTS) +test-armv6m-undef: test-armv6m-undef.S + $(CC) -mcpu=cortex-m0 -mfloat-abi=soft \ + -Wl,--build-id=none -x assembler-with-cpp \ + $< -o $@ -nostdlib -N -static \ + -T $(ARM_SRC)/[email protected] -LDFLAGS+=-nostdlib -N -static +run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel -%: %.S %.ld - $(CC) $(CFLAGS) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) -T $(ARM_SRC)/[email protected] +ARM_TESTS+=test-armv6m-undef -# Specific Test Rules +# These objects provide the basic boot code and helper functions for all tests +CRT_OBJS=boot.o -test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 -mfloat-abi=soft -Wl,--build-id=none -x assembler-with-cpp +ARM_TEST_SRCS=$(wildcard $(ARM_SRC)/*.c) +ARM_TESTS+=$(patsubst $(ARM_SRC)/%.c, %, $(ARM_TEST_SRCS)) -run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel +CRT_PATH=$(ARM_SRC) +LINK_SCRIPT=$(ARM_SRC)/kernel.ld +LDFLAGS=-Wl,-T$(LINK_SCRIPT) +CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) +LDFLAGS+=-static -nostdlib -N $(CRT_OBJS) $(MINILIB_OBJS) -lgcc + +# building head blobs +.PRECIOUS: $(CRT_OBJS) + +%.o: $(ARM_SRC)/%.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -c $< -o $@ + +# Build and link the tests +%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) + +memory: CFLAGS+=-DCHECK_UNALIGNED=0 + +# Running +QEMU_BASE_MACHINE=-M virt -cpu max -display none +QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel + +# Simple Record/Replay Test +.PHONY: memory-record +run-memory-record: memory-record memory + $(call run-test, $<, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ + -icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \ + $(QEMU_OPTS) memory) + +.PHONY: memory-replay +run-memory-replay: memory-replay run-memory-record + $(call run-test, $<, \ + $(QEMU) -monitor none -display none \ + -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ + -icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \ + $(QEMU_OPTS) memory) + +EXTRA_RUNS+=run-memory-replay -# We don't currently support the multiarch system tests -undefine MULTIARCH_TESTS +TESTS += $(ARM_TESTS) $(MULTIARCH_TESTS) +EXTRA_RUNS+=$(MULTIARCH_RUNS)
tests/tcg/arm/system/boot.S new file +301 -0
301 lines not on this page · raw message
tests/tcg/arm/system/kernel.ld new file +24 -0
@@ -0,0 +1,24 @@ +ENTRY(__start) + +SECTIONS +{ + /* virt machine, RAM starts at 1gb */ + . = (1 << 30); + .text : { + *(.text) + } + .rodata : { + *(.rodata) + } + /* align r/w section to next 2mb */ + . = ALIGN(1 << 21); + .data : { + *(.data) + } + .bss : { + *(.bss) + } + /DISCARD/ : { + *(.ARM.attributes) + } +}
Signature · 1 line
2.39.2
Re: [PATCH v2 11/14] tests/tcg: enable arm softmmu tests
Quoted 3 lines · Alex Bennée
+/*
+ * Helper macro for the linker calling subroutines from the C code.
+ */
That's not all it's for. Better "annotating functions with elf type and size".
tests/tcg/arm/system/boot.S line 40
Quoted 9 lines
tests/tcg/arm/system/boot.S new file +9
-0+vector_table: + b reset /* reset vector */ + b undef_instr /* undefined instruction vector */ + b software_intr /* software interrupt vector */ + b prefetch_abort /* prefetch abort vector */ + b data_abort /* data abort vector */ + nop /* reserved */ + b IRQ_handler /* IRQ vector */ + b FIQ_handler /* FIQ vector */
Missing endf, for the purpose of qemu load_symbols().
tests/tcg/arm/system/boot.S line 223
Quoted 8 lines
tests/tcg/arm/system/boot.S new file +8
-0+mmu_setup: +reset: +undef_instr: +software_intr: +prefetch_abort: +data_abort: +IRQ_handler: +FIQ_handler:
Also missing.
With those fixed,
r~
Re: [PATCH v2 11/14] tests/tcg: enable arm softmmu tests
In reply to Alex Bennéetests/tcg/arm/Makefile.softmmu-target ARM_SRC=$(SRC_PATH)/tests/tcg/arm/system · line 50
Quoted 13 lines · Alex Bennée
To make it easier to test 32 bit Arm softmmu issues implement a basic
boot.Sso we can build the multiarch tests. CurrentlyCHECK_UNALIGNEDis disabled as I haven't got the right magic set for it to work.Message-Id: <[email protected]>
Signed-off-by Alex Bennée <[email protected]>tests/tcg/arm/Makefile.softmmu-target +4
-0+# Running +QEMU_BASE_MACHINE=-M virt -cpu max -display none +QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel +
A minor thing, but I just ran into an awkwardness in the equivalent set of variables in the aarch64 subdirectory:
if you ever want to define a different machine type then there's no convenient way to say "give me the standard options but a different machine", because the QEMU_OPTS has the base machine in it and there's no variable with just the semihosting etc options in it. For aarch64 I opted for:
+QEMU_BASE_ARGS=-semihosting-config enable=on,target=native,chardev=output +QEMU_OPTS+=$(QEMU_BASE_MACHINE) $(QEMU_BASE_ARGS) -kernel
because then you can have a particular test do something like +QEMU_EL2_MACHINE=-machine virt,virtualization=on,gic-version=2 -cpu cortex-a57 -smp 4
+run-vtimer: QEMU_OPTS=$(QEMU_EL2_MACHINE) $(QEMU_BASE_ARGS) -kernel
You could argue about whether '-display none' should be in QEMU_BASE_ARGS. I figure -kernel should not be because it has the weird "must go last" property.
(These tweaks to the aarch64 makefile coming soon in a different patch...)
thanks
-- PMM
PATCH v2 12/14 tests/tcg: enable semiconsole test for Arm
In reply to Alex BennéeThis still remains a MANUAL test due to blocking issues.
--- tests/tcg/arm/system/semiconsole.c | 42 +++++++++++++++++++++++++++ tests/tcg/arm/Makefile.softmmu-target | 9 ++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/tcg/arm/system/semiconsole.c
tests/tcg/arm/system/semiconsole.c new file +42 -0
@@ -0,0 +1,42 @@ +/* +* Semihosting Console Test +* +* Copyright (c) 2019 Linaro Ltd +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include <stdint.h> +#include <minilib.h> + +#define SYS_READC 0x7 + +uintptr_t __semi_call (uintptr_t type,uintptr_t arg0) +{ + register uintptr_t t asm("r0") = type; + register uintptr_t a0 asm("r1") = arg0; +#ifdef __thumb__ +# define SVC "svc 0xab" +#else +# define SVC "svc 0x123456" +#endif + asm(SVC : "=r" (t) + : "r" (t), "r" (a0)); + +return t; +} + +int main (void ) +{ +char c; + +ml_printf ("Semihosting Console Test\n" ); +ml_printf ("hit X to exit:" ); + +do { + c =__semi_call (SYS_READC ,0 ); +__sys_outc (c); + }while (c !='X' ); + +return 0 ; +}
tests/tcg/arm/Makefile.softmmu-target +9 -0
@@ -48,6 +48,15 @@ memory: CFLAGS+=-DCHECK_UNALIGNED=0 QEMU_BASE_MACHINE=-M virt -cpu max -display none QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel +# console test is manual only +QEMU_SEMIHOST=-serial none -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline +run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST) -kernel +run-semiconsole: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + $(if $(V),@printf " %-7s %s %s\n" "TO RUN" $(notdir $(QEMU)) "$(QEMU_OPTS) $<") +run-plugin-semiconsole-with-%: semiconsole + $(call skip-test, $<, "MANUAL ONLY") + # Simple Record/Replay Test .PHONY: memory-record run-memory-record: memory-record memory
Signature · 1 line
2.39.2
PATCH v2 13/14 configure: don't try a "native" cross for linux-user
In reply to Alex BennéeAs 32 bit x86 become rarer we are starting to run into problems with search paths. Although we switched to a Debian container we still favour the native CC on a Bookworm host. As a result we have a broken cross compile setup which then fails to build with:
BUILD i386-linux-user guest-tests
In file included from /usr/include/linux/stat.h:5,
from /usr/include/bits/statx.h:31,
from /usr/include/sys/stat.h:465,
from /home/alex/lsrc/qemu.git/tests/tcg/multiarch/linux/linux-test.c:28:
/usr/include/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~ compilation terminated.
make[1]: *** [Makefile:119: linux-test] Error 1
make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:50: build-tcg-tests-i386-linux-user] Error 2
This is likely to affect more and more linux-user builds so wrap the whole check in a test for softmmu targets (aka bare metal) which don't worry about such header niceties. This allows us to keep using the host compiler for softmmu tests and the roms.
---
v2
- split fix for tests/docker: replace fedora-i386 with debian-i686 as still in my tree ;-)
- didn't apply dpb rb due to change requested by bonzini
--- configure | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
configure +13 -10
@@ -1391,16 +1391,19 @@ probe_target_compiler() { done try=cross - case "$target_arch:$cpu" in - aarch64_be:aarch64 | \ - armeb:arm | \ - i386:x86_64 | \ - mips*:mips64 | \ - ppc*:ppc64 | \ - sparc:sparc64 | \ - "$cpu:$cpu") - try='native cross' ;; - esac + # For softmmu/roms we might be able to use the host compiler + if [ "${1%softmmu}" != "$1" ]; then + case "$target_arch:$cpu" in + aarch64_be:aarch64 | \ + armeb:arm | \ + i386:x86_64 | \ + mips*:mips64 | \ + ppc*:ppc64 | \ + sparc:sparc64 | \ + "$cpu:$cpu") + try='native cross' ;; + esac + fi eval "target_cflags=\${cross_cc_cflags_$target_arch}" for thistry in $try; do case $thistry in
Signature · 1 line
2.39.2
PATCH v2 14/14 tests/tcg: finesse the registers check for "hidden" regs
In reply to Alex BennéeThe reason the ppc64 and s390x test where failing was because gdb hides them although they are still accessible via regnum. We can re-arrange the test a little bit and include these two arches in our test.
We still don't explicitly fail for registers that just disappear like in the ARM case:
xml-tdesc has 228 registers
remote-registers has 219 registers
of which 0 are hidden
{'name': 'CNTP_CVAL', 'regnum': 96} wasn't seen in remote-registers {'name': 'CNTV_CVAL', 'regnum': 101} wasn't seen in remote-registers {'name': 'PAR', 'regnum': 113} wasn't seen in remote-registers {'name': 'CPUACTLR', 'regnum': 114} wasn't seen in remote-registers {'name': 'CPUECTLR', 'regnum': 127} wasn't seen in remote-registers {'name': 'CPUMERRSR', 'regnum': 140} wasn't seen in remote-registers {'name': 'TTBR1', 'regnum': 148} wasn't seen in remote-registers {'name': 'L2MERRSR', 'regnum': 161} wasn't seen in remote-registers {'name': 'TTBR0', 'regnum': 168} wasn't seen in remote-registers
---
v2
- skip if check for total_regs != total_r_regs and always dump what is elided/missed
--- tests/tcg/multiarch/gdbstub/registers.py | 87 +++++++++++++++++------- tests/tcg/ppc64/Makefile.target | 7 -- tests/tcg/s390x/Makefile.target | 4 -- 3 files changed, 64 insertions(+), 34 deletions(-)
tests/tcg/multiarch/gdbstub/registers.py +64 -23
@@ -44,7 +44,6 @@ def fetch_xml_regmap(): total_regs = 0 reg_map = {} - frame = gdb.selected_frame() tree = ET.fromstring(xml) for f in tree.findall("feature"):
@@ -61,12 +60,8 @@ def fetch_xml_regmap(): for r in regs: name = r.attrib["name"] regnum = int(r.attrib["regnum"]) - try: - value = frame.read_register(name) - except ValueError: - report(False, f"failed to read reg: {name}") - entry = { "name": name, "initial": value, "regnum": regnum } + entry = { "name": name, "regnum": regnum } if name in reg_map: report(False, f"duplicate register {entry} vs {reg_map[name]}")
@@ -80,6 +75,15 @@ def fetch_xml_regmap(): return reg_map +def get_register_by_regnum(reg_map, regnum): + """ + Helper to find a register from the map via its XML regnum + """ + for regname, entry in reg_map.items(): + if entry['regnum'] == regnum: + return entry + return None + def crosscheck_remote_xml(reg_map): """ Cross-check the list of remote-registers with the XML info.
@@ -90,6 +94,7 @@ def crosscheck_remote_xml(reg_map): total_regs = len(reg_map.keys()) total_r_regs = 0 + total_r_elided_regs = 0 for r in r_regs: fields = r.split()
@@ -100,6 +105,15 @@ def crosscheck_remote_xml(reg_map): r_name = fields[0] r_regnum = int(fields[6]) + # Some registers are "hidden" so don't have a name + # although they still should have a register number + if r_name == "''": + total_r_elided_regs += 1 + x_reg = get_register_by_regnum(reg_map, r_regnum) + if x_reg is not None: + x_reg["hidden"] = True + continue + # check in the XML try: x_reg = reg_map[r_name]
@@ -117,14 +131,39 @@ def crosscheck_remote_xml(reg_map): # Just print a mismatch in totals as gdb will filter out 64 bit # registers on a 32 bit machine. Also print what is missing to # help with debug. - if total_regs != total_r_regs: - print(f"xml-tdesc has ({total_regs}) registers") - print(f"remote-registers has ({total_r_regs}) registers") + print(f"xml-tdesc has {total_regs} registers") + print(f"remote-registers has {total_r_regs} registers") + print(f"of which {total_r_elided_regs} are hidden") + + for x_key in reg_map.keys(): + x_reg = reg_map[x_key] + if "hidden" in x_reg: + print(f"{x_reg} elided by gdb") + elif "seen" not in x_reg: + print(f"{x_reg} wasn't seen in remote-registers") + +def initial_register_read(reg_map): + """ + Do an initial read of all registers that we know gdb cares about + (so ignore the elided ones). + """ + frame = gdb.selected_frame() + + for e in reg_map.values(): + name = e["name"] + regnum = e["regnum"] + + try: + if "hidden" in e: + value = frame.read_register(regnum) + e["initial"] = value + elif "seen" in e: + value = frame.read_register(name) + e["initial"] = value + + except ValueError: + report(False, f"failed to read reg: {name}") - for x_key in reg_map.keys(): - x_reg = reg_map[x_key] - if "seen" not in x_reg: - print(f"{x_reg} wasn't seen in remote-registers") def complete_and_diff(reg_map): """
@@ -144,18 +183,19 @@ def complete_and_diff(reg_map): changed = 0 for e in reg_map.values(): - name = e["name"] - old_val = e["initial"] + if "initial" in e and "hidden" not in e: + name = e["name"] + old_val = e["initial"] - try: - new_val = frame.read_register(name) - except: - report(False, f"failed to read {name} at end of run") - continue + try: + new_val = frame.read_register(name) + except ValueError: + report(False, f"failed to read {name} at end of run") + continue - if new_val != old_val: - print(f"{name} changes from {old_val} to {new_val}") - changed += 1 + if new_val != old_val: + print(f"{name} changes from {old_val} to {new_val}") + changed += 1 # as long as something changed we can be confident its working report(changed > 0, f"{changed} registers were changed")
@@ -168,6 +208,7 @@ def run_test(): if reg_map is not None: crosscheck_remote_xml(reg_map) + initial_register_read(reg_map) complete_and_diff(reg_map)
tests/tcg/ppc64/Makefile.target +0 -7
@@ -38,11 +38,4 @@ PPC64_TESTS += signal_save_restore_xer PPC64_TESTS += xxspltw PPC64_TESTS += test-aes -ifneq ($(GDB),) -# Skip for now until vsx registers sorted out -run-gdbstub-registers: - $(call skip-test, $<, "BROKEN reading VSX registers") -endif - - TESTS += $(PPC64_TESTS)
tests/tcg/s390x/Makefile.target +0 -4
@@ -103,10 +103,6 @@ run-gdbstub-svc: hello-s390x-asm --bin $< --test $(S390X_SRC)/gdbstub/test-svc.py, \ single-stepping svc) -# Skip for now until vx registers sorted out -run-gdbstub-registers: - $(call skip-test, $<, "BROKEN reading VX registers") - EXTRA_RUNS += run-gdbstub-signals-s390x run-gdbstub-svc endif
Signature · 1 line
2.39.2