From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org,
Richard Henderson <richard.henderson@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>
Cc: "Eric Auger" <eric.auger@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [PULL 4/7] tests/qtest: properly initialise the vring used idx
Date: Wed, 20 Apr 2022 12:33:06 +0200 [thread overview]
Message-ID: <20220420103309.264479-5-thuth@redhat.com> (raw)
In-Reply-To: <20220420103309.264479-1-thuth@redhat.com>
From: Alex Bennée <alex.bennee@linaro.org>
Eric noticed while attempting to enable the vhost-user-blk-test for
Aarch64 that that things didn't work unless he put in a dummy
guest_malloc() at the start of the test. Without it
qvirtio_wait_used_elem() would assert when it reads a junk value for
idx resulting in:
qvirtqueue_get_buf: idx:2401 last_idx:0
qvirtqueue_get_buf: 0x7ffcb6d3fe74, (nil)
qvirtio_wait_used_elem: 3000000/0
ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
Bail out! ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
What was actually happening is the guest_malloc() effectively pushed
the allocation of the vring into the next page which just happened to
have clear memory. After much tedious tracing of the code I could see
that qvring_init() does attempt initialise a bunch of the vring
structures but skips the vring->used.idx value. It is probably not
wise to assume guest memory is zeroed anyway. Once the ring is
properly initialised the hack is no longer needed to get things
working.
Thanks-to: John Snow <jsnow@redhat.com> for helping debug
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220406173356.1891500-1-alex.bennee@linaro.org>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/libqos/virtio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
index 6fe7bf9555..fba9186659 100644
--- a/tests/qtest/libqos/virtio.c
+++ b/tests/qtest/libqos/virtio.c
@@ -260,6 +260,8 @@ void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
/* vq->used->flags */
qvirtio_writew(vq->vdev, qts, vq->used, 0);
+ /* vq->used->idx */
+ qvirtio_writew(vq->vdev, qts, vq->used + 2, 0);
/* vq->used->avail_event */
qvirtio_writew(vq->vdev, qts, vq->used + 2 +
sizeof(struct vring_used_elem) * vq->size, 0);
--
2.27.0
next prev parent reply other threads:[~2022-04-20 10:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 10:33 [PULL 0/7] Misc patches Thomas Huth
2022-04-20 10:33 ` [PULL 1/7] tests: Drop perl-Test-Harness from the CI containers / VMs Thomas Huth
2022-04-20 10:33 ` [PULL 2/7] tests/qtest: Enable more tests for the "mipsel" target Thomas Huth
2022-04-20 10:33 ` [PULL 3/7] tests/qtest: Move the fuzz tests to x86 only Thomas Huth
2022-04-20 10:33 ` Thomas Huth [this message]
2022-04-20 10:33 ` [PULL 5/7] docs/ccid: convert to restructuredText Thomas Huth
2022-04-20 10:33 ` [PULL 6/7] hw: Add compat machines for 7.1 Thomas Huth
2022-04-20 10:33 ` [PULL 7/7] tests/avocado: Allow overwrite smp and memory size command line options Thomas Huth
2022-04-20 16:38 ` [PULL 0/7] Misc patches Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220420103309.264479-5-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=eric.auger@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).