[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/5] virtio-pci: ignore unaligned read/write in virt
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PATCH 1/5] virtio-pci: ignore unaligned read/write in virtio_address_space_read()/write() |
Date: |
Mon, 13 Jul 2015 13:46:47 +0800 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 1/5] virtio-pci: ignore unaligned read/write in virtio_address_space_read()/write(),
Jason Wang <=
- [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Jason Wang, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Michael S. Tsirkin, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Jason Wang, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Kevin Wolf, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Cornelia Huck, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Michael S. Tsirkin, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Cornelia Huck, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Michael S. Tsirkin, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Cornelia Huck, 2015/07/13
- Re: [Qemu-devel] [PATCH 2/5] virtio-blk: disable scsi passthrough for 1.0 device, Paolo Bonzini, 2015/07/13