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

[Xen-devel] [PATCH 08 of 14 V3] amd iommu: Add a new flag to indication iommuv2 feature enabled or not



# HG changeset patch
# User Wei Wang <wei.wang2@xxxxxxx>
# Date 1326213604 -3600
# Node ID 82f5e77e13c43f0e4e34dfefdd218aec092f9542
# Parent  31e61ed495ae1429e3317f8b0359ff37fdcbb6cd
amd iommu: Add a new flag to indication iommuv2 feature enabled or not.
Hypercalls should return early on non-iommuv2 systems.

Signed-off-by: Wei Wang <wei.wang2@xxxxxxx>

diff -r 31e61ed495ae -r 82f5e77e13c4 xen/drivers/passthrough/amd/iommu_guest.c
--- a/xen/drivers/passthrough/amd/iommu_guest.c Tue Jan 10 17:40:01 2012 +0100
+++ b/xen/drivers/passthrough/amd/iommu_guest.c Tue Jan 10 17:40:04 2012 +0100
@@ -821,6 +821,9 @@ int guest_iommu_set_base(struct domain *
     p2m_type_t t;
     struct guest_iommu *iommu = domain_iommu(d);
 
+    if ( !is_hvm_domain(d) || !iommuv2_enabled )
+        return 1;
+
     iommu->mmio_base = base;
     base >>= PAGE_SHIFT;
 
@@ -880,7 +883,7 @@ int guest_iommu_init(struct domain* d)
     struct guest_iommu *iommu;
     struct hvm_iommu *hd  = domain_hvm_iommu(d);
 
-    if ( !is_hvm_domain(d) )
+    if ( !is_hvm_domain(d) || !iommuv2_enabled )
         return 0;
 
     iommu = xzalloc(struct guest_iommu);
@@ -904,13 +907,11 @@ int guest_iommu_init(struct domain* d)
 
 void guest_iommu_destroy(struct domain *d)
 {
-    struct guest_iommu *iommu;
+    struct guest_iommu *iommu = domain_iommu(d);
 
-    if ( !is_hvm_domain(d) )
+    if ( !is_hvm_domain(d) || !iommuv2_enabled )
         return;
 
-    iommu = domain_iommu(d);
-
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
 
@@ -921,6 +922,9 @@ static int guest_iommu_mmio_range(struct
 {
     struct guest_iommu *iommu = vcpu_iommu(v);
 
+    if ( !iommu_found() || !iommuv2_enabled )
+        return 0;
+
     return ( addr >= iommu->mmio_base && 
              addr < (iommu->mmio_base + IOMMU_MMIO_SIZE) );
 }
@@ -938,7 +942,7 @@ int iommu_bind_bdf(struct domain* d, uin
     struct pci_dev *pdev;
     int ret = -ENODEV;
 
-    if ( !iommu_found() )
+    if ( !iommu_found() || !iommuv2_enabled )
         return 0;
 
     spin_lock(&pcidevs_lock);
@@ -964,7 +968,7 @@ void iommu_set_msi(struct domain* d, uin
 {
     struct guest_iommu *iommu = domain_iommu(d);
 
-    if ( !iommu_found() )
+    if ( !iommu_found() || !iommuv2_enabled )
         return;
 
     iommu->msi.vector = vector;
diff -r 31e61ed495ae -r 82f5e77e13c4 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c  Tue Jan 10 17:40:01 2012 +0100
+++ b/xen/drivers/passthrough/amd/iommu_init.c  Tue Jan 10 17:40:04 2012 +0100
@@ -36,6 +36,7 @@ unsigned short ivrs_bdf_entries;
 static struct radix_tree_root ivrs_maps;
 struct list_head amd_iommu_head;
 struct table_struct device_table;
+bool_t iommuv2_enabled;
 
 static int iommu_has_ht_flag(struct amd_iommu *iommu, u8 mask)
 {
@@ -765,6 +766,10 @@ static void enable_iommu(struct amd_iomm
         amd_iommu_flush_all_caches(iommu);
 
     iommu->enabled = 1;
+
+    if ( iommu->features )
+        iommuv2_enabled = 1;
+
     spin_unlock_irqrestore(&iommu->lock, flags);
 
 }
diff -r 31e61ed495ae -r 82f5e77e13c4 xen/include/asm-x86/amd-iommu.h
--- a/xen/include/asm-x86/amd-iommu.h   Tue Jan 10 17:40:01 2012 +0100
+++ b/xen/include/asm-x86/amd-iommu.h   Tue Jan 10 17:40:04 2012 +0100
@@ -182,4 +182,6 @@ struct guest_iommu {
     struct guest_iommu_msi  msi;
 };
 
+extern bool_t iommuv2_enabled;
+
 #endif /* _ASM_X86_64_AMD_IOMMU_H */


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


 


Rackspace

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