aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/kvm/kvm_virtio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index d41f234bb2c2..5953510e7d5f 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -88,16 +88,17 @@ static u32 kvm_get_features(struct virtio_device *vdev)
88 return features; 88 return features;
89} 89}
90 90
91static void kvm_set_features(struct virtio_device *vdev, u32 features) 91static void kvm_finalize_features(struct virtio_device *vdev)
92{ 92{
93 unsigned int i; 93 unsigned int i, bits;
94 struct kvm_device_desc *desc = to_kvmdev(vdev)->desc; 94 struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
95 /* Second half of bitmap is features we accept. */ 95 /* Second half of bitmap is features we accept. */
96 u8 *out_features = kvm_vq_features(desc) + desc->feature_len; 96 u8 *out_features = kvm_vq_features(desc) + desc->feature_len;
97 97
98 memset(out_features, 0, desc->feature_len); 98 memset(out_features, 0, desc->feature_len);
99 for (i = 0; i < min(desc->feature_len * 8, 32); i++) { 99 bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
100 if (features & (1 << i)) 100 for (i = 0; i < bits; i++) {
101 if (test_bit(i, vdev->features))
101 out_features[i / 8] |= (1 << (i % 8)); 102 out_features[i / 8] |= (1 << (i % 8));
102 } 103 }
103} 104}
@@ -223,7 +224,7 @@ static void kvm_del_vq(struct virtqueue *vq)
223 */ 224 */
224static struct virtio_config_ops kvm_vq_configspace_ops = { 225static struct virtio_config_ops kvm_vq_configspace_ops = {
225 .get_features = kvm_get_features, 226 .get_features = kvm_get_features,
226 .set_features = kvm_set_features, 227 .finalize_features = kvm_finalize_features,
227 .get = kvm_get, 228 .get = kvm_get,
228 .set = kvm_set, 229 .set = kvm_set,
229 .get_status = kvm_get_status, 230 .get_status = kvm_get_status,