diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 23:50:30 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 23:50:30 -0500 |
| commit | 64ec45bff6b3dade2643ed4c0f688a15ecf46ea2 (patch) | |
| tree | 29816f500d80a64c84455778918d94ff3ddf02e4 | |
| parent | c0f486fde3f353232c1cc2fd4d62783ac782a467 (diff) | |
| parent | 5ff16110c637726111662c1df41afd9df7ef36bd (diff) | |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael S Tsirkin:
"virtio 1.0 related fixes
Most importantly, this fixes using virtio_pci as a module.
Further, the big virtio 1.0 conversion missed a couple of places.
This fixes them up.
This isn't 100% sparse-clean yet because on many architectures
get_user triggers sparse warnings when used with __bitwise tag (when
same tag is on both pointer and value read).
I posted a patchset to fix it up by adding __force on all arches that
don't already have it (many do), when that's merged these warnings
will go away"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio_pci: restore module attributes
mic/host: fix up virtio 1.0 APIs
vringh: update for virtio 1.0 APIs
vringh: 64 bit features
tools/virtio: add virtio 1.0 in vringh_test
tools/virtio: add virtio 1.0 in virtio_test
tools/virtio: enable -Werror
tools/virtio: 64 bit features
tools/virtio: fix vringh test
tools/virtio: more stubs
virtio: core support for config generation
virtio_pci: add VIRTIO_PCI_NO_LEGACY
virtio_pci: move probe to common file
virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY
virtio_config: fix virtio_cread_bytes
virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore
| -rw-r--r-- | drivers/misc/mic/host/mic_debugfs.c | 18 | ||||
| -rw-r--r-- | drivers/vhost/vringh.c | 125 | ||||
| -rw-r--r-- | drivers/virtio/virtio.c | 37 | ||||
| -rw-r--r-- | drivers/virtio/virtio_pci_common.c | 39 | ||||
| -rw-r--r-- | drivers/virtio/virtio_pci_common.h | 7 | ||||
| -rw-r--r-- | drivers/virtio/virtio_pci_legacy.c | 24 | ||||
| -rw-r--r-- | include/linux/virtio_config.h | 29 | ||||
| -rw-r--r-- | include/linux/vringh.h | 37 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_pci.h | 15 | ||||
| -rw-r--r-- | tools/virtio/Makefile | 2 | ||||
| -rw-r--r-- | tools/virtio/linux/virtio.h | 1 | ||||
| -rw-r--r-- | tools/virtio/linux/virtio_byteorder.h | 8 | ||||
| -rw-r--r-- | tools/virtio/linux/virtio_config.h | 70 | ||||
| -rw-r--r-- | tools/virtio/uapi/linux/virtio_types.h | 1 | ||||
| -rw-r--r-- | tools/virtio/virtio_test.c | 15 | ||||
| -rw-r--r-- | tools/virtio/vringh_test.c | 5 |
16 files changed, 324 insertions, 109 deletions
diff --git a/drivers/misc/mic/host/mic_debugfs.c b/drivers/misc/mic/host/mic_debugfs.c index 028ba5d6fd1c..687e9aacf3bb 100644 --- a/drivers/misc/mic/host/mic_debugfs.c +++ b/drivers/misc/mic/host/mic_debugfs.c | |||
| @@ -326,21 +326,27 @@ static int mic_vdev_info_show(struct seq_file *s, void *unused) | |||
| 326 | } | 326 | } |
| 327 | avail = vrh->vring.avail; | 327 | avail = vrh->vring.avail; |
| 328 | seq_printf(s, "avail flags 0x%x idx %d\n", | 328 | seq_printf(s, "avail flags 0x%x idx %d\n", |
| 329 | avail->flags, avail->idx & (num - 1)); | 329 | vringh16_to_cpu(vrh, avail->flags), |
| 330 | vringh16_to_cpu(vrh, avail->idx) & (num - 1)); | ||
| 330 | seq_printf(s, "avail flags 0x%x idx %d\n", | 331 | seq_printf(s, "avail flags 0x%x idx %d\n", |
| 331 | avail->flags, avail->idx); | 332 | vringh16_to_cpu(vrh, avail->flags), |
| 333 | vringh16_to_cpu(vrh, avail->idx)); | ||
| 332 | for (j = 0; j < num; j++) | 334 | for (j = 0; j < num; j++) |
| 333 | seq_printf(s, "avail ring[%d] %d\n", | 335 | seq_printf(s, "avail ring[%d] %d\n", |
| 334 | j, avail->ring[j]); | 336 | j, avail->ring[j]); |
| 335 | used = vrh->vring.used; | 337 | used = vrh->vring.used; |
| 336 | seq_printf(s, "used flags 0x%x idx %d\n", | 338 | seq_printf(s, "used flags 0x%x idx %d\n", |
| 337 | used->flags, used->idx & (num - 1)); | 339 | vringh16_to_cpu(vrh, used->flags), |
| 340 | vringh16_to_cpu(vrh, used->idx) & (num - 1)); | ||
| 338 | seq_printf(s, "used flags 0x%x idx %d\n", | 341 | seq_printf(s, "used flags 0x%x idx %d\n", |
| 339 | used->flags, used->idx); | 342 | vringh16_to_cpu(vrh, used->flags), |
| 343 | vringh16_to_cpu(vrh, used->idx)); | ||
| 340 | for (j = 0; j < num; j++) | 344 | for (j = 0; j < num; j++) |
| 341 | seq_printf(s, "used ring[%d] id %d len %d\n", | 345 | seq_printf(s, "used ring[%d] id %d len %d\n", |
| 342 | j, used->ring[j].id, | 346 | j, vringh32_to_cpu(vrh, |
| 343 | used->ring[j].len); | 347 | used->ring[j].id), |
| 348 | vringh32_to_cpu(vrh, | ||
| 349 | used->ring[j].len)); | ||
| 344 | } | 350 | } |
| 345 | } | 351 | } |
| 346 | mutex_unlock(&mdev->mic_mutex); | 352 | mutex_unlock(&mdev->mic_mutex); |
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index 5174ebac288d..3bb02c60a2f5 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/uaccess.h> | 11 | #include <linux/uaccess.h> |
| 12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
| 13 | #include <linux/export.h> | 13 | #include <linux/export.h> |
| 14 | #include <uapi/linux/virtio_config.h> | ||
| 14 | 15 | ||
| 15 | static __printf(1,2) __cold void vringh_bad(const char *fmt, ...) | 16 | static __printf(1,2) __cold void vringh_bad(const char *fmt, ...) |
| 16 | { | 17 | { |
| @@ -28,13 +29,14 @@ static __printf(1,2) __cold void vringh_bad(const char *fmt, ...) | |||
| 28 | 29 | ||
| 29 | /* Returns vring->num if empty, -ve on error. */ | 30 | /* Returns vring->num if empty, -ve on error. */ |
| 30 | static inline int __vringh_get_head(const struct vringh *vrh, | 31 | static inline int __vringh_get_head(const struct vringh *vrh, |
| 31 | int (*getu16)(u16 *val, const u16 *p), | 32 | int (*getu16)(const struct vringh *vrh, |
| 33 | u16 *val, const __virtio16 *p), | ||
| 32 | u16 *last_avail_idx) | 34 | u16 *last_avail_idx) |
| 33 | { | 35 | { |
| 34 | u16 avail_idx, i, head; | 36 | u16 avail_idx, i, head; |
| 35 | int err; | 37 | int err; |
| 36 | 38 | ||
| 37 | err = getu16(&avail_idx, &vrh->vring.avail->idx); | 39 | err = getu16(vrh, &avail_idx, &vrh->vring.avail->idx); |
| 38 | if (err) { | 40 | if (err) { |
| 39 | vringh_bad("Failed to access avail idx at %p", | 41 | vringh_bad("Failed to access avail idx at %p", |
| 40 | &vrh->vring.avail->idx); | 42 | &vrh->vring.avail->idx); |
| @@ -49,7 +51,7 @@ static inline int __vringh_get_head(const struct vringh *vrh, | |||
| 49 | 51 | ||
| 50 | i = *last_avail_idx & (vrh->vring.num - 1); | 52 | i = *last_avail_idx & (vrh->vring.num - 1); |
| 51 | 53 | ||
| 52 | err = getu16(&head, &vrh->vring.avail->ring[i]); | 54 | err = getu16(vrh, &head, &vrh->vring.avail->ring[i]); |
| 53 | if (err) { | 55 | if (err) { |
| 54 | vringh_bad("Failed to read head: idx %d address %p", | 56 | vringh_bad("Failed to read head: idx %d address %p", |
| 55 | *last_avail_idx, &vrh->vring.avail->ring[i]); | 57 | *last_avail_idx, &vrh->vring.avail->ring[i]); |
| @@ -144,28 +146,32 @@ static inline bool no_range_check(struct vringh *vrh, u64 addr, size_t *len, | |||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | /* No reason for this code to be inline. */ | 148 | /* No reason for this code to be inline. */ |
| 147 | static int move_to_indirect(int *up_next, u16 *i, void *addr, | 149 | static int move_to_indirect(const struct vringh *vrh, |
| 150 | int *up_next, u16 *i, void *addr, | ||
| 148 | const struct vring_desc *desc, | 151 | const struct vring_desc *desc, |
| 149 | struct vring_desc **descs, int *desc_max) | 152 | struct vring_desc **descs, int *desc_max) |
| 150 | { | 153 | { |
| 154 | u32 len; | ||
| 155 | |||
| 151 | /* Indirect tables can't have indirect. */ | 156 | /* Indirect tables can't have indirect. */ |
| 152 | if (*up_next != -1) { | 157 | if (*up_next != -1) { |
| 153 | vringh_bad("Multilevel indirect %u->%u", *up_next, *i); | 158 | vringh_bad("Multilevel indirect %u->%u", *up_next, *i); |
| 154 | return -EINVAL; | 159 | return -EINVAL; |
| 155 | } | 160 | } |
| 156 | 161 | ||
| 157 | if (unlikely(desc->len % sizeof(struct vring_desc))) { | 162 | len = vringh32_to_cpu(vrh, desc->len); |
| 163 | if (unlikely(len % sizeof(struct vring_desc))) { | ||
| 158 | vringh_bad("Strange indirect len %u", desc->len); | 164 | vringh_bad("Strange indirect len %u", desc->len); |
| 159 | return -EINVAL; | 165 | return -EINVAL; |
| 160 | } | 166 | } |
| 161 | 167 | ||
| 162 | /* We will check this when we follow it! */ | 168 | /* We will check this when we follow it! */ |
| 163 | if (desc->flags & VRING_DESC_F_NEXT) | 169 | if (desc->flags & cpu_to_vringh16(vrh, VRING_DESC_F_NEXT)) |
| 164 | *up_next = desc->next; | 170 | *up_next = vringh16_to_cpu(vrh, desc->next); |
| 165 | else | 171 | else |
| 166 | *up_next = -2; | 172 | *up_next = -2; |
| 167 | *descs = addr; | 173 | *descs = addr; |
| 168 | *desc_max = desc->len / sizeof(struct vring_desc); | 174 | *desc_max = len / sizeof(struct vring_desc); |
| 169 | 175 | ||
| 170 | /* Now, start at the first indirect. */ | 176 | /* Now, start at the first indirect. */ |
| 171 | *i = 0; | 177 | *i = 0; |
| @@ -287,22 +293,25 @@ __vringh_iov(struct vringh *vrh, u16 i, | |||
| 287 | if (unlikely(err)) | 293 | if (unlikely(err)) |
| 288 | goto fail; | 294 | goto fail; |
| 289 | 295 | ||
| 290 | if (unlikely(desc.flags & VRING_DESC_F_INDIRECT)) { | 296 | if (unlikely(desc.flags & |
| 297 | cpu_to_vringh16(vrh, VRING_DESC_F_INDIRECT))) { | ||
| 298 | u64 a = vringh64_to_cpu(vrh, desc.addr); | ||
| 299 | |||
| 291 | /* Make sure it's OK, and get offset. */ | 300 | /* Make sure it's OK, and get offset. */ |
| 292 | len = desc.len; | 301 | len = vringh32_to_cpu(vrh, desc.len); |
| 293 | if (!rcheck(vrh, desc.addr, &len, &range, getrange)) { | 302 | if (!rcheck(vrh, a, &len, &range, getrange)) { |
| 294 | err = -EINVAL; | 303 | err = -EINVAL; |
| 295 | goto fail; | 304 | goto fail; |
| 296 | } | 305 | } |
| 297 | 306 | ||
| 298 | if (unlikely(len != desc.len)) { | 307 | if (unlikely(len != vringh32_to_cpu(vrh, desc.len))) { |
| 299 | slow = true; | 308 | slow = true; |
