Skip to contentSkip to conversation

[6905] ROM write access for debugging (Jan Kiszka)

Qemu-devel Anthony Liguori 1 participant 1 message Mar 28, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6905

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6905
Author:   aliguori
Date:     2009-03-28 17:51:36 +0000 (Sat, 28 Mar 2009)

Log Message:
-----------
ROM write access for debugging (Jan Kiszka)

Enhance cpu_memory_rw_debug so that it can write even to ROM regions. This allows to modify ROM via gdb (I see no point in denying this to the user), and it will enable us to drop kvm_patch_opcode_byte().

Credits go to Avi for suggesting this.

Modified Paths:
--------------
trunk/exec.c

Modified: trunk/exec.c
===================================================================

exec.c +8 -3
@@ -3448,7 +3448,7 @@
 
 #endif
 
-/* virtual memory access for debug */
+/* virtual memory access for debug (includes writing to ROM) */
 int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
                         uint8_t *buf, int len, int is_write)
 {
@@ -3465,8 +3465,13 @@
         l = (page + TARGET_PAGE_SIZE) - addr;
         if (l > len)
             l = len;
-        cpu_physical_memory_rw(phys_addr + (addr & ~TARGET_PAGE_MASK),
-                               buf, l, is_write);
+        phys_addr += (addr & ~TARGET_PAGE_MASK);
+#if !defined(CONFIG_USER_ONLY)
+        if (is_write)
+            cpu_physical_memory_write_rom(phys_addr, buf, l);
+        else
+#endif
+            cpu_physical_memory_rw(phys_addr, buf, l, is_write);
         len -= l;
         buf += l;
         addr += l;