Skip to contentSkip to conversation

ramfb: Add property to control if load the romfile

PATCH Superseded Shaoqin Huang 3 participants 9 messages Jul 1, 2025 – Jul 2, 2025

v6 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v6 cover ramfb: Add property to control if load the romfile

Currently the ramfb device loads the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.

Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.

So add a new property use-legacy-x86-rom in both ramfb and vfio_pci device, because the vfio display also use the ramfb_setup() to load the vgabios-ramfb.bin file.

After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.

Then I set the use_legacy_x86_rom property to false by default, and only set it to true on x86 since only x86 will need it.

At the same time, set the "use-legacy-x86-rom" property to true on those historical versioned machine types in order to avoid the memory layout being changed.

Changelog:
---------
v5 -> v6:
- Set the property to true on those historical versioned machine types.
v4 -> v5:
- Fix some typo error.
- Set the property in piix machine type.
v3 -> v4:
- Set the new property to false by default, only set it to true on x86.
v2 -> v3:
- Fix the underscore error.
- Add a new patch to set the property in arm compatibility.
v1 -> v2:
- Change the property name.

v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Shaoqin Huang (2):
ramfb: Add property to control if load the romfile hw/i386: Add the ramfb romfile compatibility

 hw/core/machine.c             |  2 ++
 hw/display/ramfb-standalone.c |  4 +++-
 hw/display/ramfb-stubs.c      |  2 +-
 hw/display/ramfb.c            |  6 ++++--
 hw/i386/pc_piix.c             | 10 ++++++++++
 hw/i386/pc_q35.c              |  3 +++
 hw/vfio/display.c             |  4 ++--
 hw/vfio/pci.c                 |  1 +
 hw/vfio/pci.h                 |  1 +
 include/hw/display/ramfb.h    |  2 +-
 10 files changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v6 1/2 ramfb: Add property to control if load the romfile

Currently the ramfb device loads the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.

Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.

So add a new property use-legacy-x86-rom in both ramfb and vfio_pci device, because the vfio display also use the ramfb_setup() to load the vgabios-ramfb.bin file.

After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.

For now the default value is true but it will be turned off by default in subsequent patch when compats get properly handled.

---
 hw/display/ramfb-standalone.c | 4 +++-
 hw/display/ramfb-stubs.c      | 2 +-
 hw/display/ramfb.c            | 6 ++++--
 hw/vfio/display.c             | 4 ++--
 hw/vfio/pci.c                 | 1 +
 hw/vfio/pci.h                 | 1 +
 include/hw/display/ramfb.h    | 2 +-
 7 files changed, 13 insertions(+), 7 deletions(-)
hw/display/ramfb-standalone.c +3 -1
index 1be106b57f..af1175bf96 100644
@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {
     QemuConsole *con;
     RAMFBState *state;
     bool migrate;
+    bool use_legacy_x86_rom;
 };
 
 static void display_update_wrapper(void *dev)
@@ -39,7 +40,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)
     RAMFBStandaloneState *ramfb = RAMFB(dev);
 
     ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
-    ramfb->state = ramfb_setup(errp);
+    ramfb->state = ramfb_setup(ramfb->use_legacy_x86_rom, errp);
 }
 
 static bool migrate_needed(void *opaque)
@@ -62,6 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
 
 static const Property ramfb_properties[] = {
     DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, true),
 };
 
 static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/display/ramfb-stubs.c +1 -1
index cf64733b10..b83551357b 100644
@@ -8,7 +8,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s)
 {
 }
 
-RAMFBState *ramfb_setup(Error **errp)
+RAMFBState *ramfb_setup(bool romfile, Error **errp)
 {
     error_setg(errp, "ramfb support not available");
     return NULL;
hw/display/ramfb.c +4 -2
index 8c0f907673..9a17d97d07 100644
@@ -135,7 +135,7 @@ const VMStateDescription ramfb_vmstate = {
     }
 };
 
