pcie: Simplify pci_adjust_config_limit()
commit2f57db8a2781787a0a31d3a9ce4a286fc45a42b3
authorDavid Gibson <david@gibson.dropbear.id.au>
Mon, 13 May 2019 06:19:37 +0000 (13 16:19 +1000)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 29 May 2019 22:00:57 +0000 (29 18:00 -0400)
tree918fc927c1a76bde7dfb73be3f2e0e91b0cdb703
parente4610781635404d494120c19bade8dad6f00f0b3
pcie: Simplify pci_adjust_config_limit()

Since c2077e2c "pci: Adjust PCI config limit based on bus topology",
pci_adjust_config_limit() has been used in the config space read and write
paths to only permit access to extended config space on buses which permit
it.  Specifically it prevents access on devices below a vanilla-PCI bus via
some combination of bridges, even if both the host bridge and the device
itself are PCI-E.

It accomplishes this with a somewhat complex call up the chain of bridges
to see if any of them prohibit extended config space access.  This is
overly complex, since we can always know if the bus will support such
access at the point it is constructed.

This patch simplifies the test by using a flag in the PCIBus instance
indicating whether extended configuration space is accessible.  It is
false for vanilla PCI buses.  For PCI-E buses, it is true for root
buses and equal to the parent bus's's capability otherwise.

For the special case of sPAPR's paravirtualized PCI root bus, which
acts mostly like vanilla PCI, but does allow extended config space
access, we override the default value of the flag from the host bridge
code.

This should cause no behavioural change.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20190513061939.3464-4-david@gibson.dropbear.id.au>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/pci/pci.c
hw/pci/pci_host.c
hw/ppc/spapr_pci.c
include/hw/pci/pci.h
include/hw/pci/pci_bus.h