Skip to contentSkip to conversation

s390x queue

GIT PULL Applied Eric Farman 3 participants 21 messages Aug 12 – Aug 17

lore
Share & tools
lore
#0 lore raw

The following changes since commit 3e3ccab106f879b1512f8e0d51a827dd4de30e22:

Update version for v11.1.0-rc3 release (2026-08-04 15:36:08 -0400)

are available in the Git repository at:

https://gitlab.com/efarman/qemu.git tags/s390x-20260812

for you to fetch changes up to 9b3d68edb24d4e04f49822c6e11641e4eb23dfd5:

pc-bios/s390-ccw.img: update s390x bios (2026-08-12 11:13:28 -0400)

----------------------------------------------------------------
First batch of s390x updates for 11.2:
- compat machines for 11.2
- allow guest backing with 2G hugepages
- fixes to TCG (and a couple tests on them)
- hardening fixes in boot/sclp code
- regenerate s390-ccw.img

----------------------------------------------------------------

Christian Borntraeger (1):
hw/char/sclpconsole-lm: avoid guest triggerable assert

Claudio Imbrenda (1):
target/s390x: Allow 2G hugepages guest backing

Cornelia Huck (1):
hw: add compat machines for 11.2

Eric Farman (1):
pc-bios/s390-ccw.img: update s390x bios

Ilya Leoshkevich (6):
target/s390x: Make PRNO TRNG interruptible tests/tcg/s390x: Test PRNO TRNG interruptibility target/s390x: Fix DR/D INT64_MIN / -1 host crash tests/tcg/s390x: Test DR overflow (INT64_MIN / -1) target/s390x/tcg: Set STCK/STCKF condition code after the store tests/tcg/s390x: Test STCKF condition code on a faulting store

Jared Rossi (1):
pc-bios/s390-ccw: Fix off-by-one errors with loadparm and boot entries

Joshua Daley (4):
s390x/ipl: validate num_comp against iplb length before iterating pc-bios/s390-ccw: fix out-of-bounds read in iso_get_file_size() pc-bios/s390-ccw: bounds-check zipl menu entry index before array
write
pc-bios/s390-ccw: bound zipl menu strlen and replace VLA in
zipl_print_entry

 hw/arm/virt.c                    |   9 ++++-
 hw/char/sclpconsole-lm.c         |   3 +-
 hw/core/machine.c                |   3 ++
 hw/i386/pc.c                     |   3 ++
 hw/i386/pc_piix.c                |  13 +++++-
 hw/i386/pc_q35.c                 |  13 +++++-
 hw/loongarch/virt.c              |  11 ++++-
 hw/m68k/virt.c                   |   9 ++++-
 hw/ppc/spapr.c                   |  15 ++++++-
 hw/s390x/ipl.h                   |   6 +++
 hw/s390x/s390-virtio-ccw.c       |  14 ++++++-
 include/hw/core/boards.h         |   3 ++
 include/hw/i386/pc.h             |   3 ++
 include/hw/s390x/ipl/qipl.h      |   2 +
 pc-bios/s390-ccw.img             | Bin 104136 -> 104216 bytes
 pc-bios/s390-ccw/bootmap.c       |   6 ++-
 pc-bios/s390-ccw/helper.h        |  10 +++++
 pc-bios/s390-ccw/menu.c          |  42 +++++++++++++++----
 pc-bios/s390-ccw/netmain.c       |  11 +++--
 pc-bios/s390-ccw/s390-ccw.h      |   4 +-
 target/s390x/diag.c              |   2 +-
 target/s390x/kvm/kvm.c           |  36 ++++++++---------
 target/s390x/kvm/kvm_s390x.h     |   2 +-
 target/s390x/kvm/stubs.c         |   2 +-
 target/s390x/tcg/crypto_helper.c |  22 +++++++---
 target/s390x/tcg/insn-data.h.inc |   4 +-
 target/s390x/tcg/int_helper.c    |   3 +-
 target/s390x/tcg/translate.c     |   2 +
 tests/tcg/s390x/Makefile.target  |   2 +
 tests/tcg/s390x/div.c            |  37 +++++++++++++++++
 tests/tcg/s390x/prno-trng.c      |  67 +++++++++++++++++++++++++++++++
 tests/tcg/s390x/stckf.c          |  44 ++++++++++++++++++++
 32 files changed, 344 insertions(+), 59 deletions(-)
 create mode 100644 tests/tcg/s390x/prno-trng.c
 create mode 100644 tests/tcg/s390x/stckf.c
Signature · 1 line
2.55.0
#1 lore raw

[PULL 02/15] tests/tcg/s390x: Test PRNO TRNG interruptibility

From: Ilya Leoshkevich <[email protected]>

Add a small test that issues a large PRNO TRNG request while a timer is running, and checks that the timer interrupts it several times.

---
 tests/tcg/s390x/Makefile.target |  1 +
 tests/tcg/s390x/prno-trng.c     | 67 +++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+)
 create mode 100644 tests/tcg/s390x/prno-trng.c
tests/tcg/s390x/Makefile.target +1 -0
index 0ca030ded0..48cba4cdfa 100644
@@ -75,6 +75,7 @@ Z13_TESTS+=vcksm
 Z13_TESTS+=vstl
 Z13_TESTS+=vrep
 Z13_TESTS+=precise-smc-user
+Z13_TESTS+=prno-trng
 $(Z13_TESTS): CFLAGS+=-march=z13 -O2
 TESTS+=$(Z13_TESTS)
 
tests/tcg/s390x/prno-trng.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.55.0
#2 lore raw

[PULL 05/15] hw/char/sclpconsole-lm: avoid guest triggerable assert

In reply to Eric Farman

From: Christian Borntraeger <[email protected]>

If a guest uses incorrect message length it can trigger an assert in process_mdb which kills the guest instead of reporting an error. Fix this by adding the correct length check.

Fixes 6a444f8507 ("s390/sclplmconsole: Add support for SCLP line-mode console")
[[email protected]: Fixed typo in commit message, added qemu-stable]
---
 hw/char/sclpconsole-lm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/char/sclpconsole-lm.c +2 -1
index 9a16896d22..f6ed282f1b 100644
@@ -243,7 +243,8 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *ebh)
     SCLPConsoleLM *scon = SCLPLM_CONSOLE(event);
 
     len = be16_to_cpu(data->mdb.header.length);
-    if (len < sizeof(data->mdb.header)) {
+    if (len < sizeof(data->mdb.header) ||
+        len > be16_to_cpu(data->header.length) - sizeof(EventBufferHeader)) {
         return SCLP_RC_INCONSISTENT_LENGTHS;
     }
     len -= sizeof(data->mdb.header);
Signature · 1 line
2.55.0
#3 lore raw

[PULL 13/15] target/s390x: Allow 2G hugepages guest backing

In reply to Eric Farman

From: Claudio Imbrenda <[email protected]>

Allow mapping guest with 2G hugepages on hosts that support it.

Rename kvm_s390_get_hpage_1m() to kvm_s390_get_hpage() to reflect that it is not anymore limited only to 1m hpages.

---
 target/s390x/diag.c          |  2 +-
 target/s390x/kvm/kvm.c       | 36 +++++++++++++++++-------------------
 target/s390x/kvm/kvm_s390x.h |  2 +-
 target/s390x/kvm/stubs.c     |  2 +-
 4 files changed, 20 insertions(+), 22 deletions(-)
target/s390x/diag.c +1 -1
index 80f0958478..46d191b87d 100644
@@ -185,7 +185,7 @@ out:
             return false;
         }
 
