From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
Mark Cave-Ayland <mark.cave-ayland@ilade.co.uk>
Subject: [Qemu-devel] [PATCH for-2.3 5/6] ioport: loosen assertions on emulation of 16-bit ports
Date: Mon, 30 Mar 2015 13:45:17 +0200 [thread overview]
Message-ID: <1427715918-25768-6-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1427715918-25768-1-git-send-email-pbonzini@redhat.com>
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 <pbonzini@redhat.com>
---
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.4
next prev parent reply other threads:[~2015-03-30 11:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 11:45 [Qemu-devel] [PATCH for-2.3 0/3] ioport fixes Paolo Bonzini
2015-03-30 11:45 ` [Qemu-devel] [PATCH for-2.3 1/6] sb16: remove useless mixer_write_indexw Paolo Bonzini
2015-03-31 11:19 ` Andreas Färber
2015-03-31 11:21 ` Paolo Bonzini
2015-03-30 11:45 ` [Qemu-devel] [PATCH for-2.3 2/6] gus: clean up MemoryRegionPortio Paolo Bonzini
2015-03-30 11:45 ` [Qemu-devel] [PATCH for-2.3 3/6] ide: there is only one data port Paolo Bonzini
2015-03-30 11:45 ` [Qemu-devel] [PATCH for-2.3 4/6] ioport: remove wrong comment Paolo Bonzini
2015-03-30 11:45 ` Paolo Bonzini [this message]
2015-03-30 11:45 ` [Qemu-devel] [PATCH for-2.3 6/6] ioport: reserve the whole range of an I/O port in the AddressSpace Paolo Bonzini
2015-03-31 21:47 ` [Qemu-devel] [PATCH for-2.3 0/3] ioport fixes Mark Cave-Ayland
2015-04-01 9:10 ` Peter Maydell
2015-04-01 9:22 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427715918-25768-6-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=mark.cave-ayland@ilade.co.uk \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).