Skip to content

Commit a7a3784

Browse files
akihikodakiphilmd
authored andcommitted
hw/pci: Use -1 as the default value for rombar
vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1 by checking dev->opts, bypassing the QOM property infrastructure. Use -1 as the default value for rombar to tell if the user explicitly set it to 1. The property is also converted from unsigned to signed. -1 is signed so it is safe to give it a new meaning. The values in [2 ^ 31, 2 ^ 32) become invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster <[email protected]> Signed-off-by: Akihiko Odaki <[email protected]> Reviewed-by: Markus Armbruster <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
1 parent 3f8bcbb commit a7a3784

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

hw/pci/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static const Property pci_props[] = {
8585
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
8686
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
8787
DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX),
88-
DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
88+
DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1),
8989
DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
9090
QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
9191
DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present,

hw/vfio/pci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
10121012
{
10131013
uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
10141014
off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
1015-
DeviceState *dev = DEVICE(vdev);
10161015
char *name;
10171016
int fd = vdev->vbasedev.fd;
10181017

@@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
10461045
}
10471046

10481047
if (vfio_opt_rom_in_denylist(vdev)) {
1049-
if (dev->opts && qdict_haskey(dev->opts, "rombar")) {
1048+
if (vdev->pdev.rom_bar > 0) {
10501049
warn_report("Device at %s is known to cause system instability"
10511050
" issues during option rom execution",
10521051
vdev->vbasedev.name);
10531052
error_printf("Proceeding anyway since user specified"
1054-
" non zero value for rombar\n");
1053+
" positive value for rombar\n");
10551054
} else {
10561055
warn_report("Rom loading for device at %s has been disabled"
10571056
" due to system instability issues",

include/hw/pci/pci_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct PCIDevice {
148148
uint32_t romsize;
149149
bool has_rom;
150150
MemoryRegion rom;
151-
uint32_t rom_bar;
151+
int32_t rom_bar;
152152

153153
/* INTx routing notifier */
154154
PCIINTxRoutingNotifier intx_routing_notifier;

0 commit comments

Comments
 (0)