-        if (kvm_enabled() && kvm_s390_get_hpage_1m()) {
+        if (kvm_enabled() && kvm_s390_get_hpage()) {
             error_report("Protected VMs can currently not be backed with "
                          "huge pages");
             env->regs[r1 + 1] = DIAG_308_RC_INVAL_FOR_PV;
target/s390x/kvm/kvm.c +17 -19
index 72031a5714..803b878b4f 100644
@@ -145,7 +145,7 @@ static int cap_mem_op;
 static int cap_mem_op_extension;
 static int cap_s390_irq;
 static int cap_ri;
-static int cap_hpage_1m;
+static int cap_hpage;
 static int cap_vcpu_resets;
 static int cap_protected;
 static int cap_zpci_op;
@@ -231,7 +231,7 @@ static void kvm_s390_enable_cmma(void)
         .attr = KVM_S390_VM_MEM_ENABLE_CMMA,
     };
 
-    if (cap_hpage_1m) {
+    if (cap_hpage) {
         warn_report("CMM will not be enabled because it is not "
                     "compatible with huge memory backings.");
         return;
@@ -292,30 +292,28 @@ void kvm_s390_crypto_reset(void)
     }
 }
 
-void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp)
+static bool kvm_s390_pgsize_cap(uint32_t capa, const char *s, Error **errp)
 {
-    if (pagesize == 4 * KiB) {
-        return;
-    }
-
-    if (pagesize != 1 * MiB) {
-        error_setg(errp, "Memory backing with 2G pages was specified, "
-                   "but KVM does not support this memory backing");
-        return;
+    if (kvm_vm_enable_cap(kvm_state, capa, 0)) {
+        error_setg(errp, "Memory backing with %s pages was specified, "
+                   "but KVM does not support this memory backing", s);
+        return false;
     }
+    return true;
+}
 
-    if (kvm_vm_enable_cap(kvm_state, KVM_CAP_S390_HPAGE_1M, 0)) {
-        error_setg(errp, "Memory backing with 1M pages was specified, "
-                   "but KVM does not support this memory backing");
-        return;
+void kvm_s390_set_max_pagesize(uint64_t pagesize, Error **errp)
+{
+    if (pagesize == MiB) {
+        cap_hpage = kvm_s390_pgsize_cap(KVM_CAP_S390_HPAGE_1M, "1M", errp);
+    } else if (pagesize != 4 * KiB) {
+        cap_hpage = 2 * kvm_s390_pgsize_cap(KVM_CAP_S390_HPAGE_2G, "2G", errp);
     }
-
-    cap_hpage_1m = 1;
 }
 
-int kvm_s390_get_hpage_1m(void)
+int kvm_s390_get_hpage(void)
 {
-    return cap_hpage_1m;
+    return cap_hpage;
 }
 
 static void ccw_machine_class_foreach(ObjectClass *oc, void *opaque)
target/s390x/kvm/kvm_s390x.h +1 -1
index 7b1cce3e60..3c4fa0489c 100644
@@ -25,7 +25,7 @@ void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code);
 int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
 void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
 int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
-int kvm_s390_get_hpage_1m(void);
+int kvm_s390_get_hpage(void);
 int kvm_s390_get_protected_dump(void);
 int kvm_s390_get_ri(void);
 int kvm_s390_get_zpci_op(void);
target/s390x/kvm/stubs.c +1 -1
index 196127baa5..ebf3c83994 100644
@@ -143,7 +143,7 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
     g_assert_not_reached();
 }
 
-int kvm_s390_get_hpage_1m(void)
+int kvm_s390_get_hpage(void)
 {
     g_assert_not_reached();
 }
Signature · 1 line
2.55.0
#4 lore raw

[PULL 14/15] hw: add compat machines for 11.2

In reply to Eric Farman

From: Cornelia Huck <[email protected]>

Add 11.2 machine types for arm/i440fx/loongarch/m68k/q35/s390x/spapr.

---
 hw/arm/virt.c              |  9 ++++++++-
 hw/core/machine.c          |  3 +++
 hw/i386/pc.c               |  3 +++
 hw/i386/pc_piix.c          | 13 +++++++++++--
 hw/i386/pc_q35.c           | 13 +++++++++++--
 hw/loongarch/virt.c        | 11 +++++++++--
 hw/m68k/virt.c             |  9 ++++++++-
 hw/ppc/spapr.c             | 15 +++++++++++++--
 hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++-
 include/hw/core/boards.h   |  3 +++
 include/hw/i386/pc.h       |  3 +++
 11 files changed, 85 insertions(+), 11 deletions(-)
hw/arm/virt.c +8 -1
index 219597cabd..e7a56e37f7 100644
@@ -4441,10 +4441,17 @@ static void machvirt_machine_init(void)
 }
 type_init(machvirt_machine_init);
 
+static void virt_machine_11_2_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(11, 2)
+
 static void virt_machine_11_1_options(MachineClass *mc)
 {
+    virt_machine_11_2_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len);
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(11, 1)
+DEFINE_VIRT_MACHINE(11, 1)
 
 static void virt_machine_11_0_options(MachineClass *mc)
 {
hw/core/machine.c +3 -0
index 73b4d82b4a..3b15645304 100644
@@ -40,6 +40,9 @@
 #include "qemu/audio.h"
 #include "hw/arm/smmuv3.h"
 
+GlobalProperty hw_compat_11_1[] = {};
+const size_t hw_compat_11_1_len = G_N_ELEMENTS(hw_compat_11_1);
+
 GlobalProperty hw_compat_11_0[] = {
     { "virtio-mmio", VIRTIO_QUEUE_SIZE_OVERRIDE, "1024" },
     { "chardev-vc", "encoding", "cp437" },
hw/i386/pc.c +3 -0
index f064aa2b3e..e9e4fc262b 100644
@@ -74,6 +74,9 @@
 #include "hw/xen/xen-bus.h"
 #endif
 
+GlobalProperty pc_compat_11_1[] = {};
+const size_t pc_compat_11_1_len = G_N_ELEMENTS(pc_compat_11_1);
+
 GlobalProperty pc_compat_11_0[] = {};
 const size_t pc_compat_11_0_len = G_N_ELEMENTS(pc_compat_11_0);
 
hw/i386/pc_piix.c +11 -2
index 82457bdb16..223a19cc4b 100644
@@ -428,12 +428,21 @@ static void pc_i440fx_machine_options(MachineClass *m)
                      pc_piix_compat_defaults, pc_piix_compat_defaults_len);
 }
 
-static void pc_i440fx_machine_11_1_options(MachineClass *m)
+static void pc_i440fx_machine_11_2_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
 }
 
-DEFINE_I440FX_MACHINE_AS_LATEST(11, 1);
+DEFINE_I440FX_MACHINE_AS_LATEST(11, 2);
+
+static void pc_i440fx_machine_11_1_options(MachineClass *m)
+{
+    pc_i440fx_machine_11_2_options(m);
+    compat_props_add(m->compat_props, hw_compat_11_1, hw_compat_11_1_len);
+    compat_props_add(m->compat_props, pc_compat_11_1, pc_compat_11_1_len);
+}
+
+DEFINE_I440FX_MACHINE(11, 1);
 
 static void pc_i440fx_machine_11_0_options(MachineClass *m)
 {
hw/i386/pc_q35.c +11 -2
index 6c1e4eff5f..94cd71124b 100644
@@ -383,12 +383,21 @@ static void pc_q35_machine_options(MachineClass *m)
                      pc_q35_compat_defaults, pc_q35_compat_defaults_len);
 }
 
-static void pc_q35_machine_11_1_options(MachineClass *m)
+static void pc_q35_machine_11_2_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
 }
 
