From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH for-11.0 3/7] hw/gpio/omap_gpio: Remove omap_badwidth_* calls
Date: Wed, 10 Dec 2025 18:36:56 +0000 [thread overview]
Message-ID: <20251210183700.3446237-4-peter.maydell@linaro.org> (raw)
In-Reply-To: <20251210183700.3446237-1-peter.maydell@linaro.org>
The omap_badwidth_read* and omap_badwidth_write* functions are
used by various OMAP devices when the guest makes an access
to registers with an invalid width; they do two things:
- log a GUEST_ERROR for the access
- call cpu_physical_memory_read() or cpu_physical_memory_write()
with the offset they are passed in
The first of these produces an unhelpful log message because the
function name that is printed is that of the omap-badwidth_*
function, not that of the read or write function of the device that
called it; this means you can't tell what device is involved.
The second is wrong because the offset is an offset into the device
but we use it as an absolute physical address, so we will access
whatever is at low memory. That happens to be the boot ROM, so we
will ignore a write and return random garbage on a read. This bug
has been present since 2011, when we did the conversions to the
MemoryRegion APIs, which involved changing all devices from working
with absolute physical addresses to working with offsets within their
MemoryRegions. We must have missed updating these functions.
Replace the uses of these functions in omap_gpio.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/gpio/omap_gpio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
index f27806b774a..170c8d1ab53 100644
--- a/hw/gpio/omap_gpio.c
+++ b/hw/gpio/omap_gpio.c
@@ -76,7 +76,9 @@ static uint64_t omap_gpio_read(void *opaque, hwaddr addr,
int offset = addr & OMAP_MPUI_REG_MASK;
if (size != 2) {
- return omap_badwidth_read16(opaque, addr);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: read at offset 0x%" HWADDR_PRIx
+ " with bad width %d\n", __func__, addr, size);
+ return 0;
}
switch (offset) {
@@ -116,7 +118,8 @@ static void omap_gpio_write(void *opaque, hwaddr addr,
int ln;
if (size != 2) {
- omap_badwidth_write16(opaque, addr, value);
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: write at offset 0x%" HWADDR_PRIx
+ " with bad width %d\n", __func__, addr, size);
return;
}
--
2.43.0
next prev parent reply other threads:[~2025-12-10 18:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 18:36 [PATCH for-11.0 0/7] hw/arm/omap: Remove omap_badwidth_* functions Peter Maydell
2025-12-10 18:36 ` [PATCH for-11.0 1/7] hw/sd/omap_mmc: Remove omap_badwidth_* calls Peter Maydell
2025-12-10 18:36 ` [PATCH for-11.0 2/7] hw/i2c/omap_i2c: " Peter Maydell
2025-12-10 18:36 ` Peter Maydell [this message]
2025-12-10 18:36 ` [PATCH for-11.0 4/7] hw/dma/omap_dma: " Peter Maydell
2025-12-10 18:36 ` [PATCH for-11.0 5/7] hw/arm/omap1: Remove omap_badwidth_read* calls Peter Maydell
2025-12-10 18:36 ` [PATCH for-11.0 6/7] hw/arm/omap1: Remove omap_badwidth_write* calls Peter Maydell
2025-12-10 18:37 ` [PATCH for-11.0 7/7] hw/arm/omap1: Remove omap_badwidth_* implementations Peter Maydell
2025-12-11 15:18 ` [PATCH for-11.0 0/7] hw/arm/omap: Remove omap_badwidth_* functions Philippe Mathieu-Daudé
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=20251210183700.3446237-4-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).