Skip to contentSkip to conversation

s390x patches and pylint support for functional tests

GIT PULL Applied Thomas Huth 3 participants 19 messages Jan 12 – Jan 13 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

Hi!

The following changes since commit b254e486242466dad881fc2bbfa215f1b67cd30f:

Merge tag 'pull-riscv-to-apply-20260109' of https://github.com/alistair23/qemu into staging (2026-01-10 10:31:57 +1100)

are available in the Git repository at:

https://gitlab.com/thuth/qemu.git tags/pull-request-2026-01-12

for you to fetch changes up to f397b7652dac77bf24a491dfee8def59a5d2591f:

tests/functional/s390x: Add reverse debugging test for s390x (2026-01-12 13:56:28 +0100)

----------------------------------------------------------------
* Check functional tests with pylint
* update copyright year to 2026
* Some more universal-binary work for the s390x code done by Philippe
* Fix reverse debugging for s390x and add a functional test for it

----------------------------------------------------------------
Ani Sinha (1):
docs: update copyright year to 2026

Ilya Leoshkevich (1):

      target/s390x: Fix infinite loop during replay

Philippe Mathieu-Daudé (6):

      target/s390x: Restrict WatchPoint API to TCG
      target/s390x: Use vaddr for $pc in get_next_pc()
      target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()
      target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c
      target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition
      target/s390x: Un-inline s390_is_pv()

Thomas Huth (7):
tests/functional: Add a pylintrc file tests/functional/mips/test_malta: Silence warnings reported by pylint tests/functional/ppc64/test_hv: Silence warnings reported by pylint tests/functional/aarch64/test_virt_gpu: Fix style issues tests/functional/aarch64/test_smmu: Silence warning from pylint tests/functional: Add a generic test that checks the files with pylint tests/functional/s390x: Add reverse debugging test for s390x

 MAINTAINERS                                  |  2 +
 docs/conf.py                                 |  2 +-
 include/hw/s390x/css.h                       |  2 +
 include/qemu/help-texts.h                    |  2 +-
 target/s390x/cpu.h                           |  6 --
 target/s390x/kvm/pv.h                        | 24 +-------
 target/s390x/s390x-internal.h                |  2 -
 target/s390x/tcg/tcg_s390x.h                 |  5 ++
 hw/s390x/tod.c                               |  5 ++
 stubs/async-run-on-cpu.c                     | 11 ++++
 stubs/cpus-queue.c                           |  8 +++
 target/s390x/cpu.c                           | 30 +++++-----
 target/s390x/gdbstub.c                       |  2 +-
 target/s390x/helper.c                        | 39 -------------
 target/s390x/kvm/kvm.c                       |  2 +
 target/s390x/kvm/pv.c                        | 18 ++++++
 target/s390x/machine.c                       |  4 ++
 target/s390x/tcg/debug.c                     | 85 ++++++++++++++++++++++++++++
 target/s390x/tcg/excp_helper.c               | 32 -----------
 target/s390x/tcg/translate.c                 |  5 +-
 util/qemu-timer.c                            | 30 ++++++++++
 stubs/meson.build                            |  2 +
 target/s390x/tcg/meson.build                 |  3 +
 tests/functional/aarch64/test_smmu.py        |  1 +
 tests/functional/aarch64/test_virt_gpu.py    | 20 +++----
 tests/functional/generic/meson.build         |  1 +
 tests/functional/generic/test_linters.py     | 41 ++++++++++++++
 tests/functional/mips/test_malta.py          |  8 +--
 tests/functional/ppc64/test_hv.py            | 10 ++--
 tests/functional/pylintrc                    | 84 +++++++++++++++++++++++++++
 tests/functional/reverse_debugging.py        |  4 +-
 tests/functional/s390x/meson.build           |  1 +
 tests/functional/s390x/test_reverse_debug.py | 21 +++++++
 33 files changed, 368 insertions(+), 144 deletions(-)
 create mode 100644 stubs/async-run-on-cpu.c
 create mode 100644 stubs/cpus-queue.c
 create mode 100644 target/s390x/tcg/debug.c
 create mode 100755 tests/functional/generic/test_linters.py
 create mode 100644 tests/functional/pylintrc
 create mode 100755 tests/functional/s390x/test_reverse_debug.py
#1 lore raw

[PULL 01/15] tests/functional: Add a pylintrc file

From: Thomas Huth <[email protected]>

Add a pylintrc file that can be used for checking the python code of the functional tests. For the beginning, we use some rather lax settings. We still can refine them later if we think that there's a need for it.

Message-Id: <[email protected]>

---
 MAINTAINERS               |  1 +
 tests/functional/pylintrc | 84 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 tests/functional/pylintrc
MAINTAINERS +1 -0
index 3a46c7fd0b0..a6168cb46f7 100644
@@ -4461,6 +4461,7 @@ F: docs/devel/testing/functional.rst
 F: scripts/clean_functional_cache.py
 F: tests/functional/meson.build
 F: tests/functional/generic/meson.build
+F: tests/functional/pylintrc
 F: tests/functional/qemu_test/
 
 Windows Hosted Continuous Integration
tests/functional/pylintrc new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.52.0
#2 lore raw

[PULL 02/15] tests/functional/mips/test_malta: Silence warnings reported by pylint

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

Pylint complains about too many positional arguments for the mips_check_wheezy() function. Add a "*" to enforce that the later ones are passed with an argument name (all calling sites are doing this already).

Also turn some old-school format strings into proper f-strings now.

Message-Id: <[email protected]>

---
 tests/functional/mips/test_malta.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/functional/mips/test_malta.py +4 -4
index 7a734bc069b..e8f49f130be 100755
@@ -50,7 +50,7 @@ def mips_run_common_commands(test, prompt='#'):
         ' : ata_piix')
     wait_for_console_pattern(test, prompt)
 
-def mips_check_wheezy(test, kernel_path, image_path, kernel_command_line,
+def mips_check_wheezy(test, kernel_path, image_path, kernel_command_line, *,
                       dl_file, hsum, nic='pcnet', cpuinfo='MIPS 24Kc'):
     test.require_netdev('user')
     test.require_device(nic)
@@ -59,10 +59,10 @@ def mips_check_wheezy(test, kernel_path, image_path, kernel_command_line,
     port=8080
     test.vm.add_args('-kernel', kernel_path,
                      '-append', kernel_command_line,
-                     '-drive', 'file=%s,snapshot=on' % image_path,
+                     '-drive', f'file={image_path},snapshot=on',
                      '-netdev', 'user,id=n1' +
                                 ',tftp=' + os.path.basename(kernel_path) +
-                                ',hostfwd=tcp:127.0.0.1:0-:%d' % port,
+                                f',hostfwd=tcp:127.0.0.1:0-:{port}',
                      '-device', f'{nic},netdev=n1',
                      '-no-reboot')
     test.vm.set_console()
@@ -111,7 +111,7 @@ def test_mips_malta(self):
         self.vm.add_args('-kernel', kernel_path,
                          '-append', kernel_command_line)
         self.vm.launch()
-        console_pattern = 'Kernel command line: %s' % kernel_command_line
+        console_pattern = f'Kernel command line: {kernel_command_line}'
         self.wait_for_console_pattern(console_pattern)
 
     ASSET_KERNEL_4_5_0 = Asset(
Signature · 1 line
2.52.0
#3 lore raw

[PULL 07/15] docs: update copyright year to 2026

In reply to Thomas Huth

From: Ani Sinha <[email protected]>

We are already in 2026. Update docs to update copyright info to year 2026.

Message-ID: <[email protected]>

---
 docs/conf.py              | 2 +-
 include/qemu/help-texts.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
docs/conf.py +1 -1
index bc4e9622dc8..f835904ba1e 100644
@@ -92,7 +92,7 @@
 
 # General information about the project.
 project = u'QEMU'
-copyright = u'2025, The QEMU Project Developers'
+copyright = u'2026, The QEMU Project Developers'
 author = u'The QEMU Project Developers'
 
 # The version info for the project you're documenting, acts as replacement for
include/qemu/help-texts.h +1 -1
index bc8fab91697..a9ccec7b38c 100644
@@ -2,7 +2,7 @@
 #define QEMU_HELP_TEXTS_H
 
 /* Copyright string for -version arguments, About dialogs, etc */
-#define QEMU_COPYRIGHT "Copyright (c) 2003-2025 " \
+#define QEMU_COPYRIGHT "Copyright (c) 2003-2026 " \
     "Fabrice Bellard and the QEMU Project developers"
 
 /* Bug reporting information for --help arguments, About dialogs, etc */
Signature · 1 line
2.52.0
#4 lore raw

[PULL 03/15] tests/functional/ppc64/test_hv: Silence warnings reported by pylint

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

To make pylint happy here, remove unused variables, switch to f-string, use "check=True" when calling subprocess.run() and split a line that was too long.

Message-Id: <[email protected]>

---
 tests/functional/ppc64/test_hv.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
tests/functional/ppc64/test_hv.py +4 -6
index d87f440fa79..beec1dbbea3 100755
@@ -29,8 +29,6 @@
 @skipBigDataTest()
 class HypervisorTest(QemuSystemTest):
 
-    timeout = 1000
-    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
     panic_message = 'Kernel panic - not syncing'
     good_message = 'VFS: Cannot open root device'
 
@@ -49,8 +47,8 @@ def extract_from_iso(self, iso, path):
         """
         filename = self.scratch_file(os.path.basename(path))
 
-        cmd = "xorriso -osirrox on -indev %s -cpx %s %s" % (iso, path, filename)
-        subprocess.run(cmd.split(),
+        cmd = f"xorriso -osirrox on -indev {iso} -cpx {path} {filename}"
+        subprocess.run(cmd.split(), check=True,
                        stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
 
         os.chmod(filename, 0o600)
@@ -66,7 +64,6 @@ def setUp(self):
 
     def do_start_alpine(self):
         self.vm.set_console()
-        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
         self.vm.add_args("-kernel", self.vmlinuz)
         self.vm.add_args("-initrd", self.initramfs)
         self.vm.add_args("-smp", "4", "-m", "2g")
@@ -78,7 +75,8 @@ def do_start_alpine(self):
         wait_for_console_pattern(self, 'localhost login:')
         exec_command_and_wait_for_pattern(self, 'root', ps1)
         # If the time is wrong, SSL certificates can fail.
-        exec_command_and_wait_for_pattern(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'), ps1)
+        cmd='date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"')
+        exec_command_and_wait_for_pattern(self, cmd, ps1)
         ps1='alpine:~#'
         exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
         exec_command_and_wait_for_pattern(self, 'setup-apkrepos -c1', ps1)
Signature · 1 line
2.52.0
#5 lore raw

[PULL 04/15] tests/functional/aarch64/test_virt_gpu: Fix style issues

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

Reshuffle the import statements according to the suggestions from pylint, use lowercase letters for variable names, and drop some spaces that flake8 did not like.

Message-Id: <[email protected]>

---
 tests/functional/aarch64/test_virt_gpu.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tests/functional/aarch64/test_virt_gpu.py +10 -10
index c26a1f20c65..6ed0e0fc1a9 100755
@@ -9,16 +9,16 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-from qemu.machine.machine import VMLaunchFailure
+from re import search
+from subprocess import check_output, CalledProcessError
 
-from qemu_test import Asset
+from qemu_test import Asset, skipIfMissingCommands
 from qemu_test import exec_command_and_wait_for_pattern as ec_and_wait
-from qemu_test import skipIfMissingCommands
 
 from qemu_test.linuxkernel import LinuxKernelTest
 
-from re import search
-from subprocess import check_output, CalledProcessError
+from qemu.machine.machine import VMLaunchFailure
+
 
 class Aarch64VirtGPUMachine(LinuxKernelTest):
 
@@ -81,16 +81,16 @@ def _launch_virt_gpu(self, gpu_device):
         self.wait_for_console_pattern('buildroot login:')
         ec_and_wait(self, 'root', '#')
 
-    def _run_virt_weston_test(self, cmd, fail = None):
+    def _run_virt_weston_test(self, cmd, fail=None):
 
         # make it easier to detect successful return to shell
-        PS1 = 'RES=[$?] # '
-        OK_CMD = 'RES=[0] # '
+        ps1 = 'RES=[$?] # '
+        ok_cmd = 'RES=[0] # '
 
         ec_and_wait(self, 'export XDG_RUNTIME_DIR=/tmp', '#')
-        ec_and_wait(self, f"export PS1='{PS1}'", OK_CMD)
+        ec_and_wait(self, f"export PS1='{ps1}'", ok_cmd)
         full_cmd = f"weston -B headless --renderer gl --shell kiosk -- {cmd}"
-        ec_and_wait(self, full_cmd, OK_CMD, fail)
+        ec_and_wait(self, full_cmd, ok_cmd, fail)
 
     @skipIfMissingCommands('zstd')
     def test_aarch64_virt_with_virgl_gpu(self):
Signature · 1 line
2.52.0
#6 lore raw

[PULL 12/15] target/s390x: Simplify S390_ADAPTER_SUPPRESSIBLE definition

In reply to Thomas Huth

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

Commit 1497c160661 ("s390x: add flags field for registering I/O adapter") defined S390_ADAPTER_SUPPRESSIBLE twice, one when KVM is available and another when it isn't. However both definitions expand to the same value. Unify them, adding an extra safety check in KVM-specific file.

This allows removing the target-specific 'CONFIG_KVM' definition in "cpu.h".

Message-ID: <[email protected]>

---
 include/hw/s390x/css.h | 2 ++
 target/s390x/cpu.h     | 6 ------
 target/s390x/kvm/kvm.c | 2 ++
 3 files changed, 4 insertions(+), 6 deletions(-)
include/hw/s390x/css.h +2 -0
index 0b0400a9d4f..d3326237c9f 100644
@@ -238,6 +238,8 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc);
 void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,
                               uint8_t flags, Error **errp);
 
+#define S390_ADAPTER_SUPPRESSIBLE 0x01
+
 SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,
                          uint16_t schid);
 bool css_subch_visible(SubchDev *sch);
target/s390x/cpu.h +0 -6
index ba2bf177e8f..40bc1f0741d 100644
@@ -39,12 +39,6 @@
 
 #define S390_MAX_CPUS 248
 
-#ifndef CONFIG_KVM
-#define S390_ADAPTER_SUPPRESSIBLE 0x01
-#else
-#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
-#endif
-
 typedef struct PSW {
     uint64_t mask;
     uint64_t addr;
target/s390x/kvm/kvm.c +2 -0
index bd6c440aefb..54d28e37d4d 100644
@@ -2082,6 +2082,8 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
     return r;
 }
 
+QEMU_BUILD_BUG_ON(S390_ADAPTER_SUPPRESSIBLE != KVM_S390_ADAPTER_SUPPRESSIBLE);
+
 int kvm_arch_fixup_msi_route(struct kvm_irq_routing_entry *route,
                              uint64_t address, uint32_t data, PCIDevice *dev)
 {
Signature · 1 line
2.52.0
#7 lore raw

[PULL 05/15] tests/functional/aarch64/test_smmu: Silence warning from pylint

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

Pylint thinks that the accel variable might be used here without being set first, since it does not know that skipTest() never returns. Thus initialize "accel = None" here to make it happy.

Message-Id: <[email protected]>

---
 tests/functional/aarch64/test_smmu.py | 1 +
 1 file changed, 1 insertion(+)
tests/functional/aarch64/test_smmu.py +1 -0
index e0f4a922176..87b9b14e7a5 100755
@@ -50,6 +50,7 @@ def common_vm_setup(self, kernel, initrd, disk):
         elif kvm_available(self.qemu_bin):
             accel = "kvm"
         else:
+            accel = None        # for keeping pylint happy
             self.skipTest("Neither HVF nor KVM accelerator is available")
         self.require_accelerator(accel)
         self.require_netdev('user')
Signature · 1 line
2.52.0
#8 lore raw

[PULL 08/15] target/s390x: Restrict WatchPoint API to TCG

In reply to Thomas Huth

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

By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move this function -- along with s390x_cpu_debug_excp_handler() which was introduced in the same commit 311918b979c ("target-s390x: PER storage-alteration event support") -- to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG.

Message-ID: <[email protected]>

---
 target/s390x/s390x-internal.h  |  2 -
 target/s390x/tcg/tcg_s390x.h   |  5 ++
 target/s390x/cpu.c             | 30 ++++++------
 target/s390x/helper.c          | 38 ---------------
 target/s390x/tcg/debug.c       | 85 ++++++++++++++++++++++++++++++++++
 target/s390x/tcg/excp_helper.c | 32 -------------
 target/s390x/tcg/meson.build   |  3 ++
 7 files changed, 108 insertions(+), 87 deletions(-)
 create mode 100644 target/s390x/tcg/debug.c
target/s390x/s390x-internal.h +0 -2
index 9691366ec91..a4b54dc441c 100644
@@ -259,7 +259,6 @@ ObjectClass *s390_cpu_class_by_name(const char *name);
 
 
 /* excp_helper.c */
-void s390x_cpu_debug_excp_handler(CPUState *cs);
 void s390_cpu_do_interrupt(CPUState *cpu);
 bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
 
@@ -317,7 +316,6 @@ void s390_cpu_gdb_init(CPUState *cs);
 void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 void do_restart_interrupt(CPUS390XState *env);
 #ifndef CONFIG_USER_ONLY
-void s390_cpu_recompute_watchpoints(CPUState *cs);
 void s390x_tod_timer(void *opaque);
 void s390x_cpu_timer(void *opaque);
 void s390_handle_wait(S390CPU *cpu);
target/s390x/tcg/tcg_s390x.h +5 -0
index 78558912f99..7c8aede80d2 100644
@@ -21,4 +21,9 @@ G_NORETURN void tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,
 G_NORETURN void tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,
                                           uintptr_t ra);
 
+#ifndef CONFIG_USER_ONLY
+void s390_cpu_recompute_watchpoints(CPUState *cs);
+void s390x_cpu_debug_excp_handler(CPUState *cs);
+#endif
+
 #endif /* TCG_S390X_H */
target/s390x/cpu.c +15 -15
index 6af7446fd9f..cd472d38be7 100644
@@ -40,6 +40,7 @@
 #include "system/reset.h"
 #endif
 #include "hw/s390x/cpu-topology.h"
+#include "tcg/tcg_s390x.h"
 
 #define CR0_RESET       0xE0UL
 #define CR14_RESET      0xC2000000UL;
@@ -74,26 +75,25 @@ void s390_cpu_set_psw(CPUS390XState *env, uint64_t mask, uint64_t addr)
     env->psw.mask = mask;
 
     /* KVM will handle all WAITs and trigger a WAIT exit on disabled_wait */
-    if (!tcg_enabled()) {
-        return;
-    }
-    env->cc_op = (mask >> 44) & 3;
+    if (tcg_enabled()) {
+        env->cc_op = (mask >> 44) & 3;
 
 #ifndef CONFIG_USER_ONLY
-    if (is_early_exception_psw(mask, addr)) {
-        env->int_pgm_ilen = 0;
-        trigger_pgm_exception(env, PGM_SPECIFICATION);
-        return;
-    }
+        if (is_early_exception_psw(mask, addr)) {
+            env->int_pgm_ilen = 0;
+            trigger_pgm_exception(env, PGM_SPECIFICATION);
+            return;
+        }
 
-    if ((old_mask ^ mask) & PSW_MASK_PER) {
-        s390_cpu_recompute_watchpoints(env_cpu(env));
-    }
+        if ((old_mask ^ mask) & PSW_MASK_PER) {
+            s390_cpu_recompute_watchpoints(env_cpu(env));
+        }
 
-    if (mask & PSW_MASK_WAIT) {
-        s390_handle_wait(env_archcpu(env));
-    }
+        if (mask & PSW_MASK_WAIT) {
+            s390_handle_wait(env_archcpu(env));
+        }
 #endif
+    }
 }
 
 uint64_t s390_cpu_get_psw_mask(CPUS390XState *env)
target/s390x/helper.c +0 -38
index 184428c6d9d..8d1e03f6768 100644
@@ -143,41 +143,3 @@ void do_restart_interrupt(CPUS390XState *env)
 
     s390_cpu_set_psw(env, mask, addr);
 }
-
-void s390_cpu_recompute_watchpoints(CPUState *cs)
-{
-    const int wp_flags = BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS;
-    CPUS390XState *env = cpu_env(cs);
-
-    /* We are called when the watchpoints have changed. First
-       remove them all.  */
-    cpu_watchpoint_remove_all(cs, BP_CPU);
-
-    /* Return if PER is not enabled */
-    if (!(env->psw.mask & PSW_MASK_PER)) {
-        return;
-    }
-
-    /* Return if storage-alteration event is not enabled.  */
-    if (!(env->cregs[9] & PER_CR9_EVENT_STORE)) {
-        return;
-    }
-
-    if (env->cregs[10] == 0 && env->cregs[11] == -1LL) {
-        /* We can't create a watchoint spanning the whole memory range, so
-           split it in two parts.   */
-        cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, NULL);
-        cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, NULL);
-    } else if (env->cregs[10] > env->cregs[11]) {
-        /* The address range loops, create two watchpoints.  */
-        cpu_watchpoint_insert(cs, env->cregs[10], -env->cregs[10],
-                              wp_flags, NULL);
-        cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, NULL);
-
-    } else {
-        /* Default case, create a single watchpoint.  */
-        cpu_watchpoint_insert(cs, env->cregs[10],
-                              env->cregs[11] - env->cregs[10] + 1,
-                              wp_flags, NULL);
-    }
-}
target/s390x/tcg/debug.c new file +85 -0

85 lines not on this page · raw message

target/s390x/tcg/excp_helper.c +0 -32
index d4a096f5998..019eb4fba1f 100644
@@ -24,7 +24,6 @@
 #include "exec/helper-proto.h"
 #include "exec/cputlb.h"
 #include "exec/target_page.h"
-#include "exec/watchpoint.h"
 #include "s390x-internal.h"
 #include "tcg_s390x.h"
 #ifndef CONFIG_USER_ONLY
@@ -607,37 +606,6 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     return false;
 }
 
-void s390x_cpu_debug_excp_handler(CPUState *cs)
-{
-    CPUS390XState *env = cpu_env(cs);
-    CPUWatchpoint *wp_hit = cs->watchpoint_hit;
-
-    if (wp_hit && wp_hit->flags & BP_CPU) {
-        /* FIXME: When the storage-alteration-space control bit is set,
-           the exception should only be triggered if the memory access
-           is done using an address space with the storage-alteration-event
-           bit set.  We have no way to detect that with the current
-           watchpoint code.  */
-        cs->watchpoint_hit = NULL;
-
-        env->per_address = env->psw.addr;
-        env->per_perc_atmid |= PER_CODE_EVENT_STORE | get_per_atmid(env);
-        /* FIXME: We currently no way to detect the address space used
-           to trigger the watchpoint.  For now just consider it is the
-           current default ASC. This turn to be true except when MVCP
-           and MVCS instrutions are not used.  */
-        env->per_perc_atmid |= env->psw.mask & (PSW_MASK_ASC) >> 46;
-
-        /*
-         * Remove all watchpoints to re-execute the code.  A PER exception
-         * will be triggered, it will call s390_cpu_set_psw which will
-         * recompute the watchpoints.
-         */
-        cpu_watchpoint_remove_all(cs, BP_CPU);
-        cpu_loop_exit_noexc(cs);
-    }
-}
-
 void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
                                    MMUAccessType access_type,
                                    int mmu_idx, uintptr_t retaddr)
target/s390x/tcg/meson.build +3 -0
index ee4e8fec77c..515cb8b473d 100644
@@ -12,3 +12,6 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files(
   'vec_int_helper.c',
   'vec_string_helper.c',
 ))
+s390x_system_ss.add(when: 'CONFIG_TCG', if_true: files(
+  'debug.c',
+))
Signature · 1 line
2.52.0
#9 lore raw

Re: [PULL 08/15] target/s390x: Restrict WatchPoint API to TCG

Quoted 23 lines · Thomas Huth

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

By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move this function -- along with s390x_cpu_debug_excp_handler() which was introduced in the same commit 311918b979c ("target-s390x: PER storage-alteration event support") -- to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG.

Message-ID: <[email protected]>

---
  target/s390x/s390x-internal.h  |  2 -
  target/s390x/tcg/tcg_s390x.h   |  5 ++
  target/s390x/cpu.c             | 30 ++++++------
  target/s390x/helper.c          | 38 ---------------
  target/s390x/tcg/debug.c       | 85 ++++++++++++++++++++++++++++++++++
  target/s390x/tcg/excp_helper.c | 32 -------------
  target/s390x/tcg/meson.build   |  3 ++
  7 files changed, 108 insertions(+), 87 deletions(-)
Quoted 1 line

create mode 100644 target/s390x/tcg/debug.c

Thanks for taking this patch, but Richard said this WatchPoint API shouldn't be TCG-only:

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

#10 lore raw

Re: [PULL 08/15] target/s390x: Restrict WatchPoint API to TCG

Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Thomas Huth

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

By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move this function -- along with s390x_cpu_debug_excp_handler() which was introduced in the same commit 311918b979c ("target-s390x: PER storage-alteration event support") -- to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG.

Message-ID: <[email protected]>

---
  target/s390x/s390x-internal.h  |  2 - target/s390x/tcg/tcg_s390x.h   |  5 ++
  target/s390x/cpu.c             | 30 ++++++------ target/s390x/helper.c          | 38 --------------- target/s390x/tcg/debug.c       | 85 ++++++++++++++++++++++++++++++++++ target/s390x/tcg/excp_helper.c | 32 ------------- target/s390x/tcg/meson.build   |  3 ++

Quoted 2 lines
  7 files changed, 108 insertions(+), 87 deletions(-)

  create mode 100644 target/s390x/tcg/debug.c

Quoted 4 lines

Thanks for taking this patch, but Richard said this WatchPoint API shouldn't be TCG-only:

https://lore.kernel.org/qemu-devel/4be5bd97-21a5-40fe-9a9c- [email protected]/

As discussed on IRC, this can easily be reverted or adapted in the unlikely case s390x gets another accelerator merged in QEMU or KVM/s390x gets watchpoint support :)

#11 lore raw

[PULL 11/15] target/s390x: Remove unused 'gdbstub/helpers.h' header in helper.c

In reply to Thomas Huth

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

"gdbstub/helpers.h" uses target-specific symbols, but we don't need it, so remove it.

Message-ID: <[email protected]>

---
 target/s390x/helper.c | 1 -
 1 file changed, 1 deletion(-)
target/s390x/helper.c +0 -1
index 8d1e03f6768..a6c89ed0af3 100644
@@ -21,7 +21,6 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "s390x-internal.h"
-#include "gdbstub/helpers.h"
 #include "qemu/timer.h"
 #include "hw/s390x/ioinst.h"
 #include "system/hw_accel.h"
Signature · 1 line
2.52.0
#12 lore raw

[PULL 06/15] tests/functional: Add a generic test that checks the files with pylint

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

To avoid that new pylint-related warnings get committed, let's check the files with pylint during each run (similar to what we are doing for the iotests already).

Message-Id: <[email protected]>

---
 MAINTAINERS                              |  1 +
 tests/functional/generic/meson.build     |  1 +
 tests/functional/generic/test_linters.py | 41 ++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100755 tests/functional/generic/test_linters.py
MAINTAINERS +1 -0
index a6168cb46f7..6dfd9b27c20 100644
@@ -4461,6 +4461,7 @@ F: docs/devel/testing/functional.rst
 F: scripts/clean_functional_cache.py
 F: tests/functional/meson.build
 F: tests/functional/generic/meson.build
+F: tests/functional/generic/test_linters.py
 F: tests/functional/pylintrc
 F: tests/functional/qemu_test/
 
tests/functional/generic/meson.build +1 -0
index 013cc96fbf8..09763c5d229 100644
@@ -3,6 +3,7 @@
 tests_generic_system = [
   'empty_cpu_model',
   'info_usernet',
+  'linters',
   'version',
   'vnc',
 ]
tests/functional/generic/test_linters.py new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.52.0
#13 lore raw

[PULL 09/15] target/s390x: Use vaddr for $pc in get_next_pc()

In reply to Thomas Huth

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

DisasContextBase::pc_next is of vaddr type. Since translator_lduw_end() returns a uint16_t, also use that type for clarity.

Message-ID: <[email protected]>

---
 target/s390x/tcg/translate.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/s390x/tcg/translate.c +2 -3
index e38607ee18c..540c5a569c0 100644
@@ -6405,10 +6405,9 @@ static void s390x_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
     tcg_gen_insn_start(dc->base.pc_next, dc->cc_op, 0);
 }
 
-static target_ulong get_next_pc(CPUS390XState *env, DisasContext *s,
-                                uint64_t pc)
+static vaddr get_next_pc(CPUS390XState *env, DisasContext *s, vaddr pc)
 {
-    uint64_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
+    uint16_t insn = translator_lduw_end(env, &s->base, pc, MO_BE);
 
     return pc + get_ilen((insn >> 8) & 0xff);
 }
Signature · 1 line
2.52.0
#14 lore raw

[PULL 14/15] target/s390x: Fix infinite loop during replay

In reply to Thomas Huth

From: Ilya Leoshkevich <[email protected]>

Replaying even trivial s390x kernels hangs, because:

- cpu_post_load() fires the TOD timer immediately.

- s390_tod_load() schedules work for firing the TOD timer.

- If rr loop sees work and then timer, we get one timer expiration.

- If rr loop sees timer and then work, we get two timer expirations.

- Record and replay may diverge due to this race.

- In this particular case divergence makes replay loop spin: it sees that TOD timer has expired, but cannot invoke its callback, because there is no recorded CHECKPOINT_CLOCK_VIRTUAL.

- The order in which rr loop sees work and timer depends on whether and when rr loop wakes up during load_snapshot().

- rr loop may wake up after the main thread kicks the CPU and drops the BQL, which may happen if it calls, e.g., qemu_cond_wait_bql().

Firing TOD timer twice is duplicate work, but it was introduced intentionally in commit 7c12f710bad6 ("s390x/tcg: rearm the CKC timer during migration") in order to avoid dependency on migration order.

The key culprits here are timers that are armed ready expired. They break the ordering between timers and CPU work, because they are not constrained by instruction execution, thus introducing non-determinism and record-replay divergence.

Fix by converting such timer callbacks to CPU work. Also add TOD clock updates to the save path, mirroring the load path, in order to have the same CHECKPOINT_CLOCK_VIRTUAL during recording and replaying.

Message-ID: <[email protected]>

[thuth: Add SPDX license identifiers to the new stubs files]
---
 hw/s390x/tod.c           |  5 +++++
 stubs/async-run-on-cpu.c | 11 +++++++++++
 stubs/cpus-queue.c       |  8 ++++++++
 target/s390x/machine.c   |  4 ++++
 util/qemu-timer.c        | 30 ++++++++++++++++++++++++++++++
 stubs/meson.build        |  2 ++
 6 files changed, 60 insertions(+)
 create mode 100644 stubs/async-run-on-cpu.c
 create mode 100644 stubs/cpus-queue.c
hw/s390x/tod.c +5 -0
index 3f913cc88ab..81bce90c030 100644
@@ -72,6 +72,11 @@ static void s390_tod_save(QEMUFile *f, void *opaque)
     qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT);
     qemu_put_byte(f, tod.high);
     qemu_put_be64(f, tod.low);
+
+    tdc->set(td, &tod, &err);
+    if (err) {
+        warn_report_err(err);
+    }
 }
 
 static int s390_tod_load(QEMUFile *f, void *opaque, int version_id)
stubs/async-run-on-cpu.c new file +11 -0
new file mode 100644
index 00000000000..b8975bf5a8a
@@ -0,0 +1,11 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/core/cpu.h"
+
+void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data)
+{
+    abort();
+}
stubs/cpus-queue.c new file +8 -0
new file mode 100644
index 00000000000..c59fb76a108
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/core/cpu.h"
+
+CPUTailQ cpus_queue = QTAILQ_HEAD_INITIALIZER(cpus_queue);
target/s390x/machine.c +4 -0
index 3bea6103ffb..f714834a98a 100644
@@ -52,6 +52,10 @@ static int cpu_pre_save(void *opaque)
         kvm_s390_vcpu_interrupt_pre_save(cpu);
     }
 
+    if (tcg_enabled()) {
+        tcg_s390_tod_updated(CPU(cpu), RUN_ON_CPU_NULL);
+    }
+
     return 0;
 }
 
util/qemu-timer.c +30 -0
index 2a6be4c7f95..d93a020064f 100644
@@ -30,6 +30,7 @@
 #include "exec/icount.h"
 #include "system/replay.h"
 #include "system/cpus.h"
+#include "hw/core/cpu.h"
 
 #ifdef CONFIG_POSIX
 #include <pthread.h>
@@ -387,11 +388,40 @@ static void timer_del_locked(QEMUTimerList *timer_list, QEMUTimer *ts)
     }
 }
 
+static void timer_fire(CPUState *cpu, run_on_cpu_data data)
+{
+    QEMUTimer *t = data.host_ptr;
+
+    t->cb(t->opaque);
+}
+
 static bool timer_mod_ns_locked(QEMUTimerList *timer_list,
                                 QEMUTimer *ts, int64_t expire_time)
 {
     QEMUTimer **pt, *t;
 
+    /*
+     * Normally during record-replay virtual clock timers and CPU work are
+     * deterministically ordered. This is because the virtual clock can be
+     * advanced only by instructions running on a CPU.
+     *
+     * A notable exception are timers that are armed already expired. Their
+     * expiration is not constrained by instruction execution, and, therefore,
+     * their ordering relative to CPU work is affected by what the
+     * record-replay thread is doing when they are armed. This introduces
+     * non-determinism.
+     *
+     * Convert such timers to CPU work in order to avoid it.
+     */
+    if (replay_mode != REPLAY_MODE_NONE &&
+        timer_list->clock->type == QEMU_CLOCK_VIRTUAL &&
+        !(ts->attributes & QEMU_TIMER_ATTR_EXTERNAL) &&
+        expire_time <= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)) {
+        async_run_on_cpu(first_cpu, timer_fire,
+                         RUN_ON_CPU_HOST_PTR(ts));
+        return false;
+    }
+
     /* add the timer in the sorted list */
     pt = &timer_list->active_timers;
     for (;;) {
stubs/meson.build +2 -0
index 0b2778c568e..d3b551f4def 100644
@@ -41,6 +41,8 @@ if have_block or have_ga
   stub_ss.add(files('monitor-internal.c'))
   stub_ss.add(files('qmp-command-available.c'))
   stub_ss.add(files('qmp-quit.c'))
+  stub_ss.add(files('async-run-on-cpu.c'))
+  stub_ss.add(files('cpus-queue.c'))
 endif
 
 if have_block or have_user
Signature · 1 line
2.52.0
#15 lore raw

[PULL 15/15] tests/functional/s390x: Add reverse debugging test for s390x

In reply to Thomas Huth

From: Thomas Huth <[email protected]>

We just have to make sure that we can set the endianness to big endian, then we can also run this test on s390x.

Message-ID: <[email protected]>

---
 tests/functional/reverse_debugging.py        |  4 +++-
 tests/functional/s390x/meson.build           |  1 +
 tests/functional/s390x/test_reverse_debug.py | 21 ++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100755 tests/functional/s390x/test_reverse_debug.py
tests/functional/reverse_debugging.py +3 -1
index 86fca8d81f1..8b9507674a0 100644
@@ -64,7 +64,7 @@ def vm_get_icount(vm):
 
     @skipIfMissingImports("pygdbmi") # Required by GDB class
     @skipIfMissingEnv("QEMU_TEST_GDB")
-    def reverse_debugging(self, gdb_arch, shift=7, args=None):
+    def reverse_debugging(self, gdb_arch, shift=7, args=None, big_endian=False):
         from qemu_test import GDB
 
         # create qcow2 for snapshots
@@ -99,6 +99,8 @@ def reverse_debugging(self, gdb_arch, shift=7, args=None):
             gdb_cmd = os.getenv('QEMU_TEST_GDB')
             gdb = GDB(gdb_cmd)
             try:
+                if big_endian:
+                    gdb.cli("set endian big")
                 self.reverse_debugging_run(gdb, vm, port, gdb_arch, last_icount)
             finally:
                 self.log.info('exiting gdb and qemu')
tests/functional/s390x/meson.build +1 -0
index 70cd36e2913..0f03e1c9db8 100644
@@ -6,6 +6,7 @@ test_s390x_timeouts = {
 
 tests_s390x_system_quick = [
   'vmstate',
+  'reverse_debug',
 ]
 
 tests_s390x_system_thorough = [
tests/functional/s390x/test_reverse_debug.py new file +21 -0
new file mode 100755
index 00000000000..0767dc91678
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+'''
+Reverse debugging test for s390x
+'''
+
+from reverse_debugging import ReverseDebugging
+
+
+class ReverseDebuggingS390x(ReverseDebugging):
+
+    def test_revdbg(self):
+        self.set_machine('s390-ccw-virtio')
+        self.reverse_debugging(gdb_arch='s390:64-bit', shift=6,
+                               big_endian=True, args=('-no-shutdown',))
+
+
+if __name__ == '__main__':
+    ReverseDebugging.main()
Signature · 1 line
2.52.0
#16 lore raw

[PULL 10/15] target/s390x: Replace target_ulong -> uint64_t in gdb_write_register()

In reply to Thomas Huth

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

On s390x target_ulong expands to uint64_t. Besides, ldq_be_p() returns a uint64_t type. Use that instead.

Message-ID: <[email protected]>

---
 target/s390x/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/s390x/gdbstub.c +1 -1
index d1f02ea5ce4..9ae715add4d 100644
@@ -46,7 +46,7 @@ int s390_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
 int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 {
     CPUS390XState *env = cpu_env(cs);
-    target_ulong tmpl = ldq_be_p(mem_buf);
+    uint64_t tmpl = ldq_be_p(mem_buf);
 
     switch (n) {
     case S390_PSWM_REGNUM:
Signature · 1 line
2.52.0
#17 lore raw

[PULL 13/15] target/s390x: Un-inline s390_is_pv()

In reply to Thomas Huth

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

Inlining a method which use a static variable is really a bad idea, as it totally defeats the point of both concepts.

Currently we have 12 + 4 = 16 static 'ccw' variables...:

  $ git grep -wl target/s390x/kvm/pv.h | fgrep .h
  hw/s390x/ipl.h
  $ git grep -wl target/s390x/kvm/pv.h | fgrep .c | wc -l
        12
  $ git grep -wl hw/s390x/ipl.h | fgrep .c | wc -l
         4
Fixes c3347ed0d2e ("s390x: protvirt: Support unpack facility")

Message-ID: <[email protected]>

---
 target/s390x/kvm/pv.h | 24 +-----------------------
 target/s390x/kvm/pv.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 23 deletions(-)
target/s390x/kvm/pv.h +1 -23
index 94e885e9335..e266fc3d545 100644
@@ -12,8 +12,6 @@
 #ifndef HW_S390_PV_H
 #define HW_S390_PV_H
 
-#include "qapi/error.h"
-#include "system/kvm.h"
 #include "hw/s390x/s390-virtio-ccw.h"
 
 struct S390PVResponse {
@@ -23,27 +21,7 @@ struct S390PVResponse {
 };
 
 #ifdef CONFIG_KVM
-#include "cpu.h"
-
-static inline bool s390_is_pv(void)
-{
-    static S390CcwMachineState *ccw;
-    Object *obj;
-
-    if (ccw) {
-        return ccw->pv;
-    }
-
-    /* we have to bail out for the "none" machine */
-    obj = object_dynamic_cast(qdev_get_machine(),
-                              TYPE_S390_CCW_MACHINE);
-    if (!obj) {
-        return false;
-    }
-    ccw = S390_CCW_MACHINE(obj);
-    return ccw->pv;
-}
-
+bool s390_is_pv(void);
 int s390_pv_query_info(void);
 int s390_pv_vm_enable(void);
 void s390_pv_vm_disable(void);
target/s390x/kvm/pv.c +18 -0
index 2bc916a5455..3d508165f34 100644
@@ -25,6 +25,24 @@
 #include "target/s390x/kvm/kvm_s390x.h"
 #include "target/s390x/kvm/pv.h"
 
+bool s390_is_pv(void)
+{
+    static S390CcwMachineState *ccw;
+    Object *obj;
+
+    if (ccw) {
+        return ccw->pv;
+    }
+
+    /* we have to bail out for the "none" machine */
+    obj = object_dynamic_cast(qdev_get_machine(), TYPE_S390_CCW_MACHINE);
+    if (!obj) {
+        return false;
+    }
+    ccw = S390_CCW_MACHINE(obj);
+    return ccw->pv;
+}
+
 static bool info_valid;
 static struct kvm_s390_pv_info_vm info_vm;
 static struct kvm_s390_pv_info_dump info_dump;
Signature · 1 line
2.52.0
#18 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth

Hi!

The following changes since commit b254e486242466dad881fc2bbfa215f1b67cd30f:

   Merge tag 'pull-riscv-to-apply-20260109' ofhttps://github.com/alistair23/qemu into staging (2026-01-10 10:31:57 +1100)

are available in the Git repository at:

   https://gitlab.com/thuth/qemu.git tags/pull-request-2026-01-12

for you to fetch changes up to f397b7652dac77bf24a491dfee8def59a5d2591f:

Quoted 7 lines
   tests/functional/s390x: Add reverse debugging test for s390x (2026-01-12 13:56:28 +0100)

----------------------------------------------------------------
* Check functional tests with pylint
* update copyright year to 2026
* Some more universal-binary work for the s390x code done by Philippe
* Fix reverse debugging for s390x and add a functional test for it

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/11.0 as appropriate.

r~