Skip to content

Commit 653055b

Browse files
jasowangmstsirkin
authored andcommitted
vhost-vdpa: support get/set backend features
This patch makes userspace can get and set backend features to vhost-vdpa. Signed-off-by: Cindy Lu <[email protected]> Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 460f7ce commit 653055b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/vhost/vdpa.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
#include "vhost.h"
2828

29+
enum {
30+
VHOST_VDPA_BACKEND_FEATURES = (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)
31+
};
32+
2933
/* Currently, only network backend w/o multiqueue is supported. */
3034
#define VHOST_VDPA_VQ_MAX 2
3135

@@ -347,6 +351,8 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
347351
struct vdpa_callback cb;
348352
struct vhost_virtqueue *vq;
349353
struct vhost_vring_state s;
354+
u64 __user *featurep = argp;
355+
u64 features;
350356
u32 idx;
351357
long r;
352358

@@ -369,6 +375,18 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
369375
case VHOST_GET_VRING_BASE:
370376
vq->last_avail_idx = ops->get_vq_state(v->vdpa, idx);
371377
break;
378+
case VHOST_GET_BACKEND_FEATURES:
379+
features = VHOST_VDPA_BACKEND_FEATURES;
380+
if (copy_to_user(featurep, &features, sizeof(features)))
381+
return -EFAULT;
382+
return 0;
383+
case VHOST_SET_BACKEND_FEATURES:
384+
if (copy_from_user(&features, featurep, sizeof(features)))
385+
return -EFAULT;
386+
if (features & ~VHOST_VDPA_BACKEND_FEATURES)
387+
return -EOPNOTSUPP;
388+
vhost_set_backend_features(&v->vdev, features);
389+
return 0;
372390
}
373391

374392
r = vhost_vring_ioctl(&v->vdev, cmd, argp);

0 commit comments

Comments
 (0)