-RAMFBState *ramfb_setup(Error **errp)
+RAMFBState *ramfb_setup(bool romfile, Error **errp)
 {
     FWCfgState *fw_cfg = fw_cfg_find();
     RAMFBState *s;
@@ -147,7 +147,9 @@ RAMFBState *ramfb_setup(Error **errp)
 
     s = g_new0(RAMFBState, 1);
 
-    rom_add_vga("vgabios-ramfb.bin");
+    if (romfile) {
+        rom_add_vga("vgabios-ramfb.bin");
+    }
     fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
                              NULL, ramfb_fw_cfg_write, s,
                              &s->cfg, sizeof(s->cfg), false);
hw/vfio/display.c +2 -2
index ea87830fe0..8bfd8eb1e3 100644
@@ -365,7 +365,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
                                           &vfio_display_dmabuf_ops,
                                           vdev);
     if (vdev->enable_ramfb) {
-        vdev->dpy->ramfb = ramfb_setup(errp);
+        vdev->dpy->ramfb = ramfb_setup(vdev->use_legacy_x86_rom, errp);
         if (!vdev->dpy->ramfb) {
             return false;
         }
@@ -494,7 +494,7 @@ static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
                                           &vfio_display_region_ops,
                                           vdev);
     if (vdev->enable_ramfb) {
-        vdev->dpy->ramfb = ramfb_setup(errp);
+        vdev->dpy->ramfb = ramfb_setup(vdev->use_legacy_x86_rom, errp);
         if (!vdev->dpy->ramfb) {
             return false;
         }
hw/vfio/pci.c +1 -0
index 7f1532fbed..ff0d93fae0 100644
@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
 
 static const Property vfio_pci_dev_nohotplug_properties[] = {
     DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, true),
     DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                             ON_OFF_AUTO_AUTO),
 };
hw/vfio/pci.h +1 -0
index d94ecaba68..713956157e 100644
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {
     bool no_kvm_ioeventfd;
     bool no_vfio_ioeventfd;
     bool enable_ramfb;
+    bool use_legacy_x86_rom;
     OnOffAuto ramfb_migrate;
     bool defer_kvm_irq_routing;
     bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
index a7e0019144..172aa6dc89 100644
@@ -6,7 +6,7 @@
 /* ramfb.c */
 typedef struct RAMFBState RAMFBState;
 void ramfb_display_update(QemuConsole *con, RAMFBState *s);
-RAMFBState *ramfb_setup(Error **errp);
+RAMFBState *ramfb_setup(bool romfile, Error **errp);
 
 extern const VMStateDescription ramfb_vmstate;
 
Signature · 1 line
2.40.1
Reviewed-by on v6 1/2
#2 lore raw

Hi Shaoqin,

Quoted 12 lines · Shaoqin Huang

Currently the ramfb device loads the vgabios-ramfb.bin unconditionally, but only the x86 need the vgabios-ramfb.bin, this can cause that when use the release package on arm64 it can't find the vgabios-ramfb.bin.

Because only seabios will use the vgabios-ramfb.bin, load the rom logic is x86-specific. For other !x86 platforms, the edk2 ships an EFI driver for ramfb, so they don't need to load the romfile.

So add a new property use-legacy-x86-rom in both ramfb and vfio_pci device, because the vfio display also use the ramfb_setup() to load the vgabios-ramfb.bin file.

Quoted 7 lines

After have this property, the machine type can set the compatibility to not load the vgabios-ramfb.bin if the arch doesn't need it.

For now the default value is true but it will be turned off by default in subsequent patch when compats get properly handled.

Eric

Quoted 135 lines
---
 hw/display/ramfb-standalone.c | 4 +++-
 hw/display/ramfb-stubs.c      | 2 +-
 hw/display/ramfb.c            | 6 ++++--
 hw/vfio/display.c             | 4 ++--
 hw/vfio/pci.c                 | 1 +
 hw/vfio/pci.h                 | 1 +
 include/hw/display/ramfb.h    | 2 +-
 7 files changed, 13 insertions(+), 7 deletions(-)
hw/display/ramfb-standalone.c +3 -1
index 1be106b57f..af1175bf96 100644
@@ -17,6 +17,7 @@ struct RAMFBStandaloneState {
     QemuConsole *con;
     RAMFBState *state;
     bool migrate;
+    bool use_legacy_x86_rom;
 };
 
 static void display_update_wrapper(void *dev)
@@ -39,7 +40,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **errp)
     RAMFBStandaloneState *ramfb = RAMFB(dev);
 
     ramfb->con = graphic_console_init(dev, 0, &wrapper_ops, dev);
