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@xxxxxxxxx> --- drivers/vhost/vdpa.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 166044642fd5..084fbf04c6bb 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -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: -- 2.31.1