xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] xen:vtd: missing RMRR mapping while share EPT
@ 2014-07-23  9:35 Tiejun Chen
  2014-07-23 15:42 ` Jan Beulich
  0 siblings, 1 reply; 13+ messages in thread
From: Tiejun Chen @ 2014-07-23  9:35 UTC (permalink / raw)
  To: yang.z.zhang, kevin.tian; +Cc: xen-devel

intel_iommu_map_page() does nothing if VT-d shares EPT page table.
So rmrr_identity_mapping() never create RMRR mapping but in some
cases like some GFX drivers it still need to access RMRR.

Here we will create those RMRR mappings even in shared EPT case.

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
---
 xen/drivers/passthrough/vtd/iommu.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 042b882..be9384d 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -41,6 +41,7 @@
 #include "extern.h"
 #include "vtd.h"
 #include "../ats.h"
+#include "../../../arch/x86/mm/mm-locks.h"
 
 struct mapped_rmrr {
     struct list_head list;
@@ -1842,6 +1843,7 @@ static int rmrr_identity_mapping(struct domain *d,
     unsigned long base_pfn, end_pfn;
     struct mapped_rmrr *mrmrr;
     struct hvm_iommu *hd = domain_hvm_iommu(d);
+    struct p2m_domain *p2m = p2m_get_hostp2m(d);
 
     ASSERT(spin_is_locked(&pcidevs_lock));
     ASSERT(rmrr->base_address < rmrr->end_address);
@@ -1867,7 +1869,19 @@ static int rmrr_identity_mapping(struct domain *d,
 
     while ( base_pfn < end_pfn )
     {
-        if ( intel_iommu_map_page(d, base_pfn, base_pfn,
+        if ( iommu_use_hap_pt(d) ) {
+            dprintk(XENLOG_DEBUG VTDPREFIX,
+                    "Set RMRR mapping: pfn:0x%lx mfn:0x%lx.\n",
+                    base_pfn, mfn_x(_mfn(base_pfn)));
+            p2m_lock(p2m);
+            if ( p2m_set_entry(p2m, base_pfn, _mfn(base_pfn), PAGE_ORDER_4K,
+                    p2m_mmio_direct, p2m_access_rw) ) {
+                p2m_unlock(p2m);
+                return -1;
+            }
+            p2m_unlock(p2m);
+        }
+        else if ( intel_iommu_map_page(d, base_pfn, base_pfn,
                                   IOMMUF_readable|IOMMUF_writable) )
             return -1;
         base_pfn++;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-07-24 10:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-23  9:35 [PATCH 1/1] xen:vtd: missing RMRR mapping while share EPT Tiejun Chen
2014-07-23 15:42 ` Jan Beulich
2014-07-24  1:23   ` Chen, Tiejun
2014-07-24  6:14     ` Jan Beulich
2014-07-24  7:00       ` Chen, Tiejun
2014-07-24  7:15         ` Chen, Tiejun
2014-07-24  7:47           ` Jan Beulich
2014-07-24  7:45         ` Jan Beulich
2014-07-24  8:28           ` Chen, Tiejun
2014-07-24  9:41             ` Jan Beulich
2014-07-24  9:56               ` Chen, Tiejun
2014-07-24 10:11                 ` Jan Beulich
2014-07-24 10:42                   ` Chen, Tiejun

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).