Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1499690

[PATCH v14 14/16] vfio/type1: Check doorbell safety

From Eric Auger <eric.auger@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v14 14/16] vfio/type1: Check doorbell safety
Date 2016-10-12 15:40 +0200
Message-ID <srrVf-52p-3@gated-at.bofh.it> (permalink)
References <srrLz-4Wx-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On x86 IRQ remapping is abstracted by the IOMMU. On ARM this is abstracted
by the msi controller.

Since we currently have no way to detect whether the MSI controller is
upstream or downstream to the IOMMU we rely on the MSI doorbell information
registered by the interrupt controllers. In case at least one doorbell
does not implement proper isolation, we state the assignment is unsafe
with regard to interrupts. This is a coarse assessment but should allow to
wait for a better system description.

At this point ARM sMMU still advertises IOMMU_CAP_INTR_REMAP. This is
removed in next patch.

Signed-off-by: Eric Auger <eric.auger@redhat.com>

---
v13 -> v15:
- check vfio_msi_resv before checking whether msi doorbell is safe

v9 -> v10:
- coarse safety assessment based on MSI doorbell info

v3 -> v4:
- rename vfio_msi_parent_irq_remapping_capable into vfio_safe_irq_domain
  and irq_remapping into safe_irq_domains

v2 -> v3:
- protect vfio_msi_parent_irq_remapping_capable with
  CONFIG_GENERIC_MSI_IRQ_DOMAIN
---
 drivers/vfio/vfio_iommu_type1.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index e0c97ef..c18ba9d 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -442,6 +442,29 @@ static void vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma)
 }
 
 /**
+ * vfio_msi_resv - Return whether any VFIO iommu domain requires
+ * MSI mapping
+ *
+ * @iommu: vfio iommu handle
+ *
+ * Return: true of MSI mapping is needed, false otherwise
+ */
+static bool vfio_msi_resv(struct vfio_iommu *iommu)
+{
+	struct iommu_domain_msi_resv msi_resv;
+	struct vfio_domain *d;
+	int ret;
+
+	list_for_each_entry(d, &iommu->domain_list, next) {
+		ret = iommu_domain_get_attr(d->domain, DOMAIN_ATTR_MSI_RESV,
+					    &msi_resv);
+		if (!ret)
+			return true;
+	}
+	return false;
+}
+
+/**
  * vfio_set_msi_aperture - Sets the msi aperture on all domains
  * requesting MSI mapping
  *
@@ -945,8 +968,13 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 	INIT_LIST_HEAD(&domain->group_list);
 	list_add(&group->next, &domain->group_list);
 
+	/*
+	 * to advertise safe interrupts either the IOMMU or the MSI controllers
+	 * must support IRQ remapping (aka. interrupt translation)
+	 */
 	if (!allow_unsafe_interrupts &&
-	    !iommu_capable(bus, IOMMU_CAP_INTR_REMAP)) {
+	    (!iommu_capable(bus, IOMMU_CAP_INTR_REMAP) &&
+		!(vfio_msi_resv(iommu) && iommu_msi_doorbell_safe()))) {
 		pr_warn("%s: No interrupt remapping support.  Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n",
 		       __func__);
 		ret = -EPERM;
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:30 +0200
  [PATCH v14 14/16] vfio/type1: Check doorbell safety Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 11/16] vfio/type1: Implement recursive vfio_find_dma_from_node Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 09/16] vfio: Introduce a vfio_dma type field Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 12/16] vfio/type1: Handle unmap/unpin and replay for VFIO_IOVA_RESERVED slots Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 13/16] vfio: Allow reserved msi iova registration Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 10/16] vfio/type1: vfio_find_dma accepting a type argument Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  [PATCH v14 15/16] iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
  Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Punit Agrawal <punit.agrawal@arm.com> - 2016-10-14 13:30 +0200
    Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Auger Eric <eric.auger@redhat.com> - 2016-10-17 16:20 +0200
      Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Punit Agrawal <punit.agrawal@arm.com> - 2016-10-17 17:20 +0200
  Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Will Deacon <will.deacon@arm.com> - 2016-10-20 19:40 +0200
    Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Auger Eric <eric.auger@redhat.com> - 2016-10-21 11:30 +0200
      Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Robin Murphy <robin.murphy@arm.com> - 2016-10-24 21:40 +0200

csiph-web