This check didn't allow the vring to actually wrap around, if the next
available index was less than the last index, it caused the error to be
triggered.

Change-Id: I90c26cfd894a9b729e44937e1894ce5bfbf1d144
Signed-off-by: Kyle Milka <[email protected]>
---
 user/vmm/virtio_lguest_helpers.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/user/vmm/virtio_lguest_helpers.c b/user/vmm/virtio_lguest_helpers.c
index 4d8585f..00a8fd6 100644
--- a/user/vmm/virtio_lguest_helpers.c
+++ b/user/vmm/virtio_lguest_helpers.c
@@ -191,10 +191,10 @@ uint32_t virtio_next_avail_vq_desc(struct virtio_vq *vq, 
struct iovec iov[],
        // we last incremented vq->last_avail, because it would have run out of
        // places to put descriptors after incrementing exactly vring.num times
        // (prior to our next vq->last_avail++)
-       if ((vq->vring.avail->idx - vq->last_avail) > vq->vring.num)
+       if ((uint16_t)(vq->vring.avail->idx - vq->last_avail) > vq->vring.num)
                VIRTIO_DRI_ERRX(vq->vqdev,
-                       "The driver advanced vq->vring.avail->idx from %u to 
%u, which have a difference greater than the capacity of a queue. The idx is 
supposed to increase by 1 for each descriptor chain added to the available 
ring; the driver should have run out of room and thus been forced to wait for 
us to catch up!",
-                       vq->last_avail, vq->vring.avail);
+                               "vq index increased from %u to %u, exceeded 
capacity %u\n",
+                               vq->last_avail, vq->vring.avail->idx, 
vq->vring.num);
 
        // lguest says here:
        /*
-- 
2.8.0.rc3.226.g39d4020

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to