@@ -547,11 +547,41 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
vq->last_avail_idx = vq_state.split.avail_index;
break;
- }
+ case VHOST_SET_VRING_ENDIAN:
+ if (!ops->set_vq_endian)
+ return -EOPNOTSUPP;
+
+ if (copy_from_user(&s, argp, sizeof(s)))
+ return -EFAULT;
+
+ if (s.num != VHOST_VRING_LITTLE_ENDIAN &&
+ s.num != VHOST_VRING_BIG_ENDIAN)
+ return -EINVAL;
+
+ if (ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK)
+ return -EFAULT;
+
+ r = ops->set_vq_endian(vdpa, s.index, s.num);
+ if (r)
+ return -EFAULT;
+
+ return 0;
+ case VHOST_GET_VRING_ENDIAN:
+ if (!ops->get_vq_endian)
+ return -EOPNOTSUPP;
+
+ s.index = idx;
+ s.num = ops->get_vq_endian(vdpa, idx);
+
+ if (copy_to_user(argp, &s, sizeof(s)))
+ return -EFAULT;
+
+ return 0;
r = vhost_vring_ioctl(&v->vdev, cmd, argp);
if (r)
return r;
+ }
switch (cmd) {
case VHOST_SET_VRING_ADDR:
This commit add ioctl VHOST_GET_VRING_ENDIAN and VHOST_SET_VRING_ENDIAN support for vhost_vdpa. So that QEMU can be aware of the endian-ness of the vDPA device. Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> --- drivers/vhost/vdpa.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)