[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] intel/iommu: setup inclusive mappings before enabling iommu



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

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

Note that in order to restore previous behavior a new enable hook is
added to the iommu_ops struct that's only used by VT-d.

Reported-by: Dario Faggioli <dfaggioli@xxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
Cc: Dario Faggioli <dfaggioli@xxxxxxxx>
---
 xen/drivers/passthrough/iommu.c     |  3 +++
 xen/drivers/passthrough/vtd/iommu.c | 10 ++++++++--
 xen/include/xen/iommu.h             |  1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index ee3f523fdf..1e291aa673 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -248,6 +248,9 @@ void __hwdom_init iommu_hwdom_init(struct domain *d)
     }
 
     arch_iommu_hwdom_init(d);
+
+    if ( hd->platform_ops->enable )
+        hd->platform_ops->enable();
 }
 
 void iommu_teardown(struct domain *d)
diff --git a/xen/drivers/passthrough/vtd/iommu.c 
b/xen/drivers/passthrough/vtd/iommu.c
index adc70f205a..ac30623697 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1319,12 +1319,17 @@ static void __hwdom_init intel_iommu_hwdom_init(struct 
domain *d)
                " IOMMU flush all failed for hardware domain\n");
 
     for_each_drhd_unit ( drhd )
-    {
         if ( iomem_deny_access(d, PFN_DOWN(drhd->address),
                                PFN_DOWN(drhd->address)) )
             BUG();
+}
+
+static void __hwdom_init intel_iommu_enable(void)
+{
+    struct acpi_drhd_unit *drhd;
+
+    for_each_drhd_unit ( drhd )
         iommu_enable_translation(drhd);
-    }
 }
 
 int domain_context_mapping_one(
@@ -2650,6 +2655,7 @@ static void vtd_dump_p2m_table(struct domain *d)
 
 const struct iommu_ops intel_iommu_ops = {
     .init = intel_iommu_domain_init,
+    .enable = intel_iommu_enable,
     .hwdom_init = intel_iommu_hwdom_init,
     .add_device = intel_iommu_add_device,
     .enable_device = intel_iommu_enable_device,
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 57c4e81ec6..96b4ff6e1e 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -140,6 +140,7 @@ typedef int iommu_grdm_t(xen_pfn_t start, xen_ulong_t nr, 
u32 id, void *ctxt);
 
 struct iommu_ops {
     int (*init)(struct domain *d);
+    void (*enable)(void);
     void (*hwdom_init)(struct domain *d);
     int (*add_device)(u8 devfn, device_t *dev);
     int (*enable_device)(device_t *dev);
-- 
2.18.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.