From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH v2 1/7] hw/char/serial: Assert serial_ioport_read/write offset fits 8 bytes
Date: Sat, 12 Sep 2020 13:40:34 +0200 [thread overview]
Message-ID: <20200912114040.918464-2-f4bug@amsat.org> (raw)
In-Reply-To: <20200912114040.918464-1-f4bug@amsat.org>
The serial device has 8 registers, each 8-bit. The MemoryRegionOps
'serial_io_ops' is initialized with max_access_size=1, and all
memory_region_init_io() callers correctly set the region size to
8 bytes:
- serial_io_realize
- serial_isa_realizefn
- serial_pci_realize
- multi_serial_pci_realize
It is safe to assert the offset argument of serial_ioport_read()
and serial_ioport_write() is always less than 8.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/char/serial.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 23864794929..a855ef66ea2 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -344,7 +344,7 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val,
{
SerialState *s = opaque;
- addr &= 7;
+ assert(size == 1 && addr < 8);
trace_serial_ioport_write(addr, val);
switch(addr) {
default:
@@ -485,7 +485,7 @@ static uint64_t serial_ioport_read(void *opaque, hwaddr addr, unsigned size)
SerialState *s = opaque;
uint32_t ret;
- addr &= 7;
+ assert(size == 1 && addr < 8);
switch(addr) {
default:
case 0:
--
2.26.2
next prev parent reply other threads:[~2020-09-12 11:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-12 11:40 [PATCH v2 0/7] hw/char/serial: Housekeeping Philippe Mathieu-Daudé
2020-09-12 11:40 ` Philippe Mathieu-Daudé [this message]
2020-09-12 11:40 ` [PATCH v2 2/7] hw/char/serial: Replace commented DPRINTF() by trace event Philippe Mathieu-Daudé
2020-09-12 11:40 ` [PATCH v2 3/7] hw/char/serial: Remove old DEBUG_SERIAL commented code Philippe Mathieu-Daudé
2020-09-12 11:40 ` [PATCH v2 4/7] hw/char/serial: Rename I/O read/write trace events Philippe Mathieu-Daudé
2020-09-12 11:40 ` [PATCH v2 5/7] hw/char/serial: Make 'wakeup' property boolean Philippe Mathieu-Daudé
2020-09-12 11:40 ` [PATCH v2 6/7] hw/char/serial: Alias QDEV properties from generic serial object Philippe Mathieu-Daudé
2020-09-12 11:40 ` [PATCH v2 7/7] hw/char/serial: Let SerialState have an 'id' field Philippe Mathieu-Daudé
2020-09-12 11:45 ` [PATCH v2 0/7] hw/char/serial: Housekeeping no-reply
2020-09-12 19:09 ` Ed Maste
2020-09-12 11:51 ` no-reply
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=20200912114040.918464-2-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=richard.henderson@linaro.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).