From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation Date: Wed, 7 Feb 2018 20:03:27 +0100 Message-ID: <20180207190334.16516-2-drjones@redhat.com> References: <20180207190334.16516-1-drjones@redhat.com> Cc: pbonzini@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54420 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754026AbeBGTDi (ORCPT ); Wed, 7 Feb 2018 14:03:38 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EBB78182D17 for ; Wed, 7 Feb 2018 19:03:37 +0000 (UTC) In-Reply-To: <20180207190334.16516-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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