From: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx> Add BUG_ON to ensure that the correct virtio queue type is used for the virtqueue functions. In addition the function virtqueue_kick_prepare() is changed so that it always returns true if the virtio-ring is reversed. Signed-off-by: Sjur Brændeland <sjur.brandeland@xxxxxxxxxxxxxx> --- drivers/virtio/virtio_ring.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 67f7bcd..a6f38c1 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -176,6 +176,7 @@ int virtqueue_add_buf(struct virtqueue *_vq, START_USE(vq); + BUG_ON(vq->vq.reversed); BUG_ON(data == NULL); #ifdef DEBUG @@ -282,6 +283,9 @@ bool virtqueue_kick_prepare(struct virtqueue *_vq) u16 new, old; bool needs_kick; + if (_vq->reversed) + return true; + START_USE(vq); /* We need to expose available array entries before checking avail * event. */ @@ -346,6 +350,7 @@ static void detach_buf(struct vring_virtqueue *vq, unsigned int head) { unsigned int i; + BUG_ON(vq->vq.reversed); /* Clear data ptr. */ vq->data[head] = NULL; @@ -395,6 +400,7 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len) unsigned int i; u16 last_used; + BUG_ON(vq->vq.reversed); START_USE(vq); if (unlikely(vq->broken)) { @@ -457,6 +463,7 @@ EXPORT_SYMBOL_GPL(virtqueue_get_buf); void virtqueue_disable_cb(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); + BUG_ON(vq->vq.reversed); vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; } @@ -477,6 +484,7 @@ bool virtqueue_enable_cb(struct virtqueue *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); + BUG_ON(vq->vq.reversed); START_USE(vq); /* We optimistically turn back on interrupts, then check if there was @@ -515,6 +523,7 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *_vq) struct vring_virtqueue *vq = to_vvq(_vq); u16 bufs; + BUG_ON(vq->vq.reversed); START_USE(vq); /* We optimistically turn back on interrupts, then check if there was @@ -551,6 +560,7 @@ void *virtqueue_detach_unused_buf(struct virtqueue *_vq) unsigned int i; void *buf; + BUG_ON(vq->vq.reversed); START_USE(vq); for (i = 0; i < vq->vring.num; i++) { @@ -575,6 +585,7 @@ irqreturn_t __vring_interrupt(int irq, void *_vq) { struct vring_virtqueue *vq = to_vvq(_vq); + BUG_ON(vq->vq.reversed); if (!more_used(vq)) { pr_debug("virtqueue interrupt with no work for %p\n", vq); return IRQ_NONE; -- 1.7.5.4 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization