diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-06 09:20:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-06 09:20:13 -0400 |
commit | 0803e04011c2e107b9611660301edde94d7010cc (patch) | |
tree | 75699c1999c71a93dc8194a9cac338412e36d78d /drivers/virtio | |
parent | 80fac0f577a35c437219a2786c1804ab8ca1e998 (diff) | |
parent | b226acab2f6aaa45c2af27279b63f622b23a44bd (diff) |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/vhost updates from Michael Tsirkin:
- new vsock device support in host and guest
- platform IOMMU support in host and guest, including compatibility
quirks for legacy systems.
- misc fixes and cleanups.
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
VSOCK: Use kvfree()
vhost: split out vringh Kconfig
vhost: detect 32 bit integer wrap around
vhost: new device IOTLB API
vhost: drop vringh dependency
vhost: convert pre sorted vhost memory array to interval tree
vhost: introduce vhost memory accessors
VSOCK: Add Makefile and Kconfig
VSOCK: Introduce vhost_vsock.ko
VSOCK: Introduce virtio_transport.ko
VSOCK: Introduce virtio_vsock_common.ko
VSOCK: defer sock removal to transports
VSOCK: transport-specific vsock_transport functions
vhost: drop vringh dependency
vop: pull in vhost Kconfig
virtio: new feature to detect IOMMU device quirk
balloon: check the number of available pages in leak balloon
vhost: lockless enqueuing
vhost: simplify work flushing
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_balloon.c | 2 | ||||
-rw-r--r-- | drivers/virtio/virtio_ring.c | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 888d5f8322ce..4e7003db12c4 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -207,6 +207,8 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num) | |||
207 | num = min(num, ARRAY_SIZE(vb->pfns)); | 207 | num = min(num, ARRAY_SIZE(vb->pfns)); |
208 | 208 | ||
209 | mutex_lock(&vb->balloon_lock); | 209 | mutex_lock(&vb->balloon_lock); |
210 | /* We can't release more pages than taken */ | ||
211 | num = min(num, (size_t)vb->num_pages); | ||
210 | for (vb->num_pfns = 0; vb->num_pfns < num; | 212 | for (vb->num_pfns = 0; vb->num_pfns < num; |
211 | vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) { | 213 | vb->num_pfns += VIRTIO_BALLOON_PAGES_PER_PAGE) { |
212 | page = balloon_page_dequeue(vb_dev_info); | 214 | page = balloon_page_dequeue(vb_dev_info); |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index ca6bfddaacad..114a0c88afb8 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -117,7 +117,10 @@ struct vring_virtqueue { | |||
117 | #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) | 117 | #define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq) |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * The interaction between virtio and a possible IOMMU is a mess. | 120 | * Modern virtio devices have feature bits to specify whether they need a |
121 | * quirk and bypass the IOMMU. If not there, just use the DMA API. | ||
122 | * | ||
123 | * If there, the interaction between virtio and DMA API is messy. | ||
121 | * | 124 | * |
122 | * On most systems with virtio, physical addresses match bus addresses, | 125 | * On most systems with virtio, physical addresses match bus addresses, |
123 | * and it doesn't particularly matter whether we use the DMA API. | 126 | * and it doesn't particularly matter whether we use the DMA API. |
@@ -133,10 +136,18 @@ struct vring_virtqueue { | |||
133 | * | 136 | * |
134 | * For the time being, we preserve historic behavior and bypass the DMA | 137 | * For the time being, we preserve historic behavior and bypass the DMA |
135 | * API. | 138 | * API. |
139 | * | ||
140 | * TODO: install a per-device DMA ops structure that does the right thing | ||
141 | * taking into account all the above quirks, and use the DMA API | ||
142 | * unconditionally on data path. | ||
136 | */ | 143 | */ |
137 | 144 | ||
138 | static bool vring_use_dma_api(struct virtio_device *vdev) | 145 | static bool vring_use_dma_api(struct virtio_device *vdev) |
139 | { | 146 | { |
147 | if (!virtio_has_iommu_quirk(vdev)) | ||
148 | return true; | ||
149 | |||
150 | /* Otherwise, we are left to guess. */ | ||
140 | /* | 151 | /* |
141 | * In theory, it's possible to have a buggy QEMU-supposed | 152 | * In theory, it's possible to have a buggy QEMU-supposed |
142 | * emulated Q35 IOMMU and Xen enabled at the same time. On | 153 | * emulated Q35 IOMMU and Xen enabled at the same time. On |
@@ -1099,6 +1110,8 @@ void vring_transport_features(struct virtio_device *vdev) | |||
1099 | break; | 1110 | break; |
1100 | case VIRTIO_F_VERSION_1: | 1111 | case VIRTIO_F_VERSION_1: |
1101 | break; | 1112 | break; |
1113 | case VIRTIO_F_IOMMU_PLATFORM: | ||
1114 | break; | ||
1102 | default: | 1115 | default: |
1103 | /* We don't understand this bit. */ | 1116 | /* We don't understand this bit. */ |
1104 | __virtio_clear_bit(vdev, i); | 1117 | __virtio_clear_bit(vdev, i); |