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

[Xen-changelog] [xen-unstable] x86/mm: Add a generic interface for vtd and amd iommu p2m sharing.



# HG changeset patch
# User Wei Wang <wei.wang2@xxxxxxx>
# Date 1303143861 -3600
# Node ID 5e445a5a8eefceb0bee403e91322aa9f825e6975
# Parent  835550a0c6c0064fcd65e70d209c5deb8ae756c8
x86/mm: Add a generic interface for vtd and amd iommu p2m sharing.
Also introduce a new parameter (iommu=sharept) to enable this feature.

Signed-off-by: Wei Wang <wei.wang2@xxxxxxx>
Acked-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Committed-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---


diff -r 835550a0c6c0 -r 5e445a5a8eef xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c     Mon Apr 18 17:24:21 2011 +0100
+++ b/xen/arch/x86/mm/p2m.c     Mon Apr 18 17:24:21 2011 +0100
@@ -2061,8 +2061,8 @@
 
     p2m->phys_table = pagetable_from_mfn(page_to_mfn(p2m_top));
 
-    if ( hap_enabled(d) && (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) )
-        iommu_set_pgd(d);
+    if ( hap_enabled(d) )
+        iommu_share_p2m_table(d);
 
     P2M_PRINTK("populating p2m table\n");
 
diff -r 835550a0c6c0 -r 5e445a5a8eef xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c   Mon Apr 18 17:24:21 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_map.c   Mon Apr 18 17:24:21 2011 +0100
@@ -722,6 +722,9 @@
 
     ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
 
+    if ( !iommu_hap_pt_share )
+        return;
+
     pgd_mfn = pagetable_get_mfn(p2m_get_pagetable(p2m_get_hostp2m(d)));
     p2m_table = mfn_to_page(mfn_x(pgd_mfn));
 
@@ -732,8 +735,6 @@
 
         /* When sharing p2m with iommu, paging mode = 4 */
         hd->paging_mode = IOMMU_PAGING_MODE_LEVEL_4;
-        iommu_hap_pt_share = 1;
-
         AMD_IOMMU_DEBUG("Share p2m table with iommu: p2m table = 0x%lx\n",
                         mfn_x(pgd_mfn));
     }
diff -r 835550a0c6c0 -r 5e445a5a8eef xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c       Mon Apr 18 17:24:21 
2011 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c       Mon Apr 18 17:24:21 
2011 +0100
@@ -458,4 +458,5 @@
     .read_msi_from_ire = amd_iommu_read_msi_from_ire,
     .suspend = amd_iommu_suspend,
     .resume = amd_iommu_resume,
+    .share_p2m = amd_iommu_share_p2m,
 };
diff -r 835550a0c6c0 -r 5e445a5a8eef xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c   Mon Apr 18 17:24:21 2011 +0100
+++ b/xen/drivers/passthrough/iommu.c   Mon Apr 18 17:24:21 2011 +0100
@@ -82,6 +82,8 @@
             iommu_passthrough = 1;
         else if ( !strcmp(s, "dom0-strict") )
             iommu_dom0_strict = 1;
+        else if ( !strcmp(s, "sharept") )
+            iommu_hap_pt_share = 1;
 
         s = ss + 1;
     } while ( ss );
@@ -419,6 +421,14 @@
         ops->suspend();
 }
 
+void iommu_share_p2m_table(struct domain* d)
+{
+    const struct iommu_ops *ops = iommu_get_ops();
+
+    if ( iommu_enabled && is_hvm_domain(d) )
+        ops->share_p2m(d);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r 835550a0c6c0 -r 5e445a5a8eef xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Mon Apr 18 17:24:21 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Mon Apr 18 17:24:21 2011 +0100
@@ -45,9 +45,6 @@
 #define nr_ioapics              iosapic_get_nr_iosapics()
 #endif
 
-static int sharept = 0;
-boolean_param("sharept", sharept);
-
 int nr_iommus;
 
 static void setup_dom0_devices(struct domain *d);
@@ -1747,7 +1744,7 @@
     bool_t share = TRUE;
 
     /* sharept defaults to 0 for now, default to 1 when feature matures */
-    if ( !sharept )
+    if ( !iommu_hap_pt_share )
         share = FALSE;
 
     /*
@@ -2299,6 +2296,7 @@
     .read_msi_from_ire = msi_msg_read_remap_rte,
     .suspend = vtd_suspend,
     .resume = vtd_resume,
+    .share_p2m = iommu_set_pgd,
 };
 
 /*
diff -r 835550a0c6c0 -r 5e445a5a8eef xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h   Mon Apr 18 17:24:21 2011 +0100
+++ b/xen/include/xen/iommu.h   Mon Apr 18 17:24:21 2011 +0100
@@ -132,6 +132,7 @@
     unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
     void (*suspend)(void);
     void (*resume)(void);
+    void (*share_p2m)(struct domain *d);
 };
 
 void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned 
int value);
@@ -143,5 +144,6 @@
 void iommu_resume(void);
 
 void iommu_set_dom0_mapping(struct domain *d);
+void iommu_share_p2m_table(struct domain *d);
 
 #endif /* _IOMMU_H_ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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