From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEWZv-0006Hm-Ax for qemu-devel@nongnu.org; Mon, 13 Jul 2015 01:47:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEWZs-0006Hw-59 for qemu-devel@nongnu.org; Mon, 13 Jul 2015 01:46:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEWZr-0006Hm-Vw for qemu-devel@nongnu.org; Mon, 13 Jul 2015 01:46:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 1E121B6698 for ; Mon, 13 Jul 2015 05:46:55 +0000 (UTC) From: Jason Wang Date: Mon, 13 Jul 2015 13:46:47 +0800 Message-Id: <1436766411-29144-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PATCH 1/5] virtio-pci: ignore unaligned read/write in virtio_address_space_read()/write() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mst@redhat.com Cc: Jason Wang We abort on unaligned read/write in virtio_address_space_read()/write() but since len in under control of guest so qemu will simply crash when booting a modern guest (guest is try to read when len is zero). Fix this by ignoring unaligned write or read. Fixes 1e40356ce5f6ccfa0bb57104a533c62952c560ce ("virtio fix cfg endian-ness for BE targets") Signed-off-by: Jason Wang --- hw/virtio/virtio-pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ccca2b6..bed9735 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -466,8 +466,8 @@ void virtio_address_space_write(AddressSpace *as, hwaddr addr, */ addr &= ~(len - 1); - /* Make sure caller aligned buf properly */ - assert(!(((uintptr_t)buf) & (len - 1))); + if (!(((uintptr_t)buf) & (len - 1))) + return; switch (len) { case 1: @@ -498,8 +498,8 @@ virtio_address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len) */ addr &= ~(len - 1); - /* Make sure caller aligned buf properly */ - assert(!(((uintptr_t)buf) & (len - 1))); + if (!(((uintptr_t)buf) & (len - 1))) + return; switch (len) { case 1: -- 2.1.4