aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-10-07 10:39:43 -0400
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:05:24 -0500
commitd025477368792b272802146a86e41f81a54d8a19 (patch)
tree7e296d48d57796d6b797f4da6dac74d1644092fe
parent0ffaeadfc451a11b5da35578b2f9b977f9f46489 (diff)
virtio: add support for 64 bit features.
Change u32 to u64, and use BIT_ULL and 1ULL everywhere. Note: transports are unchanged, and only set low 32 bit. This guarantees that no transport sets e.g. VERSION_1 by mistake without proper support. Based on patch by Rusty. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
-rw-r--r--drivers/lguest/lguest_device.c2
-rw-r--r--drivers/misc/mic/card/mic_virtio.c2
-rw-r--r--drivers/remoteproc/remoteproc_virtio.c2
-rw-r--r--drivers/s390/kvm/kvm_virtio.c2
-rw-r--r--drivers/s390/kvm/virtio_ccw.c2
-rw-r--r--drivers/virtio/virtio.c8
-rw-r--r--drivers/virtio/virtio_mmio.c2
-rw-r--r--drivers/virtio/virtio_pci.c2
-rw-r--r--include/linux/virtio.h2
-rw-r--r--include/linux/virtio_config.h20
-rw-r--r--tools/virtio/linux/virtio.h2
11 files changed, 23 insertions, 23 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 97aeb7dce5fc..d81170a78a8d 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -94,7 +94,7 @@ static unsigned desc_size(const struct lguest_device_desc *desc)
94} 94}
95 95
96/* This gets the device's feature bits. */ 96/* This gets the device's feature bits. */
97static u32 lg_get_features(struct virtio_device *vdev) 97static u64 lg_get_features(struct virtio_device *vdev)
98{ 98{
99 unsigned int i; 99 unsigned int i;
100 u32 features = 0; 100 u32 features = 0;
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index d5da9ff646cb..f5e756132bdb 100644
--- a/drivers/misc/mic/card/mic_virtio.c
+++ b/drivers/misc/mic/card/mic_virtio.c
@@ -68,7 +68,7 @@ static inline struct device *mic_dev(struct mic_vdev *mvdev)
68} 68}
69 69
70/* This gets the device's feature bits. */ 70/* This gets the device's feature bits. */
71static u32 mic_get_features(struct virtio_device *vdev) 71static u64 mic_get_features(struct virtio_device *vdev)
72{ 72{
73 unsigned int i, bits; 73 unsigned int i, bits;
74 u32 features = 0; 74 u32 features = 0;
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index dafaf38dac0a..62897db1331e 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -207,7 +207,7 @@ static void rproc_virtio_reset(struct virtio_device *vdev)
207} 207}
208 208
209/* provide the vdev features as retrieved from the firmware */ 209/* provide the vdev features as retrieved from the firmware */
210static u32 rproc_virtio_get_features(struct virtio_device *vdev) 210static u64 rproc_virtio_get_features(struct virtio_device *vdev)
211{ 211{
212 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); 212 struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
213 struct fw_rsc_vdev *rsc; 213 struct fw_rsc_vdev *rsc;
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index fcd312d0c018..2336c7e3b0cf 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -80,7 +80,7 @@ static unsigned desc_size(const struct kvm_device_desc *desc)
80} 80}
81 81
82/* This gets the device's feature bits. */ 82/* This gets the device's feature bits. */
83static u32 kvm_get_features(struct virtio_device *vdev) 83static u64 kvm_get_features(struct virtio_device *vdev)
84{ 84{
85 unsigned int i; 85 unsigned int i;
86 u32 features = 0; 86 u32 features = 0;
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 1dbee95838fe..56d78956a8cb 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -660,7 +660,7 @@ static void virtio_ccw_reset(struct virtio_device *vdev)
660 kfree(ccw); 660 kfree(ccw);
661} 661}
662 662
663static u32 virtio_ccw_get_features(struct virtio_device *vdev) 663static u64 virtio_ccw_get_features(struct virtio_device *vdev)
664{ 664{
665 struct virtio_ccw_device *vcdev = to_vc_device(vdev); 665 struct virtio_ccw_device *vcdev = to_vc_device(vdev);
666 struct virtio_feature_desc *features; 666 struct virtio_feature_desc *features;
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 2b9aafb4d679..746d350c8062 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -159,7 +159,7 @@ static int virtio_dev_probe(struct device *_d)
159 int err, i; 159 int err, i;
160 struct virtio_device *dev = dev_to_virtio(_d); 160 struct virtio_device *dev = dev_to_virtio(_d);
161 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver); 161 struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
162 u32 device_features; 162 u64 device_features;
163 163
164 /* We have a driver! */ 164 /* We have a driver! */
165 add_status(dev, VIRTIO_CONFIG_S_DRIVER); 165 add_status(dev, VIRTIO_CONFIG_S_DRIVER);
@@ -171,14 +171,14 @@ static int virtio_dev_probe(struct device *_d)
171 dev->features = 0; 171 dev->features = 0;
172 for (i = 0; i < drv->feature_table_size; i++) { 172 for (i = 0; i < drv->feature_table_size; i++) {
173 unsigned int f = drv->feature_table[i]; 173 unsigned int f = drv->feature_table[i];
174 BUG_ON(f >= 32); 174 BUG_ON(f >= 64);
175 if (device_features & (1 << f)) 175 if (device_features & (1ULL << f))
176 __virtio_set_bit(dev, f); 176 __virtio_set_bit(dev, f);
177 } 177 }
178 178
179 /* Transport features always preserved to pass to finalize_features. */ 179 /* Transport features always preserved to pass to finalize_features. */
180 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) 180 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++)
181 if (device_features & (1 << i)) 181 if (device_features & (1ULL << i))
182 __virtio_set_bit(dev, i); 182 __virtio_set_bit(dev, i);
183 183
184 dev->config->finalize_features(dev); 184 dev->config->finalize_features(dev);
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index eb5b0e2b434a..c63d0efa947b 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -142,7 +142,7 @@ struct virtio_mmio_vq_info {
142 142
143/* Configuration interface */ 143/* Configuration interface */
144 144
145static u32 vm_get_features(struct virtio_device *vdev) 145static u64 vm_get_features(struct virtio_device *vdev)
146{ 146{
147 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev); 147 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
148 148
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 4e112c158488..7e0efa7fc384 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -102,7 +102,7 @@ static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
102} 102}
103 103
104/* virtio config->get_features() implementation */ 104/* virtio config->get_features() implementation */
105static u32 vp_get_features(struct virtio_device *vdev) 105static u64 vp_get_features(struct virtio_device *vdev)
106{ 106{
107 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 107 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
108 108
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 7828a7f47c2c..149284e5196d 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -101,7 +101,7 @@ struct virtio_device {
101 const struct virtio_config_ops *config; 101 const struct virtio_config_ops *config;
102 const struct vringh_config_ops *vringh_config; 102 const struct vringh_config_ops *vringh_config;
103 struct list_head vqs; 103 struct list_head vqs;
104 u32 features; 104 u64 features;
105 void *priv; 105 void *priv;
106}; 106};
107 107
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index ffc2ae04879c..f51788439574 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -66,7 +66,7 @@ struct virtio_config_ops {
66 vq_callback_t *callbacks[], 66 vq_callback_t *callbacks[],
67 const char *names[]); 67 const char *names[]);
68 void (*del_vqs)(struct virtio_device *); 68 void (*del_vqs)(struct virtio_device *);
69 u32 (*get_features)(struct virtio_device *vdev); 69 u64 (*get_features)(struct virtio_device *vdev);
70 void (*finalize_features)(struct virtio_device *vdev); 70 void (*finalize_features)(struct virtio_device *vdev);
71 const char *(*bus_name)(struct virtio_device *vdev); 71 const char *(*bus_name)(struct virtio_device *vdev);
72 int (*set_vq_affinity)(struct virtqueue *vq, int cpu); 72 int (*set_vq_affinity)(struct virtqueue *vq, int cpu);
@@ -88,11 +88,11 @@ static inline bool __virtio_test_bit(const struct virtio_device *vdev,
88{ 88{
89 /* Did you forget to fix assumptions on max features? */ 89 /* Did you forget to fix assumptions on max features? */
90 if (__builtin_constant_p(fbit)) 90 if (__builtin_constant_p(fbit))
91 BUILD_BUG_ON(fbit >= 32); 91 BUILD_BUG_ON(fbit >= 64);
92 else 92 else
93 BUG_ON(fbit >= 32); 93 BUG_ON(fbit >= 64);
94 94
95 return vdev->features & BIT(fbit); 95 return vdev->features & BIT_ULL(fbit);
96} 96}
97 97
98/** 98/**
@@ -105,11 +105,11 @@ static inline void __virtio_set_bit(struct virtio_device *vdev,
105{ 105{
106 /* Did you forget to fix assumptions on max features? */ 106 /* Did you forget to fix assumptions on max features? */
107 if (__builtin_constant_p(fbit)) 107 if (__builtin_constant_p(fbit))
108 BUILD_BUG_ON(fbit >= 32); 108 BUILD_BUG_ON(fbit >= 64);
109 else 109 else
110 BUG_ON(fbit >= 32); 110 BUG_ON(fbit >= 64);
111 111
112 vdev->features |= BIT(fbit); 112 vdev->features |= BIT_ULL(fbit);
113} 113}
114 114
115/** 115/**
@@ -122,11 +122,11 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev,
122{ 122{
123 /* Did you forget to fix assumptions on max features? */ 123 /* Did you forget to fix assumptions on max features? */
124 if (__builtin_constant_p(fbit)) 124 if (__builtin_constant_p(fbit))
125 BUILD_BUG_ON(fbit >= 32); 125 BUILD_BUG_ON(fbit >= 64);
126 else 126 else
127 BUG_ON(fbit >= 32); 127 BUG_ON(fbit >= 64);
128 128
129 vdev->features &= ~BIT(fbit); 129 vdev->features &= ~BIT_ULL(fbit);
130} 130}
131 131
132/** 132/**
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index 72bff70bfeeb..8eb6421761cd 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -10,7 +10,7 @@
10 10
11struct virtio_device { 11struct virtio_device {
12 void *dev; 12 void *dev;
13 u32 features; 13 u64 features;
14}; 14};
15 15
16struct virtqueue { 16struct virtqueue {