lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  1 Sep 2022 18:15:59 +0800
From:   Zhu Lingshan <lingshan.zhu@...el.com>
To:     jasowang@...hat.com, mst@...hat.com
Cc:     virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
        kvm@...r.kernel.org, Zhu Lingshan <lingshan.zhu@...el.com>
Subject: [RFC 2/4] vDPA: support ioctl VHOST_GET/SET_VRING_ENDIAN

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@...el.com>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