-DEFINE_Q35_MACHINE_AS_LATEST(11, 1);
+DEFINE_Q35_MACHINE_AS_LATEST(11, 2);
+
+static void pc_q35_machine_11_1_options(MachineClass *m)
+{
+    pc_q35_machine_11_2_options(m);
+    compat_props_add(m->compat_props, hw_compat_11_1, hw_compat_11_1_len);
+    compat_props_add(m->compat_props, pc_compat_11_1, pc_compat_11_1_len);
+}
+
+DEFINE_Q35_MACHINE(11, 1);
 
 static void pc_q35_machine_11_0_options(MachineClass *m)
 {
hw/loongarch/virt.c +9 -2
index 6693dea647..9cc79929a8 100644
@@ -1465,7 +1465,6 @@ static void virt_class_init(ObjectClass *oc, const void *data)
     mc->default_ram_id = "loongarch.ram";
     mc->desc = "QEMU LoongArch Virtual Machine";
     mc->max_cpus = LOONGARCH_MAX_CPUS;
-    mc->is_default = 1;
     mc->default_kernel_irqchip_split = false;
     mc->block_default_type = IF_VIRTIO;
     mc->default_boot_order = "c";
@@ -1546,6 +1545,7 @@ static void virt_class_init(ObjectClass *oc, const void *data)
         MACHINE_VER_DEPRECATION(__VA_ARGS__); \
         if (latest) { \
             mc->alias = "virt"; \
+            mc->is_default = true; \
         } \
     } \
     static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = \
@@ -1600,7 +1600,14 @@ static void machvirt_machine_init(void)
 
 type_init(machvirt_machine_init);
 
+static void virt_machine_11_2_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(11, 2)
+
 static void virt_machine_11_1_options(MachineClass *mc)
 {
+    virt_machine_11_2_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len);
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(11, 1)
+DEFINE_VIRT_MACHINE(11, 1)
hw/m68k/virt.c +8 -1
index 51158ce1c0..274970978f 100644
@@ -367,10 +367,17 @@ type_init(virt_machine_register_types)
 #define DEFINE_VIRT_MACHINE(major, minor) \
     DEFINE_VIRT_MACHINE_IMPL(false, major, minor)
 
+static void virt_machine_11_2_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(11, 2)
+
 static void virt_machine_11_1_options(MachineClass *mc)
 {
+    virt_machine_11_2_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len);
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(11, 1)
+DEFINE_VIRT_MACHINE(11, 1)
 
 static void virt_machine_11_0_options(MachineClass *mc)
 {
hw/ppc/spapr.c +13 -2
index b79828b4e9..7e284edd7d 100644
@@ -4763,15 +4763,26 @@ static void spapr_machine_latest_class_options(MachineClass *mc)
 #define DEFINE_SPAPR_MACHINE(major, minor) \
     DEFINE_SPAPR_MACHINE_IMPL(false, major, minor)
 
+/*
+ * pseries-11.2
+ */
+static void spapr_machine_11_2_class_options(MachineClass *mc)
+{
+    /* Defaults for the latest behaviour inherited from the base class */
+}
+
+DEFINE_SPAPR_MACHINE_AS_LATEST(11, 2);
+
 /*
  * pseries-11.1
  */
 static void spapr_machine_11_1_class_options(MachineClass *mc)
 {
-    /* Defaults for the latest behaviour inherited from the base class */
+    spapr_machine_11_2_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len);
 }
 
-DEFINE_SPAPR_MACHINE_AS_LATEST(11, 1);
+DEFINE_SPAPR_MACHINE(11, 1);
 
 /*
  * pseries-11.0
hw/s390x/s390-virtio-ccw.c +13 -1
index 25a9fa4955..55131c1a44 100644
@@ -925,14 +925,26 @@ static const TypeInfo ccw_machine_info = {
     DEFINE_CCW_MACHINE_IMPL(false, major, minor)
 
 
+static void ccw_machine_11_2_instance_options(MachineState *machine)
+{
+}
+
+static void ccw_machine_11_2_class_options(MachineClass *mc)
+{
+}
+DEFINE_CCW_MACHINE_AS_LATEST(11, 2);
+
 static void ccw_machine_11_1_instance_options(MachineState *machine)
 {
+    ccw_machine_11_2_instance_options(machine);
 }
 
 static void ccw_machine_11_1_class_options(MachineClass *mc)
 {
+    ccw_machine_11_2_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len);
 }
-DEFINE_CCW_MACHINE_AS_LATEST(11, 1);
+DEFINE_CCW_MACHINE(11, 1);
 
 static void ccw_machine_11_0_instance_options(MachineState *machine)
 {
include/hw/core/boards.h +3 -0
index 29c68931d8..a436d48c8e 100644
@@ -815,6 +815,9 @@ compat_props_add(GPtrArray *arr,
     }
 }
 
+extern GlobalProperty hw_compat_11_1[];
+extern const size_t hw_compat_11_1_len;
+
 extern GlobalProperty hw_compat_11_0[];
 extern const size_t hw_compat_11_0_len;
 
include/hw/i386/pc.h +3 -0
index d4b6d3ed57..ac03da97b6 100644
@@ -209,6 +209,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size);
 /* sgx.c */
 void pc_machine_init_sgx_epc(PCMachineState *pcms);
 
+extern GlobalProperty pc_compat_11_1[];
+extern const size_t pc_compat_11_1_len;
+
 extern GlobalProperty pc_compat_11_0[];
 extern const size_t pc_compat_11_0_len;
 
Signature · 1 line
2.55.0
#5 lore raw

[PULL 03/15] target/s390x: Fix DR/D INT64_MIN / -1 host crash

In reply to Eric Farman

From: Ilya Leoshkevich <[email protected]>

helper_divs32() divides the 64-bit dividend by the 32-bit divisor as a 64-bit host operation, guarding only against a zero divisor. INT64_MIN / -1 therefore overflows the host division before the representability check runs; on hosts that trap this, QEMU is killed with SIGFPE instead of raising the fixed-point-divide exception the guest expects:

    qemu-s390x: QEMU internal SIGFPE {code=INTDIV, addr=...}

helper_divs64() already guards the same case; add the missing check to helper_divs32().

---
 target/s390x/tcg/int_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/s390x/tcg/int_helper.c +2 -1
index fbda396f5b..5aedd1405b 100644
@@ -39,7 +39,8 @@ uint64_t HELPER(divs32)(CPUS390XState *env, int64_t a, int64_t b64)
     int32_t b = b64;
     int64_t q, r;
 
-    if (b == 0) {
+    /* Catch divide by zero, and non-representable quotient (MIN / -1).  */
+    if (b == 0 || (b == -1 && a == (1ll << 63))) {
         tcg_s390_program_interrupt(env, PGM_FIXPT_DIVIDE, GETPC());
     }
 
Signature · 1 line
2.55.0
#6 lore raw

[PULL 08/15] pc-bios/s390-ccw: bounds-check zipl menu entry index before array write

In reply to Eric Farman

From: Joshua Daley <[email protected]>

menu_get_zipl_boot_index() iterates NUL-separated strings from the zipl stage-2 boot-menu block, passes each to zipl_print_entry() which converts EBCDIC to ASCII and returns atoi(), then writes true into valid_entries[entry]. valid_entries is a MAX_BOOT_ENTRIES element stack array, but entry was never bounds-checked, so a crafted on-disk value could index arbitrarily beyond the array.

Fix this in two places:

- zipl_print_entry() now validates that the first significant character (after an optional leading space) is a digit. Entries that fail this check return -1 without printing.

- menu_get_zipl_boot_index() skips any entry whose index is outside [0, MAX_BOOT_ENTRIES) before writing to valid_entries[].

Fixes 7385e947fc65 ("pc-bios/s390-ccw: fix non-sequential boot entries (eckd)")
[[email protected]: Added qemu-stable]
---
 pc-bios/s390-ccw/menu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
pc-bios/s390-ccw/menu.c +11 -2
index eeaff78f87..b6a9a56d46 100644
@@ -176,18 +176,24 @@ int menu_get_boot_index(bool *valid_entries)
     return boot_index;
 }
 
