aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorAlex Williamson2014-02-26 12:38:40 -0600
committerAlex Williamson2014-02-26 12:38:40 -0600
commit9d830d47c7a756da6f0b55fa25d51eec0739eb02 (patch)
tree3f40dbe93c1b0120246eab829f33490a127e336c /virt
parent88d7ab8949427f492c39f6daf0ac67f0242a88bc (diff)
downloadlinux-phy-9d830d47c7a756da6f0b55fa25d51eec0739eb02.tar.gz
linux-phy-9d830d47c7a756da6f0b55fa25d51eec0739eb02.tar.xz
linux-phy-9d830d47c7a756da6f0b55fa25d51eec0739eb02.zip
kvm/vfio: Support for DMA coherent IOMMUs
VFIO now has support for using the IOMMU_CACHE flag and a mechanism for an external user to test the current operating mode of the IOMMU. Add support for this to the kvm-vfio pseudo device so that we only register noncoherent DMA when necessary. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Cc: Gleb Natapov <gleb@kernel.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/vfio.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c
index b4f9507ae650..ba1a93f935c7 100644
--- a/virt/kvm/vfio.c
+++ b/virt/kvm/vfio.c
@@ -59,6 +59,22 @@ static void kvm_vfio_group_put_external_user(struct vfio_group *vfio_group)
59 symbol_put(vfio_group_put_external_user); 59 symbol_put(vfio_group_put_external_user);
60} 60}
61 61
62static bool kvm_vfio_group_is_coherent(struct vfio_group *vfio_group)
63{
64 long (*fn)(struct vfio_group *, unsigned long);
65 long ret;
66
67 fn = symbol_get(vfio_external_check_extension);
68 if (!fn)
69 return false;
70
71 ret = fn(vfio_group, VFIO_DMA_CC_IOMMU);
72
73 symbol_put(vfio_external_check_extension);
74
75 return ret > 0;
76}
77
62/* 78/*
63 * Groups can use the same or different IOMMU domains. If the same then 79 * Groups can use the same or different IOMMU domains. If the same then
64 * adding a new group may change the coherency of groups we've previously 80 * adding a new group may change the coherency of groups we've previously
@@ -75,13 +91,10 @@ static void kvm_vfio_update_coherency(struct kvm_device *dev)
75 mutex_lock(&kv->lock); 91 mutex_lock(&kv->lock);
76 92
77 list_for_each_entry(kvg, &kv->group_list, node) { 93 list_for_each_entry(kvg, &kv->group_list, node) {
78 /* 94 if (!kvm_vfio_group_is_coherent(kvg->vfio_group)) {
79 * TODO: We need an interface to check the coherency of 95 noncoherent = true;
80 * the IOMMU domain this group is using. For now, assume 96 break;
81 * it's always noncoherent. 97 }
82 */
83 noncoherent = true;
84 break;
85 } 98 }
86 99
87 if (noncoherent != kv->noncoherent) { 100 if (noncoherent != kv->noncoherent) {