On Fri, Dec 23, 2016 at 11:21:53AM +0000, Peter Maydell wrote: > On 22 December 2016 at 09:42, Peter Xu <pet...@redhat.com> wrote: > > Hello, > > > > Since this is a general topic, I picked it out from the VT-d > > discussion and put it here, just want to be more clear of it. > > > > The issue is, whether we have exposed too much address spaces for > > emulated PCI devices? > > > > Now for each PCI device, we are having PCIDevice::bus_master_as for > > the device visible address space, which derived from > > pci_device_iommu_address_space(): > > > > AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) > > { > > PCIBus *bus = PCI_BUS(dev->bus); > > PCIBus *iommu_bus = bus; > > > > while(iommu_bus && !iommu_bus->iommu_fn && iommu_bus->parent_dev) { > > iommu_bus = PCI_BUS(iommu_bus->parent_dev->bus); > > } > > if (iommu_bus && iommu_bus->iommu_fn) { > > return iommu_bus->iommu_fn(bus, iommu_bus->iommu_opaque, > > dev->devfn); > > } > > return &address_space_memory; > > } > > > > By default (for no-iommu case), it's pointed to system memory space, > > which includes MMIO, and looks wrong - PCI device should not be able to > > write to MMIO regions. > > This is just legacy, I think, ie a combination of "this used to > be system memory space so let's not break things" and "PC works > mostly like this". It should be possible for the PCI host bridge > emulation to set things up so that the device's visible address > space is whatever it feels like. The PCI APIs we have for doing > this have "iommu" in the name but they work just as well even > if the host bridge doesn't actually have an iommu and is just > setting up a fixed or slightly configurable mapping. > I think it just hasn't been implemented because for guests which > aren't misbehaving it doesn't make any difference.
Hmm, yes I see ppc e500 is using that for setting up its own address space, possibly x86 can leverage it too when we really need this. For now, I see no strong reason for this enhancement, so let me keep it as it is, and wait until we have both a strong reason and a PCI guru. Thank you for your answer! (to Paolo/David as well) -- peterx