Skip to content

Commit 1ccfa66

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "A couple of last minute fixes" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost-vdpa: fix backend feature ioctls vhost: Fix documentation
2 parents fb0155a + a127c5b commit 1ccfa66

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

drivers/vhost/iotlb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(vhost_iotlb_free);
149149
* vhost_iotlb_itree_first - return the first overlapped range
150150
* @iotlb: the IOTLB
151151
* @start: start of IOVA range
152-
* @end: end of IOVA range
152+
* @last: last byte in IOVA range
153153
*/
154154
struct vhost_iotlb_map *
155155
vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last)
@@ -162,7 +162,7 @@ EXPORT_SYMBOL_GPL(vhost_iotlb_itree_first);
162162
* vhost_iotlb_itree_next - return the next overlapped range
163163
* @map: the starting map node
164164
* @start: start of IOVA range
165-
* @end: end of IOVA range
165+
* @last: last byte IOVA range
166166
*/
167167
struct vhost_iotlb_map *
168168
vhost_iotlb_itree_next(struct vhost_iotlb_map *map, u64 start, u64 last)

drivers/vhost/vdpa.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
353353
struct vdpa_callback cb;
354354
struct vhost_virtqueue *vq;
355355
struct vhost_vring_state s;
356-
u64 __user *featurep = argp;
357-
u64 features;
358356
u32 idx;
359357
long r;
360358

@@ -381,18 +379,6 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
381379

382380
vq->last_avail_idx = vq_state.avail_index;
383381
break;
384-
case VHOST_GET_BACKEND_FEATURES:
385-
features = VHOST_VDPA_BACKEND_FEATURES;
386-
if (copy_to_user(featurep, &features, sizeof(features)))
387-
return -EFAULT;
388-
return 0;
389-
case VHOST_SET_BACKEND_FEATURES:
390-
if (copy_from_user(&features, featurep, sizeof(features)))
391-
return -EFAULT;
392-
if (features & ~VHOST_VDPA_BACKEND_FEATURES)
393-
return -EOPNOTSUPP;
394-
vhost_set_backend_features(&v->vdev, features);
395-
return 0;
396382
}
397383

398384
r = vhost_vring_ioctl(&v->vdev, cmd, argp);
@@ -440,8 +426,20 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
440426
struct vhost_vdpa *v = filep->private_data;
441427
struct vhost_dev *d = &v->vdev;
442428
void __user *argp = (void __user *)arg;
429+
u64 __user *featurep = argp;
430+
u64 features;
443431
long r;
444432

433+
if (cmd == VHOST_SET_BACKEND_FEATURES) {
434+
r = copy_from_user(&features, featurep, sizeof(features));
435+
if (r)
436+
return r;
437+
if (features & ~VHOST_VDPA_BACKEND_FEATURES)
438+
return -EOPNOTSUPP;
439+
vhost_set_backend_features(&v->vdev, features);
440+
return 0;
441+
}
442+
445443
mutex_lock(&d->mutex);
446444

447445
switch (cmd) {
@@ -476,6 +474,10 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
476474
case VHOST_VDPA_SET_CONFIG_CALL:
477475
r = vhost_vdpa_set_config_call(v, argp);
478476
break;
477+
case VHOST_GET_BACKEND_FEATURES:
478+
features = VHOST_VDPA_BACKEND_FEATURES;
479+
r = copy_to_user(featurep, &features, sizeof(features));
480+
break;
479481
default:
480482
r = vhost_dev_ioctl(&v->vdev, cmd, argp);
481483
if (r == -ENOIOCTLCMD)

0 commit comments

Comments
 (0)