vfio/type1: Cope with hardware MSI reserved regions
authorRobin Murphy <robin.murphy@arm.com>
Thu, 10 Aug 2017 19:11:49 +0000 (13:11 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 10 Aug 2017 19:11:49 +0000 (13:11 -0600)
For ARM-based systems with a GICv3 ITS to provide interrupt isolation,
but hardware limitations which are worked around by having MSIs bypass
SMMU translation (e.g. HiSilicon Hip06/Hip07), VFIO neglects to check
for the IRQ_DOMAIN_FLAG_MSI_REMAP capability, (and thus erroneously
demands unsafe_interrupts) if a software-managed MSI region is absent.

Fix this by always checking for isolation capability at both the IRQ
domain and IOMMU domain levels, rather than predicating that on whether
MSIs require an IOMMU mapping (which was always slightly tenuous logic).

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_type1.c

index 8549cb111627f0b4bc64956df7c2b1e945bbfdc2..2328be628f21e24fe4153ac67a877568031b7a39 100644 (file)
@@ -1265,8 +1265,8 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
        INIT_LIST_HEAD(&domain->group_list);
        list_add(&group->next, &domain->group_list);
 
-       msi_remap = resv_msi ? irq_domain_check_msi_remap() :
-                               iommu_capable(bus, IOMMU_CAP_INTR_REMAP);
+       msi_remap = irq_domain_check_msi_remap() ||
+                   iommu_capable(bus, IOMMU_CAP_INTR_REMAP);
 
        if (!allow_unsafe_interrupts && !msi_remap) {
                pr_warn("%s: No interrupt remapping support.  Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n",