On Thu, Apr 20, 2017 at 06:36:16AM +0000, Liu, Yi L wrote: [...]
> > > 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? Again I should say s/memory region/address space/... > > It actually returns the AddressSpace, and the AddressSpace includes a memory > region. > It is as->root. But after adding the vfio series, through the IOMMU memory > region > is got, but it has no iommu_ops. Just as the following code shows. That's why > I said > even without passthru-mode, Tianyu's that code snippet is not able to get the > correct > check. > > memory_region_init(&vtd_dev_as->root, OBJECT(s), > "vtd_root", UINT64_MAX); > address_space_init(&vtd_dev_as->as, &vtd_dev_as->root, name); The problem is, I am not sure whether there is always _only_ one IOMMU region behind one device. E.g., IIUC ppc can have more than one IOMMU memory regions, but translate for different address ranges. Thanks, -- Peter Xu