Skip to contentSkip to conversation

memory: call begin, log_start and commit when registering a new listener

PATCH In review Paolo Bonzini 2 participants 2 messages Nov 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory: call begin, log_start and commit when registering a new listener

This ensures that cpu_reload_memory_map() is called as soon as tcg_cpu_address_space_init() is called, and before cpu->memory_dispatch is used. qemu-system-s390x never changes the address spaces after tcg_cpu_address_space_init() is called, and thus tcg_commit() is never called. This causes a SIGSEGV.

Cc Peter Maydell <[email protected]>
Fixes 0a1c71cec63e95f9b8d0dc96d049d2daa00c5210
---
 memory.c | 9 +++++++++
 1 file changed, 9 insertions(+)
memory.c +9 -0
index 2eb1597..c435c88 100644
@@ -2036,6 +2036,9 @@ static void listener_add_address_space(MemoryListener *listener,
         return;
     }
 
+    if (listener->begin) {
+        listener->begin(listener);
+    }
     if (global_dirty_log) {
         if (listener->log_global_start) {
             listener->log_global_start(listener);
@@ -2052,10 +2055,16 @@ static void listener_add_address_space(MemoryListener *listener,
             .offset_within_address_space = int128_get64(fr->addr.start),
             .readonly = fr->readonly,
         };
+        if (fr->dirty_log_mask && listener->log_start) {
+            listener->log_start(listener, &section, 0, fr->dirty_log_mask);
+        }
         if (listener->region_add) {
             listener->region_add(listener, &section);
         }
     }
+    if (listener->commit) {
+        listener->commit(listener);
+    }
     flatview_unref(view);
 }
 
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Paolo Bonzini

This ensures that cpu_reload_memory_map() is called as soon as tcg_cpu_address_space_init() is called, and before cpu->memory_dispatch is used. qemu-system-s390x never changes the address spaces after tcg_cpu_address_space_init() is called, and thus tcg_commit() is never called. This causes a SIGSEGV.

Cc Peter Maydell <[email protected]>
Fixes 0a1c71cec63e95f9b8d0dc96d049d2daa00c5210

This is how I expected the memory listener API to work when I wrote the exec.c change, anyway :-)

thanks
-- PMM