iommu: setup inclusive mappings before enabling iommu
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 21 Sep 2018 10:22:38 +0000 (12:22 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 21 Sep 2018 10:22:38 +0000 (12:22 +0200)
Or else it can lead to freezes when enabling the iommu on certain
Intel hardware:

[...]
(XEN) ELF: addresses:
(XEN)     virt_base        = 0xffffffff80000000
(XEN)     elf_paddr_offset = 0x0
(XEN)     virt_offset      = 0xffffffff80000000
(XEN)     virt_kstart      = 0xffffffff81000000
(XEN)     virt_kend        = 0xffffffff82953000
(XEN)     virt_entry       = 0xffffffff8274e180
(XEN)     p2m_base         = 0x8000000000
(XEN)  Xen  kernel: 64-bit, lsb, compat32
(XEN)  Dom0 kernel: 64-bit, PAE, lsb, paddr 0x1000000 -> 0x295300
<freeze>

This restores the behavior before commit 66a9274cc3435 that changed
the order and enabled the iommu without having the inclusive mappings
setup.

Note that on AMD hardware the order is also changed to add inclusive
mappings before adding any devices.

Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/drivers/passthrough/amd/pci_amd_iommu.c
xen/drivers/passthrough/arm/smmu.c
xen/drivers/passthrough/iommu.c
xen/drivers/passthrough/vtd/iommu.c
xen/drivers/passthrough/x86/iommu.c

index 330f9ce38674bc7db6e6ce5c119745d0b14b8b61..4a633ca940833a8cc0618797f3be6bc36a6e0588 100644 (file)
@@ -300,6 +300,8 @@ static void __hwdom_init amd_iommu_hwdom_init(struct domain *d)
                                         IOMMU_MMIO_REGION_LENGTH - 1)) )
             BUG();
 
+    /* Make sure workarounds are applied (if needed) before adding devices. */
+    arch_iommu_hwdom_init(d);
     setup_hwdom_pci_devices(d, amd_iommu_add_device);
 }
 
index 43ece42a50ee06909e3bdd5aedc79fe73c6f0203..8f91807b1b2878306872161833be76a139562f1d 100644 (file)
@@ -2736,6 +2736,8 @@ static void __hwdom_init arm_smmu_iommu_hwdom_init(struct domain *d)
                printk(XENLOG_WARNING
                "map-reserved dom0-iommu option is not supported on ARM\n");
        iommu_hwdom_reserved = 0;
+
+       arch_iommu_hwdom_init(d);
 }
 
 static void arm_smmu_iommu_domain_teardown(struct domain *d)
index ee3f523fdfafde2d3bfe2765f35423783693d8ec..ae6cf2f0ffd57b5af02188f028776e71421412a3 100644 (file)
@@ -238,16 +238,6 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)
     }
 
     hd->platform_ops->hwdom_init(d);
-
-    ASSERT(iommu_hwdom_inclusive != -1 && iommu_hwdom_inclusive != -1);
-    if ( iommu_hwdom_inclusive && !is_pv_domain(d) )
-    {
-        printk(XENLOG_WARNING
-               "IOMMU inclusive mappings are only supported on PV Dom0\n");
-        iommu_hwdom_inclusive = 0;
-    }
-
-    arch_iommu_hwdom_init(d);
 }
 
 void iommu_teardown(struct domain *d)
index adc70f205a7732c8d38a4320ef5116ede56c9a2a..bb422ec58c753aca72485eb521b676ce24f521d3 100644 (file)
@@ -1313,6 +1313,8 @@ static void __hwdom_init intel_iommu_hwdom_init(struct domain *d)
 
     setup_hwdom_pci_devices(d, setup_hwdom_device);
     setup_hwdom_rmrr(d);
+    /* Make sure workarounds are applied before enabling the IOMMU(s). */
+    arch_iommu_hwdom_init(d);
 
     if ( iommu_flush_all() )
         printk(XENLOG_WARNING VTDPREFIX
index 47a078272aa6e808f1bd1e0c8ca31cabe3cfcc21..b7c8b5be41da41a4cc18d19964d05423cf0eb418 100644 (file)
@@ -210,6 +210,14 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
 
     BUG_ON(!is_hardware_domain(d));
 
+    ASSERT(iommu_hwdom_inclusive != -1 && iommu_hwdom_inclusive != -1);
+    if ( iommu_hwdom_inclusive && !is_pv_domain(d) )
+    {
+        printk(XENLOG_WARNING
+               "IOMMU inclusive mappings are only supported on PV Dom0\n");
+        iommu_hwdom_inclusive = 0;
+    }
+
     if ( iommu_hwdom_passthrough )
         return;