[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/25] tests: add test to check VirtQueue object
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 04/25] tests: add test to check VirtQueue object |
Date: |
Thu, 21 Dec 2017 16:28:12 +0200 |
From: Prasad J Pandit <address@hidden>
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 <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
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 e6fb9ba..45f368d 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);
--
MST
- [Qemu-devel] [PULL 00/25] pc, pci, virtio: features, fixes, cleanups, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 01/25] smbios: support setting OEM strings table, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 02/25] qdev-properties: add UUID property type, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 03/25] vmgenid: use UUID property type, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 04/25] tests: add test to check VirtQueue object,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 05/25] pci: Rename root bus initialization functions for clarity, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 06/25] pci: Move bridge data structures from pci_bus.h to pci_bridge.h, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 07/25] pci: Add pci_dev_bus_num() helper, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 10/25] virtio_error: don't invoke status callbacks, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 09/25] pci: Eliminate pci_find_primary_bus(), Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 11/25] tests/pxe-test: Remove unnecessary special case test functions, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 14/25] tests/pxe-test: Add some extra tests, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 08/25] pci: Eliminate redundant PCIDevice::bus pointer, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 12/25] tests/pxe-test: Use table of testcases rather than open-coding, Michael S. Tsirkin, 2017/12/21
- [Qemu-devel] [PULL 13/25] tests/pxe-test: Test net booting over IPv6 in some cases, Michael S. Tsirkin, 2017/12/21