On Thu, Apr 20, 2017 at 02:51:11PM +0800, Lan, Tianyu wrote: > On 4/20/2017 1:40 PM, Peter Xu wrote:
[...] > >>>a slightly hackish way. > >> > >>In my understanding, container->space->as->root cannot work here no matter > >>passthru-mode > >>is enabled or not. The code here is aiming to check if vIOMMU exists. After > >>the vfio series, > >>the vtd_dev_as->root is not initialized to be a iommu MemoryRegion. > >>Compared with checking > >>if it is system_memory(), I think adding a mechanism to get the iommu > >>MemoryRegion may > >>be a better choice. Just like the current pci_device_iommu_address_space(). > > > >Isn't pci_device_iommu_address_space() used to get that IOMMU memory > >region? And, one thing to mention is that container->space->as is > >actually derived from pci_device_iommu_address_space() (when calling > >vfio_get_group()). > > > >I feel like that playing around with an IOMMU memory region is still > >not clear enough in many cases. I still feel like some day we would > >like an "IOMMU object". Then, we can register non-iotlb notifiers > >against that IOMMU object, rather than memory regions... > > Our target is to check whether assigned device is under a vIOMMU. > We may check whether iommu_fn point has been populated in its pci bus' data > structure(PCIDevice). This is what pci_device_iommu_address_space() > does. Agreed. Thanks, -- Peter Xu