Skip to contentSkip to conversation

amd iommu: Add a new flag to indication iommuv2 feature enabled or not

PATCH Superseded Wei Wang 1 participant 2 messages Jan 20, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Wei Wang

author
#1 lore raw

PATCH v4 1/1 amd iommu: Add a new flag to indication iommuv2 feature enabled or not

# HG changeset patch
# User Wei Wang <[email protected]>
# Date 1327066820 -3600
# Node ID ea3af8fa078c07d357de79931a102450b59156ea
# Parent 978e61814be49ec544151803be3e3b2717551316
amd iommu: Add a new flag to indication iommuv2 feature enabled or not. Hypercalls should return early on non-iommuv2 systems.

xen/drivers/passthrough/amd/iommu_guest.c +9 -3
diff -r 978e61814be4 -r ea3af8fa078c xen/drivers/passthrough/amd/iommu_guest.c
@@ -825,6 +825,9 @@ int guest_iommu_set_base(struct domain *
     if ( !iommu )
         return -EACCES;
 
+    if ( !is_hvm_domain(d) || !iommuv2_enabled )
+        return 1;
+
     iommu->mmio_base = base;
     base >>= PAGE_SHIFT;
 
@@ -884,7 +887,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);
@@ -916,6 +919,9 @@ void guest_iommu_destroy(struct domain *
     iommu = domain_iommu(d);
     if ( !iommu )
         return;
+
+    if ( !iommuv2_enabled )
+        return;
 
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
@@ -944,7 +950,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);
@@ -970,7 +976,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;
xen/drivers/passthrough/amd/iommu_init.c +5 -0
diff -r 978e61814be4 -r ea3af8fa078c xen/drivers/passthrough/amd/iommu_init.c
@@ -38,6 +38,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)
 {
@@ -799,6 +800,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);
 
 }
xen/include/asm-x86/amd-iommu.h +2 -0
diff -r 978e61814be4 -r ea3af8fa078c xen/include/asm-x86/amd-iommu.h
@@ -182,4 +182,6 @@ struct guest_iommu {
     struct guest_iommu_msi  msi;
 };
 
+extern bool_t iommuv2_enabled;
+
 #endif /* _ASM_X86_64_AMD_IOMMU_H */

_______________________________________________
osrc-patches mailing list
[email protected]
https://elbe.amd.com/mailman/listinfo/osrc-patches

author
#2 lore raw

PATCH v4 1/1 amd iommu: Add a new flag to indication iommuv2 feature enabled or not

In reply to a message not in the archive

# HG changeset patch
# User Wei Wang <[email protected]>
# Date 1327066820 -3600
# Node ID ea3af8fa078c07d357de79931a102450b59156ea
# Parent 978e61814be49ec544151803be3e3b2717551316
amd iommu: Add a new flag to indication iommuv2 feature enabled or not. Hypercalls should return early on non-iommuv2 systems.

xen/drivers/passthrough/amd/iommu_guest.c +9 -3
diff -r 978e61814be4 -r ea3af8fa078c xen/drivers/passthrough/amd/iommu_guest.c
@@ -825,6 +825,9 @@ int guest_iommu_set_base(struct domain *
     if ( !iommu )
         return -EACCES;
 
+    if ( !is_hvm_domain(d) || !iommuv2_enabled )
+        return 1;
+
     iommu->mmio_base = base;
     base >>= PAGE_SHIFT;
 
@@ -884,7 +887,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);
@@ -916,6 +919,9 @@ void guest_iommu_destroy(struct domain *
     iommu = domain_iommu(d);
     if ( !iommu )
         return;
+
+    if ( !iommuv2_enabled )
+        return;
 
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
@@ -944,7 +950,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);
@@ -970,7 +976,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;
xen/drivers/passthrough/amd/iommu_init.c +5 -0
diff -r 978e61814be4 -r ea3af8fa078c xen/drivers/passthrough/amd/iommu_init.c
@@ -38,6 +38,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)
 {
@@ -799,6 +800,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);
 
 }
xen/include/asm-x86/amd-iommu.h +2 -0
diff -r 978e61814be4 -r ea3af8fa078c xen/include/asm-x86/amd-iommu.h
@@ -182,4 +182,6 @@ struct guest_iommu {
     struct guest_iommu_msi  msi;
 };
 
+extern bool_t iommuv2_enabled;
+
 #endif /* _ASM_X86_64_AMD_IOMMU_H */

_______________________________________________
osrc-patches mailing list
[email protected]
https://elbe.amd.com/mailman/listinfo/osrc-patches