virtio: Allow to fill a whole virtqueue in order
As the while steps < max_steps is already one less than the vq size, the right maximum max_steps variable is queue length, not the maximum possible remainder of % vq->vring.num. Fixes: b44135daa37 ("virtio: virtqueue_ordered_fill - VIRTIO_F_IN_ORDER support") Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260304173535.2702587-2-eperezma@redhat.com>
Eugenio Pérez committed
Mar 4, 2026 at 18:35 UTC
eceff0982f97cc79a26883b93f8eac05cd126dd8
1 file changed
+1
-1
hw/virtio/virtio.c
+1
-1
@@ -986,7 +986,7 @@ static void virtqueue_ordered_fill(VirtQueue *vq, const VirtQueueElement *elem,
986
* We shouldn't need to increase 'i' by more than or equal to
987
* the distance between used_idx and last_avail_idx (max_steps).
988
*/
989
- max_steps = (vq->last_avail_idx - vq->used_idx) % vq->vring.num;
989
+ max_steps = MIN(vq->last_avail_idx - vq->used_idx, vq->vring.num);
990
991
/* Search for element in vq->used_elems */
992
while (steps < max_steps) {