Skip to contentSkip to conversation

hw/display/sm501: Don't use vmstate_register_ram_global()

PATCH In review Peter Maydell 2 participants 4 messages Jul 17, 2017 – Jul 25, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/sm501: Don't use vmstate_register_ram_global()

The sm501 device uses vmstate_register_ram_global() to register its memory region for migration. This means it gets a name that is assumed to be global to the whole system, which in turn means that if you create two of the device we assert because of the duplication:

qemu-system-ppc -device sm501 -device sm501
RAMBlock "sm501.local" already registered, abort!
Aborted (core dumped)

Changing this to just use memory_region_init_ram()'s automatic registration of the memory region with a device-local name fixes this. The downside is that it breaks migration compatibility, but luckily we only added migration support to this device in the 2.10 release cycle so we haven't released a QEMU version with the broken implementation.

---
Recent refactoring that renamed the old "memory_region_init_ram" to memory_region_init_ram_nomigrate" made this bug a bit easier to find via grep...

 hw/display/sm501.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/display/sm501.c +1 -2
index af792c5..9aa515b 100644
@@ -1578,9 +1578,8 @@ static void sm501_init(SM501State *s, DeviceState *dev,
                   s->local_mem_size_index);
 
     /* local memory */
-    memory_region_init_ram_nomigrate(&s->local_mem_region, OBJECT(dev), "sm501.local",
+    memory_region_init_ram(&s->local_mem_region, OBJECT(dev), "sm501.local",
                            get_local_mem_size(s), &error_fatal);
-    vmstate_register_ram_global(&s->local_mem_region);
     memory_region_set_log(&s->local_mem_region, true, DIRTY_MEMORY_VGA);
     s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region);
 
Signature · 1 line
2.7.4
#1 lore raw

Ping for review, please? Would be nice to get this into rc0.

thanks
-- PMM

Quoted 41 lines · Peter Maydell

The sm501 device uses vmstate_register_ram_global() to register its memory region for migration. This means it gets a name that is assumed to be global to the whole system, which in turn means that if you create two of the device we assert because of the duplication:

qemu-system-ppc -device sm501 -device sm501
RAMBlock "sm501.local" already registered, abort!
Aborted (core dumped)

Changing this to just use memory_region_init_ram()'s automatic registration of the memory region with a device-local name fixes this. The downside is that it breaks migration compatibility, but luckily we only added migration support to this device in the 2.10 release cycle so we haven't released a QEMU version with the broken implementation.

---
Recent refactoring that renamed the old "memory_region_init_ram" to memory_region_init_ram_nomigrate" made this bug a bit easier to find via grep...

 hw/display/sm501.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/display/sm501.c +1 -3
index af792c5..9aa515b 100644
@@ -1578,9 +1578,8 @@ static void sm501_init(SM501State *s, DeviceState *dev,
                   s->local_mem_size_index);
 
     /* local memory */
-    memory_region_init_ram_nomigrate(&s->local_mem_region, OBJECT(dev), "sm501.local",
+    memory_region_init_ram(&s->local_mem_region, OBJECT(dev), "sm501.local",
                            get_local_mem_size(s), &error_fatal);
-    vmstate_register_ram_global(&s->local_mem_region);
     memory_region_set_log(&s->local_mem_region, true, DIRTY_MEMORY_VGA);
     s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region);
 
--P
#2 lore raw
Quoted 1 line · * Peter Maydell ([email protected]) wrote:

Ping for review, please? Would be nice to get this into rc0.

Quoted 45 lines

thanks
-- PMM

Quoted 40 lines · Peter Maydell

The sm501 device uses vmstate_register_ram_global() to register its memory region for migration. This means it gets a name that is assumed to be global to the whole system, which in turn means that if you create two of the device we assert because of the duplication:

qemu-system-ppc -device sm501 -device sm501
RAMBlock "sm501.local" already registered, abort!
Aborted (core dumped)

Changing this to just use memory_region_init_ram()'s automatic registration of the memory region with a device-local name fixes this. The downside is that it breaks migration compatibility, but luckily we only added migration support to this device in the 2.10 release cycle so we haven't released a QEMU version with the broken implementation.

---
Recent refactoring that renamed the old "memory_region_init_ram" to memory_region_init_ram_nomigrate" made this bug a bit easier to find via grep...

 hw/display/sm501.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/display/sm501.c +1 -2
index af792c5..9aa515b 100644
@@ -1578,9 +1578,8 @@ static void sm501_init(SM501State *s, DeviceState *dev,
                   s->local_mem_size_index);
 
     /* local memory */
-    memory_region_init_ram_nomigrate(&s->local_mem_region, OBJECT(dev), "sm501.local",
+    memory_region_init_ram(&s->local_mem_region, OBJECT(dev), "sm501.local",
                            get_local_mem_size(s), &error_fatal);
-    vmstate_register_ram_global(&s->local_mem_region);
     memory_region_set_log(&s->local_mem_region, true, DIRTY_MEMORY_VGA);
     s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region);
 
Quoted 2 lines
Quoted 1 line

--P

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK