]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
irqdomain: irq_domain_check_msi_remap
authorEric Auger <eric.auger@redhat.com>
Thu, 19 Jan 2017 20:57:59 +0000 (20:57 +0000)
committerWill Deacon <will.deacon@arm.com>
Mon, 23 Jan 2017 15:00:45 +0000 (15:00 +0000)
This new function checks whether all MSI irq domains
implement IRQ remapping. This is useful to understand
whether VFIO passthrough is safe with respect to interrupts.

On ARM typically an MSI controller can sit downstream
to the IOMMU without preventing VFIO passthrough.
As such any assigned device can write into the MSI doorbell.
In case the MSI controller implements IRQ remapping, assigned
devices will not be able to trigger interrupts towards the
host. On the contrary, the assignment must be emphasized as
unsafe with respect to interrupts.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
Tested-by: Bharat Bhushan <bharat.bhushan@nxp.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
include/linux/irqdomain.h
kernel/irq/irqdomain.c

index bc2f5719dace25faf19aae25754d1b115825517b..188eced6813eddb9c313fdb59016b972835e7674 100644 (file)
@@ -222,6 +222,7 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
                                         void *host_data);
 extern struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
                                                   enum irq_domain_bus_token bus_token);
+extern bool irq_domain_check_msi_remap(void);
 extern void irq_set_default_host(struct irq_domain *host);
 extern int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
                                  irq_hw_number_t hwirq, int node,
index 876e13172dc83f89f02d0b47edbd6d97fdca97fe..80c4f931218710eab830f2e83711007b06bf147c 100644 (file)
@@ -277,6 +277,31 @@ struct irq_domain *irq_find_matching_fwspec(struct irq_fwspec *fwspec,
 }
 EXPORT_SYMBOL_GPL(irq_find_matching_fwspec);
 
+/**
+ * irq_domain_check_msi_remap - Check whether all MSI irq domains implement
+ * IRQ remapping
+ *
+ * Return: false if any MSI irq domain does not support IRQ remapping,
+ * true otherwise (including if there is no MSI irq domain)
+ */
+bool irq_domain_check_msi_remap(void)
+{
+       struct irq_domain *h;
+       bool ret = true;
+
+       mutex_lock(&irq_domain_mutex);
+       list_for_each_entry(h, &irq_domain_list, link) {
+               if (irq_domain_is_msi(h) &&
+                   !irq_domain_hierarchical_is_msi_remap(h)) {
+                       ret = false;
+                       break;
+               }
+       }
+       mutex_unlock(&irq_domain_mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(irq_domain_check_msi_remap);
+
 /**
  * irq_set_default_host() - Set a "default" irq domain
  * @domain: default domain pointer