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 /tools | |
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
Diffstat (limited to 'tools')
-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 |
7 files changed, 97 insertions, 5 deletions
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile index 9325f4693821..505ad51b3b51 100644 --- a/tools/virtio/Makefile +++ b/tools/virtio/Makefile | |||
@@ -3,7 +3,7 @@ test: virtio_test vringh_test | |||
3 | virtio_test: virtio_ring.o virtio_test.o | 3 | virtio_test: virtio_ring.o virtio_test.o |
4 | vringh_test: vringh_test.o vringh.o virtio_ring.o | 4 | vringh_test: vringh_test.o vringh.o virtio_ring.o |
5 | 5 | ||
6 | CFLAGS += -g -O2 -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE | 6 | CFLAGS += -g -O2 -Werror -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE |
7 | vpath %.c ../../drivers/virtio ../../drivers/vhost | 7 | vpath %.c ../../drivers/virtio ../../drivers/vhost |
8 | mod: | 8 | mod: |
9 | ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test | 9 | ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test |
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index 8eb6421761cd..a3e07016a440 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h | |||
@@ -6,6 +6,7 @@ | |||
6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ | 6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ |
7 | #define list_add_tail(a, b) do {} while (0) | 7 | #define list_add_tail(a, b) do {} while (0) |
8 | #define list_del(a) do {} while (0) | 8 | #define list_del(a) do {} while (0) |
9 | #define list_for_each_entry(a, b, c) while (0) | ||
9 | /* end of stubs */ | 10 | /* end of stubs */ |
10 | 11 | ||
11 | struct virtio_device { | 12 | struct virtio_device { |
diff --git a/tools/virtio/linux/virtio_byteorder.h b/tools/virtio/linux/virtio_byteorder.h new file mode 100644 index 000000000000..9de9e6ac1d10 --- /dev/null +++ b/tools/virtio/linux/virtio_byteorder.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _LINUX_VIRTIO_BYTEORDER_STUB_H | ||
2 | #define _LINUX_VIRTIO_BYTEORDER_STUB_H | ||
3 | |||
4 | #include <asm/byteorder.h> | ||
5 | #include "../../include/linux/byteorder/generic.h" | ||
6 | #include "../../include/linux/virtio_byteorder.h" | ||
7 | |||
8 | #endif | ||
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h index 83b27e8e9d72..806d683ab107 100644 --- a/tools/virtio/linux/virtio_config.h +++ b/tools/virtio/linux/virtio_config.h | |||
@@ -1,6 +1,72 @@ | |||
1 | #define VIRTIO_TRANSPORT_F_START 28 | 1 | #include <linux/virtio_byteorder.h> |
2 | #define VIRTIO_TRANSPORT_F_END 32 | 2 | #include <linux/virtio.h> |
3 | #include <uapi/linux/virtio_config.h> | ||
4 | |||
5 | /* | ||
6 | * __virtio_test_bit - helper to test feature bits. For use by transports. | ||
7 | * Devices should normally use virtio_has_feature, | ||
8 | * which includes more checks. | ||
9 | * @vdev: the device | ||
10 | * @fbit: the feature bit | ||
11 | */ | ||
12 | static inline bool __virtio_test_bit(const struct virtio_device *vdev, | ||
13 | unsigned int fbit) | ||
14 | { | ||
15 | return vdev->features & (1ULL << fbit); | ||
16 | } | ||
17 | |||
18 | /** | ||
19 | * __virtio_set_bit - helper to set feature bits. For use by transports. | ||
20 | * @vdev: the device | ||
21 | * @fbit: the feature bit | ||
22 | */ | ||
23 | static inline void __virtio_set_bit(struct virtio_device *vdev, | ||
24 | unsigned int fbit) | ||
25 | { | ||
26 | vdev->features |= (1ULL << fbit); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * __virtio_clear_bit - helper to clear feature bits. For use by transports. | ||
31 | * @vdev: the device | ||
32 | * @fbit: the feature bit | ||
33 | */ | ||
34 | static inline void __virtio_clear_bit(struct virtio_device *vdev, | ||
35 | unsigned int fbit) | ||
36 | { | ||
37 | vdev->features &= ~(1ULL << fbit); | ||
38 | } | ||
3 | 39 | ||
4 | #define virtio_has_feature(dev, feature) \ | 40 | #define virtio_has_feature(dev, feature) \ |
5 | (__virtio_test_bit((dev), feature)) | 41 | (__virtio_test_bit((dev), feature)) |
6 | 42 | ||
43 | static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val) | ||
44 | { | ||
45 | return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
46 | } | ||
47 | |||
48 | static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val) | ||
49 | { | ||
50 | return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
51 | } | ||
52 | |||
53 | static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val) | ||
54 | { | ||
55 | return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
56 | } | ||
57 | |||
58 | static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val) | ||
59 | { | ||
60 | return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
61 | } | ||
62 | |||
63 | static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val) | ||
64 | { | ||
65 | return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
66 | } | ||
67 | |||
68 | static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) | ||
69 | { | ||
70 | return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
71 | } | ||
72 | |||
diff --git a/tools/virtio/uapi/linux/virtio_types.h b/tools/virtio/uapi/linux/virtio_types.h new file mode 100644 index 000000000000..e7a1096e7c97 --- /dev/null +++ b/tools/virtio/uapi/linux/virtio_types.h | |||
@@ -0,0 +1 @@ | |||
#include "../../include/uapi/linux/virtio_types.h" | |||
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index db3437c641a6..e0445898f08f 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <sys/types.h> | 11 | #include <sys/types.h> |
12 | #include <fcntl.h> | 12 | #include <fcntl.h> |
13 | #include <stdbool.h> | 13 | #include <stdbool.h> |
14 | #include <linux/virtio_types.h> | ||
14 | #include <linux/vhost.h> | 15 | #include <linux/vhost.h> |
15 | #include <linux/virtio.h> | 16 | #include <linux/virtio.h> |
16 | #include <linux/virtio_ring.h> | 17 | #include <linux/virtio_ring.h> |
@@ -227,6 +228,14 @@ const struct option longopts[] = { | |||
227 | .val = 'i', | 228 | .val = 'i', |
228 | }, | 229 | }, |
229 | { | 230 | { |
231 | .name = "virtio-1", | ||
232 | .val = '1', | ||
233 | }, | ||
234 | { | ||
235 | .name = "no-virtio-1", | ||
236 | .val = '0', | ||
237 | }, | ||
238 | { | ||
230 | .name = "delayed-interrupt", | 239 | .name = "delayed-interrupt", |
231 | .val = 'D', | 240 | .val = 'D', |
232 | }, | 241 | }, |
@@ -243,6 +252,7 @@ static void help(void) | |||
243 | fprintf(stderr, "Usage: virtio_test [--help]" | 252 | fprintf(stderr, "Usage: virtio_test [--help]" |
244 | " [--no-indirect]" | 253 | " [--no-indirect]" |
245 | " [--no-event-idx]" | 254 | " [--no-event-idx]" |
255 | " [--no-virtio-1]" | ||
246 | " [--delayed-interrupt]" | 256 | " [--delayed-interrupt]" |
247 | "\n"); | 257 | "\n"); |
248 | } | 258 | } |
@@ -251,7 +261,7 @@ int main(int argc, char **argv) | |||
251 | { | 261 | { |
252 | struct vdev_info dev; | 262 | struct vdev_info dev; |
253 | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | | 263 | unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | |
254 | (1ULL << VIRTIO_RING_F_EVENT_IDX); | 264 | (1ULL << VIRTIO_RING_F_EVENT_IDX) | (1ULL << VIRTIO_F_VERSION_1); |
255 | int o; | 265 | int o; |
256 | bool delayed = false; | 266 | bool delayed = false; |
257 | 267 | ||
@@ -272,6 +282,9 @@ int main(int argc, char **argv) | |||
272 | case 'i': | 282 | case 'i': |
273 | features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); | 283 | features &= ~(1ULL << VIRTIO_RING_F_INDIRECT_DESC); |
274 | break; | 284 | break; |
285 | case '0': | ||
286 | features &= ~(1ULL << VIRTIO_F_VERSION_1); | ||
287 | break; | ||
275 | case 'D': | 288 | case 'D': |
276 | delayed = true; | 289 | delayed = true; |
277 | break; | 290 | break; |
diff --git a/tools/virtio/vringh_test.c b/tools/virtio/vringh_test.c index 9d4b1bca54be..5f94f5105678 100644 --- a/tools/virtio/vringh_test.c +++ b/tools/virtio/vringh_test.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/virtio.h> | 7 | #include <linux/virtio.h> |
8 | #include <linux/vringh.h> | 8 | #include <linux/vringh.h> |
9 | #include <linux/virtio_ring.h> | 9 | #include <linux/virtio_ring.h> |
10 | #include <linux/virtio_config.h> | ||
10 | #include <linux/uaccess.h> | 11 | #include <linux/uaccess.h> |
11 | #include <sys/types.h> | 12 | #include <sys/types.h> |
12 | #include <sys/stat.h> | 13 | #include <sys/stat.h> |
@@ -131,7 +132,7 @@ static inline int vringh_get_head(struct vringh *vrh, u16 *head) | |||
131 | return 1; | 132 | return 1; |
132 | } | 133 | } |
133 | 134 | ||
134 | static int parallel_test(unsigned long features, | 135 | static int parallel_test(u64 features, |
135 | bool (*getrange)(struct vringh *vrh, | 136 | bool (*getrange)(struct vringh *vrh, |
136 | u64 addr, struct vringh_range *r), | 137 | u64 addr, struct vringh_range *r), |
137 | bool fast_vringh) | 138 | bool fast_vringh) |
@@ -456,6 +457,8 @@ int main(int argc, char *argv[]) | |||
456 | __virtio_set_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); | 457 | __virtio_set_bit(&vdev, VIRTIO_RING_F_INDIRECT_DESC); |
457 | else if (strcmp(argv[1], "--eventidx") == 0) | 458 | else if (strcmp(argv[1], "--eventidx") == 0) |
458 | __virtio_set_bit(&vdev, VIRTIO_RING_F_EVENT_IDX); | 459 | __virtio_set_bit(&vdev, VIRTIO_RING_F_EVENT_IDX); |
460 | else if (strcmp(argv[1], "--virtio-1") == 0) | ||
461 | __virtio_set_bit(&vdev, VIRTIO_F_VERSION_1); | ||
459 | else if (strcmp(argv[1], "--slow-range") == 0) | 462 | else if (strcmp(argv[1], "--slow-range") == 0) |
460 | getrange = getrange_slow; | 463 | getrange = getrange_slow; |
461 | else if (strcmp(argv[1], "--fast-vringh") == 0) | 464 | else if (strcmp(argv[1], "--fast-vringh") == 0) |