@samitouri / QOSamiQemu / commits / 26103c13cf

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) Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com> Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr> Reviewed-by: Halil Pasic <pasic@linux.ibm.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> Message-ID: <20260420144759.2970726-2-jhkim@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Jaehoon Kim committed Apr 20, 2026 at 09:47 UTC 26103c13cff0178f4ad981293041561ec4180673
1 file changed +26
hw/s390x/s390-virtio-ccw.c
+26
@@ -788,6 +788,21 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
788 g_free(val);
789 }
790
791 + /*
792 + * S390x-specific global compatibility properties.
793 + *
794 + * On the s390 kernel, legacy virtio-pci is not usable because I/O BARs
795 + * are not supported (IO_SPACE_LIMIT is 0), and would only result in
796 + * unusable BARs and firmware warnings.
797 + *
798 + * Therefore, starting from v11.1, disable legacy virtio-pci by default,
799 + * while older machine types keep legacy behavior for compatibility.
800 + */
801 +static GlobalProperty hw_compat_s390x[] = {
802 + { TYPE_VIRTIO_PCI, "disable-legacy", "on", .optional = true},
803 +};
804 +static const size_t hw_compat_s390x_len = G_N_ELEMENTS(hw_compat_s390x);
805 +
806 static void ccw_machine_class_init(ObjectClass *oc, const void *data)
807 {
808 MachineClass *mc = MACHINE_CLASS(oc);
@@ -878,6 +893,9 @@ static const TypeInfo ccw_machine_info = {
893 const void *data) \
894 { \
895 MachineClass *mc = MACHINE_CLASS(oc); \
896 + /* Apply global s390x-wide default properties */ \
897 + compat_props_add(mc->compat_props, hw_compat_s390x, \
898 + hw_compat_s390x_len); \
899 MACHINE_VER_SYM(class_options, ccw, __VA_ARGS__)(mc); \
900 mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \
901 mc->init = MACHINE_VER_SYM(mach_init, ccw, __VA_ARGS__); \
@@ -923,7 +941,15 @@ static void ccw_machine_11_0_instance_options(MachineState *machine)
941
942 static void ccw_machine_11_0_class_options(MachineClass *mc)
943 {
944 + /*
945 + * Preserve v11.0 and older version behavior:
946 + * keep legacy virtio-pci enabled.
947 + */
948 + static GlobalProperty compat[] = {
949 + { TYPE_VIRTIO_PCI, "disable-legacy", "off" },
950 + };
951 ccw_machine_11_1_class_options(mc);
952 + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
953 compat_props_add(mc->compat_props, hw_compat_11_0, hw_compat_11_0_len);
954 }
955 DEFINE_CCW_MACHINE(11, 0);