Skip to contentSkip to conversation

hw/s390x/ccw: Disable legacy mode

PATCH In review Jaehoon Kim 4 participants 5 messages Apr 20 – Apr 22

lore
Share & tools
lore
#0 lore raw

v2 cover hw/s390x/ccw: Disable legacy mode

Hello,

This is v2 of the patch.

Changes in v2:
- Drop RFC tag as the approach has been reviewed and agreed in principle.
- Improve comments to clarify why legacy virtio-pci is not usable on s390x due to lack of I/O BAR support (IO_SPACE_LIMIT is 0).

No functional changes.

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

Thanks,
Jaehoon Kim.

Jaehoon Kim (1):
hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+)

 hw/s390x/s390-virtio-ccw.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/1 hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+)

On the s390 Linux kernel, IO_SPACE_LIMIT has been 0 since the initial zPCI implementation (commit cd24834130ac "s390/pci: base support"), making I/O BARs unusable.

However, when virtio-pci devices operate in transitional mode, QEMU unconditionally exposes the legacy interface via BAR0. This results in firmware warnings during PCI enumeration, such as:

pci 0005:00:00.0: [Firmware Bug]: BAR 0: invalid; can't size

even though BAR0 is never usable on the s390 kernel.

Close this gap by disabling legacy virtio-pci support starting from machine version 11.1. This effectively makes virtio-pci devices non-transitional and prevents the creation of the unusable legacy I/O BAR.

This introduces s390x-specific global compatibility properties that set disable-legacy=on as the default for virtio-pci devices. Machine versions v11.0 and earlier set disable-legacy=off to maintain their original default behavior (legacy support enabled), ensuring VMs created with those versions continue to work identically.

Users can override the default on the command line if needed:
- On v11.1+: -global virtio-pci.disable-legacy=off (to enable legacy)
- On v11.0-: -global virtio-pci.disable-legacy=on (to disable legacy)

---
 hw/s390x/s390-virtio-ccw.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
hw/s390x/s390-virtio-ccw.c +26 -0
index cc768daeb0..4d35f9b10b 100644
@@ -788,6 +788,21 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
     g_free(val);
 }
 
+ /*
+  * S390x-specific global compatibility properties.
+  *
+  * On the s390 kernel, legacy virtio-pci is not usable because I/O BARs
+  * are not supported (IO_SPACE_LIMIT is 0), and would only result in
+  * unusable BARs and firmware warnings.
+  *
+  * Therefore, starting from v11.1, disable legacy virtio-pci by default,
+  * while older machine types keep legacy behavior for compatibility.
+  */
+static GlobalProperty hw_compat_s390x[] = {
+    { TYPE_VIRTIO_PCI, "disable-legacy", "on", .optional = true},
+};
+static const size_t hw_compat_s390x_len = G_N_ELEMENTS(hw_compat_s390x);
+
 static void ccw_machine_class_init(ObjectClass *oc, const void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -878,6 +893,9 @@ static const TypeInfo ccw_machine_info = {
         const void *data)                                                     \
     {                                                                         \
         MachineClass *mc = MACHINE_CLASS(oc);                                 \
+        /* Apply global s390x-wide default properties */                      \
+        compat_props_add(mc->compat_props, hw_compat_s390x,                   \
+                         hw_compat_s390x_len);                                \
         MACHINE_VER_SYM(class_options, ccw, __VA_ARGS__)(mc);                 \
         mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \
         mc->init = MACHINE_VER_SYM(mach_init, ccw, __VA_ARGS__);              \
@@ -923,7 +941,15 @@ static void ccw_machine_11_0_instance_options(MachineState *machine)
 
 static void ccw_machine_11_0_class_options(MachineClass *mc)
 {
+    /*
+     * Preserve v11.0 and older version behavior:
+     * keep legacy virtio-pci enabled.
+     */
+    static GlobalProperty compat[] = {
+        { TYPE_VIRTIO_PCI, "disable-legacy", "off" },
+    };
     ccw_machine_11_1_class_options(mc);
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     compat_props_add(mc->compat_props, hw_compat_11_0, hw_compat_11_0_len);
 }
 DEFINE_CCW_MACHINE(11, 0);
Signature · 1 line
2.50.1
Reviewed-by Tested-by on v2 1/1
#2 lore raw

Re: [PATCH v2 1/1] hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+)

Quoted 23 lines · Jaehoon Kim

On the s390 Linux kernel, IO_SPACE_LIMIT has been 0 since the initial zPCI implementation (commit cd24834130ac "s390/pci: base support"), making I/O BARs unusable.

However, when virtio-pci devices operate in transitional mode, QEMU unconditionally exposes the legacy interface via BAR0. This results in firmware warnings during PCI enumeration, such as:

pci 0005:00:00.0: [Firmware Bug]: BAR 0: invalid; can't size

even though BAR0 is never usable on the s390 kernel.

Close this gap by disabling legacy virtio-pci support starting from machine version 11.1. This effectively makes virtio-pci devices non-transitional and prevents the creation of the unusable legacy I/O BAR.

This introduces s390x-specific global compatibility properties that set disable-legacy=on as the default for virtio-pci devices. Machine versions v11.0 and earlier set disable-legacy=off to maintain their original default behavior (legacy support enabled), ensuring VMs created with those versions continue to work identically.

Quoted 6 lines

Users can override the default on the command line if needed:
- On v11.1+: -global virtio-pci.disable-legacy=off (to enable legacy)
- On v11.0-: -global virtio-pci.disable-legacy=on (to disable legacy)

Code looks good to me:

I also took the patch (along with 11.1 compat machine update) and did a general regression of various virtio-pci devices with kvm-accelerated s390x guests using s390-ccw-virtio-11.1.

Thanks Jaehoon!

Quoted 56 lines
---
 hw/s390x/s390-virtio-ccw.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
hw/s390x/s390-virtio-ccw.c +26 -0
index cc768daeb0..4d35f9b10b 100644
@@ -788,6 +788,21 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
     g_free(val);
 }
 
