From: P J P <ppandit@redhat.com>
To: Qemu Developers <qemu-devel@nongnu.org>
Cc: Cornelia Huck <cohuck@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
zhangboxian <zhangboxian@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Prasad J Pandit <pjp@fedoraproject.org>
Subject: [Qemu-devel] [PATCH v4 2/2] tests: add test to check VirtQueue object
Date: Wed, 29 Nov 2017 23:14:28 +0530 [thread overview]
Message-ID: <20171129174428.27548-3-ppandit@redhat.com> (raw)
In-Reply-To: <20171129174428.27548-1-ppandit@redhat.com>
From: Prasad J Pandit <pjp@fedoraproject.org>
An uninitialised VirtQueue object or one with Vring.align field
set to zero(0) could lead to arithmetic exceptions. Add a unit
test to validate it.
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
tests/virtio-blk-test.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index e6fb9bac87..45f368dcd9 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -674,6 +674,30 @@ static void pci_hotplug(void)
qtest_shutdown(qs);
}
+/*
+ * Check that setting the vring addr on a non-existent virtqueue does
+ * not crash.
+ */
+static void test_nonexistent_virtqueue(void)
+{
+ QPCIBar bar0;
+ QOSState *qs;
+ QPCIDevice *dev;
+
+ qs = pci_test_start();
+ dev = qpci_device_find(qs->pcibus, QPCI_DEVFN(4, 0));
+ g_assert(dev != NULL);
+
+ qpci_device_enable(dev);
+ bar0 = qpci_iomap(dev, 0, NULL);
+
+ qpci_io_writeb(dev, bar0, VIRTIO_PCI_QUEUE_SEL, 2);
+ qpci_io_writel(dev, bar0, VIRTIO_PCI_QUEUE_PFN, 1);
+
+ g_free(dev);
+ qtest_shutdown(qs);
+}
+
static void mmio_basic(void)
{
QVirtioMMIODevice *dev;
@@ -724,6 +748,7 @@ int main(int argc, char **argv)
qtest_add_func("/virtio/blk/pci/basic", pci_basic);
qtest_add_func("/virtio/blk/pci/indirect", pci_indirect);
qtest_add_func("/virtio/blk/pci/config", pci_config);
+ qtest_add_func("/virtio/blk/pci/nxvirtq", test_nonexistent_virtqueue);
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
qtest_add_func("/virtio/blk/pci/msix", pci_msix);
qtest_add_func("/virtio/blk/pci/idx", pci_idx);
--
2.13.6
next prev parent reply other threads:[~2017-11-29 17:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 17:44 [Qemu-devel] [PATCH v4 0/2] check VirtiQueue Vring objects P J P
2017-11-29 17:44 ` [Qemu-devel] [PATCH v4 1/2] virtio: check VirtQueue Vring object is set P J P
2017-11-30 9:32 ` Cornelia Huck
2017-11-29 17:44 ` P J P [this message]
2017-11-30 14:53 ` [Qemu-devel] [PATCH v4 0/2] check VirtiQueue Vring objects Stefan Hajnoczi
2017-11-30 14:54 ` Stefan Hajnoczi
2017-11-30 18:11 ` P J P
2017-12-07 7:07 ` P J P
2017-12-07 17:53 ` Michael S. Tsirkin
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=20171129174428.27548-3-ppandit@redhat.com \
--to=ppandit@redhat.com \
--cc=cohuck@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=zhangboxian@huawei.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).