All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] physmem: allow cpu_memory_rw_debug to write to MMIO devices
@ 2024-12-20 19:49 Stefan Zabka
  2024-12-20 20:59 ` David Hildenbrand
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Zabka @ 2024-12-20 19:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefan Zabka, Paolo Bonzini, Peter Xu, David Hildenbrand,
	Philippe Mathieu-Daudé

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/213
Signed-off-by: Stefan Zabka <git@zabka.it>
---
Addressed initial review by David Hildenbrand
The other change made more sense to me, so I'd like to write a test
to verify that an AddressSpace like
0x00..0x0F MMIO Device A
0x10..0x1F ROM
0x20..0x2F MMIO Device B

and a debug write from 0x00-0x2F still writes to MMIO Device B
and that there isn't an early exit in address_space_rw
when it encounters a ROM region.

How would I go about doing that?
---
 system/physmem.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/system/physmem.c b/system/physmem.c
index dc1db3a384..623f41ae06 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3573,12 +3573,13 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
         if (l > len)
             l = len;
         phys_addr += (addr & ~TARGET_PAGE_MASK);
-        if (is_write) {
-            res = address_space_write_rom(cpu->cpu_ases[asidx].as, phys_addr,
-                                          attrs, buf, l);
-        } else {
-            res = address_space_read(cpu->cpu_ases[asidx].as, phys_addr,
-                                     attrs, buf, l);
+        res = address_space_rw(cpu->cpu_ases[asidx].as, phys_addr,
+                                   attrs, buf, l, is_write);
+        if (res != MEMTX_OK && is_write) {
+            /* Fallback since it might be a ROM region*/
+            /* TODO verify that this works as expected*/
+            res = address_space_write_rom(cpu->cpu_ases[asidx].as,
+                                          phys_addr, attrs, buf, l);
         }
         if (res != MEMTX_OK) {
             return -1;
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-01-10 17:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20 19:49 [PATCH v2] physmem: allow cpu_memory_rw_debug to write to MMIO devices Stefan Zabka
2024-12-20 20:59 ` David Hildenbrand
2024-12-20 22:22   ` vringar
2024-12-21 14:55     ` David Hildenbrand
2025-01-08 18:35       ` Stefan Zabka
2025-01-08 20:09         ` David Hildenbrand
2025-01-10 15:44           ` Peter Maydell
2025-01-10 16:02             ` David Hildenbrand
2025-01-10 16:55             ` Alex Bennée
2025-01-10 17:06               ` Peter Maydell
2025-01-10 15:16         ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.