Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vhost: support PACKED when setting-getting vring_base

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

Fixes: 4c8cf31885f6 ("vhost: introduce vDPA-based backend")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Message-Id: <20230424225031.18947-3-shannon.nelson@amd.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>

authored by

Shannon Nelson and committed by
Michael S. Tsirkin
55d8122f 4b13cbef

+19 -7
+13 -5
drivers/vhost/vhost.c
··· 1600 1600 r = -EFAULT; 1601 1601 break; 1602 1602 } 1603 - if (s.num > 0xffff) { 1604 - r = -EINVAL; 1605 - break; 1603 + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { 1604 + vq->last_avail_idx = s.num & 0xffff; 1605 + vq->last_used_idx = (s.num >> 16) & 0xffff; 1606 + } else { 1607 + if (s.num > 0xffff) { 1608 + r = -EINVAL; 1609 + break; 1610 + } 1611 + vq->last_avail_idx = s.num; 1606 1612 } 1607 - vq->last_avail_idx = s.num; 1608 1613 /* Forget the cached index value. */ 1609 1614 vq->avail_idx = vq->last_avail_idx; 1610 1615 break; 1611 1616 case VHOST_GET_VRING_BASE: 1612 1617 s.index = idx; 1613 - s.num = vq->last_avail_idx; 1618 + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) 1619 + s.num = (u32)vq->last_avail_idx | ((u32)vq->last_used_idx << 16); 1620 + else 1621 + s.num = vq->last_avail_idx; 1614 1622 if (copy_to_user(argp, &s, sizeof s)) 1615 1623 r = -EFAULT; 1616 1624 break;
+6 -2
drivers/vhost/vhost.h
··· 92 92 /* The routine to call when the Guest pings us, or timeout. */ 93 93 vhost_work_fn_t handle_kick; 94 94 95 - /* Last available index we saw. */ 95 + /* Last available index we saw. 96 + * Values are limited to 0x7fff, and the high bit is used as 97 + * a wrap counter when using VIRTIO_F_RING_PACKED. */ 96 98 u16 last_avail_idx; 97 99 98 100 /* Caches available index value from user. */ 99 101 u16 avail_idx; 100 102 101 - /* Last index we used. */ 103 + /* Last index we used. 104 + * Values are limited to 0x7fff, and the high bit is used as 105 + * a wrap counter when using VIRTIO_F_RING_PACKED. */ 102 106 u16 last_used_idx; 103 107 104 108 /* Used flags */