-    ramfb->state = ramfb_setup(errp);
+    ramfb->state = ramfb_setup(ramfb->use_legacy_x86_rom, errp);
 }
 
 static bool migrate_needed(void *opaque)
@@ -62,6 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
 
 static const Property ramfb_properties[] = {
     DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, true),
 };
 
 static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/display/ramfb-stubs.c +1 -1
index cf64733b10..b83551357b 100644
@@ -8,7 +8,7 @@ void ramfb_display_update(QemuConsole *con, RAMFBState *s)
 {
 }
 
-RAMFBState *ramfb_setup(Error **errp)
+RAMFBState *ramfb_setup(bool romfile, Error **errp)
 {
     error_setg(errp, "ramfb support not available");
     return NULL;
hw/display/ramfb.c +4 -2
index 8c0f907673..9a17d97d07 100644
@@ -135,7 +135,7 @@ const VMStateDescription ramfb_vmstate = {
     }
 };
 
-RAMFBState *ramfb_setup(Error **errp)
+RAMFBState *ramfb_setup(bool romfile, Error **errp)
 {
     FWCfgState *fw_cfg = fw_cfg_find();
     RAMFBState *s;
@@ -147,7 +147,9 @@ RAMFBState *ramfb_setup(Error **errp)
 
     s = g_new0(RAMFBState, 1);
 
-    rom_add_vga("vgabios-ramfb.bin");
+    if (romfile) {
+        rom_add_vga("vgabios-ramfb.bin");
+    }
     fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
                              NULL, ramfb_fw_cfg_write, s,
                              &s->cfg, sizeof(s->cfg), false);
hw/vfio/display.c +2 -2
index ea87830fe0..8bfd8eb1e3 100644
@@ -365,7 +365,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
                                           &vfio_display_dmabuf_ops,
                                           vdev);
     if (vdev->enable_ramfb) {
-        vdev->dpy->ramfb = ramfb_setup(errp);
+        vdev->dpy->ramfb = ramfb_setup(vdev->use_legacy_x86_rom, errp);
         if (!vdev->dpy->ramfb) {
             return false;
         }
@@ -494,7 +494,7 @@ static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
                                           &vfio_display_region_ops,
                                           vdev);
     if (vdev->enable_ramfb) {
-        vdev->dpy->ramfb = ramfb_setup(errp);
+        vdev->dpy->ramfb = ramfb_setup(vdev->use_legacy_x86_rom, errp);
         if (!vdev->dpy->ramfb) {
             return false;
         }
hw/vfio/pci.c +1 -0
index 7f1532fbed..ff0d93fae0 100644
@@ -3564,6 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
 
 static const Property vfio_pci_dev_nohotplug_properties[] = {
     DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, true),
     DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                             ON_OFF_AUTO_AUTO),
 };
hw/vfio/pci.h +1 -0
index d94ecaba68..713956157e 100644
@@ -177,6 +177,7 @@ struct VFIOPCIDevice {
     bool no_kvm_ioeventfd;
     bool no_vfio_ioeventfd;
     bool enable_ramfb;
+    bool use_legacy_x86_rom;
     OnOffAuto ramfb_migrate;
     bool defer_kvm_irq_routing;
     bool clear_parent_atomics_on_exit;
include/hw/display/ramfb.h +1 -1
index a7e0019144..172aa6dc89 100644
@@ -6,7 +6,7 @@
 /* ramfb.c */
 typedef struct RAMFBState RAMFBState;
 void ramfb_display_update(QemuConsole *con, RAMFBState *s);
-RAMFBState *ramfb_setup(Error **errp);
+RAMFBState *ramfb_setup(bool romfile, Error **errp);
 
 extern const VMStateDescription ramfb_vmstate;
 
#3 lore raw

PATCH v6 2/2 hw/i386: Add the ramfb romfile compatibility

In reply to Shaoqin Huang

Set the "use-legacy-x86-rom" property to false by default, and only set it to true on x86 since only x86 will need it.

At the same time, set the "use-legacy-x86-rom" property to true on those historical versioned machine types in order to avoid the memory layout being changed.

---
 hw/core/machine.c             |  2 ++
 hw/display/ramfb-standalone.c |  2 +-
 hw/i386/pc_piix.c             | 10 ++++++++++
 hw/i386/pc_q35.c              |  3 +++
 hw/vfio/pci.c                 |  2 +-
 5 files changed, 17 insertions(+), 2 deletions(-)
hw/core/machine.c +2 -0
index 63c6ef93d2..349aec1e0d 100644
@@ -46,6 +46,8 @@ GlobalProperty hw_compat_9_2[] = {
     { "migration", "multifd-clean-tls-termination", "false" },
     { "migration", "send-switchover-start", "off"},
     { "vfio-pci", "x-migration-multifd-transfer", "off" },
+    { "ramfb", "use-legacy-x86-rom", "true"},
+    { "vfio-pci", "use-legacy-x86-rom", "true" },
 };
 const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
 
hw/display/ramfb-standalone.c +1 -1
index af1175bf96..ddbf42f181 100644
@@ -63,7 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
 
 static const Property ramfb_properties[] = {
     DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, false),
 };
 
 static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/i386/pc_piix.c +10 -0
index 6c91e2d292..4a8bbc0e28 100644
@@ -49,6 +49,7 @@
 #include "hw/i2c/smbus_eeprom.h"
 #include "exec/memory.h"
 #include "hw/acpi/acpi.h"
+#include "hw/vfio/pci.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "system/xen.h"
@@ -77,6 +78,13 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 #endif
 