-/* Returns the entry number that was printed */
+/* Returns the entry number that was printed, or -1 on invalid entry */
 static int zipl_print_entry(const char *data, size_t len)
 {
     char buf[len + 2];
+    const char *p;
 
     ebcdic_to_ascii(data, buf, len);
     buf[len] = '\n';
     buf[len + 1] = '\0';
 
+    p = (buf[0] == ' ') ? buf + 1 : buf;
+    if (!isdigit((unsigned char)*p)) {
+        return -1;
+    }
+
     printf("%s", buf);
 
-    return buf[0] == ' ' ? atoi(buf + 1) : atoi(buf);
+    return atoi(p);
 }
 
 int menu_get_zipl_boot_index(const char *menu_data)
@@ -216,6 +222,9 @@ int menu_get_zipl_boot_index(const char *menu_data)
         entry = zipl_print_entry(menu_data, len);
         menu_data += len + 1;
 
+        if (entry < 0 || entry >= MAX_BOOT_ENTRIES) {
+            continue;
+        }
         valid_entries[entry] = true;
 
         if (entry == 0) {
Signature · 1 line
2.55.0
#7 lore raw

[PULL 09/15] pc-bios/s390-ccw: bound zipl menu strlen and replace VLA in zipl_print_entry

In reply to Eric Farman

From: Joshua Daley <[email protected]>

menu_get_zipl_boot_index() calls strlen() on a pointer into the middle of _s2 with no upper bound, so a stage-2 image whose blocks contain no NUL bytes causes strlen() to walk beyond _s2. The resulting length is then used to size a stack VLA in zipl_print_entry(), risking a stack overflow.

Fix by:

- Implementing strnlen(), a bounded version of strlen(). s390-ccw uses libc from SLOF, which includes strlen() but does not have an implementation of strnlen(), so we must implement our own.

- Adding a menu_data_end parameter to menu_get_zipl_boot_index() and replacing both strlen() calls with strnlen() bounded by the remaining buffer space. The loop guard also checks that the pointer has not reached menu_data_end. The function returns 0 (boot default) if somehow menu_data reaches menu_data_end before printing any entries.

- Replacing the VLA char buf[len + 2] in zipl_print_entry() with a fixed ZIPL_ENTRY_MAX + 2 (82-byte) buffer and truncating len before use.

- Passing s2_end (_s2 + sizeof(_s2)) as menu_data_end at the one call site in eckd_get_boot_menu_index(), so the bound is exactly the end of the buffer.

[[email protected]: Per list, add strnlen rationale to commit message
and added cc stable]

---
 pc-bios/s390-ccw/bootmap.c  |  4 +++-
 pc-bios/s390-ccw/helper.h   | 10 ++++++++++
 pc-bios/s390-ccw/menu.c     | 29 +++++++++++++++++++++++------
 pc-bios/s390-ccw/s390-ccw.h |  2 +-
 4 files changed, 37 insertions(+), 8 deletions(-)
pc-bios/s390-ccw/bootmap.c +3 -1
index ed6e8cbbc7..81512265ce 100644
@@ -61,6 +61,7 @@ static uint8_t _s2[MAX_SECTOR_SIZE * 3] __attribute__((__aligned__(PAGE_SIZE)));
 static void *s2_prev_blk = _s2;
 static void *s2_cur_blk = _s2 + MAX_SECTOR_SIZE;
 static void *s2_next_blk = _s2 + MAX_SECTOR_SIZE * 2;
+static void *s2_end = _s2 + sizeof(_s2);
 
 static inline int verify_boot_info(BootInfo *bip)
 {
@@ -308,7 +309,8 @@ static int eckd_get_boot_menu_index(block_number_t s1b_block_nr)
                 }
             }
 
-            return menu_get_zipl_boot_index(s2_cur_blk + banner_offset);
+            return menu_get_zipl_boot_index(s2_cur_blk + banner_offset,
+                                            s2_end);
         }
 
         prev_block_nr = cur_block_nr;
pc-bios/s390-ccw/helper.h +10 -0
index 8e3dfcb6d6..d9b7da444a 100644
@@ -45,4 +45,14 @@ static inline void sleep(unsigned int seconds)
     }
 }
 
+static inline size_t strnlen(const char *s, size_t maxlen)
+{
+    size_t len = 0;
+
+    while (len < maxlen && s[len]) {
+        len++;
+    }
+    return len;
+}
+
 #endif
pc-bios/s390-ccw/menu.c +23 -6
index b6a9a56d46..9b81154b0e 100644
@@ -16,6 +16,7 @@
 #include "s390-ccw.h"
 #include "sclp.h"
 #include "s390-time.h"
+#include "helper.h"
 
 #define KEYCODE_NO_INP '\0'
 #define KEYCODE_ESCAPE '\033'
@@ -26,6 +27,9 @@
 #define ZIPL_TIMEOUT_OFFSET 138
 #define ZIPL_FLAG_OFFSET    140
 
+/* Max printable chars for a zipl boot menu entry */
+#define ZIPL_ENTRY_MAX 80
+
 #define TOD_CLOCK_MILLISECOND   0x3e8000
 
 #define LOW_CORE_EXTERNAL_INT_ADDR   0x86
@@ -179,9 +183,13 @@ int menu_get_boot_index(bool *valid_entries)
 /* Returns the entry number that was printed, or -1 on invalid entry */
 static int zipl_print_entry(const char *data, size_t len)
 {
-    char buf[len + 2];
+    char buf[ZIPL_ENTRY_MAX + 2];
     const char *p;
 
+    if (len > ZIPL_ENTRY_MAX) {
+        len = ZIPL_ENTRY_MAX;
+    }
+
     ebcdic_to_ascii(data, buf, len);
     buf[len] = '\n';
     buf[len + 1] = '\0';
@@ -196,7 +204,7 @@ static int zipl_print_entry(const char *data, size_t len)
     return atoi(p);
 }
 
-int menu_get_zipl_boot_index(const char *menu_data)
+int menu_get_zipl_boot_index(const char *menu_data, const char *menu_data_end)
 {
     size_t len;
     int entry;
@@ -212,13 +220,22 @@ int menu_get_zipl_boot_index(const char *menu_data)
         timeout = zipl_timeout * 1000;
     }
 
-    /* Print banner */
+    if (menu_data >= menu_data_end) {
+        return 0; /* Boot default */
+    }
+
+    /* Skip banner */
+    len = strnlen(menu_data, menu_data_end - menu_data);
+    menu_data += len + 1;
+    if (menu_data >= menu_data_end || !(*menu_data)) {
+        return 0; /* No entries, boot default */
+    }
+
     puts("s390-ccw zIPL Boot Menu\n");
-    menu_data += strlen(menu_data) + 1;
 
     /* Print entries */
