@@ -219,6 +219,17 @@ static int vhost_vdpa_reset(struct vhost_vdpa *v)
return vdpa_reset(vdpa);
}
+static long vhost_vdpa_bind_mm(struct vhost_vdpa *v)
+{
+ struct vdpa_device *vdpa = v->vdpa;
+ const struct vdpa_config_ops *ops = vdpa->config;
+
+ if (!vdpa->use_va || !ops->bind_mm)
+ return 0;
+
+ return ops->bind_mm(vdpa, v->vdev.mm, current);
+}
+
static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
{
struct vdpa_device *vdpa = v->vdpa;
@@ -276,6 +287,10 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
ret = vdpa_reset(vdpa);
if (ret)
return ret;
+
+ ret = vhost_vdpa_bind_mm(v);
+ if (ret)
+ return ret;
} else
vdpa_set_status(vdpa, status);
@@ -679,6 +694,13 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
break;
default:
r = vhost_dev_ioctl(&v->vdev, cmd, argp);
+ if (!r && cmd == VHOST_SET_OWNER) {
+ r = vhost_vdpa_bind_mm(v);
+ if (r) {
+ vhost_dev_reset_owner(&v->vdev, NULL);
+ break;
+ }
+ }
if (r == -ENOIOCTLCMD)
r = vhost_vdpa_vring_ioctl(v, cmd, argp);
break;
When the user call VHOST_SET_OWNER ioctl and the vDPA device has `use_va` set to true, let's call the bind_mm callback. In this way we can bind the device to the user address space and directly use the user VA. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> --- drivers/vhost/vdpa.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)