qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH for-11.0 4/7] hw/dma/omap_dma: Remove omap_badwidth_* calls
Date: Wed, 10 Dec 2025 18:36:57 +0000	[thread overview]
Message-ID: <20251210183700.3446237-5-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_dma.c with an
open-coded call to qemu_log_mask() and RAZ/WI behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/dma/omap_dma.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c
index 101f91f4a33..ba0a70d84bd 100644
--- a/hw/dma/omap_dma.c
+++ b/hw/dma/omap_dma.c
@@ -1454,7 +1454,9 @@ static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size)
     uint16_t ret;
 
     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 (addr) {
@@ -1501,7 +1503,8 @@ static void omap_dma_write(void *opaque, hwaddr addr,
     int reg, ch;
 
     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



  parent reply	other threads:[~2025-12-10 18:39 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 ` [PATCH for-11.0 3/7] hw/gpio/omap_gpio: " Peter Maydell
2025-12-10 18:36 ` Peter Maydell [this message]
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-5-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).