vfio: Force nested if iommu requires it
Hi Eric,
Quoted 5 lines
(quoted diff) +0
-0@@ -1668,6 +1679,14 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, VFIOContainer *container; int ret, fd; VFIOAddressSpace *space;
Review static int vfio_connect_container(VFIOGroup *group, · line 1692
Quoted 10 lines
(quoted diff) +8
-0+ IOMMUMemoryRegion *iommu_mr; + bool nested = false; + + if (as != &address_space_memory && memory_region_is_iommu(as->root)) { + iommu_mr = IOMMU_MEMORY_REGION(as->root); + memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED, + (void *)&nested); + } space = vfio_get_address_space(as);
Is the condition "as != &address_space_memory" needed to determine whether a vIOMMU is in place? I think "memory_region_is_iommu(as->root)" is enough.
Looking forward to your reply.:)
Thanks,
Kunkun Jiang
Hi Kunkun,
Quoted 15 lines · Kunkun Jiang
Hi Eric,
Quoted 14 lines
(quoted diff) +8
-0@@ -1668,6 +1679,14 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, VFIOContainer *container; int ret, fd; VFIOAddressSpace *space; + IOMMUMemoryRegion *iommu_mr; + bool nested = false; + + if (as != &address_space_memory && memory_region_is_iommu(as->root)) { + iommu_mr = IOMMU_MEMORY_REGION(as->root); + memory_region_iommu_get_attr(iommu_mr, IOMMU_ATTR_VFIO_NESTED, + (void *)&nested); + }
Quoted 5 lines
Review static int vfio_connect_container(VFIOGroup *group, · line 1692
Quoted 1 line
(quoted diff) +0
-0space = vfio_get_address_space(as);Is the condition "as !=
&address_space_memory" needed to determine whether a vIOMMU is in place? I think "memory_region_is_iommu(as->root)" is enough.Looking forward to your reply.:)
Yes I think so.
Thank you for your report!
Eric
Quoted 5 lines
Thanks,
Kunkun Jiang