hw/boards: Remove legacy MachineClass::pci_allow_0_address flag
Subsystems (2)
v2 cover hw/boards: Remove legacy MachineClass::pci_allow_0_address flag
Since v1:
- Looked at previous analysis from Peter [1]
- Invert logic so "allow address 0 accesses" is default
---
This series aims to remove a legacy field from MachineClass. Why? Because it doesn't scale on heterogeneous machine where different host bridges are created.
Rather than a global exposed to all machines, use a pci-bus specific flag on each machine requiring it, propagated by the host bridge device.
No logical change intended, only machines previously using pci_allow_0_address do not set refuse-bar-at-addr-0.
Presumably various machines neither need to set this 'refuse-bar-at-addr-0' flag, but updating that is deferred to each machine maintainer since I don't have the knowledge and sufficient test suite IMHO.
[1] https://lore.kernel.org/qemu-devel/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/T/#u
Philippe Mathieu-Daudé (13):
hw/pci: Do not declare PCIBus::flags mask as enum hw/pci-bridge: Initialize bridge with parent bus flags hw/pci: Factor machine_refuses_bar_at_addr_0() helper out hw/pci: Introduce PCIBusFlag::PCI_BUS_BAR_AT_ADDR0_REFUSED hw/pci: Propagate bar_at_addr_0_refused to
pci_root_bus_internal_init()
hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_init() hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_new() hw/pci: Propagate bar_at_addr_0_refused to pci_register_root_bus() hw/ppc/spapr: Create host bridge setting bar_at_addr_0_refused=false hw/pci-host/gpex: Expose 'refuse-bar-at-addr-0' property hw/arm/virt: Create GPEX host bridge without refuse-bar-at-addr-0 hw/riscv/virt: Create GPEX host bridge without refuse-bar-at-addr-0 hw/pci/pci: Remove legacy MachineClass::pci_allow_0_address flag
include/hw/boards.h | 1 - include/hw/pci-host/gpex.h | 1 + include/hw/pci/pci.h | 8 +++++--- include/hw/pci/pci_bus.h | 10 ++++++++-- hw/alpha/typhoon.c | 2 +- hw/arm/sbsa-ref.c | 1 - hw/arm/virt.c | 1 - hw/i386/microvm.c | 2 ++ hw/loongarch/virt.c | 2 ++ hw/mips/loongson3_virt.c | 2 ++ hw/openrisc/virt.c | 2 ++ hw/pci-bridge/pci_expander_bridge.c | 17 +++++++++++----- hw/pci-host/articia.c | 3 ++- hw/pci-host/astro.c | 3 ++- hw/pci-host/bonito.c | 2 +- hw/pci-host/designware.c | 2 +- hw/pci-host/dino.c | 2 +- hw/pci-host/gpex.c | 5 ++++- hw/pci-host/grackle.c | 2 +- hw/pci-host/gt64120.c | 2 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/mv64361.c | 2 +- hw/pci-host/pnv_phb3.c | 2 +- hw/pci-host/pnv_phb4.c | 2 +- hw/pci-host/ppc440_pcix.c | 2 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 3 ++- hw/pci-host/q35.c | 2 +- hw/pci-host/raven.c | 2 +- hw/pci-host/remote.c | 2 +- hw/pci-host/sabre.c | 2 +- hw/pci-host/sh_pci.c | 2 +- hw/pci-host/uninorth.c | 8 ++++---- hw/pci-host/versatile.c | 2 +- hw/pci-host/xilinx-pcie.c | 2 +- hw/pci/pci.c | 31 ++++++++++++++++++----------- hw/pci/pci_bridge.c | 1 + hw/ppc/ppc440_uc.c | 2 +- hw/ppc/spapr.c | 1 - hw/ppc/spapr_pci.c | 2 +- hw/riscv/virt.c | 1 - hw/s390x/s390-pci-bus.c | 2 +- hw/xen/xen-pvh-common.c | 2 ++ hw/xtensa/virt.c | 2 ++ 44 files changed, 94 insertions(+), 57 deletions(-)
Signature · 1 line
2.45.2
PATCH v2 1/13 hw/pci: Do not declare PCIBus::flags mask as enum
We use PCIBus::flags to mask various flags. It is not an enum, and doing so confuses static analyzers. Rename the enum as singular. Use a generic unsigned type for the mask.
--- include/hw/pci/pci_bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/hw/pci/pci_bus.h +2 -2
@@ -19,7 +19,7 @@ struct PCIBusClass {uint16_t (*numa_node)(PCIBus *bus); }; -enum PCIBusFlags { +enum PCIBusFlag {/* This bus is the root of a PCI domain */ PCI_BUS_IS_ROOT =0x0001 ,/* PCIe extended configuration space is accessible on this bus */
@@ -32,7 +32,7 @@ enum PCIBusFlags {struct PCIBus {BusState qbus; -enum PCIBusFlags flags; +unsigned flags;const PCIIOMMUOps *iommu_ops;void *iommu_opaque;uint8_t devfn_min;
Signature · 1 line
2.45.2
Re: [PATCH-for-10.0 v2 01/13] hw/pci: Do not declare PCIBus::flags mask as enum
Quoted 15 lines · Philippe Mathieu-Daudé
We use
PCIBus::flagsto mask various flags. It is not an enum, and doing so confuses static analyzers. Rename the enum as singular. Use a generic unsigned type for the mask.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/pci/pci_bus.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/hw/pci/pci_bus.h +0
-0
include/hw/pci/pci_bus.h struct PCIBusClass { · line 25
Quoted 8 lines
include/hw/pci/pci_bus.h +1
-1@@ -19,7 +19,7 @@ struct PCIBusClass {uint16_t (*numa_node)(PCIBus *bus); }; -enum PCIBusFlags { +enum PCIBusFlag {/* This bus is the root of a PCI domain */ PCI_BUS_IS_ROOT =0x0001 ,/* PCIe extended configuration space is accessible on this bus */
(more diff context:)
PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002,
/* This is a CXL Type BUS */
PCI_BUS_CXL = 0x0004,Enum would be the [0, 1, 2] bits. Since we define bitmask and use bitmask arguments in the code, shouldn't we simply replace that enum by #define?
Quoted 9 lines
include/hw/pci/pci_bus.h +1
-1@@ -32,7 +32,7 @@ enum PCIBusFlags {struct PCIBus {BusState qbus; -enum PCIBusFlags flags; +unsigned flags;const PCIIOMMUOps *iommu_ops;void *iommu_opaque;uint8_t devfn_min;
Re: [PATCH-for-10.0 v2 01/13] hw/pci: Do not declare PCIBus::flags mask as enum
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Philippe Mathieu-Daudé
We use
PCIBus::flagsto mask various flags. It is not an enum, and doing so confuses static analyzers. Rename the enum as singular. Use a generic unsigned type for the mask.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/hw/pci/pci_bus.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)include/hw/pci/pci_bus.h +0
-0include/hw/pci/pci_bus.h struct PCIBusClass { · line 24
Quoted 7 lines
include/hw/pci/pci_bus.h +1
-1@@ -19,7 +19,7 @@ struct PCIBusClass { uint16_t (*numa_node)(PCIBus *bus); }; -enum PCIBusFlags { +enum PCIBusFlag { /* This bus is the root of a PCI domain */ PCI_BUS_IS_ROOT = 0x0001, /* PCIe extended configuration space is accessible on this bus */(more diff context:)
Quoted 7 lines
PCI_BUS_EXTENDED_CONFIG_SPACE =
0x0002, /* This is a CXL Type BUS */
PCI_BUS_CXL =0x0004,Enum would be the [0, 1, 2] bits. Since we define bitmask and use bitmask arguments in the code, shouldn't we simply replace that enum by #define?
Agreed, this rather sounds like #defines than an enum to me, too.
Thomas
PATCH v2 2/13 hw/pci-bridge: Initialize bridge with parent bus flags
In reply to Philippe Mathieu-DaudéBridged buses inherit their parent flag,
except they can not be a root.
--- hw/pci-bridge/pci_expander_bridge.c | 8 ++++++-- hw/pci/pci_bridge.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
hw/pci-bridge/pci_expander_bridge.c +6 -2
@@ -336,6 +336,7 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type,PXBDev *pxb =PXB_DEV (dev);DeviceState *ds, *bds =NULL ;PCIBus *bus; +PCIBus *parent_bus =pci_get_bus (dev);const char *dev_name =NULL ;Error *local_err =NULL ;MachineState *ms =MACHINE (qdev_get_machine ());
@@ -358,12 +359,15 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, ds =qdev_new (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST );if (type ==PCIE ) { bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_PCIE_BUS ); + bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; }else if (type ==CXL ) { bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_CXL_BUS ); + bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; bus->flags |=PCI_BUS_CXL ;PXB_CXL_DEV (dev)->cxl_host_bridge =PXB_CXL_HOST (ds); }else { bus =pci_root_bus_new (ds,"pxb-internal" ,NULL ,NULL ,0 ,TYPE_PXB_BUS ); + bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; bds =qdev_new ("pci-bridge" ); bds->id =g_strdup (dev_name);qdev_prop_set_uint8 (bds,PCI_BRIDGE_DEV_PROP_CHASSIS_NR , pxb->bus_nr);
@@ -371,8 +375,8 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, } bus->parent_dev = dev; - bus->address_space_mem =pci_get_bus (dev)->address_space_mem; - bus->address_space_io =pci_get_bus (dev)->address_space_io; + bus->address_space_mem = parent_bus->address_space_mem; + bus->address_space_io = parent_bus->address_space_io; bus->map_irq = pxb_map_irq_fn;PCI_HOST_BRIDGE (ds)->bus = bus;
hw/pci/pci_bridge.c +1 -0
@@ -376,6 +376,7 @@ void pci_bridge_initfn(PCIDevice *dev, const char *typename)qbus_init (sec_bus,sizeof (br->sec_bus), typename,DEVICE (dev), br->bus_name); + sec_bus->flags = parent->flags & ~PCI_BUS_IS_ROOT ; sec_bus->parent_dev = dev; sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn; sec_bus->address_space_mem = &br->address_space_mem;
Signature · 1 line
2.45.2
PATCH v2 3/13 hw/pci: Factor machine_refuses_bar_at_addr_0() helper out
In reply to Philippe Mathieu-DaudéSince we are going to re-use access to the MachineClass::pci_allow_0_address field, factor the current code as a new machine_refuses_bar_at_addr_0() helper. In pci_bar_address() invert 'allow_0_address' logic as 'bar_at_addr_0_refused'.
--- hw/pci/pci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
hw/pci/pci.c +10 -4
@@ -520,6 +520,13 @@ bool pci_bus_bypass_iommu(PCIBus *bus)return host_bridge->bypass_iommu; } +static bool machine_refuses_bar_at_addr_0 (void ) +{ +MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); + +return !mc->pci_allow_0_address; +} +static void pci_root_bus_internal_init (PCIBus *bus,DeviceState *parent,MemoryRegion *mem,MemoryRegion *io,uint8_t devfn_min)
@@ -1472,8 +1479,7 @@ pcibus_t pci_bar_address(PCIDevice *d, {pcibus_t new_addr, last_addr;uint16_t cmd =pci_get_word (d->config +PCI_COMMAND ); -MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); -bool allow_0_address = mc->pci_allow_0_address; +bool bar_at_addr_0_refused =machine_refuses_bar_at_addr_0 ();if (type &PCI_BASE_ADDRESS_SPACE_IO ) {if (!(cmd &PCI_COMMAND_IO )) {
@@ -1485,7 +1491,7 @@ pcibus_t pci_bar_address(PCIDevice *d,* TODO: make priorities correct and remove this work around. */ if (last_addr <= new_addr || last_addr >=UINT32_MAX || - (!allow_0_address && new_addr ==0 )) { + (bar_at_addr_0_refused && new_addr ==0 )) {return PCI_BAR_UNMAPPED ; }return new_addr;
@@ -1506,7 +1512,7 @@ pcibus_t pci_bar_address(PCIDevice *d,mappings, we handle specific values as invalid mappings. */ if (last_addr <= new_addr || last_addr ==PCI_BAR_UNMAPPED || - (!allow_0_address && new_addr ==0 )) { + (bar_at_addr_0_refused && new_addr ==0 )) {return PCI_BAR_UNMAPPED ; }
Signature · 1 line
2.45.2
PATCH v2 4/13 hw/pci: Introduce PCIBusFlag::PCI_BUS_BAR_AT_ADDR0_REFUSED
In reply to Philippe Mathieu-DaudéSome machines need PCI buses to allow access at BAR0. Introduce the PCI_BUS_BAR_AT_ADDR0_REFUSED flag and the pci_bus_refuse_bar_at_addr_0() helper. Set the flag in pci_root_bus_internal_init() where all root buses are created.
--- include/hw/pci/pci_bus.h | 6 ++++++ hw/pci/pci.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/hw/pci/pci_bus.h +6 -0
@@ -26,6 +26,7 @@ enum PCIBusFlag {PCI_BUS_EXTENDED_CONFIG_SPACE =0x0002 ,/* This is a CXL Type BUS */ PCI_BUS_CXL =0x0004 , + PCI_BUS_BAR_AT_ADDR0_REFUSED = 0x0008, };#define PCI_NO_PASID UINT32_MAX
@@ -72,4 +73,9 @@ static inline bool pci_bus_allows_extended_config_space(PCIBus *bus) return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE); } +static inline bool pci_bus_refuse_bar_at_addr_0 (PCIBus *bus) +{ +return !!(bus->flags &PCI_BUS_BAR_AT_ADDR0_REFUSED ); +} +#endif /* QEMU_PCI_BUS_H */
hw/pci/pci.c +4 -1
@@ -537,6 +537,9 @@ static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, bus->address_space_mem = mem; bus->address_space_io = io; bus->flags |=PCI_BUS_IS_ROOT ; +if (machine_refuses_bar_at_addr_0 ()) { + bus->flags |=PCI_BUS_BAR_AT_ADDR0_REFUSED ; + }/* host bridge */ QLIST_INIT (&bus->child);
@@ -1479,7 +1482,7 @@ pcibus_t pci_bar_address(PCIDevice *d, {pcibus_t new_addr, last_addr;uint16_t cmd =pci_get_word (d->config +PCI_COMMAND ); -bool bar_at_addr_0_refused =machine_refuses_bar_at_addr_0 (); +bool bar_at_addr_0_refused =pci_bus_refuse_bar_at_addr_0 (pci_get_bus (d));if (type &PCI_BASE_ADDRESS_SPACE_IO ) {if (!(cmd &PCI_COMMAND_IO )) {
Signature · 1 line
2.45.2
PATCH v2 5/13 hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_internal_init()
In reply to Philippe Mathieu-DaudéHave pci_root_bus_internal_init() callers set the 'bar_at_addr_0_refused' argument. No logical change.
--- hw/pci/pci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/pci/pci.c +7 -4
@@ -529,7 +529,8 @@ static bool machine_refuses_bar_at_addr_0(void)static void pci_root_bus_internal_init (PCIBus *bus,DeviceState *parent,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min) +uint8_t devfn_min, +bool bar_at_addr_0_refused) {assert (PCI_FUNC (devfn_min) ==0 ); bus->devfn_min = devfn_min;
@@ -537,7 +538,7 @@ static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, bus->address_space_mem = mem; bus->address_space_io = io; bus->flags |=PCI_BUS_IS_ROOT ; -if (machine_refuses_bar_at_addr_0 ()) { +if (bar_at_addr_0_refused &&machine_refuses_bar_at_addr_0 ()) { bus->flags |=PCI_BUS_BAR_AT_ADDR0_REFUSED ; }
@@ -563,7 +564,8 @@ void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent, uint8_t devfn_min, const char *typename) {qbus_init (bus ,bus_size ,typename ,parent ,name ); -pci_root_bus_internal_init (bus, parent, mem, io, devfn_min); +pci_root_bus_internal_init (bus, parent, mem, io, devfn_min, + true); } PCIBus *pci_root_bus_new(DeviceState *parent, const char *name,
@@ -573,7 +575,8 @@ PCIBus *pci_root_bus_new(DeviceState *parent, const char *name,PCIBus *bus; bus =PCI_BUS (qbus_new (typename, parent, name)); -pci_root_bus_internal_init (bus, parent, mem, io, devfn_min); +pci_root_bus_internal_init (bus, parent, mem, io, devfn_min, + true);return bus; }
Signature · 1 line
2.45.2
Re: [PATCH-for-10.0 v2 05/13] hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_internal_init()
Quoted 24 lines · Philippe Mathieu-Daudé
Have
pci_root_bus_internal_init()callers set the 'bar_at_addr_0_refused' argument. No logical change.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/pci/pci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)hw/pci/pci.c +2
-1@@ -529,7 +529,8 @@ static bool machine_refuses_bar_at_addr_0(void)static void pci_root_bus_internal_init (PCIBus *bus,DeviceState *parent,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min) +uint8_t devfn_min, +bool bar_at_addr_0_refused) {assert (PCI_FUNC (devfn_min) ==0 ); bus->devfn_min = devfn_min;
hw/pci/pci.c static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, · line 541
Quoted 5 lines
hw/pci/pci.c +1
-1@@ -537,7 +538,7 @@ static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, bus->address_space_mem = mem; bus->address_space_io = io; bus->flags |=PCI_BUS_IS_ROOT ; -if (machine_refuses_bar_at_addr_0 ()) { +if (bar_at_addr_0_refused &&machine_refuses_bar_at_addr_0 ()) {
Should this be || rather than && ? If I understand the intent correctly, we want to prevent a BAR at address 0 if either:
* the MachineClass field says we don't want one (legacy handling, eventually goes away)
* the new command line argument says we don't want one
rather than only if *both* say "no address 0" ?
thanks
-- PMM
Re: [PATCH-for-10.0 v2 05/13] hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_internal_init()
Quoted 38 lines · Peter Maydell
Quoted 24 lines · Philippe Mathieu-Daudé
Have
pci_root_bus_internal_init()callers set the 'bar_at_addr_0_refused' argument. No logical change.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/pci/pci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)hw/pci/pci.c +2
-1@@ -529,7 +529,8 @@ static bool machine_refuses_bar_at_addr_0(void)static void pci_root_bus_internal_init (PCIBus *bus,DeviceState *parent,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min) +uint8_t devfn_min, +bool bar_at_addr_0_refused) {assert (PCI_FUNC (devfn_min) ==0 ); bus->devfn_min = devfn_min;hw/pci/pci.c static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, · line 541
Quoted 5 lines
hw/pci/pci.c +1
-1@@ -537,7 +538,7 @@ static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, bus->address_space_mem = mem; bus->address_space_io = io; bus->flags |=PCI_BUS_IS_ROOT ; -if (machine_refuses_bar_at_addr_0 ()) { +if (bar_at_addr_0_refused &&machine_refuses_bar_at_addr_0 ()) {Should this be || rather than && ? If I understand the intent correctly, we want to prevent a BAR at address 0 if either:
* the MachineClass field says we don't want one (legacy handling, eventually goes away)
* the new command line argument says we don't want one
Quoted 1 line
rather than only if *both* say "no address 0" ?
Oops :)
Quoted 3 lines
thanks
-- PMM
PATCH v2 6/13 hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_init()
In reply to Philippe Mathieu-DaudéHave pci_root_bus_init() callers set the 'bar_at_addr_0_refused' argument. No logical change.
--- include/hw/pci/pci.h | 3 ++- hw/pci-host/raven.c | 2 +- hw/pci-host/versatile.c | 2 +- hw/pci/pci.c | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-)
include/hw/pci/pci.h +2 -1
@@ -284,7 +284,8 @@ bool pci_bus_is_express(const PCIBus *bus);void pci_root_bus_init (PCIBus *bus,size_t bus_size,DeviceState *parent,const char *name,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min,const char *typename); +uint8_t devfn_min,const char *typename, +bool bar_at_addr_0_refused);PCIBus *pci_root_bus_new (DeviceState *parent,const char *name,MemoryRegion *mem,MemoryRegion *io,uint8_t devfn_min,const char *typename);
hw/pci-host/raven.c +1 -1
@@ -313,7 +313,7 @@ static void raven_pcihost_initfn(Object *obj) &s->pci_io_non_contiguous, 1);memory_region_add_subregion (address_space_mem,0xc0000000 , &s->pci_memory);pci_root_bus_init (&s->pci_bus,sizeof (s->pci_bus),DEVICE (obj),NULL , - &s->pci_memory, &s->pci_io,0 ,TYPE_PCI_BUS ); + &s->pci_memory, &s->pci_io,0 ,TYPE_PCI_BUS , true);/* Bus master address space */ memory_region_init (&s->bm, obj,"bm-raven" ,4 * GiB);
hw/pci-host/versatile.c +1 -1
@@ -407,7 +407,7 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp)pci_root_bus_init (&s->pci_bus,sizeof (s->pci_bus), dev,"pci" , &s->pci_mem_space, &s->pci_io_space, -PCI_DEVFN (11 ,0 ),TYPE_PCI_BUS ); +PCI_DEVFN (11 ,0 ),TYPE_PCI_BUS , true); h->bus = &s->pci_bus;object_initialize (&s->pci_dev,sizeof (s->pci_dev),TYPE_VERSATILE_PCI_HOST );
hw/pci/pci.c +3 -2
@@ -561,11 +561,12 @@ bool pci_bus_is_express(const PCIBus *bus)void pci_root_bus_init (PCIBus *bus,size_t bus_size,DeviceState *parent,const char *name,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min,const char *typename) +uint8_t devfn_min,const char *typename, +bool bar_at_addr_0_refused) {qbus_init (bus, bus_size, typename, parent, name);pci_root_bus_internal_init (bus, parent, mem, io, devfn_min, - true); + bar_at_addr_0_refused); } PCIBus *pci_root_bus_new(DeviceState *parent, const char *name,
Signature · 1 line
2.45.2
PATCH v2 7/13 hw/pci: Propagate bar_at_addr_0_refused to pci_root_bus_new()
In reply to Philippe Mathieu-DaudéHave pci_root_bus_new() callers set the 'bar_at_addr_0_refused' argument. No logical change.
--- include/hw/pci/pci.h | 3 ++- hw/pci-bridge/pci_expander_bridge.c | 9 ++++++--- hw/pci-host/gt64120.c | 2 +- hw/pci-host/i440fx.c | 2 +- hw/pci-host/q35.c | 2 +- hw/pci-host/remote.c | 2 +- hw/pci/pci.c | 7 ++++--- 7 files changed, 16 insertions(+), 11 deletions(-)
include/hw/pci/pci.h +2 -1
@@ -288,7 +288,8 @@ void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent, bool bar_at_addr_0_refused);PCIBus *pci_root_bus_new (DeviceState *parent,const char *name,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min,const char *typename); +uint8_t devfn_min,const char *typename, +bool bar_at_addr_0_refused);void pci_root_bus_cleanup (PCIBus *bus);void pci_bus_irqs (PCIBus *bus,pci_set_irq_fn set_irq,void *irq_opaque,int nirq);
hw/pci-bridge/pci_expander_bridge.c +6 -3
@@ -358,15 +358,18 @@ static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, ds =qdev_new (type ==CXL ?TYPE_PXB_CXL_HOST :TYPE_PXB_HOST );if (type ==PCIE ) { - bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_PCIE_BUS ); + bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_PCIE_BUS , + true); bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; }else if (type ==CXL ) { - bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_CXL_BUS ); + bus =pci_root_bus_new (ds, dev_name,NULL ,NULL ,0 ,TYPE_PXB_CXL_BUS , + true); bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; bus->flags |=PCI_BUS_CXL ;PXB_CXL_DEV (dev)->cxl_host_bridge =PXB_CXL_HOST (ds); }else { - bus =pci_root_bus_new (ds,"pxb-internal" ,NULL ,NULL ,0 ,TYPE_PXB_BUS ); + bus =pci_root_bus_new (ds,"pxb-internal" ,NULL ,NULL ,0 ,TYPE_PXB_BUS , + true); bus->flags = parent_bus->flags & ~PCI_BUS_IS_ROOT ; bds =qdev_new ("pci-bridge" ); bds->id =g_strdup (dev_name);
hw/pci-host/gt64120.c +1 -1
@@ -1193,7 +1193,7 @@ static void gt64120_realize(DeviceState *dev, Error **errp) phb->bus =pci_root_bus_new (dev,"pci" , &s->pci0_mem,get_system_io (), -PCI_DEVFN (18 ,0 ),TYPE_PCI_BUS ); +PCI_DEVFN (18 ,0 ),TYPE_PCI_BUS , true);pci_create_simple (phb->bus,PCI_DEVFN (0 ,0 ),"gt64120_pci" ); memory_region_init_io(&phb->conf_mem, OBJECT(phb),
hw/pci-host/i440fx.c +1 -1
@@ -268,7 +268,7 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp)memory_region_add_coalescing (&phb->conf_mem,0 ,4 ); b =pci_root_bus_new (dev,NULL , s->pci_address_space, - s->io_memory,0 ,TYPE_PCI_BUS ); + s->io_memory,0 ,TYPE_PCI_BUS , true); phb->bus = b; d =pci_create_simple (b,0 , s->pci_type);
hw/pci-host/q35.c +1 -1
@@ -65,7 +65,7 @@ static void q35_host_realize(DeviceState *dev, Error **errp) pci->bus =pci_root_bus_new (DEVICE (s),"pcie.0" , s->mch.pci_address_space, s->mch.address_space_io, -0 ,TYPE_PCIE_BUS ); +0 ,TYPE_PCIE_BUS , true);qdev_realize (DEVICE (&s->mch),BUS (pci->bus), &error_fatal); }
hw/pci-host/remote.c +1 -1
@@ -43,7 +43,7 @@ static void remote_pcihost_realize(DeviceState *dev, Error **errp) pci->bus =pci_root_bus_new (DEVICE (s),"remote-pci" , s->mr_pci_mem, s->mr_sys_io, -0 ,TYPE_PCIE_BUS ); +0 ,TYPE_PCIE_BUS , true); }static void remote_pcihost_class_init (ObjectClass *klass,void *data)
hw/pci/pci.c +4 -3
@@ -571,13 +571,14 @@ void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent,PCIBus *pci_root_bus_new (DeviceState *parent,const char *name,MemoryRegion *mem,MemoryRegion *io, -uint8_t devfn_min,const char *typename) +uint8_t devfn_min,const char *typename, +bool bar_at_addr_0_refused) {PCIBus *bus; bus =PCI_BUS (qbus_new (typename, parent, name));pci_root_bus_internal_init (bus, parent, mem, io, devfn_min, - true); + bar_at_addr_0_refused);return bus; }
@@ -622,7 +623,7 @@ PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, {PCIBus *bus; - bus =pci_root_bus_new (parent, name, mem, io, devfn_min, typename); + bus =pci_root_bus_new (parent, name, mem, io, devfn_min, typename, true);pci_bus_irqs (bus, set_irq, irq_opaque, nirq);pci_bus_map_irqs (bus, map_irq);return bus;
Signature · 1 line
2.45.2
PATCH v2 8/13 hw/pci: Propagate bar_at_addr_0_refused to pci_register_root_bus()
In reply to Philippe Mathieu-DaudéHave pci_register_root_bus() callers set the 'bar_at_addr_0_refused' argument. No logical change.
--- include/hw/pci/pci.h | 2 +- hw/alpha/typhoon.c | 2 +- hw/pci-host/articia.c | 3 ++- hw/pci-host/astro.c | 3 ++- hw/pci-host/bonito.c | 2 +- hw/pci-host/designware.c | 2 +- hw/pci-host/dino.c | 2 +- hw/pci-host/gpex.c | 3 ++- hw/pci-host/grackle.c | 2 +- hw/pci-host/mv64361.c | 2 +- hw/pci-host/pnv_phb3.c | 2 +- hw/pci-host/pnv_phb4.c | 2 +- hw/pci-host/ppc440_pcix.c | 2 +- hw/pci-host/ppc4xx_pci.c | 2 +- hw/pci-host/ppce500.c | 3 ++- hw/pci-host/sabre.c | 2 +- hw/pci-host/sh_pci.c | 2 +- hw/pci-host/uninorth.c | 8 ++++---- hw/pci-host/xilinx-pcie.c | 2 +- hw/pci/pci.c | 5 +++-- hw/ppc/ppc440_uc.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/s390x/s390-pci-bus.c | 2 +- 23 files changed, 32 insertions(+), 27 deletions(-)
include/hw/pci/pci.h +1 -1
@@ -310,7 +310,7 @@ PCIBus *pci_register_root_bus(DeviceState *parent, const char *name,void *irq_opaque, MemoryRegion *mem, MemoryRegion *io, uint8_t devfn_min, int nirq, - const char *typename); + const char *typename, bool bar_at_addr_0_refused);void pci_unregister_root_bus (PCIBus *bus);void pci_bus_set_route_irq_fn (PCIBus *,pci_route_irq_fn );PCIINTxRoute pci_device_route_intx_to_irq (PCIDevice *dev,int pin);
hw/alpha/typhoon.c +1 -1
@@ -891,7 +891,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq, b =pci_register_root_bus (dev,"pci" , typhoon_set_irq, sys_map_irq, s, &s->pchip.reg_mem, &s->pchip.reg_io, - devfn_min,64 ,TYPE_PCI_BUS ); + devfn_min,64 ,TYPE_PCI_BUS , true); phb->bus = b;sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/pci-host/articia.c +2 -1
@@ -184,7 +184,8 @@ static void articia_realize(DeviceState *dev, Error **errp)/* devfn_min is 8 that matches first PCI slot in AmigaOne */ h->bus =pci_register_root_bus (dev,NULL , articia_pcihost_set_irq, amigaone_pcihost_bus0_map_irq, dev, &s->mem, - &s->io,PCI_DEVFN (8 ,0 ),4 ,TYPE_PCI_BUS ); + &s->io,PCI_DEVFN (8 ,0 ),4 ,TYPE_PCI_BUS , + true); pdev =pci_create_simple_multifunction (h->bus,PCI_DEVFN (0 ,0 ),TYPE_ARTICIA_PCI_HOST );ARTICIA_PCI_HOST (pdev)->as = s;
hw/pci-host/astro.c +2 -1
@@ -454,7 +454,8 @@ static void elroy_pcihost_init(Object *obj) phb->bus =pci_register_root_bus (DEVICE (s),"pci" , elroy_set_irq, elroy_pci_map_irq, s, &s->pci_mmio, &s->pci_io, -PCI_DEVFN (0 ,0 ),ELROY_IRQS ,TYPE_PCI_BUS ); +PCI_DEVFN (0 ,0 ),ELROY_IRQS ,TYPE_PCI_BUS , + true);sysbus_init_mmio (sbd, &s->this_mem);
hw/pci-host/bonito.c +1 -1
@@ -635,7 +635,7 @@ static void bonito_host_realize(DeviceState *dev, Error **errp) phb->bus =pci_register_root_bus (dev,"pci" , pci_bonito_set_irq, pci_bonito_map_irq, dev, &bs->pci_mem,get_system_io (), -PCI_DEVFN (5 ,0 ),32 ,TYPE_PCI_BUS ); +PCI_DEVFN (5 ,0 ),32 ,TYPE_PCI_BUS , true);for (size_t i =0 ; i <3 ; i++) {char *name =g_strdup_printf ("pci.lomem%zu" , i);
hw/pci-host/designware.c +1 -1
@@ -700,7 +700,7 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) &s->pci.memory, &s->pci.io,0 ,4 , - TYPE_PCIE_BUS); + TYPE_PCIE_BUS, true); pci->bus->flags |=PCI_BUS_EXTENDED_CONFIG_SPACE ; memory_region_init(&s->pci.address_space_root,
hw/pci-host/dino.c +1 -1
@@ -473,7 +473,7 @@ static void dino_pcihost_init(Object *obj) phb->bus =pci_register_root_bus (DEVICE (s),"pci" , dino_set_irq, dino_pci_map_irq, s, &s->pci_mem,get_system_io (), -PCI_DEVFN (0 ,0 ),32 ,TYPE_PCI_BUS ); +PCI_DEVFN (0 ,0 ),32 ,TYPE_PCI_BUS , true);/* Set up windows into PCI bus memory. */ for (i =1 ; i <31 ; i++) {
hw/pci-host/gpex.c +2 -1
@@ -135,7 +135,8 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) pci->bus =pci_register_root_bus (dev,"pcie.0" , gpex_set_irq, pci_swizzle_map_irq_fn, s, &s->io_mmio, - &s->io_ioport,0 ,4 ,TYPE_PCIE_BUS ); + &s->io_ioport,0 ,4 ,TYPE_PCIE_BUS , + true);pci_bus_set_route_irq_fn (pci->bus, gpex_route_intx_pin_to_irq);qdev_realize (DEVICE (&s->gpex_root),BUS (pci->bus), &error_fatal);
hw/pci-host/grackle.c +1 -1
@@ -58,7 +58,7 @@ static void grackle_realize(DeviceState *dev, Error **errp) s, &s->pci_mmio, &s->pci_io, - 0, 4, TYPE_PCI_BUS); + 0, 4, TYPE_PCI_BUS, true);pci_create_simple (phb->bus,0 ,"grackle" ); }
hw/pci-host/mv64361.c +1 -1
@@ -92,7 +92,7 @@ static void mv64361_pcihost_realize(DeviceState *dev, Error **errp) name =g_strdup_printf ("pci.%d" , s->index); h->bus =pci_register_root_bus (dev, name, mv64361_pcihost_set_irq, pci_swizzle_map_irq_fn, dev, - &s->mem, &s->io,0 ,4 ,TYPE_PCI_BUS ); + &s->mem, &s->io,0 ,4 ,TYPE_PCI_BUS , true);g_free (name);pci_create_simple (h->bus,0 ,TYPE_MV64361_PCI_BRIDGE ); }
hw/pci-host/pnv_phb3.c +1 -1
@@ -1009,7 +1009,7 @@ void pnv_phb3_bus_init(DeviceState *dev, PnvPHB3 *phb) dev->id ? dev->id :NULL , pnv_phb3_set_irq, pnv_phb3_map_irq, phb, &phb->pci_mmio, &phb->pci_io, - 0, 4, TYPE_PNV_PHB3_ROOT_BUS); + 0, 4, TYPE_PNV_PHB3_ROOT_BUS, true);object_property_set_int (OBJECT (pci->bus),"phb-id" , phb->phb_id, &error_abort);
hw/pci-host/pnv_phb4.c +1 -1
@@ -1563,7 +1563,7 @@ void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb) pci->bus =pci_register_root_bus (dev, dev->id ? dev->id :NULL , pnv_phb4_set_irq, pnv_phb4_map_irq, phb, &phb->pci_mmio, &phb->pci_io, -0 ,4 ,TYPE_PNV_PHB4_ROOT_BUS ); +0 ,4 ,TYPE_PNV_PHB4_ROOT_BUS , true);object_property_set_int (OBJECT (pci->bus),"phb-id" , phb->phb_id, &error_abort);
hw/pci-host/ppc440_pcix.c +1 -1
@@ -498,7 +498,7 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp)memory_region_init (&s->iomem,OBJECT (dev),"pci-io" ,64 * KiB); h->bus =pci_register_root_bus (dev,NULL , ppc440_pcix_set_irq, ppc440_pcix_map_irq, &s->irq, &s->busmem, &s->iomem, -PCI_DEVFN (1 ,0 ),1 ,TYPE_PCI_BUS ); +PCI_DEVFN (1 ,0 ),1 ,TYPE_PCI_BUS , true);memory_region_init (&s->bm,OBJECT (s),"bm-ppc440-pcix" ,UINT64_MAX );memory_region_add_subregion (&s->bm,0x0 , &s->busmem);
hw/pci-host/ppc4xx_pci.c +1 -1
@@ -329,7 +329,7 @@ static void ppc4xx_pcihost_realize(DeviceState *dev, Error **errp) b =pci_register_root_bus (dev,NULL , ppc4xx_pci_set_irq, ppc4xx_pci_map_irq, s->irq,get_system_memory (),get_system_io (),0 ,ARRAY_SIZE (s->irq), -TYPE_PCI_BUS ); +TYPE_PCI_BUS , true); h->bus = b;pci_create_simple (b,0 , TYPE_PPC4xx_HOST_BRIDGE);
hw/pci-host/ppce500.c +2 -1
@@ -465,7 +465,8 @@ static void e500_pcihost_realize(DeviceState *dev, Error **errp) b =pci_register_root_bus (dev,NULL , mpc85xx_pci_set_irq, mpc85xx_pci_map_irq, s, &s->busmem, &s->pio, -PCI_DEVFN (s->first_slot,0 ),4 ,TYPE_PCI_BUS ); +PCI_DEVFN (s->first_slot,0 ),4 ,TYPE_PCI_BUS , + true); h->bus = b;/* Set up PCI view of memory */
hw/pci-host/sabre.c +1 -1
@@ -381,7 +381,7 @@ static void sabre_realize(DeviceState *dev, Error **errp) pci_sabre_set_irq, pci_sabre_map_irq, s, &s->pci_mmio, &s->pci_ioport, - 0, 0x40, TYPE_PCI_BUS); + 0, 0x40, TYPE_PCI_BUS, true);pci_create_simple (phb->bus,0 ,TYPE_SABRE_PCI_DEVICE );
hw/pci-host/sh_pci.c +1 -1
@@ -132,7 +132,7 @@ static void sh_pcic_host_realize(DeviceState *dev, Error **errp)get_system_memory (),get_system_io (),PCI_DEVFN (0 ,0 ),PCI_NUM_PINS , - TYPE_PCI_BUS); + TYPE_PCI_BUS, true);memory_region_init_io (&s->memconfig_p4,OBJECT (s), &sh_pci_reg_ops, s,"sh_pci" ,0x224 ); memory_region_init_alias(&s->memconfig_a7, OBJECT(s), "sh_pci.2",
hw/pci-host/uninorth.c +4 -4
@@ -124,7 +124,7 @@ static void pci_unin_main_realize(DeviceState *dev, Error **errp) s, &s->pci_mmio, &s->pci_io, - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS, true);pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-pci" );
@@ -174,7 +174,7 @@ static void pci_u3_agp_realize(DeviceState *dev, Error **errp) s, &s->pci_mmio, &s->pci_io, - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS, false);pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"u3-agp" ); }
@@ -218,7 +218,7 @@ static void pci_unin_agp_realize(DeviceState *dev, Error **errp) s, &s->pci_mmio, &s->pci_io, - PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); + PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS, false);pci_create_simple (h->bus,PCI_DEVFN (11 ,0 ),"uni-north-agp" ); }
@@ -251,7 +251,7 @@ static void pci_unin_internal_realize(DeviceState *dev, Error **errp) s, &s->pci_mmio, &s->pci_io, - PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS); + PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS, false);pci_create_simple (h->bus,PCI_DEVFN (14 ,0 ),"uni-north-internal-pci" ); }
hw/pci-host/xilinx-pcie.c +1 -1
@@ -135,7 +135,7 @@ static void xilinx_pcie_host_realize(DeviceState *dev, Error **errp) pci->bus =pci_register_root_bus (dev, s->name, xilinx_pcie_set_irq, pci_swizzle_map_irq_fn, s, &s->mmio, - &s->io,0 ,4 ,TYPE_PCIE_BUS ); + &s->io,0 ,4 ,TYPE_PCIE_BUS , true);qdev_realize (DEVICE (&s->root),BUS (pci->bus), &error_fatal); }
hw/pci/pci.c +3 -2
@@ -619,11 +619,12 @@ PCIBus *pci_register_root_bus(DeviceState *parent, const char *name,void *irq_opaque, MemoryRegion *mem, MemoryRegion *io, uint8_t devfn_min, int nirq, - const char *typename) + const char *typename, bool bar_at_addr_0_refused) { PCIBus *bus; - bus =pci_root_bus_new (parent, name, mem, io, devfn_min, typename, true); + bus =pci_root_bus_new (parent, name, mem, io, devfn_min, typename, + bar_at_addr_0_refused);pci_bus_irqs (bus, set_irq, irq_opaque, nirq);pci_bus_map_irqs (bus, map_irq);return bus;
hw/ppc/ppc440_uc.c +1 -1
@@ -1016,7 +1016,7 @@ static void ppc460ex_pcie_realize(DeviceState *dev, Error **errp)snprintf (buf,sizeof (buf),"pcie.%d" , s->num); pci->bus =pci_register_root_bus (DEVICE (s), buf, ppc460ex_set_irq, pci_swizzle_map_irq_fn, s, &s->busmem, - &s->iomem,0 ,4 ,TYPE_PCIE_BUS ); + &s->iomem,0 ,4 ,TYPE_PCIE_BUS , true);ppc460ex_pcie_register_dcrs (s); }
hw/ppc/spapr_pci.c +1 -1
@@ -1886,7 +1886,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) pci_spapr_set_irq, pci_swizzle_map_irq_fn, sphb, &sphb->memspace, &sphb->iospace,PCI_DEVFN (0 ,0 ),PCI_NUM_PINS , - TYPE_PCI_BUS); + TYPE_PCI_BUS, true);/* * Despite resembling a vanilla PCI bus in most ways, the PAPR
hw/s390x/s390-pci-bus.c +1 -1
@@ -834,7 +834,7 @@ static void s390_pcihost_realize(DeviceState *dev, Error **errp) b =pci_register_root_bus (dev,NULL , s390_pci_set_irq, s390_pci_map_irq,NULL ,get_system_memory (),get_system_io (),0 , -64 ,TYPE_PCI_BUS ); +64 ,TYPE_PCI_BUS , true);pci_setup_iommu (b, &s390_iommu_ops, s); bus =BUS (b);
Signature · 1 line
2.45.2
PATCH v2 9/13 hw/ppc/spapr: Create host bridge setting bar_at_addr_0_refused=false
In reply to Philippe Mathieu-DaudéSince all sPAPR machines set MachineClass::pci_allow_0_address (see commit e402463073 "pci: allow 0 address for PCI IO/MEM regions"), directly create the host bridge passing bar_at_addr_0_refused=false to pci_register_root_bus().
--- hw/ppc/spapr.c | 1 - hw/ppc/spapr_pci.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
hw/ppc/spapr.c +0 -1
@@ -4600,7 +4600,6 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->default_display ="std" ; mc->kvm_type = spapr_kvm_type;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_SPAPR_PCI_HOST_BRIDGE ); - mc->pci_allow_0_address = true;assert (!mc->get_hotplug_handler); mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug;
hw/ppc/spapr_pci.c +1 -1
@@ -1886,7 +1886,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) pci_spapr_set_irq, pci_swizzle_map_irq_fn, sphb, &sphb->memspace, &sphb->iospace,PCI_DEVFN (0 ,0 ),PCI_NUM_PINS , - TYPE_PCI_BUS, true); + TYPE_PCI_BUS, false);/* * Despite resembling a vanilla PCI bus in most ways, the PAPR
Signature · 1 line
2.45.2
PATCH v2 10/13 hw/pci-host/gpex: Expose 'refuse-bar-at-addr-0' property
In reply to Philippe Mathieu-DaudéExpose the "refuse-bar-at-addr-0" property so machines using a GPEX host bridge can set this flag on the bus. While the default property is set to 'false', all caller set it to 'true' so there is no logical change so far.
--- include/hw/pci-host/gpex.h | 1 + hw/arm/sbsa-ref.c | 2 ++ hw/arm/virt.c | 2 ++ hw/i386/microvm.c | 2 ++ hw/loongarch/virt.c | 2 ++ hw/mips/loongson3_virt.c | 2 ++ hw/openrisc/virt.c | 2 ++ hw/pci-host/gpex.c | 4 +++- hw/riscv/virt.c | 2 ++ hw/xen/xen-pvh-common.c | 2 ++ hw/xtensa/virt.c | 2 ++ 11 files changed, 22 insertions(+), 1 deletion(-)
include/hw/pci-host/gpex.h +1 -0
@@ -64,6 +64,7 @@ struct GPEXHost {int irq_num[GPEX_NUM_IRQS ];bool allow_unmapped_accesses; +bool refuse_bar_at_addr_0;struct GPEXConfig gpex_cfg; };
hw/arm/sbsa-ref.c +2 -0
@@ -647,6 +647,8 @@ static void create_pcie(SBSAMachineState *sms)int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */
hw/arm/virt.c +2 -0
@@ -1510,6 +1510,8 @@ static void create_pcie(VirtMachineState *vms)MachineClass *mc =MACHINE_GET_CLASS (ms); dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);
hw/i386/microvm.c +2 -0
@@ -108,6 +108,8 @@ static void create_gpex(MicrovmMachineState *mms)int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space */
hw/loongarch/virt.c +2 -0
@@ -712,6 +712,8 @@ static void virt_devices_init(DeviceState *pch_pic,int i; gpex_dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (gpex_dev),"refuse-bar-at-addr-0" , + true, &error_fatal); d =SYS_BUS_DEVICE (gpex_dev);sysbus_realize_and_unref (d, &error_fatal); pci_bus =PCI_HOST_BRIDGE (gpex_dev)->bus;
hw/mips/loongson3_virt.c +2 -0
@@ -430,6 +430,8 @@ static inline void loongson3_virt_devices_init(MachineState *machine,LoongsonMachineState *s =LOONGSON_MACHINE (machine); dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); pci_bus =PCI_HOST_BRIDGE (dev)->bus;
hw/openrisc/virt.c +2 -0
@@ -380,6 +380,8 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state,int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space. */
hw/pci-host/gpex.c +3 -1
@@ -136,7 +136,7 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) pci->bus =pci_register_root_bus (dev,"pcie.0" , gpex_set_irq, pci_swizzle_map_irq_fn, s, &s->io_mmio, &s->io_ioport,0 ,4 ,TYPE_PCIE_BUS , - true); + s->refuse_bar_at_addr_0);pci_bus_set_route_irq_fn (pci->bus, gpex_route_intx_pin_to_irq);qdev_realize (DEVICE (&s->gpex_root),BUS (pci->bus), &error_fatal);
@@ -155,6 +155,8 @@ static Property gpex_host_properties[] = {*/ DEFINE_PROP_BOOL ("allow-unmapped-accesses" , GPEXHost, allow_unmapped_accesses, true), +DEFINE_PROP_BOOL ("refuse-bar-at-addr-0" , GPEXHost, + refuse_bar_at_addr_0, false),DEFINE_PROP_UINT64 (PCI_HOST_ECAM_BASE , GPEXHost, gpex_cfg.ecam.base,0 ),DEFINE_PROP_SIZE (PCI_HOST_ECAM_SIZE , GPEXHost, gpex_cfg.ecam.size,0 ), DEFINE_PROP_UINT64(PCI_HOST_PIO_BASE, GPEXHost, gpex_cfg.pio.base, 0),
hw/riscv/virt.c +2 -0
@@ -1158,6 +1158,8 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, pio_base, NULL);object_property_set_int (OBJECT (GPEX_HOST (dev)),PCI_HOST_PIO_SIZE , pio_size,NULL ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/xen/xen-pvh-common.c +2 -0
@@ -139,6 +139,8 @@ static inline void xenpvh_gpex_init(XenPVHMachineState *s,object_initialize_child (OBJECT (s),"gpex" , &s->pci.gpex,TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (s),"refuse-bar-at-addr-0" , + true, &error_fatal); dev =DEVICE (&s->pci.gpex);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
hw/xtensa/virt.c +2 -0
@@ -62,6 +62,8 @@ static void create_pcie(MachineState *ms, CPUXtensaState *env, int irq_base,int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map only the first size_ecam bytes of ECAM space. */
Signature · 1 line
2.45.2
Re: [PATCH-for-10.0 v2 10/13] hw/pci-host/gpex: Expose 'refuse-bar-at-addr-0' property
Quoted 51 lines · Philippe Mathieu-Daudé
Expose the "refuse-bar-at-addr-0" property so machines using a GPEX host bridge can set this flag on the bus. While the default property is set to 'false', all caller set it to 'true' so there is no logical change so far.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/pci-host/gpex.h | 1 + hw/arm/sbsa-ref.c | 2 ++ hw/arm/virt.c | 2 ++ hw/i386/microvm.c | 2 ++ hw/loongarch/virt.c | 2 ++ hw/mips/loongson3_virt.c | 2 ++ hw/openrisc/virt.c | 2 ++ hw/pci-host/gpex.c | 4 +++- hw/riscv/virt.c | 2 ++ hw/xen/xen-pvh-common.c | 2 ++ hw/xtensa/virt.c | 2 ++ 11 files changed, 22 insertions(+), 1 deletion(-)include/hw/pci-host/gpex.h +1
-0@@ -64,6 +64,7 @@ struct GPEXHost {int irq_num[GPEX_NUM_IRQS ];bool allow_unmapped_accesses; +bool refuse_bar_at_addr_0;struct GPEXConfig gpex_cfg; };hw/arm/sbsa-ref.c +2
-0@@ -647,6 +647,8 @@ static void create_pcie(SBSAMachineState *sms)int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */ hw/arm/virt.c +0
-0
hw/arm/virt.c static void create_pcie(VirtMachineState *vms) · line 1517
Quoted 8 lines
hw/arm/virt.c +2
-0@@ -1510,6 +1510,8 @@ static void create_pcie(VirtMachineState *vms)MachineClass *mc =MACHINE_GET_CLASS (ms); dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);
These don't look right, because both virt and sbsa-ref set mc->pci_allow_0_address = true. And in the next patch you delete them again...
-- PMM
Re: [PATCH-for-10.0 v2 10/13] hw/pci-host/gpex: Expose 'refuse-bar-at-addr-0' property
Quoted 59 lines · Peter Maydell
Quoted 58 lines · Philippe Mathieu-Daudé
Expose the "refuse-bar-at-addr-0" property so machines using a GPEX host bridge can set this flag on the bus. While the default property is set to 'false', all caller set it to 'true' so there is no logical change so far.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/pci-host/gpex.h | 1 + hw/arm/sbsa-ref.c | 2 ++ hw/arm/virt.c | 2 ++ hw/i386/microvm.c | 2 ++ hw/loongarch/virt.c | 2 ++ hw/mips/loongson3_virt.c | 2 ++ hw/openrisc/virt.c | 2 ++ hw/pci-host/gpex.c | 4 +++- hw/riscv/virt.c | 2 ++ hw/xen/xen-pvh-common.c | 2 ++ hw/xtensa/virt.c | 2 ++ 11 files changed, 22 insertions(+), 1 deletion(-)include/hw/pci-host/gpex.h +1
-0@@ -64,6 +64,7 @@ struct GPEXHost {int irq_num[GPEX_NUM_IRQS ];bool allow_unmapped_accesses; +bool refuse_bar_at_addr_0;struct GPEXConfig gpex_cfg; };hw/arm/sbsa-ref.c +2
-0@@ -647,6 +647,8 @@ static void create_pcie(SBSAMachineState *sms)int i; dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */ hw/arm/virt.c +2
-0@@ -1510,6 +1510,8 @@ static void create_pcie(VirtMachineState *vms)MachineClass *mc =MACHINE_GET_CLASS (ms); dev =qdev_new (TYPE_GPEX_HOST ); +object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , + true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
Quoted 5 lines
hw/arm/virt.c static void create_pcie(VirtMachineState *vms) · line 1517
Quoted 1 line
hw/arm/virt.c +0
-0ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);These don't look right, because both virt and sbsa-ref set
mc->pci_allow_0_address= true. And in the next patch you delete them again...
Indeed.
PATCH v2 11/13 hw/arm/virt: Create GPEX host bridge without refuse-bar-at-addr-0
In reply to Philippe Mathieu-DaudéARM virt and sbsa-ref machines set MachineClass::pci_allow_0_address (see commit 74de8c3568 "hw/arm/virt: Allow zero address for PCI IO space"), directly create the GPEX host bridge using the default 'false' value of the "refuse-bar-at-addr-0" property.
--- hw/arm/sbsa-ref.c | 3 --- hw/arm/virt.c | 3 --- 2 files changed, 6 deletions(-)
hw/arm/sbsa-ref.c +0 -3
@@ -647,8 +647,6 @@ static void create_pcie(SBSAMachineState *sms)int i; dev =qdev_new (TYPE_GPEX_HOST ); -object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , - true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);/* Map ECAM space */
@@ -898,7 +896,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =ARM_CPU_TYPE_NAME ("neoverse-n2" ); mc->valid_cpu_types = valid_cpu_types; mc->max_cpus =512 ; - mc->pci_allow_0_address = true; mc->minimum_page_bits =12 ; mc->block_default_type =IF_IDE ; mc->no_cdrom =1 ;
hw/arm/virt.c +0 -3
@@ -1510,8 +1510,6 @@ static void create_pcie(VirtMachineState *vms)MachineClass *mc =MACHINE_GET_CLASS (ms); dev =qdev_new (TYPE_GPEX_HOST ); -object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , - true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); ecam_id =VIRT_ECAM_ID (vms->highmem_ecam);
@@ -3126,7 +3124,6 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)#endif mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; - mc->pci_allow_0_address = true;/* We know we will never create a pre-ARMv7 CPU which needs 1K pages */ mc->minimum_page_bits =12 ; mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
Signature · 1 line
2.45.2
PATCH v2 12/13 hw/riscv/virt: Create GPEX host bridge without refuse-bar-at-addr-0
In reply to Philippe Mathieu-DaudéRISCV virt machine set MachineClass::pci_allow_0_address (see commit acead54c78 "riscv: virt: Allow PCI address 0"), directly create the GPEX host bridge using the default 'false' value of the "refuse-bar-at-addr-0" property.
--- hw/riscv/virt.c | 3 --- 1 file changed, 3 deletions(-)
hw/riscv/virt.c +0 -3
@@ -1158,8 +1158,6 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, pio_base, NULL);object_property_set_int (OBJECT (GPEX_HOST (dev)),PCI_HOST_PIO_SIZE , pio_size,NULL ); -object_property_set_bool (OBJECT (dev),"refuse-bar-at-addr-0" , - true, &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal);
@@ -1807,7 +1805,6 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->default_cpu_type =TYPE_RISCV_CPU_BASE ; mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; - mc->pci_allow_0_address = true; mc->possible_cpu_arch_ids = riscv_numa_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id;
Signature · 1 line
2.45.2
PATCH v2 13/13 hw/pci/pci: Remove legacy MachineClass::pci_allow_0_address flag
In reply to Philippe Mathieu-DaudéThere are no more users of MachineClass::pci_allow_0_address, remove the field along with the machine_refuses_bar_at_addr_0() method.
--- include/hw/boards.h | 1 - hw/pci/pci.c | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-)
include/hw/boards.h +0 -1
@@ -284,7 +284,6 @@ struct MachineClass { no_floppy:1, no_cdrom:1, no_sdcard:1, - pci_allow_0_address:1, legacy_fw_cfg_order:1;bool is_default;const char *default_machine_opts;
hw/pci/pci.c +1 -9
@@ -45,7 +45,6 @@#include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/hotplug.h" -#include "hw/boards.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "pci-internal.h"
@@ -520,13 +519,6 @@ bool pci_bus_bypass_iommu(PCIBus *bus)return host_bridge->bypass_iommu; } -static bool machine_refuses_bar_at_addr_0 (void ) -{ -MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); - -return !mc->pci_allow_0_address; -} - static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, MemoryRegion *mem, MemoryRegion *io, uint8_t devfn_min,
@@ -538,7 +530,7 @@ static void pci_root_bus_internal_init(PCIBus *bus, DeviceState *parent, bus->address_space_mem = mem; bus->address_space_io = io; bus->flags |=PCI_BUS_IS_ROOT ; -if (bar_at_addr_0_refused &&machine_refuses_bar_at_addr_0 ()) { +if (bar_at_addr_0_refused) { bus->flags |=PCI_BUS_BAR_AT_ADDR0_REFUSED ; }
Signature · 1 line
2.45.2