Skip to contentSkip to conversation

vhost: do not verify ring mappings when IOMMU is enabled

PATCH In review Jason Wang 2 participants 2 messages Apr 13, 2018 – Apr 16, 2018

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 vhost: do not verify ring mappings when IOMMU is enabled

When IOMMU is enabled, we store virtqueue metadata as iova (though it may has _phys suffix) and access them through dma helpers. Any translation failures could be reported by IOMMU.

In this case, trying to validate iova against gpa won't work and will cause a false error reporting. So this patch bypasses the ring verification if IOMMU is enabled which is similar to the behavior before 0ca1fd2d6878 that calls vhost_memory_map() which is a nop when IOMMU is enabled.

Fixes 0ca1fd2d6878 ("vhost: Simplify ring verification checks")
Cc Dr. David Alan Gilbert <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 hw/virtio/vhost.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/virtio/vhost.c +4 -0
index f51bf57..9d5850a 100644
@@ -342,6 +342,10 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
         "used ring"
     };
 
+    if (vhost_dev_has_iommu(dev)) {
+        return 0;
+    }
+
     for (i = 0; i < dev->nvqs; ++i) {
         struct vhost_virtqueue *vq = dev->vqs + i;
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Fri, 13 Apr 2018 11:01:49 +0800 Jason Wang <[email protected]> wrote:

When IOMMU is enabled, we store virtqueue metadata as iova (though it may has _phys suffix) and access them through dma helpers. Any translation failures could be reported by IOMMU.

In this case, trying to validate iova against gpa won't work and will cause a false error reporting. So this patch bypasses the ring verification if IOMMU is enabled which is similar to the behavior before 0ca1fd2d6878 that calls vhost_memory_map() which is a nop when IOMMU is enabled.

Quoted 5 lines
Fixes 0ca1fd2d6878 ("vhost: Simplify ring verification checks")
Cc Dr. David Alan Gilbert <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Michael S. Tsirkin <[email protected]>

Looks like candidat for 2.12 if it's not too late?

Quoted 19 lines
---
 hw/virtio/vhost.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/virtio/vhost.c +4 -0
index f51bf57..9d5850a 100644
@@ -342,6 +342,10 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
         "used ring"
     };
 
+    if (vhost_dev_has_iommu(dev)) {
+        return 0;
+    }
+
     for (i = 0; i < dev->nvqs; ++i) {
         struct vhost_virtqueue *vq = dev->vqs + i;