[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/22] ioport: loosen assertions on emulation of 16-b
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 14/22] ioport: loosen assertions on emulation of 16-bit ports |
Date: |
Tue, 28 Apr 2015 16:40:21 +0200 |
Right now, ioport.c assumes that the entire range specified with
MemoryRegionPortio includes a region with size == 1. This however
is not true for the VBE DISPI ports, which are 16-bit only. The
next patch will make these regions' length equal to two, which can
cause the assertions to trigger. Replace them with simple conditionals.
Also, ioport.c will emulate a 16-bit ioport with two distinct reads
or writes, even if one of the two accesses is out of the bounds given
by the MemoryRegionPortio array. Do not do this anymore, instead
discard writes to the incorrect register and read it as all-ones.
This ensures that the mrp->read and mrp->write callbacks get an
in-range ioport number.
Signed-off-by: Paolo Bonzini <address@hidden>
---
ioport.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/ioport.c b/ioport.c
index eb954e3..090c262 100644
--- a/ioport.c
+++ b/ioport.c
@@ -187,9 +187,14 @@ static uint64_t portio_read(void *opaque, hwaddr addr,
unsigned size)
data = mrp->read(mrpio->portio_opaque, mrp->base + addr);
} else if (size == 2) {
mrp = find_portio(mrpio, addr, 1, false);
- assert(mrp);
- data = mrp->read(mrpio->portio_opaque, mrp->base + addr) |
- (mrp->read(mrpio->portio_opaque, mrp->base + addr + 1) << 8);
+ if (mrp) {
+ data = mrp->read(mrpio->portio_opaque, mrp->base + addr);
+ if (addr + 1 < mrp->offset + mrp->len) {
+ data |= mrp->read(mrpio->portio_opaque, mrp->base + addr + 1)
<< 8;
+ } else {
+ data |= 0xff00;
+ }
+ }
}
return data;
}
@@ -204,9 +209,12 @@ static void portio_write(void *opaque, hwaddr addr,
uint64_t data,
mrp->write(mrpio->portio_opaque, mrp->base + addr, data);
} else if (size == 2) {
mrp = find_portio(mrpio, addr, 1, true);
- assert(mrp);
- mrp->write(mrpio->portio_opaque, mrp->base + addr, data & 0xff);
- mrp->write(mrpio->portio_opaque, mrp->base + addr + 1, data >> 8);
+ if (mrp) {
+ mrp->write(mrpio->portio_opaque, mrp->base + addr, data & 0xff);
+ if (addr + 1 < mrp->offset + mrp->len) {
+ mrp->write(mrpio->portio_opaque, mrp->base + addr + 1, data >>
8);
+ }
+ }
}
}
--
2.3.5
- [Qemu-devel] [PULL 03/22] linux-user, bsd-user: Remove two calls to cpu_exec_init_all, (continued)
- [Qemu-devel] [PULL 03/22] linux-user, bsd-user: Remove two calls to cpu_exec_init_all, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 05/22] exec: Notify cpu_register_map_client caller if the bounce buffer is available, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 06/22] dma-helpers: Fix race condition of continue_after_map_failure and dma_aio_cancel, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 07/22] memory: add memory_region_ram_resize, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 08/22] acpi-build: remove dependency from ram_addr.h, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 09/22] sun4m: fix slavio sysctrl and led register sizes, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 10/22] sb16: remove useless mixer_write_indexw, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 11/22] gus: clean up MemoryRegionPortio, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 12/22] ide: there is only one data port, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 13/22] ioport: remove wrong comment, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 14/22] ioport: loosen assertions on emulation of 16-bit ports,
Paolo Bonzini <=
- [Qemu-devel] [PULL 15/22] ioport: reserve the whole range of an I/O port in the AddressSpace, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 16/22] exec: Respect as_translate_internal length clamp, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 18/22] milkymist: do not modify libs-softmmu, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 17/22] configure: Add support for tcmalloc, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 19/22] Makefile.target: prepend $libs_softmmu to $LIBS, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 21/22] translate-all: use bitmap helpers for PageDesc's bitmap, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 20/22] target-i386: disable LINT0 after reset, Paolo Bonzini, 2015/04/28
- [Qemu-devel] [PULL 22/22] nbd/trivial: fix type cast for ioctl, Paolo Bonzini, 2015/04/28
- Re: [Qemu-devel] [PULL 00/22] Memory, TCG, NBD, build system changes for 2015-04-27, Peter Maydell, 2015/04/28