Index: sys/dev/virtio/random/virtio_random.c =================================================================== --- sys/dev/virtio/random/virtio_random.c +++ sys/dev/virtio/random/virtio_random.c @@ -229,6 +229,7 @@ struct sglist_seg segs[1]; struct sglist sg; struct virtqueue *vq; + void *cookie; uint32_t value[HARVESTSIZE] __aligned(sizeof(uint32_t) * HARVESTSIZE); uint32_t rdlen; int error; @@ -252,7 +253,9 @@ * done when we return from the notify. */ virtqueue_notify(vq); - virtqueue_poll(vq, &rdlen); + cookie = virtqueue_poll(vq, &rdlen); + /* Almost trivially true, but could indicate something bad. */ + KASSERT(cookie == buf, ("inconsistent virtqueue state")); if (rdlen > *sz) panic("%s: random device wrote %zu bytes beyond end of provided"