* [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues
@ 2018-01-12 10:13 Zheng Xiang
2018-01-12 10:39 ` Maxime Coquelin
2018-01-12 11:36 ` no-reply
0 siblings, 2 replies; 3+ messages in thread
From: Zheng Xiang @ 2018-01-12 10:13 UTC (permalink / raw)
To: qemu-devel
Cc: lersek, pbonzini, maxime.coquelin, zhaoshenglong,
christoffer.dall, Zheng Xiang, Michael S . Tsirkin
When guest driver only setup part of queues declared in QEMU, it
would corrupt guest's physical address 0 when using uninitialized
queues in vhost_virtqueue_start.
In AARCH64 virtual machines, the address of system memory starts at
0x40000000 and the address of rom starts at 0. So, when using qemu
with vhost-scsi, it will fail with below error:
qemu-kvm: Error start vhost dev
qemu-kvm: unable to start vhost-scsi: Cannot allocate memory
This patch fix this issue by skipping calling vhost_virtqueue_start
for uninitialized queues.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Zheng Xiang <zhengxiang9@huawei.com>
---
hw/virtio/vhost.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e4290ce..ac79ffd 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1532,6 +1532,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
goto fail_mem;
}
for (i = 0; i < hdev->nvqs; ++i) {
+ if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0)
+ continue;
r = vhost_virtqueue_start(hdev,
vdev,
hdev->vqs + i,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues
2018-01-12 10:13 [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues Zheng Xiang
@ 2018-01-12 10:39 ` Maxime Coquelin
2018-01-12 11:36 ` no-reply
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-01-12 10:39 UTC (permalink / raw)
To: Zheng Xiang, qemu-devel
Cc: lersek, pbonzini, zhaoshenglong, christoffer.dall,
Michael S . Tsirkin
On 01/12/2018 11:13 AM, Zheng Xiang wrote:
> When guest driver only setup part of queues declared in QEMU, it
> would corrupt guest's physical address 0 when using uninitialized
> queues in vhost_virtqueue_start.
>
> In AARCH64 virtual machines, the address of system memory starts at
> 0x40000000 and the address of rom starts at 0. So, when using qemu
> with vhost-scsi, it will fail with below error:
> qemu-kvm: Error start vhost dev
> qemu-kvm: unable to start vhost-scsi: Cannot allocate memory
>
> This patch fix this issue by skipping calling vhost_virtqueue_start
> for uninitialized queues.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Zheng Xiang <zhengxiang9@huawei.com>
> ---
> hw/virtio/vhost.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index e4290ce..ac79ffd 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -1532,6 +1532,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
> goto fail_mem;
> }
> for (i = 0; i < hdev->nvqs; ++i) {
> + if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0)
> + continue;
> r = vhost_virtqueue_start(hdev,
> vdev,
> hdev->vqs + i,
>
Thanks, it fixes the silent corruption that happens with vhost-user net
backend and Windows guests, when the number of queues pairs declared in
Qemu is higher than the number of vcpus.
Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues
2018-01-12 10:13 [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues Zheng Xiang
2018-01-12 10:39 ` Maxime Coquelin
@ 2018-01-12 11:36 ` no-reply
1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2018-01-12 11:36 UTC (permalink / raw)
To: zhengxiang9
Cc: famz, qemu-devel, mst, maxime.coquelin, zhaoshenglong, pbonzini,
lersek, christoffer.dall
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20180112101356.27044-1-zhengxiang9@huawei.com
Subject: [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))
done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
fb66f184ae vhost: fix corrupting GPA 0 when using uninitialized queues
=== OUTPUT BEGIN ===
Checking PATCH 1/1: vhost: fix corrupting GPA 0 when using uninitialized queues...
ERROR: trailing whitespace
#32: FILE: hw/virtio/vhost.c:1535:
+ if (virtio_queue_get_desc_addr(vdev, hdev->vq_index + i) == 0) $
total: 1 errors, 0 warnings, 8 lines checked
Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-12 11:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12 10:13 [Qemu-devel] [PATCH] vhost: fix corrupting GPA 0 when using uninitialized queues Zheng Xiang
2018-01-12 10:39 ` Maxime Coquelin
2018-01-12 11:36 ` no-reply
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).