aboutsummaryrefslogtreecommitdiffstats
path: root/xen
diff options
context:
space:
mode:
authorWei Wang <wei.wang2@amd.com>2012-01-28 13:40:36 +0000
committerWei Wang <wei.wang2@amd.com>2012-01-28 13:40:36 +0000
commit90803ac5c9354fc5cb8042b494a53fa083b672e8 (patch)
tree34181700d9609e1a525762a2a820abc0c78563c3 /xen
parentc1cdf27925e1bfebf16fe33000509cce5e115df5 (diff)
downloadxen-90803ac5c9354fc5cb8042b494a53fa083b672e8.tar.gz
xen-90803ac5c9354fc5cb8042b494a53fa083b672e8.tar.bz2
xen-90803ac5c9354fc5cb8042b494a53fa083b672e8.zip
amd iommu: disable iommu emulation on non-iommu systems
Introduce a new flag to disable iommu emulation on old iommu systems. This patch is taken from my v4 patch queue, which is till pending, to make old or non-iommu system to run cleanly without interfered by iommuv2 codes. This might be helpful to isolate iommuv2 code in debugging unstable regressions. The reset part of v4 will be re-based. Signed-off-by: Wei Wang <wei.wang2@amd.com> Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen')
-rw-r--r--xen/drivers/passthrough/amd/iommu_guest.c7
-rw-r--r--xen/drivers/passthrough/amd/iommu_init.c5
-rw-r--r--xen/include/asm-x86/amd-iommu.h2
3 files changed, 12 insertions, 2 deletions
diff --git a/xen/drivers/passthrough/amd/iommu_guest.c b/xen/drivers/passthrough/amd/iommu_guest.c
index b88056ec60..337d72b268 100644
--- a/xen/drivers/passthrough/amd/iommu_guest.c
+++ b/xen/drivers/passthrough/amd/iommu_guest.c
@@ -805,6 +805,9 @@ int guest_iommu_set_base(struct domain *d, uint64_t base)
p2m_type_t t;
struct guest_iommu *iommu = domain_iommu(d);
+ if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled )
+ return 0;
+
if ( !iommu )
return -EACCES;
@@ -867,7 +870,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) || !iommu_enabled || !iommuv2_enabled )
return 0;
iommu = xzalloc(struct guest_iommu);
@@ -893,7 +896,7 @@ void guest_iommu_destroy(struct domain *d)
{
struct guest_iommu *iommu;
- if ( !is_hvm_domain(d) )
+ if ( !is_hvm_domain(d) || !iommu_enabled || !iommuv2_enabled )
return;
iommu = domain_iommu(d);
diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 5a98cb83a8..e091fb2490 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/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)
{
@@ -887,6 +888,9 @@ static int __init amd_iommu_init_one(struct amd_iommu *iommu)
get_iommu_features(iommu);
+ if ( iommu->features )
+ iommuv2_enabled = 1;
+
if ( allocate_cmd_buffer(iommu) == NULL )
goto error_out;
@@ -950,6 +954,7 @@ static void __init amd_iommu_init_cleanup(void)
iommu_enabled = 0;
iommu_passthrough = 0;
iommu_intremap = 0;
+ iommuv2_enabled = 0;
}
/*
diff --git a/xen/include/asm-x86/amd-iommu.h b/xen/include/asm-x86/amd-iommu.h
index 41e0a05ca7..0a781c90d2 100644
--- a/xen/include/asm-x86/amd-iommu.h
+++ b/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 */