|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 11 of 16] amd iommu: Add a new flag to indication iommuv2 feature enabled or not
# HG changeset patch
# User Wei Wang <wei.wang2@xxxxxxx>
# Date 1324569405 -3600
# Node ID b70cf1dcb110f79546f3efac3201a08d70c8b96e
# Parent 30b1f434160d989be5e0bb6c6956bb7e3985db59
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 30b1f434160d -r b70cf1dcb110 xen/drivers/passthrough/amd/iommu_guest.c
--- a/xen/drivers/passthrough/amd/iommu_guest.c Thu Dec 22 16:56:41 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_guest.c Thu Dec 22 16:56:45 2011 +0100
@@ -48,6 +48,8 @@
(reg)->hi = (val >> 32) & 0xFFFFFFFF; \
} while(0)
+extern bool_t iommuv2_enabled;
+
static unsigned int machine_bdf(struct domain *d, uint16_t guest_bdf)
{
struct pci_dev *pdev;
@@ -819,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;
@@ -878,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);
@@ -902,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);
@@ -919,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) );
}
@@ -935,7 +941,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);
@@ -960,7 +966,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 30b1f434160d -r b70cf1dcb110 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c Thu Dec 22 16:56:41 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_init.c Thu Dec 22 16:56:45 2011 +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)
{
@@ -759,6 +760,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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |