virtio: Ensure virt_queue is always initialised
PATCH 1/1 virtio: Ensure virt_queue is always initialised
Failing to initialise the virt_queue via virtio_init_device_vq() leaves, amongst other things, the endianness unspecified. On arm/arm64 this results in virtio_guest_to_host_uxx() treating the queue as big-endian and trying to translate bogus addresses:
Warning: unable to translate guest address 0x80b8249800000000 to host
Ensure the virt_queue is always initialised by the virtio device during setup.
--- virtio/balloon.c | 1 + virtio/rng.c | 1 + virtio/scsi.c | 1 + 3 files changed, 3 insertions(+)
virtio/balloon.c +1 -0
@@ -212,6 +212,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align,thread_pool__init_job (&bdev->jobs[vq], kvm, virtio_bln_do_io, queue);vring_init (&queue->vring,VIRTIO_BLN_QUEUE_SIZE , p, align); +virtio_init_device_vq (&bdev->vdev, queue);return 0 ; }
virtio/rng.c +1 -0
@@ -103,6 +103,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, job = &rdev->jobs[vq];vring_init (&queue->vring,VIRTIO_RNG_QUEUE_SIZE , p, align); +virtio_init_device_vq (&rdev->vdev, queue); *job = (struct rng_dev_job ) { .vq = queue,
virtio/scsi.c +1 -0
@@ -72,6 +72,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, p =virtio_get_vq (kvm, queue->pfn, page_size);vring_init (&queue->vring,VIRTIO_SCSI_QUEUE_SIZE , p, align); +virtio_init_device_vq (&sdev->vdev, queue);if (sdev->vhost_fd ==0 )return 0 ;
Signature · 1 line
2.23.0.700.g56cf767bdb-goog
On Thu, 10 Oct 2019 15:28:52 +0100
Will Deacon <[email protected]> wrote:
Hi Will,
Quoted 6 lines
Failing to initialise the
virt_queueviavirtio_init_device_vq()leaves, amongst other things, the endianness unspecified. On arm/arm64 this results invirtio_guest_to_host_uxx()treating the queue as big-endian and trying to translate bogus addresses:Warning: unable to translate guest address
0x80b8249800000000to host
Ouch, a user! ;-)
Quoted 2 lines
Ensure the
virt_queueis always initialised by the virtio device during setup.
Indeed, this is also what the other virtio devices do. Confirmed to fix rng and balloon.
Thanks for spotting this!
Cheers,
Andre.
Quoted 47 lines
Cc Marc Zyngier <[email protected]>Cc Julien Thierry <[email protected]>Cc Andre Przywara <[email protected]>Signed-off-by Will Deacon <[email protected]>--- virtio/balloon.c | 1 + virtio/rng.c | 1 + virtio/scsi.c | 1 + 3 files changed, 3 insertions(+)virtio/balloon.c +1
-0@@ -212,6 +212,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align,thread_pool__init_job (&bdev->jobs[vq], kvm, virtio_bln_do_io, queue);vring_init (&queue->vring,VIRTIO_BLN_QUEUE_SIZE , p, align); +virtio_init_device_vq (&bdev->vdev, queue);return 0 ; }virtio/rng.c +1
-0@@ -103,6 +103,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, job = &rdev->jobs[vq];vring_init (&queue->vring,VIRTIO_RNG_QUEUE_SIZE , p, align); +virtio_init_device_vq (&rdev->vdev, queue); *job = (struct rng_dev_job ) { .vq = queue,virtio/scsi.c +1
-0@@ -72,6 +72,7 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, p =virtio_get_vq (kvm, queue->pfn, page_size);vring_init (&queue->vring,VIRTIO_SCSI_QUEUE_SIZE , p, align); +virtio_init_device_vq (&sdev->vdev, queue);if (sdev->vhost_fd ==0 )return 0 ;
Quoted 14 lines · Andre Przywara
Quoted 6 lines · On Thu, 10 Oct 2019 15:28:52 +0100 Will Deacon <[email protected]> wrote:
Failing to initialise the
virt_queueviavirtio_init_device_vq()leaves, amongst other things, the endianness unspecified. On arm/arm64 this results invirtio_guest_to_host_uxx()treating the queue as big-endian and trying to translate bogus addresses:Warning: unable to translate guest address
0x80b8249800000000to hostOuch, a user! ;-)
Quoted 2 lines
Ensure the
virt_queueis always initialised by the virtio device during setup.
Quoted 7 lines
Indeed, this is also what the other virtio devices do. Confirmed to fix rng and balloon.
Thanks for spotting this!
Reviewed-by Andre Przywara <[email protected]>Tested-by Andre Przywara <[email protected]>
Cheers, Andre. Now pushed with your tags.
Will