[PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Before 031755db ("arm: enable vmalloc") we were allocating the
queue with two pages of zeroed memory using memalign(), but
afterwards with only one uninitialized page using alloc_pages().
We can keep alloc_pages(), but we need two pages, and they need
to be clean, otherwise QEMU gets angry when we attempt to migrate
a unit test as the used vring index is corrupted by the page
allocator's next page link.

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/virtio-mmio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/virtio-mmio.c b/lib/virtio-mmio.c
index e5e8f660b5cd..cbc9e6217bbe 100644
--- a/lib/virtio-mmio.c
+++ b/lib/virtio-mmio.c
@@ -55,7 +55,8 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev,
 
 	vq = calloc(1, sizeof(*vq));
 	assert(VIRTIO_MMIO_QUEUE_SIZE_MIN <= 2*PAGE_SIZE);
-	queue = alloc_pages(1);
+	queue = alloc_pages(2);
+	memset(queue, 0, 2*PAGE_SIZE);
 	assert(vq && queue);
 
 	writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
-- 
2.13.6




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux