Re: [PATCH 2/3] vhost: support PACKED when setting-getting vring_base

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/22/23 11:36 PM, Jason Wang wrote:
On Sat, Apr 22, 2023 at 3:57 AM Shannon Nelson <shannon.nelson@xxxxxxx> wrote:

Use the right structs for PACKED or split vqs when setting and
getting the vring base.

Signed-off-by: Shannon Nelson <shannon.nelson@xxxxxxx>
---
  drivers/vhost/vhost.c | 18 +++++++++++++-----
  1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index f11bdbe4c2c5..f64efda48f21 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1633,17 +1633,25 @@ long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *arg
                         r = -EFAULT;
                         break;
                 }
-               if (s.num > 0xffff) {
-                       r = -EINVAL;
-                       break;
+               if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) {
+                       vq->last_avail_idx = s.num & 0xffff;
+                       vq->last_used_idx = (s.num >> 16) & 0xffff;

I think we need to tweak the comment around last_avail_idx and last_used_idx:

         /* Last available index we saw. */
         u16 last_avail_idx;

         /* Last index we used. */
         u16 last_used_idx;

To describe that it contains wrap counters as well in the case of
packed virtqueue

Sure, I can add into the comments that these counters are limited to 0x7fff and the high bits are used for a wrap counter/flag.

or maybe it's time to rename them (since they are
invented for split virtqueue).

Should we change them to bitfields as in struct vdpa_vq_state_packed?
Or perhaps just add new fields for bool/u16/u8 last_avail_counter and last_used_counter?

That might be a later patch in order to also deal with whatever fallout happens from a new name.

sln

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux