Skip to contentSkip to conversation

vhost-user-blk: prevent using uninitialized vqs

PATCH In review Raphael Norwitz 3 participants 5 messages Aug 22, 2019 – Aug 28, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 vhost-user-blk: prevent using uninitialized vqs

Same rational as: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844

Of the 3 virtqueues, seabios only sets cmd, leaving ctrl and event without a physical address. This can cause vhost_verify_ring_part_mapping to return ENOMEM, causing the following logs:

qemu-system-x86_64: Unable to map available ring for ring 0
qemu-system-x86_64: Verify ring failure on region 0

This has already been fixed for vhost scsi devices and was recently vhost-user scsi devices. This commit fixes it for vhost-user-blk devices.

---
 hw/block/vhost-user-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/vhost-user-blk.c +1 -1
index 0b8c5df..63da9bb 100644
@@ -421,7 +421,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
     }
 
     s->inflight = g_new0(struct vhost_inflight, 1);
-    s->vqs = g_new(struct vhost_virtqueue, s->num_queues);
+    s->vqs = g_new0(struct vhost_virtqueue, s->num_queues);
     s->watch = 0;
     s->connected = false;
 
Signature · 1 line
1.9.4
#1 lore raw

PATCH 2/2 backends/vhost-user.c: prevent using uninitialized vqs

Similar rational to: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844

For vhost scsi and vhost-user-scsi an issue was observed where, of the 3 virtqueues, seabios would only set cmd, leaving ctrl and event without a physical address. This can caused vhost_verify_ring_part_mapping to return ENOMEM, causing the following logs:

qemu-system-x86_64: Unable to map available ring for ring 0
qemu-system-x86_64: Verify ring failure on region 0

The issue has already been fixed elsewhere, but it was noted that in backends/vhost-user.c, the vhost_user_backend_dev_init() function, which other vdevs use in their realize() to initialize their vqs, was not being properly zeroing out the queues. This commit ensures hardware modules using the vhost_user_backend_dev_init() API properly zero out their vqs on initialization.

---
 backends/vhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
backends/vhost-user.c +1 -1
index 0a13506..2bf3406 100644
@@ -46,7 +46,7 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
 
     b->vdev = vdev;
     b->dev.nvqs = nvqs;
-    b->dev.vqs = g_new(struct vhost_virtqueue, nvqs);
+    b->dev.vqs = g_new0(struct vhost_virtqueue, nvqs);
 
     ret = vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USER, 0);
     if (ret < 0) {
Signature · 1 line
1.9.4
Reviewed-by on v1 2/2
#2 lore raw

Re: [Qemu-devel] [PATCH 2/2] backends/vhost-user.c: prevent using uninitialized vqs

Quoted 19 lines · Raphael Norwitz

Similar rational to: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844

For vhost scsi and vhost-user-scsi an issue was observed where, of the 3 virtqueues, seabios would only set cmd, leaving ctrl and event without a physical address. This can caused vhost_verify_ring_part_mapping to return ENOMEM, causing the following logs:

qemu-system-x86_64: Unable to map available ring for ring 0
qemu-system-x86_64: Verify ring failure on region 0

The issue has already been fixed elsewhere, but it was noted that in backends/vhost-user.c, the vhost_user_backend_dev_init() function, which other vdevs use in their realize() to initialize their vqs, was not being properly zeroing out the queues. This commit ensures hardware modules using the vhost_user_backend_dev_init() API properly zero out their vqs on initialization.

Quoted 5 lines
---
 backends/vhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw
In reply to Raphael Norwitz

Raphael Norwitz <[email protected]> 於 2019-08-23 04:16 寫道: > > Same rational as: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844 > > Of the 3 virtqueues, seabios only sets cmd, leaving ctrl > and event without a physical address. This can cause > vhost_verify_ring_part_mapping to return ENOMEM, causing > the following logs: > > qemu-system-x86_64: Unable to map available ring for ring 0 > qemu-system-x86_64: Verify ring failure on region 0 > > This has already been fixed for vhost scsi devices and was > recently vhost-user scsi devices. This commit fixes it for > vhost-user-blk devices. > > Suggested-by: Phillippe Mathieu-Daude <[email protected]> > Signed-off-by: Raphael Norwitz <[email protected]> Reviewed-by: yuchenlin <[email protected]> Thanks. > > > --- > hw/block/vhost-user-blk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c > index 0b8c5df..63da9bb 100644 > --- a/hw/block/vhost-user-blk.c > +++ b/hw/block/vhost-user-blk.c > @@ -421,7 +421,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) > } > > s->inflight = g_new0(struct vhost_inflight, 1); > - s->vqs = g_new(struct vhost_virtqueue, s->num_queues); > + s->vqs = g_new0(struct vhost_virtqueue, s->num_queues); > s->watch = 0; > s->connected = false; > > -- > 1.9.4 > >

Reviewed-by on v1 1/2
#4 lore raw
In reply to Raphael Norwitz
Quoted 14 lines · Raphael Norwitz

Same rational as: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844

Of the 3 virtqueues, seabios only sets cmd, leaving ctrl and event without a physical address. This can cause vhost_verify_ring_part_mapping to return ENOMEM, causing the following logs:

qemu-system-x86_64: Unable to map available ring for ring 0
qemu-system-x86_64: Verify ring failure on region 0

This has already been fixed for vhost scsi devices and was recently vhost-user scsi devices. This commit fixes it for vhost-user-blk devices.

Quoted 5 lines
---
 hw/block/vhost-user-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)