* [Qemu-devel] [PATCH 1/2] vhost: avoid to start/stop virtqueue which is not ready
@ 2018-02-28 9:35 Jia He
2018-02-28 9:35 ` [Qemu-devel] [PATCH 2/2] vhost: fix incorrect check in vhost_verify_ring_mappings Jia He
0 siblings, 1 reply; 3+ messages in thread
From: Jia He @ 2018-02-28 9:35 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel; +Cc: Dr . David Alan Gilbert, Jia He, Jia He
In our Armv8a server, we try to configure the vhost scsi but fail
to boot up the guest (-machine virt-2.10). The guest's boot failure
is very early, even earlier than grub.
There are 3 virtqueues (ctrl, event and cmd) for virtio scsi device,
but ovmf and seabios will only set the physical address for the 3rd
one (cmd). Then in vhost_virtqueue_start(), virtio_queue_get_desc_addr
will be 0 for ctrl and event vq when qemu negotiates with ovmf. So
vhost_memory_map fails with ENOMEM.
This patch just fixs it by early quitting the virtqueue start/stop
when virtio_queue_get_desc_addr is 0.
Btw, after guest kernel starts, all the 3 queues will be initialized
and set address correctly.
Already tested on Arm64 and X86_64 qemu.
Signed-off-by: Jia He <jia.he@hxt-semitech.com>
---
hw/virtio/vhost.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 4a44e6e..00f2512 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -345,6 +345,10 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
for (i = 0; i < dev->nvqs; ++i) {
struct vhost_virtqueue *vq = dev->vqs + i;
+ if (vq->desc_phys == 0) {
+ continue;
+ }
+
j = 0;
r = vhost_verify_ring_part_mapping(
vq->desc, vq->desc_phys, vq->desc_size,
@@ -881,6 +885,11 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
+ a = virtio_queue_get_desc_addr(vdev, idx);
+ if (a == 0) {
+ /* Queue might not be ready for start */
+ return 0;
+ }
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_set_vring_num(dev, &state);
@@ -906,7 +915,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
}
vq->desc_size = s = l = virtio_queue_get_desc_size(vdev, idx);
- vq->desc_phys = a = virtio_queue_get_desc_addr(vdev, idx);
+ vq->desc_phys = a;
vq->desc = vhost_memory_map(dev, a, &l, 0);
if (!vq->desc || l != s) {
r = -ENOMEM;
@@ -989,6 +998,13 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
.index = vhost_vq_index,
};
int r;
+ int a;
+
+ a = virtio_queue_get_desc_addr(vdev, idx);
+ if (a == 0) {
+ /* Don't stop the virtqueue which might have not been started */
+ return;
+ }
r = dev->vhost_ops->vhost_get_vring_base(dev, &state);
if (r < 0) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] [PATCH 2/2] vhost: fix incorrect check in vhost_verify_ring_mappings
2018-02-28 9:35 [Qemu-devel] [PATCH 1/2] vhost: avoid to start/stop virtqueue which is not ready Jia He
@ 2018-02-28 9:35 ` Jia He
2018-02-28 19:00 ` Dr. David Alan Gilbert
0 siblings, 1 reply; 3+ messages in thread
From: Jia He @ 2018-02-28 9:35 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel; +Cc: Dr . David Alan Gilbert, Jia He, Jia He
In commit 0ca1fd2d6878 ("vhost: Simplify ring verification checks"),
it checks the virtqueue desc mapping for 3 times.
Fixed: commit 0ca1fd2d6878 ("vhost: Simplify ring verification checks")
Signed-off-by: Jia He <jia.he@hxt-semitech.com>
---
hw/virtio/vhost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 00f2512..bbf6c0c 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -359,7 +359,7 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
j++;
r = vhost_verify_ring_part_mapping(
- vq->desc, vq->desc_phys, vq->desc_size,
+ vq->avail, vq->avail_phys, vq->avail_size,
reg_hva, reg_gpa, reg_size);
if (r) {
break;
@@ -367,7 +367,7 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
j++;
r = vhost_verify_ring_part_mapping(
- vq->desc, vq->desc_phys, vq->desc_size,
+ vq->used, vq->used_phys, vq->used_size,
reg_hva, reg_gpa, reg_size);
if (r) {
break;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] vhost: fix incorrect check in vhost_verify_ring_mappings
2018-02-28 9:35 ` [Qemu-devel] [PATCH 2/2] vhost: fix incorrect check in vhost_verify_ring_mappings Jia He
@ 2018-02-28 19:00 ` Dr. David Alan Gilbert
0 siblings, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2018-02-28 19:00 UTC (permalink / raw)
To: Jia He; +Cc: Michael S. Tsirkin, qemu-devel, Jia He
* Jia He (hejianet@gmail.com) wrote:
> In commit 0ca1fd2d6878 ("vhost: Simplify ring verification checks"),
> it checks the virtqueue desc mapping for 3 times.
>
> Fixed: commit 0ca1fd2d6878 ("vhost: Simplify ring verification checks")
> Signed-off-by: Jia He <jia.he@hxt-semitech.com>
Oops, well spotted; copy & paste strikes again.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> hw/virtio/vhost.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 00f2512..bbf6c0c 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -359,7 +359,7 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
>
> j++;
> r = vhost_verify_ring_part_mapping(
> - vq->desc, vq->desc_phys, vq->desc_size,
> + vq->avail, vq->avail_phys, vq->avail_size,
> reg_hva, reg_gpa, reg_size);
> if (r) {
> break;
> @@ -367,7 +367,7 @@ static int vhost_verify_ring_mappings(struct vhost_dev *dev,
>
> j++;
> r = vhost_verify_ring_part_mapping(
> - vq->desc, vq->desc_phys, vq->desc_size,
> + vq->used, vq->used_phys, vq->used_size,
> reg_hva, reg_gpa, reg_size);
> if (r) {
> break;
> --
> 2.7.4
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-28 19:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-28 9:35 [Qemu-devel] [PATCH 1/2] vhost: avoid to start/stop virtqueue which is not ready Jia He
2018-02-28 9:35 ` [Qemu-devel] [PATCH 2/2] vhost: fix incorrect check in vhost_verify_ring_mappings Jia He
2018-02-28 19:00 ` Dr. David Alan Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).