xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Kevin Tian <kevin.tian@intel.com>,
	Dario Faggioli <dfaggioli@suse.com>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH] intel/iommu: setup inclusive mappings before enabling iommu
Date: Fri, 14 Sep 2018 10:02:43 +0200	[thread overview]
Message-ID: <20180914080243.20961-1-roger.pau@citrix.com> (raw)

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@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Dario Faggioli <dfaggioli@suse.com>
---
 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2018-09-14  8:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14  8:02 Roger Pau Monne [this message]
2018-09-14  9:06 ` [PATCH] intel/iommu: setup inclusive mappings before enabling iommu Jan Beulich
2018-09-14  9:54   ` Roger Pau Monné
2018-09-14 10:49     ` Jan Beulich
2018-09-14 11:06       ` Roger Pau Monné
2018-09-14 11:13         ` Jan Beulich
2018-09-14 11:32           ` Roger Pau Monné
2018-09-14 13:07 ` Dario Faggioli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180914080243.20961-1-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=dfaggioli@suse.com \
    --cc=jbeulich@suse.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).