[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] physmem: allow cpu_memory_rw_debug to write to MMIO devices
From: |
Stefan Zabka |
Subject: |
[PATCH] physmem: allow cpu_memory_rw_debug to write to MMIO devices |
Date: |
Wed, 18 Dec 2024 20:31:53 +0100 |
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/213
Signed-off-by: Stefan Zabka <git@zabka.it>
---
system/physmem.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/system/physmem.c b/system/physmem.c
index dc1db3a384..53cdccefcb 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3556,6 +3556,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
hwaddr phys_addr;
vaddr l, page;
uint8_t *buf = ptr;
+ bool is_memcpy_access;
cpu_synchronize_state(cpu);
while (len > 0) {
@@ -3574,11 +3575,24 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
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);
+ /* if ram/rom region we access the memory
+ via memcpy instead of via the cpu */
+ hwaddr mr_len, addr1;
+ AddressSpace *as = cpu->cpu_ases[asidx].as;
+ MemoryRegion *mr = address_space_translate(as, phys_addr, &addr1,
&mr_len, is_write, attrs);
+
+ is_memcpy_access = memory_region_is_ram(mr) ||
memory_region_is_romd(mr);
+ if(!is_memcpy_access) {
+ l = memory_access_size(mr, l, addr1);
+ }
+ } else {
+ is_memcpy_access = false;
+ }
+
+ if (is_write && is_memcpy_access) {
+ 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) {
return -1;
--
2.47.1
- [PATCH] physmem: allow cpu_memory_rw_debug to write to MMIO devices,
Stefan Zabka <=