-    while (*menu_data) {
-        len = strlen(menu_data);
+    while (menu_data < menu_data_end && *menu_data) {
+        len = strnlen(menu_data, menu_data_end - menu_data);
         entry = zipl_print_entry(menu_data, len);
         menu_data += len + 1;
 
pc-bios/s390-ccw/s390-ccw.h +1 -1
index 1e1f71775e..f6030a6071 100644
@@ -76,7 +76,7 @@ void jump_to_low_kernel(void);
 
 /* menu.c */
 void menu_set_parms(uint8_t boot_menu_flag, uint32_t boot_menu_timeout);
-int menu_get_zipl_boot_index(const char *menu_data);
+int menu_get_zipl_boot_index(const char *menu_data, const char *menu_data_end);
 bool menu_is_enabled_zipl(void);
 int menu_get_enum_boot_index(bool *valid_entries);
 bool menu_is_enabled_enum(void);
Signature · 1 line
2.55.0
#8 lore raw

[PULL 04/15] tests/tcg/s390x: Test DR overflow (INT64_MIN / -1)

In reply to Eric Farman

From: Ilya Leoshkevich <[email protected]>

Check that DR with a non-representable quotient raises SIGFPE rather than crashing the emulator.

---
 tests/tcg/s390x/div.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
tests/tcg/s390x/div.c +37 -0
index 6ad9900e08..124c9ecc33 100644
@@ -1,6 +1,15 @@
 #include <assert.h>
+#include <signal.h>
 #include <stdint.h>
 
+/* Set asynchronously by the signal handler. */
+static volatile int signum;
+
+static void signal_handler(int n)
+{
+    signum = n;
+}
+
 static void test_dr(void)
 {
     register int32_t r0 asm("r0") = -1;
@@ -65,11 +74,39 @@ static void test_dlgr(void)
     assert(r == 1);
 }
 
+/*
+ * The most negative dividend divided by -1 yields a quotient that does not
+ * fit into 32 bits, so DR must raise a fixed-point-divide exception.
+ */
+static void test_dr_overflow(void)
+{
+    struct sigaction act = { .sa_handler = signal_handler };
+    register int32_t r0 asm("r0");
+    register int32_t r1 asm("r1");
+    int32_t b = -1;
+    int err;
+
+    err = sigaction(SIGFPE, &act, NULL);
+    assert(err == 0);
+    signum = -1;
+
+    r0 = 0x80000000;
+    r1 = 0;
+    asm volatile("dr %[r0],%[b]"
+                 : [r0] "+r" (r0), [r1] "+r" (r1)
+                 : [b] "r" (b)
+                 : "cc");
+    assert(signum == SIGFPE);
+
+    signal(SIGFPE, SIG_DFL);
+}
+
 int main(void)
 {
     test_dr();
     test_dlr();
     test_dsgr();
     test_dlgr();
+    test_dr_overflow();
     return 0;
 }
Signature · 1 line
2.55.0
#9 lore raw

[PULL 06/15] s390x/ipl: validate num_comp against iplb length before iterating

In reply to Eric Farman

From: Joshua Daley <[email protected]>

In ipl_valid_pv_components(), the upper bound of the for loop, ipib_pv->num_comp, is read from guest memory. Before iterating, verify that its value will not cause a read beyond the end of the IplParameterBlock.

---
 hw/s390x/ipl.h | 6 ++++++
 1 file changed, 6 insertions(+)
hw/s390x/ipl.h +6 -0
index fac30763df..ef9c063d90 100644
@@ -124,6 +124,12 @@ static inline bool ipl_valid_pv_components(IplParameterBlock *iplb)
         return false;
     }
 
+    if (offsetof(IplParameterBlock, pv.components) +
+        ipib_pv->num_comp * sizeof(IPLBlockPVComp) >
+        be32_to_cpu(iplb->len)) {
+        return false;
+    }
+
     for (i = 0; i < ipib_pv->num_comp; i++) {
         /* Addr must be 4k aligned */
         if (ipib_pv->components[i].addr & ~TARGET_PAGE_MASK) {
Signature · 1 line
2.55.0
#10 lore raw

[PULL 12/15] tests/tcg/s390x: Test STCKF condition code on a faulting store

In reply to Eric Farman

From: Ilya Leoshkevich <[email protected]>

Add a small test to prevent regressions.

---
 tests/tcg/s390x/Makefile.target |  1 +
 tests/tcg/s390x/stckf.c         | 44 +++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 tests/tcg/s390x/stckf.c
tests/tcg/s390x/Makefile.target +1 -0
index 48cba4cdfa..97c0f02190 100644
@@ -50,6 +50,7 @@ TESTS+=cvb
 TESTS+=ts
 TESTS+=ex-smc
 TESTS+=divide-to-integer
+TESTS+=stckf
 
 cdsg: CFLAGS+=-pthread
 cdsg: LDFLAGS+=-pthread
tests/tcg/s390x/stckf.c new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.55.0
#11 lore raw

[PULL 15/15] pc-bios/s390-ccw.img: update s390x bios

In reply to Eric Farman

Update the s390 bios with recent fixes for out-of-bounds accesses.

---
 pc-bios/s390-ccw.img | Bin 104136 -> 104216 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
index e24a93e14a880aa3a5d498fc84c7bdd1a0964d7c..291cd77eaff40679d0cc2d5697d0c7b73c493e94 100644
GIT binary patch
Signature · 1 line
2.55.0
#12 lore raw

Re: [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios

Quoted 6 lines · Eric Farman

Update the s390 bios with recent fixes for out-of-bounds accesses.

---
  pc-bios/s390-ccw.img | Bin 104136 -> 104216 bytes
  1 file changed, 0 insertions(+), 0 deletions(-)

How do you guys build s390x-ccw.img - which compiler version(s) are used for that?

Since we're updating source files in the stable series, where this image is not the same as in current master, I'll have to rebuild it after patching. Now I wonder how should I build it.

In official debian we always build it from source, and there were no complains - maybe because no one uses debian to run qemu-system-s390x? :)

Anyway, on debian stable we have gcc-14.2.0, -- is it okay to use it for building the image?

Also, there's little changes in s390-ccw.img between qemu 11.0 and 11.1, here's the list:

b2b5dec9295 s390x: Enable boot menu for virtio pci device
d0473643803 pc-bios/s390-ccw: write IPLB location for non-net virtio devices e26dafb207b pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x 084feb90980 pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations 730173107a9 pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications c12bb74fd57 pc-bios/s390-ccw: Refactor byte swapping

I think I can pick all that stuff for 11.0.x series just fine, to avoid (re)building the image for 11.0.x series.

For 10.0.x, things are really much larger:

14c29f29064 pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled d72fb5e6b2e pc-bios/s390-ccw: Add support for virtio-blk-pci IPL 40d80aedd5a pc-bios/s390-ccw: Introduce virtio-pci functions
5ed17bb32ab pc-bios/s390-ccw: Introduce PCI device
d3da8afd1dd pc-bios/s390-ccw: Introduce CLP Architecture
4ff1499adab pc-bios/s390-ccw: Split virtio-ccw and generic virtio ada7a60056c pc-bios/s390-ccw: Store device type independent of sense data 4228a92b2a3 s390x: Remove duplicate definitions of IPL types
dd8c8f16c02 pc-bios/s390-ccw: Always reset virtio device on failed boot attempt 5dbabcfee89 pc-bios/s390-ccw: Remove redundant vring schid attribute 1ef532cbcfc pc-bios/s390-ccw: Fix misattributed function prototypes acb00a7aae4 pc-bios/s390-ccw: link statically
fc24fd9342e pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg 47d68f7475f pc-bios/s390-ccw: Make get_boot_index() from menu.c global 108977796fb pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg a4adf071dc7 pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm

basically it's whole virtio and pci support added, which might be too much? Please note that 10.0.x is an LTS series, also used in current debian stable (trixie), so maybe it is also okay to pick everything up to this series, to bring the image in-line with current development.

In this case I'll just pick the commits updating the image too :)

What do you think?

Thanks,

/mjt

#13 lore raw

Re: [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios

Quoted 10 lines · Michael Tokarev
Quoted 6 lines · Eric Farman

Update the s390 bios with recent fixes for out-of-bounds accesses.

---
  pc-bios/s390-ccw.img | Bin 104136 -> 104216 bytes

  1 file changed, 0 insertions(+), 0 deletions(-)

How do you guys build s390x-ccw.img - which compiler version(s) are used for that?

This was gcc-16.1.1

Quoted 10 lines

Since we're updating source files in the stable series, where this image is not the same as in current master, I'll have to rebuild it after patching.  Now I wonder how should I build it.

In official debian we always build it from source, and there were no complains - maybe because no one uses debian to run qemu-system-s390x? :)

Anyway, on debian stable we have gcc-14.2.0, -- is it okay to use it for building the image?

I should think so. But if it doesn't work, let's look into why.

Quoted 41 lines

Also, there's little changes in s390-ccw.img between qemu 11.0 and 11.1, here's the list:

 b2b5dec9295 s390x: Enable boot menu for virtio pci device d0473643803 pc-bios/s390-ccw: write IPLB location for non-net virtio
devices
 e26dafb207b pc-bios/s390-ccw: Verify virtio support when booting from
virtio PCI device on s390x
 084feb90980 pc-bios/s390-ccw: Add per-queue notification offset for
multi-queue virtio configurations
 730173107a9 pc-bios/s390-ccw/virtio.c: Fix missing break for PCI
notifications
 c12bb74fd57 pc-bios/s390-ccw: Refactor byte swapping

I think I can pick all that stuff for 11.0.x series just fine, to avoid (re)building the image for 11.0.x series.

For 10.0.x, things are really much larger:

 14c29f29064 pc-bios/s390-ccw: Fix compiler warning when compiling with
DEBUG enabled
 d72fb5e6b2e pc-bios/s390-ccw: Add support for virtio-blk-pci IPL 40d80aedd5a pc-bios/s390-ccw: Introduce virtio-pci functions 5ed17bb32ab pc-bios/s390-ccw: Introduce PCI device d3da8afd1dd pc-bios/s390-ccw: Introduce CLP Architecture 4ff1499adab pc-bios/s390-ccw: Split virtio-ccw and generic virtio ada7a60056c pc-bios/s390-ccw: Store device type independent of sense data 4228a92b2a3 s390x: Remove duplicate definitions of IPL types dd8c8f16c02 pc-bios/s390-ccw: Always reset virtio device on failed
boot attempt
 5dbabcfee89 pc-bios/s390-ccw: Remove redundant vring schid attribute 1ef532cbcfc pc-bios/s390-ccw: Fix misattributed function prototypes acb00a7aae4 pc-bios/s390-ccw: link statically
 fc24fd9342e pc-bios/s390-ccw: Add a boot menu for booting via
pxelinux.cfg
 47d68f7475f pc-bios/s390-ccw: Make get_boot_index() from menu.c global 108977796fb pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg a4adf071dc7 pc-bios/s390-ccw: Allow to select a different pxelinux.cfg
entry via loadparm

Quoted 8 lines

basically it's whole virtio and pci support added, which might be too much? Please note that 10.0.x is an LTS series, also used in current debian stable (trixie), so maybe it is also okay to pick everything up to this series, to bring the image in-line with current development.

In this case I'll just pick the commits updating the image too :)

What do you think?

Yeah, might be a bit much. The smaller fixes were contained enough that targeting them for stable made sense. Of the four fixes that were in this rebuild, three of the blamed commits date to the v2/v3 days. The fourth went in in 9.2.

Everything else in your lists is new function and whatnot, so my gut says leave it there.

Thanks,
Eric

#14 lore raw

Re: [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios

On 8/14/26 19:07, Eric Farman wrote:
..

Quoted 4 lines
Quoted 2 lines

Anyway, on debian stable we have gcc-14.2.0, -- is it okay to use it for building the image?

I should think so. But if it doesn't work, let's look into why.

When building for the official debian archives, the images are built by the compilers available on official debian archives, so that's gcc-14, and hopefully the resulting images works :) But honestly I don't know if anyone/anything is actually using these images on debian.

I just never tried to build the images for the official qemu git tree and tarballs.

Quoted 37 lines
Quoted 37 lines

Also, there's little changes in s390-ccw.img between qemu 11.0 and 11.1, here's the list:

  b2b5dec9295 s390x: Enable boot menu for virtio pci device
  d0473643803 pc-bios/s390-ccw: write IPLB location for non-net virtio devices e26dafb207b pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x 084feb90980 pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations 730173107a9 pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications c12bb74fd57 pc-bios/s390-ccw: Refactor byte swapping

I think I can pick all that stuff for 11.0.x series just fine, to avoid (re)building the image for 11.0.x series.

For 10.0.x, things are really much larger:

  14c29f29064 pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled d72fb5e6b2e pc-bios/s390-ccw: Add support for virtio-blk-pci IPL 40d80aedd5a pc-bios/s390-ccw: Introduce virtio-pci functions
  5ed17bb32ab pc-bios/s390-ccw: Introduce PCI device
  d3da8afd1dd pc-bios/s390-ccw: Introduce CLP Architecture
  4ff1499adab pc-bios/s390-ccw: Split virtio-ccw and generic virtio ada7a60056c pc-bios/s390-ccw: Store device type independent of sense data 4228a92b2a3 s390x: Remove duplicate definitions of IPL types
  dd8c8f16c02 pc-bios/s390-ccw: Always reset virtio device on failed boot attempt 5dbabcfee89 pc-bios/s390-ccw: Remove redundant vring schid attribute 1ef532cbcfc pc-bios/s390-ccw: Fix misattributed function prototypes acb00a7aae4 pc-bios/s390-ccw: link statically
  fc24fd9342e pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg 47d68f7475f pc-bios/s390-ccw: Make get_boot_index() from menu.c global 108977796fb pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg a4adf071dc7 pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm

basically it's whole virtio and pci support added, which might be too much? Please note that 10.0.x is an LTS series, also used in current debian stable (trixie), so maybe it is also okay to pick everything up to this series, to bring the image in-line with current development.

Quoted 7 lines
Quoted 3 lines

In this case I'll just pick the commits updating the image too :)

What do you think?

Yeah, might be a bit much. The smaller fixes were contained enough that targeting them for stable made sense. Of the four fixes that were in this rebuild, three of the blamed commits date to the v2/v3 days. The fourth went in in 9.2.

Everything else in your lists is new function and whatnot, so my gut says leave it there.

Um. It's kinda difficult for me to guess what did you mean by all this :)

For 11.0.x stable series, I'm picking all commits in s390x-ccw which were made after 11.0.0 release -- that would be 6 commits from the first list above, plus all the changes which went into this pull request. This way, s390-ccw.img image will be the same in 11.0.x and in 11.1.x and in the master branch, - the binary which you made on your system.

For 10.0.x though (which is an LTS series), I'm picking just the fixes from this pull request, and will rebuild the image using the tools available on debian. At the time of qemu 10.0.0, I think you used older gcc too, so everything should match.

Thanks,

/mjt

#15 lore raw

Re: [PULL 15/15] pc-bios/s390-ccw.img: update s390x bios

Quoted 69 lines · Michael Tokarev

On 8/14/26 19:07, Eric Farman wrote:
..

Quoted 4 lines
Quoted 2 lines

Anyway, on debian stable we have gcc-14.2.0, -- is it okay to use it for building the image?

I should think so. But if it doesn't work, let's look into why.

When building for the official debian archives, the images are built by the compilers available on official debian archives, so that's gcc-14, and hopefully the resulting images works :)  But honestly I don't know if anyone/anything is actually using these images on debian.

I just never tried to build the images for the official qemu git tree and tarballs.

Quoted 37 lines
Quoted 37 lines

Also, there's little changes in s390-ccw.img between qemu 11.0 and 11.1, here's the list:

  b2b5dec9295 s390x: Enable boot menu for virtio pci device
  d0473643803 pc-bios/s390-ccw: write IPLB location for non-net virtio devices e26dafb207b pc-bios/s390-ccw: Verify virtio support when booting from virtio PCI device on s390x 084feb90980 pc-bios/s390-ccw: Add per-queue notification offset for multi-queue virtio configurations 730173107a9 pc-bios/s390-ccw/virtio.c: Fix missing break for PCI notifications c12bb74fd57 pc-bios/s390-ccw: Refactor byte swapping

I think I can pick all that stuff for 11.0.x series just fine, to avoid (re)building the image for 11.0.x series.

For 10.0.x, things are really much larger:

  14c29f29064 pc-bios/s390-ccw: Fix compiler warning when compiling with DEBUG enabled d72fb5e6b2e pc-bios/s390-ccw: Add support for virtio-blk-pci IPL 40d80aedd5a pc-bios/s390-ccw: Introduce virtio-pci functions
  5ed17bb32ab pc-bios/s390-ccw: Introduce PCI device
  d3da8afd1dd pc-bios/s390-ccw: Introduce CLP Architecture
  4ff1499adab pc-bios/s390-ccw: Split virtio-ccw and generic virtio ada7a60056c pc-bios/s390-ccw: Store device type independent of sense data 4228a92b2a3 s390x: Remove duplicate definitions of IPL types
  dd8c8f16c02 pc-bios/s390-ccw: Always reset virtio device on failed boot attempt 5dbabcfee89 pc-bios/s390-ccw: Remove redundant vring schid attribute 1ef532cbcfc pc-bios/s390-ccw: Fix misattributed function prototypes acb00a7aae4 pc-bios/s390-ccw: link statically
  fc24fd9342e pc-bios/s390-ccw: Add a boot menu for booting via pxelinux.cfg 47d68f7475f pc-bios/s390-ccw: Make get_boot_index() from menu.c global 108977796fb pc-bios/s390-ccw: Allow up to 31 entries for pxelinux.cfg a4adf071dc7 pc-bios/s390-ccw: Allow to select a different pxelinux.cfg entry via loadparm

basically it's whole virtio and pci support added, which might be too much? Please note that 10.0.x is an LTS series, also used in current debian stable (trixie), so maybe it is also okay to pick everything up to this series, to bring the image in-line with current development.

Quoted 7 lines
Quoted 3 lines

In this case I'll just pick the commits updating the image too :)

What do you think?

Yeah, might be a bit much. The smaller fixes were contained enough that targeting them for stable made sense. Of the four fixes that were in this rebuild, three of the blamed commits date to the v2/v3 days. The fourth went in in 9.2.

Everything else in your lists is new function and whatnot, so my gut says leave it there.

Um.  It's kinda difficult for me to guess what did you mean by all this :)

For 11.0.x stable series, I'm picking all commits in s390x-ccw which were made after 11.0.0 release -- that would be 6 commits from the first list above, plus all the changes which went into this pull request.  This way, s390-ccw.img image will be the same in 11.0.x and in 11.1.x and in the master branch, - the binary which you made on your system.

Quoted 4 lines

For 10.0.x though (which is an LTS series), I'm picking just the fixes from this pull request, and will rebuild the image using the tools available on debian.  At the time of qemu 10.0.0, I think you used older gcc too, so everything should match.

I think we're saying the same thing. :)

Certainly picking the smaller set of fixes for 11.0.x is fine, while leaving out the larger list for 10.0.x makes sense to me because of the scope of changes.

Thank you!
Eric

#16 lore raw

[PULL 11/15] target/s390x/tcg: Set STCK/STCKF condition code after the store

In reply to Eric Farman

From: Ilya Leoshkevich <[email protected]>

STORE CLOCK [FAST] to an inaccessible address aborts QEMU:

  $ qemu-s390x ./stckf
  ERROR:cc_helper.c:128:cc_calc_addu: assertion failed: (carry_out <= 1)

op_stck() sets the condition code with gen_op_movi_cc() before the output operand store, which is deferred to wout_m1_64(). Assigning a constant condition code discards the lazy CC values, so the optimizer drops the writes that produced them. When the store then raises an exception, the instruction is suppressed and s390x_restore_state_to_opc() reinstates the cc_op recorded at the start of STCK[F], but cc_src/cc_dst now hold stale values, so the next condition code evaluation reads garbage.

Fix by performing the store manually. The alternative of not discarding in gen_op_movi_cc() keeps the inputs live, but results in less optimal code.

---
 target/s390x/tcg/insn-data.h.inc | 4 ++--
 target/s390x/tcg/translate.c     | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
target/s390x/tcg/insn-data.h.inc +2 -2
index 0d5392eac5..1ea72248a6 100644
@@ -887,8 +887,8 @@
     C(0xe32f, STRVG,   RXY_a, Z,   la2, r1_o, new, m1_64, rev64, 0)
 
 /* STORE CLOCK */
-    F(0xb205, STCK,    S,     Z,   la2, 0, new, m1_64, stck, 0, IF_IO)
-    F(0xb27c, STCKF,   S,     SCF, la2, 0, new, m1_64, stck, 0, IF_IO)
+    F(0xb205, STCK,    S,     Z,   la2, 0, new, 0, stck, 0, IF_IO)
+    F(0xb27c, STCKF,   S,     SCF, la2, 0, new, 0, stck, 0, IF_IO)
 /* STORE CLOCK EXTENDED */
     F(0xb278, STCKE,   S,     Z,   0, a2, 0, 0, stcke, 0, IF_IO)
 
target/s390x/tcg/translate.c +2 -0
index 82165ac1ec..1b6023168b 100644
@@ -4108,7 +4108,9 @@ static DisasJumpType op_stap(DisasContext *s, DisasOps *o)
 static DisasJumpType op_stck(DisasContext *s, DisasOps *o)
 {
     gen_helper_stck(o->out, tcg_env);
+    tcg_gen_qemu_st_i64(o->out, o->addr1, get_mem_index(s), MO_BEUQ);
     /* ??? We don't implement clock states.  */
+    /* Set the CC after the store; a suppressed store must preserve it. */
     gen_op_movi_cc(s, 0);
     return DISAS_NEXT;
 }
Signature · 1 line
2.55.0
#17 lore raw

[PULL 07/15] pc-bios/s390-ccw: fix out-of-bounds read in iso_get_file_size()

In reply to Eric Farman

From: Joshua Daley <[email protected]>

In the dir_rem[level] == 0 case, level is decremented, then a virtio_read() is issued on sec_loc[level]. If level is -1, then the 4 bytes before the static sec_loc array are read, and the virtio_read() is issued on that garbage block number.

Guard the call to virtio_read() against the value of level to prevent this.

Fixes 869648e87eeb ("pc-bios/s390-ccw: El Torito 16-bit boot image size field workaround")
[[email protected]: Fixed typo on Christian's tag, added qemu-stable]
---
 pc-bios/s390-ccw/bootmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pc-bios/s390-ccw/bootmap.c +1 -1
index 420ee32eff..ed6e8cbbc7 100644
@@ -902,7 +902,7 @@ static inline long iso_get_file_size(uint32_t load_rba)
         if (dir_rem[level] == 0) {
             /* Nothing remaining */
             level--;
-            if (virtio_read(sec_loc[level], temp)) {
+            if (level >= 0 && virtio_read(sec_loc[level], temp)) {
                 puts("Failed to read ISO directory");
                 return -EIO;
             }
Signature · 1 line
2.55.0
#18 lore raw

[PULL 10/15] pc-bios/s390-ccw: Fix off-by-one errors with loadparm and boot entries

In reply to Eric Farman

From: Jared Rossi <[email protected]>

The loadparm may optionally be used to select a boot entry, with the intended range being 0 through 31 inclusive, for a total of 32 entries. Previously, MAX_BOOT_ENTRIES was defined as 31, indicating that it was intended to correspond to the index of the boot entry rather than the count; however, some guards also used MAX_BOOT_ENTRIES as a count of the maximum allowed entries, which resulted in a mismatch between the intended and actual range such that index 31 could never be used in practice.

Move the definition of MAX_BOOT_ENTRIES to qipl.h so it is shared and change the value to 32, representing a count of the maximum number of allowed boot entries and allowing the loadparm to accept values 0 through 31 as intended. Update some instances in the netboot code where MAX_BOOT_ENTRIES was used as the max index so that all guards treat MAX_BOOT_ENTRIES as a count across all boot methods.

Fixes 806315279d5c ("pc-bios/s390-ccw: Remove panics from ECKD IPL path")
---
 include/hw/s390x/ipl/qipl.h |  2 ++
 pc-bios/s390-ccw/netmain.c  | 11 +++++++----
 pc-bios/s390-ccw/s390-ccw.h |  2 --
 3 files changed, 9 insertions(+), 6 deletions(-)
include/hw/s390x/ipl/qipl.h +2 -0
index 8d3c83a80b..b390f2f112 100644
@@ -20,6 +20,8 @@
 #define LOADPARM_LEN    8
 #define NO_LOADPARM "\0\0\0\0\0\0\0\0"
 
+#define MAX_BOOT_ENTRIES  32
+
 enum S390IplType {
     S390_IPL_TYPE_FCP = 0x00,
     S390_IPL_TYPE_CCW = 0x02,
pc-bios/s390-ccw/netmain.c +7 -4
index 651cedf6ef..791854fce0 100644
@@ -40,6 +40,9 @@
 #define DEFAULT_BOOT_RETRIES 10
 #define DEFAULT_TFTP_RETRIES 20
 
+/* Index 0 is reserved for default alias, start PXE cfg indices at 1 */
+#define PXECFG_MAX              (MAX_BOOT_ENTRIES - 1)
+
 extern char _start[];
 
 #define KERNEL_ADDR             ((void *)0L)
@@ -381,13 +384,13 @@ static int net_select_and_load_kernel(filename_ip_t *fn_ip,
 
 static int net_try_pxelinux_cfg(filename_ip_t *fn_ip)
 {
-    struct pl_cfg_entry entries[MAX_BOOT_ENTRIES];
+    struct pl_cfg_entry entries[PXECFG_MAX];
     int num_ent, def_ent = 0;
 
     num_ent = pxelinux_load_parse_cfg(fn_ip, mac, get_uuid(),
                                       DEFAULT_TFTP_RETRIES,
                                       cfgbuf, sizeof(cfgbuf),
-                                      entries, MAX_BOOT_ENTRIES, &def_ent);
+                                      entries, PXECFG_MAX, &def_ent);
 
     return net_select_and_load_kernel(fn_ip, num_ent, def_ent, entries);
 }
@@ -470,11 +473,11 @@ static int net_try_direct_tftp_load(filename_ip_t *fn_ip)
          * a magic comment string.
          */
         if (!strncasecmp("# pxelinux", cfgbuf, 10)) {
-            struct pl_cfg_entry entries[MAX_BOOT_ENTRIES];
+            struct pl_cfg_entry entries[PXECFG_MAX];
             int num_ent, def_ent = 0;
 
             num_ent = pxelinux_parse_cfg(cfgbuf, sizeof(cfgbuf), entries,
-                                         MAX_BOOT_ENTRIES, &def_ent);
+                                         PXECFG_MAX, &def_ent);
             return net_select_and_load_kernel(fn_ip, num_ent, def_ent,
                                               entries);
         }
pc-bios/s390-ccw/s390-ccw.h +0 -2
index f6030a6071..25aac91d45 100644
@@ -82,8 +82,6 @@ int menu_get_enum_boot_index(bool *valid_entries);
 bool menu_is_enabled_enum(void);
 int menu_get_boot_index(bool *valid_entries);
 
-#define MAX_BOOT_ENTRIES  31
-
 __attribute__ ((__noreturn__))
 static inline void panic(const char *string)
 {
Signature · 1 line
2.55.0
#19 lore raw

[PULL 01/15] target/s390x: Make PRNO TRNG interruptible

In reply to Eric Farman

From: Ilya Leoshkevich <[email protected]>

fill_buf_random() writes the entire guest-requested amount of random bytes in one go. Since the length is a full 64-bit value, a guest can request several gigabytes and keep the vCPU spinning inside the helper, without a chance to react to interrupts.

Do the same thing as HELPER(mvcl): check cpu_loop_exit_requested() at the bottom of the loop, and when a return to the main loop is pending, stop and report partial completion with condition code 3.

---
 target/s390x/tcg/crypto_helper.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
target/s390x/tcg/crypto_helper.c +17 -5
index 8fe0a22219..6a5dbe1caf 100644
@@ -16,6 +16,7 @@
 #include "qemu/guest-random.h"
 #include "s390x-internal.h"
 #include "tcg_s390x.h"
+#include "exec/cpu-common.h"
 #include "exec/helper-proto.h"
 #include "accel/tcg/cpu-ldst-common.h"
 #include "accel/tcg/cpu-mmu-index.h"
@@ -242,8 +243,8 @@ static int cpacf_sha512(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
     return !len ? 0 : 3;
 }
 
-static void fill_buf_random(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
-                            uint64_t *buf_reg, uint64_t *len_reg)
+static int fill_buf_random(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
+                           uint64_t *buf_reg, uint64_t *len_reg)
 {
     const MemOpIdx oi = make_memop_idx(MO_8, mmu_idx);
     uint8_t tmp[256];
@@ -265,7 +266,13 @@ static void fill_buf_random(CPUS390XState *env, const int mmu_idx, uintptr_t ra,
             --*len_reg;
         }
         len -= block;
+
+        if (cpu_loop_exit_requested(env_cpu(env))) {
+            break;
+        }
     }
+
+    return len == 0 ? 0 : 3;
 }
 
 uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
@@ -278,6 +285,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
     uint8_t subfunc[16] = { 0 };
     uint64_t param_addr;
     MemOpIdx oi;
+    int cc;
 
     switch (type) {
     case S390_FEAT_TYPE_KMAC:
@@ -308,9 +316,13 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
         return cpacf_sha512(env, mmu_idx, ra, env->regs[1], &env->regs[r2],
                             &env->regs[r2 + 1], type);
     case 114: /* CPACF_PRNO_TRNG */
-        fill_buf_random(env, mmu_idx, ra, &env->regs[r1], &env->regs[r1 + 1]);
-        fill_buf_random(env, mmu_idx, ra, &env->regs[r2], &env->regs[r2 + 1]);
-        break;
+        cc = fill_buf_random(env, mmu_idx, ra,
+                             &env->regs[r1], &env->regs[r1 + 1]);
+        if (cc == 0) {
+            cc = fill_buf_random(env, mmu_idx, ra,
+                                 &env->regs[r2], &env->regs[r2 + 1]);
+        }
+        return cc;
     default:
         /* we don't implement any other subfunction yet */
         g_assert_not_reached();
Signature · 1 line
2.55.0
#20 lore raw
In reply to Eric Farman
Quoted 12 lines · Eric Farman

The following changes since commit 3e3ccab106f879b1512f8e0d51a827dd4de30e22:

   Update version for v11.1.0-rc3 release (2026-08-04 15:36:08 -0400)

are available in the Git repository at:

   https://gitlab.com/efarman/qemu.git tags/s390x-20260812

for you to fetch changes up to 9b3d68edb24d4e04f49822c6e11641e4eb23dfd5:

   pc-bios/s390-ccw.img: update s390x bios (2026-08-12 11:13:28 -0400)
Quoted 7 lines

----------------------------------------------------------------
First batch of s390x updates for 11.2:
- compat machines for 11.2
- allow guest backing with 2G hugepages
- fixes to TCG (and a couple tests on them)
- hardening fixes in boot/sclp code
- regenerate s390-ccw.img

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

r~