Commit 0dbc2392d8 for qemu.org
commit 0dbc2392d8ef0cefff6f07cf5e653e2eadb97f5a
Author: Peter Maydell <peter.maydell@linaro.org>
Date: Thu Jan 15 15:26:30 2026 +0000
hw/dma/omap_dma: Remove omap_badwidth_* calls
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c
index 963ce6fd10..784a3a4f7f 100644
--- a/hw/dma/omap_dma.c
+++ b/hw/dma/omap_dma.c
@@ -1455,7 +1455,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) {
@@ -1502,7 +1504,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;
}