+ /*
+  * S390x-specific global compatibility properties.
+  *
+  * On the s390 kernel, legacy virtio-pci is not usable because I/O BARs
+  * are not supported (IO_SPACE_LIMIT is 0), and would only result in
+  * unusable BARs and firmware warnings.
+  *
+  * Therefore, starting from v11.1, disable legacy virtio-pci by default,
+  * while older machine types keep legacy behavior for compatibility.
+  */
+static GlobalProperty hw_compat_s390x[] = {
+    { TYPE_VIRTIO_PCI, "disable-legacy", "on", .optional = true},
+};
+static const size_t hw_compat_s390x_len = G_N_ELEMENTS(hw_compat_s390x);
+
 static void ccw_machine_class_init(ObjectClass *oc, const void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -878,6 +893,9 @@ static const TypeInfo ccw_machine_info = {
         const void *data)                                                     \
     {                                                                         \
         MachineClass *mc = MACHINE_CLASS(oc);                                 \
+        /* Apply global s390x-wide default properties */                      \
+        compat_props_add(mc->compat_props, hw_compat_s390x,                   \
+                         hw_compat_s390x_len);                                \
         MACHINE_VER_SYM(class_options, ccw, __VA_ARGS__)(mc);                 \
         mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \
         mc->init = MACHINE_VER_SYM(mach_init, ccw, __VA_ARGS__);              \
@@ -923,7 +941,15 @@ static void ccw_machine_11_0_instance_options(MachineState *machine)
 
 static void ccw_machine_11_0_class_options(MachineClass *mc)
 {
+    /*
+     * Preserve v11.0 and older version behavior:
+     * keep legacy virtio-pci enabled.
+     */
+    static GlobalProperty compat[] = {
+        { TYPE_VIRTIO_PCI, "disable-legacy", "off" },
+    };
     ccw_machine_11_1_class_options(mc);
+    compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
     compat_props_add(mc->compat_props, hw_compat_11_0, hw_compat_11_0_len);
 }
 DEFINE_CCW_MACHINE(11, 0);
Reviewed-by on v2 1/1
#3 lore raw

Re: [PATCH v2 1/1] hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+)

In reply to Jaehoon Kim
Quoted 23 lines · On Mon, 20 Apr 2026 09:47:34 -0500 Jaehoon Kim <[email protected]> wrote:

On the s390 Linux kernel, IO_SPACE_LIMIT has been 0 since the initial zPCI implementation (commit cd24834130ac "s390/pci: base support"), making I/O BARs unusable.

However, when virtio-pci devices operate in transitional mode, QEMU unconditionally exposes the legacy interface via BAR0. This results in firmware warnings during PCI enumeration, such as:

pci 0005:00:00.0: [Firmware Bug]: BAR 0: invalid; can't size

even though BAR0 is never usable on the s390 kernel.

Close this gap by disabling legacy virtio-pci support starting from machine version 11.1. This effectively makes virtio-pci devices non-transitional and prevents the creation of the unusable legacy I/O BAR.

This introduces s390x-specific global compatibility properties that set disable-legacy=on as the default for virtio-pci devices. Machine versions v11.0 and earlier set disable-legacy=off to maintain their original default behavior (legacy support enabled), ensuring VMs created with those versions continue to work identically.

Quoted 6 lines

Users can override the default on the command line if needed:
- On v11.1+: -global virtio-pci.disable-legacy=off (to enable legacy)
- On v11.0-: -global virtio-pci.disable-legacy=on (to disable legacy)

#4 lore raw

Re: [PATCH v2 1/1] hw/s390x/ccw: Disable legacy virtio-pci by default (v11.1+)

In reply to Jaehoon Kim
Quoted 27 lines · Jaehoon Kim

On the s390 Linux kernel, IO_SPACE_LIMIT has been 0 since the initial zPCI implementation (commit cd24834130ac "s390/pci: base support"), making I/O BARs unusable.

However, when virtio-pci devices operate in transitional mode, QEMU unconditionally exposes the legacy interface via BAR0. This results in firmware warnings during PCI enumeration, such as:

pci 0005:00:00.0: [Firmware Bug]: BAR 0: invalid; can't size

even though BAR0 is never usable on the s390 kernel.

Close this gap by disabling legacy virtio-pci support starting from machine version 11.1. This effectively makes virtio-pci devices non-transitional and prevents the creation of the unusable legacy I/O BAR.

This introduces s390x-specific global compatibility properties that set disable-legacy=on as the default for virtio-pci devices. Machine versions v11.0 and earlier set disable-legacy=off to maintain their original default behavior (legacy support enabled), ensuring VMs created with those versions continue to work identically.

Users can override the default on the command line if needed:
- On v11.1+: -global virtio-pci.disable-legacy=off (to enable legacy)
- On v11.0-: -global virtio-pci.disable-legacy=on (to disable legacy)

Quoted 5 lines
---
 hw/s390x/s390-virtio-ccw.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Thanks, queued to s390-next.