+static GlobalProperty pc_piix_compat_defaults[] = {
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },
+};
+static const size_t pc_piix_compat_defaults_len =
+    G_N_ELEMENTS(pc_piix_compat_defaults);
+
 /*
  * Return the global irq number corresponding to a given device irq
  * pin. We could also use the bus number to have a more precise mapping.
@@ -477,6 +485,8 @@ static void pc_i440fx_machine_options(MachineClass *m)
                                    pc_set_south_bridge);
     object_class_property_set_description(oc, "x-south-bridge",
                                      "Use a different south bridge than PIIX3");
+    compat_props_add(m->compat_props,
+                     pc_piix_compat_defaults, pc_piix_compat_defaults_len);
 }
 
 static void pc_i440fx_machine_10_0_options(MachineClass *m)
hw/i386/pc_q35.c +3 -0
index fd96d0345c..f6d89578d0 100644
@@ -45,6 +45,7 @@
 #include "hw/i386/pc.h"
 #include "hw/i386/amd_iommu.h"
 #include "hw/i386/intel_iommu.h"
+#include "hw/vfio/pci.h"
 #include "hw/virtio/virtio-iommu.h"
 #include "hw/display/ramfb.h"
 #include "hw/ide/pci.h"
@@ -67,6 +68,8 @@
 
 static GlobalProperty pc_q35_compat_defaults[] = {
     { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" },
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },
 };
 static const size_t pc_q35_compat_defaults_len =
     G_N_ELEMENTS(pc_q35_compat_defaults);
hw/vfio/pci.c +1 -1
index ff0d93fae0..a529500b70 100644
@@ -3564,7 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
 
 static const Property vfio_pci_dev_nohotplug_properties[] = {
     DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, false),
     DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                             ON_OFF_AUTO_AUTO),
 };
Signature · 1 line
2.40.1
#4 lore raw

Re: [PATCH v6 2/2] hw/i386: Add the ramfb romfile compatibility

Hi,

Quoted 21 lines · Shaoqin Huang

Set the "use-legacy-x86-rom" property to false by default, and only set it to true on x86 since only x86 will need it.

At the same time, set the "use-legacy-x86-rom" property to true on those historical versioned machine types in order to avoid the memory layout being changed.

---
 hw/core/machine.c             |  2 ++
 hw/display/ramfb-standalone.c |  2 +-
 hw/i386/pc_piix.c             | 10 ++++++++++
 hw/i386/pc_q35.c              |  3 +++
 hw/vfio/pci.c                 |  2 +-
 5 files changed, 17 insertions(+), 2 deletions(-)
hw/core/machine.c +0 -0
index 63c6ef93d2..349aec1e0d 100644

hw/core/machine.c GlobalProperty hw_compat_9_2[] = { · line 50

Quoted 5 lines
hw/core/machine.c +2 -0
@@ -46,6 +46,8 @@ GlobalProperty hw_compat_9_2[] = {
     { "migration", "multifd-clean-tls-termination", "false" },
     { "migration", "send-switchover-start", "off"},
     { "vfio-pci", "x-migration-multifd-transfer", "off" },
+    { "ramfb", "use-legacy-x86-rom", "true"},
+    { "vfio-pci", "use-legacy-x86-rom", "true" },

why 9.2? The 10.0 machine type should also apply the previous "true" default setting. To me the new default shall only affect the latest 10.1 machine type.

Quoted 64 lines
hw/core/machine.c +0 -0
 };
 const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
 
hw/display/ramfb-standalone.c +1 -1
index af1175bf96..ddbf42f181 100644
@@ -63,7 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
 
 static const Property ramfb_properties[] = {
     DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, false),
 };
 
 static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/i386/pc_piix.c +10 -0
index 6c91e2d292..4a8bbc0e28 100644
@@ -49,6 +49,7 @@
 #include "hw/i2c/smbus_eeprom.h"
 #include "exec/memory.h"
 #include "hw/acpi/acpi.h"
+#include "hw/vfio/pci.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "system/xen.h"
@@ -77,6 +78,13 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 #endif
 
+static GlobalProperty pc_piix_compat_defaults[] = {
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },
+};
+static const size_t pc_piix_compat_defaults_len =
+    G_N_ELEMENTS(pc_piix_compat_defaults);
+
 /*
  * Return the global irq number corresponding to a given device irq
  * pin. We could also use the bus number to have a more precise mapping.
@@ -477,6 +485,8 @@ static void pc_i440fx_machine_options(MachineClass *m)
                                    pc_set_south_bridge);
     object_class_property_set_description(oc, "x-south-bridge",
                                      "Use a different south bridge than PIIX3");
+    compat_props_add(m->compat_props,
+                     pc_piix_compat_defaults, pc_piix_compat_defaults_len);
 }
 
 static void pc_i440fx_machine_10_0_options(MachineClass *m)
hw/i386/pc_q35.c +1 -0
index fd96d0345c..f6d89578d0 100644
@@ -45,6 +45,7 @@
 #include "hw/i386/pc.h"
 #include "hw/i386/amd_iommu.h"
 #include "hw/i386/intel_iommu.h"
+#include "hw/vfio/pci.h"
 #include "hw/virtio/virtio-iommu.h"
 #include "hw/display/ramfb.h"
 #include "hw/ide/pci.h"

hw/i386/pc_q35.c line 72

Quoted 5 lines
hw/i386/pc_q35.c +2 -0
@@ -67,6 +68,8 @@
 
 static GlobalProperty pc_q35_compat_defaults[] = {
     { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" },
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },

I hope we do not omit any other machine that would actually need ramfb rom. At the moment we take care of q35 and piix. Anyone aware of any other user?

Thanks

Eric

Quoted 16 lines
hw/i386/pc_q35.c +0 -0
 };
 static const size_t pc_q35_compat_defaults_len =
     G_N_ELEMENTS(pc_q35_compat_defaults);
hw/vfio/pci.c +1 -1
index ff0d93fae0..a529500b70 100644
@@ -3564,7 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
 
 static const Property vfio_pci_dev_nohotplug_properties[] = {
     DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, false),
     DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                             ON_OFF_AUTO_AUTO),
 };
#5 lore raw

Re: [PATCH v6 2/2] hw/i386: Add the ramfb romfile compatibility

Hi Eric,

Thanks for your review.

Quoted 19 lines · Eric Auger

Hi,

Quoted 16 lines · Shaoqin Huang

Set the "use-legacy-x86-rom" property to false by default, and only set it to true on x86 since only x86 will need it.

At the same time, set the "use-legacy-x86-rom" property to true on those historical versioned machine types in order to avoid the memory layout being changed.

---
  hw/core/machine.c             |  2 ++
  hw/display/ramfb-standalone.c |  2 +-
  hw/i386/pc_piix.c             | 10 ++++++++++
  hw/i386/pc_q35.c              |  3 +++
  hw/vfio/pci.c                 |  2 +-
  5 files changed, 17 insertions(+), 2 deletions(-)
Quoted 13 lines

hw/core/machine.c GlobalProperty hw_compat_9_2[] = { · line 50

Quoted 10 lines
hw/core/machine.c +2 -0
index 63c6ef93d2..349aec1e0d 100644
@@ -46,6 +46,8 @@ GlobalProperty hw_compat_9_2[] = {
      { "migration", "multifd-clean-tls-termination", "false" },
      { "migration", "send-switchover-start", "off"},
      { "vfio-pci", "x-migration-multifd-transfer", "off" },
+    { "ramfb", "use-legacy-x86-rom", "true"},
+    { "vfio-pci", "use-legacy-x86-rom", "true" },

why 9.2? The 10.0 machine type should also apply the previous "true" default setting. To me the new default shall only affect the latest 10.1 machine type.

It seems what I understand is wrong, I thought the 9.2 is the historical machine type.

10.0 machine type is the current machine type, it also should be included into the historical machine type when we add the property.

ok I will update it again with add those property into 10.0 machine type.

Thanks

Quoted 93 lines
Quoted 64 lines
hw/core/machine.c +0 -0
  };
  const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
 
hw/display/ramfb-standalone.c +1 -1
index af1175bf96..ddbf42f181 100644
@@ -63,7 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
 
  static const Property ramfb_properties[] = {
      DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, use_legacy_x86_rom, false),
  };
 
  static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/i386/pc_piix.c +10 -0
index 6c91e2d292..4a8bbc0e28 100644
@@ -49,6 +49,7 @@
  #include "hw/i2c/smbus_eeprom.h"
  #include "exec/memory.h"
  #include "hw/acpi/acpi.h"
+#include "hw/vfio/pci.h"
  #include "qapi/error.h"
  #include "qemu/error-report.h"
  #include "system/xen.h"
@@ -77,6 +78,13 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
  static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
  #endif
 
+static GlobalProperty pc_piix_compat_defaults[] = {
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },
+};
+static const size_t pc_piix_compat_defaults_len =
+    G_N_ELEMENTS(pc_piix_compat_defaults);
+
  /*
   * Return the global irq number corresponding to a given device irq
   * pin. We could also use the bus number to have a more precise mapping.
@@ -477,6 +485,8 @@ static void pc_i440fx_machine_options(MachineClass *m)
                                     pc_set_south_bridge);
      object_class_property_set_description(oc, "x-south-bridge",
                                       "Use a different south bridge than PIIX3");
+    compat_props_add(m->compat_props,
+                     pc_piix_compat_defaults, pc_piix_compat_defaults_len);
  }
 
  static void pc_i440fx_machine_10_0_options(MachineClass *m)
hw/i386/pc_q35.c +1 -0
index fd96d0345c..f6d89578d0 100644
@@ -45,6 +45,7 @@
  #include "hw/i386/pc.h"
  #include "hw/i386/amd_iommu.h"
  #include "hw/i386/intel_iommu.h"
+#include "hw/vfio/pci.h"
  #include "hw/virtio/virtio-iommu.h"
  #include "hw/display/ramfb.h"
  #include "hw/ide/pci.h"

hw/i386/pc_q35.c line 72

Quoted 5 lines
hw/i386/pc_q35.c +2 -0
@@ -67,6 +68,8 @@
 
  static GlobalProperty pc_q35_compat_defaults[] = {
      { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" },
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },

I hope we do not omit any other machine that would actually need ramfb rom. At the moment we take care of q35 and piix. Anyone aware of any other user?

Thanks

Eric

Quoted 16 lines
hw/i386/pc_q35.c +0 -0
  };
  static const size_t pc_q35_compat_defaults_len =
      G_N_ELEMENTS(pc_q35_compat_defaults);
hw/vfio/pci.c +1 -1
index ff0d93fae0..a529500b70 100644
@@ -3564,7 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
 
  static const Property vfio_pci_dev_nohotplug_properties[] = {
      DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, use_legacy_x86_rom, false),
      DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                              ON_OFF_AUTO_AUTO),
  };
Signature · 1 line
Shaoqin
#6 lore raw

Re: [PATCH v6 2/2] hw/i386: Add the ramfb romfile compatibility

Hi Eric,

Quoted 38 lines · Shaoqin Huang

Hi Eric,

Thanks for your review.

Quoted 19 lines · Eric Auger

Hi,

Quoted 16 lines · Shaoqin Huang

Set the "use-legacy-x86-rom" property to false by default, and only set it to true on x86 since only x86 will need it.

At the same time, set the "use-legacy-x86-rom" property to true on those historical versioned machine types in order to avoid the memory layout being changed.

---
  hw/core/machine.c             |  2 ++
  hw/display/ramfb-standalone.c |  2 +-
  hw/i386/pc_piix.c             | 10 ++++++++++
  hw/i386/pc_q35.c              |  3 +++
  hw/vfio/pci.c                 |  2 +-

  5 files changed, 17 insertions(+), 2 deletions(-)
Quoted 13 lines

hw/core/machine.c GlobalProperty hw_compat_9_2[] = { · line 50

Quoted 10 lines
hw/core/machine.c +2 -0
index 63c6ef93d2..349aec1e0d 100644
@@ -46,6 +46,8 @@ GlobalProperty hw_compat_9_2[] = {
       { "migration", "multifd-clean-tls-termination", "false" },
       { "migration", "send-switchover-start", "off"},
       { "vfio-pci", "x-migration-multifd-transfer", "off" },
+    { "ramfb", "use-legacy-x86-rom", "true"},
+    { "vfio-pci", "use-legacy-x86-rom", "true" },

why 9.2? The 10.0 machine type should also apply the previous "true" default setting. To me the new default shall only affect the latest 10.1 machine type.

Quoted 7 lines

It seems what I understand is wrong, I thought the 9.2 is the historical machine type.

10.0 machine type is the current machine type, it also should be included into the historical machine type when we add the property.

ok I will update it again with add those property into 10.0 machine type.

Thanks

One more question, now the qemu doesn't have the hw_compat_10_1, should I first add another patch to add it just like the commit:
0a7c438a42 hw: add compat machines for 10.0

I think it should have the hw_compat_10_1 first, then I can add the property into it.

Thanks,
Shaoqin

Quoted 95 lines
Quoted 94 lines
Quoted 65 lines
hw/core/machine.c +0 -0
   };
   const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
hw/display/ramfb-standalone.c +1 -1
index af1175bf96..ddbf42f181 100644
@@ -63,7 +63,7 @@ static const VMStateDescription ramfb_dev_vmstate = {
   static const Property ramfb_properties[] = {
       DEFINE_PROP_BOOL("x-migrate", RAMFBStandaloneState, migrate,  true),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, 
 use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", RAMFBStandaloneState, 
 use_legacy_x86_rom, false),
   };
   static void ramfb_class_initfn(ObjectClass *klass, void *data)
hw/i386/pc_piix.c +10 -0
index 6c91e2d292..4a8bbc0e28 100644
@@ -49,6 +49,7 @@
   #include "hw/i2c/smbus_eeprom.h"
   #include "exec/memory.h"
   #include "hw/acpi/acpi.h"
+#include "hw/vfio/pci.h"
   #include "qapi/error.h"
   #include "qemu/error-report.h"
   #include "system/xen.h"
@@ -77,6 +78,13 @@ static const int ide_iobase2[MAX_IDE_BUS] = 
 { 0x3f6, 0x376 };
   static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
   #endif
+static GlobalProperty pc_piix_compat_defaults[] = {
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },
+};
+static const size_t pc_piix_compat_defaults_len =
+    G_N_ELEMENTS(pc_piix_compat_defaults);
+
   /*
    * Return the global irq number corresponding to a given device irq
    * pin. We could also use the bus number to have a more precise mapping.
@@ -477,6 +485,8 @@ static void 
 pc_i440fx_machine_options(MachineClass *m)
                                      pc_set_south_bridge);
       object_class_property_set_description(oc, "x-south-bridge",
                                        "Use a different south bridge than PIIX3");
+    compat_props_add(m->compat_props,
+                     pc_piix_compat_defaults, 
 pc_piix_compat_defaults_len);
   }

  static void pc_i440fx_machine_10_0_options(MachineClass *m)

hw/i386/pc_q35.c +1 -0
index fd96d0345c..f6d89578d0 100644
@@ -45,6 +45,7 @@
   #include "hw/i386/pc.h"
   #include "hw/i386/amd_iommu.h"
   #include "hw/i386/intel_iommu.h"
+#include "hw/vfio/pci.h"
   #include "hw/virtio/virtio-iommu.h"
   #include "hw/display/ramfb.h"
   #include "hw/ide/pci.h"

hw/i386/pc_q35.c line 71

Quoted 4 lines
hw/i386/pc_q35.c +2 -0
@@ -67,6 +68,8 @@
   static GlobalProperty pc_q35_compat_defaults[] = {
       { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" },
+    { TYPE_RAMFB_DEVICE, "use-legacy-x86-rom", "true" },
+    { TYPE_VFIO_PCI, "use-legacy-x86-rom", "true" },

I hope we do not omit any other machine that would actually need ramfb rom. At the moment we take care of q35 and  piix. Anyone aware of any other user?

Thanks

Eric

Quoted 17 lines
hw/i386/pc_q35.c +0 -0
   };

  static const size_t pc_q35_compat_defaults_len = G_N_ELEMENTS(pc_q35_compat_defaults);

hw/vfio/pci.c +1 -1
index ff0d93fae0..a529500b70 100644
@@ -3564,7 +3564,7 @@ static const TypeInfo vfio_pci_dev_info = {
   static const Property vfio_pci_dev_nohotplug_properties[] = {
       DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false),
-    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, 
 use_legacy_x86_rom, true),
+    DEFINE_PROP_BOOL("use-legacy-x86-rom", VFIOPCIDevice, 
 use_legacy_x86_rom, false),
       DEFINE_PROP_ON_OFF_AUTO("x-ramfb-migrate", VFIOPCIDevice, ramfb_migrate,
                               ON_OFF_AUTO_AUTO),

  };

Signature · 1 line
Shaoqin
#7 lore raw

Re: [PATCH v6 2/2] hw/i386: Add the ramfb romfile compatibility

Quoted 3 lines

One more question, now the qemu doesn't have the hw_compat_10_1, should I first add another patch to add it just like the commit:
0a7c438a42 hw: add compat machines for 10.0

Hi Shaoqin, I think you can add compat option in hw_compat_10_0. Then the compat property will be applied for v10.0 and before. And you can find v10.1 won't be affected by compat option you set.

You can test this with "-machine pc-q35-10.0" or older, with "-machine pc-q35" or "-machine pc-q35-10.1".

Quoted 2 lines

I think it should have the hw_compat_10_1 first, then I can add the property into it.

This hw_compat_10_1 will be added when v10.1 is realeased.

Thanks,
Zhao

#8 lore raw

Re: [PATCH v6 2/2] hw/i386: Add the ramfb romfile compatibility

Hi Zhao,

Quoted 11 lines · Zhao Liu
Quoted 3 lines

One more question, now the qemu doesn't have the hw_compat_10_1, should I first add another patch to add it just like the commit:
0a7c438a42 hw: add compat machines for 10.0

Hi Shaoqin, I think you can add compat option in hw_compat_10_0. Then the compat property will be applied for v10.0 and before. And you can find v10.1 won't be affected by compat option you set.

You can test this with "-machine pc-q35-10.0" or older, with "-machine pc-q35" or "-machine pc-q35-10.1".

Thanks for your explaination, it helps a lot.

Thanks,
Shaoqin

Quoted 8 lines
Quoted 2 lines

I think it should have the hw_compat_10_1 first, then I can add the property into it.

This hw_compat_10_1 will be added when v10.1 is realeased.

Thanks,
Zhao

Signature · 1 line
Shaoqin