Skip to contentSkip to conversation

vfio: Force nested if iommu requires it

RFC Kunkun Jiang 2 participants 2 messages Nov 28, 2020 – Dec 1, 2020

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

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 -0
     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.:)

Yes I think so.

Thank you for your report!

Eric

Quoted 5 lines

Thanks,

Kunkun Jiang