Skip to contentSkip to conversation

aspeed, highbank: fix RAM migration oddities

PATCH In review Peter Maydell 2 participants 8 messages Apr 20, 2018 – Apr 21, 2018 Arm/Aspeed machine support

lore
Share & tools
lore
#1 lore raw

PATCH 1/3 hw/arm/highbank: don't make sysram 'nomigrate'

In reply to Peter Maydell

Currently we use memory_region_init_ram_nomigrate() to create the "highbank.sysram" memory region, and we don't manually register it with vmstate_register_ram(). This currently means that its contents are migrated but as a ram block whose name is the empty string; in future it may mean they are not migrated at all. Use memory_region_init_ram() instead.

Note that this is a cross-version migration compatibility break for the "highbank" and "midway" machines.

---
 hw/arm/highbank.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/highbank.c +1 -1
index 1742cf6f6c..88326d1bfd 100644
@@ -291,7 +291,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
     memory_region_add_subregion(sysmem, 0, dram);
 
     sysram = g_new(MemoryRegion, 1);
-    memory_region_init_ram_nomigrate(sysram, NULL, "highbank.sysram", 0x8000,
+    memory_region_init_ram(sysram, NULL, "highbank.sysram", 0x8000,
                            &error_fatal);
     memory_region_add_subregion(sysmem, 0xfff88000, sysram);
     if (bios_name != NULL) {
Signature · 1 line
2.17.0
#0 lore raw

cover aspeed, highbank: fix RAM migration oddities

In a couple of places in the highbank and aspeed boards, we create RAM regions with memory_region_init_ram_nomigrate() and then either:
* don't call vmstate_register_ram()
* from a device, register it with vmstate_register_ram_global()

The first case is a bug. Currently it means that the underlying RAM block will have a name which is the empty string; it will migrate, but if there is more than one such RAM block in the system migration will fail. Future changes to the migration code are likely to mean that the RAM block isn't migrated at all.

The second case is also a bug: since the name used for the RAM block is global to all of QEMU, it means that you can't have more than one instance of the device without QEMU abort()ing because of the name clash.

Fix both of these by using memory_region_init_ram(), which automatically registers the RAM block for migration with a sensible name.

This patchset is a cross-version migration compatibility break for the boards "palmetto-bmc", "ast2500-evb", "romulus-bmc", "highbank" and "midway". We don't promise migration compat for those boards, so this is OK.

NB: I haven't tested this code beyond "does make check pass", because I don't have a test image for any of these boards. Testing welcomed :-)

thanks
-- PMM

Peter Maydell (3):
hw/arm/highbank: don't make sysram 'nomigrate' hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate' hw/arm/aspeed_soc: don't use vmstate_register_ram_global for SRAM

 hw/arm/aspeed.c     | 2 +-
 hw/arm/aspeed_soc.c | 3 +--
 hw/arm/highbank.c   | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.0
#2 lore raw

PATCH 2/3 hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'

Currently we use memory_region_init_ram_nomigrate() to create the "aspeed.boot_rom" memory region, and we don't manually register it with vmstate_register_ram(). This currently means that its contents are migrated but as a ram block whose name is the empty string; in future it may mean they are not migrated at all. Use memory_region_init_ram() instead.

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

---
 hw/arm/aspeed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/aspeed.c +1 -1
index 7088c907bd..aecb3c1e75 100644
@@ -225,7 +225,7 @@ static void aspeed_board_init(MachineState *machine,
          * SoC and 128MB for the AST2500 SoC, which is twice as big as
          * needed by the flash modules of the Aspeed machines.
          */
-        memory_region_init_rom_nomigrate(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
+        memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
                                fl->size, &error_abort);
         memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
                                     boot_rom);
Signature · 1 line
2.17.0
#6 lore raw

PATCH 3/3 hw/arm/aspeed_soc: don't use vmstate_register_ram_global for SRAM

In reply to Peter Maydell

Currently we use vmstate_register_ram_global() for the SRAM; this is not a good idea for devices, because it means that you can only ever create one instance of the device, as the second instance would get a RAM block name clash. Instead, use memory_region_init_ram(), which automatically registers the RAM block with a local-to-the-device name.

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

---
 hw/arm/aspeed_soc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/arm/aspeed_soc.c +1 -2
index 30d25f8b06..407f10d0d4 100644
@@ -186,13 +186,12 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     }
 
     /* SRAM */
-    memory_region_init_ram_nomigrate(&s->sram, OBJECT(dev), "aspeed.sram",
+    memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram",
                            sc->info->sram_size, &err);
     if (err) {
         error_propagate(errp, err);
         return;
     }
-    vmstate_register_ram_global(&s->sram);
     memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE,
                                 &s->sram);
 
Signature · 1 line
2.17.0
Reviewed-by Tested-by on v1 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'

In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

Currently we use memory_region_init_ram_nomigrate() to create the "aspeed.boot_rom" memory region, and we don't manually register it with vmstate_register_ram(). This currently means that its contents are migrated but as a ram block whose name is the empty string; in future it may mean they are not migrated at all. Use memory_region_init_ram() instead.

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

Migration does not work for these.

Quoted 1 line

On palmetto, romulus and ast2500-evb boards

Thanks

C.

Quoted 18 lines
---
 hw/arm/aspeed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/aspeed.c +1 -1
index 7088c907bd..aecb3c1e75 100644
@@ -225,7 +225,7 @@ static void aspeed_board_init(MachineState *machine,
          * SoC and 128MB for the AST2500 SoC, which is twice as big as
          * needed by the flash modules of the Aspeed machines.
          */
-        memory_region_init_rom_nomigrate(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
+        memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom",
                                fl->size, &error_abort);
         memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
                                     boot_rom);
Reviewed-by Tested-by on v1 3/3
#7 lore raw

Re: [Qemu-arm] [PATCH 3/3] hw/arm/aspeed_soc: don't use vmstate_register_ram_global for SRAM

In reply to Peter Maydell
Quoted 11 lines · Peter Maydell

Currently we use vmstate_register_ram_global() for the SRAM; this is not a good idea for devices, because it means that you can only ever create one instance of the device, as the second instance would get a RAM block name clash. Instead, use memory_region_init_ram(), which automatically registers the RAM block with a local-to-the-device name.

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

On palmetto, romulus and ast2500-evb boards

Thanks

C.> ---

Quoted 23 lines
 hw/arm/aspeed_soc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/arm/aspeed_soc.c +1 -2
index 30d25f8b06..407f10d0d4 100644
@@ -186,13 +186,12 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     }
 
     /* SRAM */
-    memory_region_init_ram_nomigrate(&s->sram, OBJECT(dev), "aspeed.sram",
+    memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram",
                            sc->info->sram_size, &err);
     if (err) {
         error_propagate(errp, err);
         return;
     }
-    vmstate_register_ram_global(&s->sram);
     memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE,
                                 &s->sram);
 
#4 lore raw

Re: [Qemu-arm] [PATCH 2/3] hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'

In reply to Cédric Le Goater
Quoted 8 lines · Cédric Le Goater
Quoted 7 lines · Peter Maydell

Currently we use memory_region_init_ram_nomigrate() to create the "aspeed.boot_rom" memory region, and we don't manually register it with vmstate_register_ram(). This currently means that its contents are migrated but as a ram block whose name is the empty string; in future it may mean they are not migrated at all. Use memory_region_init_ram() instead.

Quoted 4 lines
Quoted 2 lines

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

Migration does not work for these.

Well, at least we're not breaking anything :-)
Do you know why migration doesn't work?

thanks
-- PMM

#5 lore raw

Re: [Qemu-arm] [PATCH 2/3] hw/arm/aspeed: don't make 'boot_rom' region 'nomigrate'

Quoted 9 lines · Peter Maydell
Quoted 8 lines · Cédric Le Goater
Quoted 7 lines · Peter Maydell

Currently we use memory_region_init_ram_nomigrate() to create the "aspeed.boot_rom" memory region, and we don't manually register it with vmstate_register_ram(). This currently means that its contents are migrated but as a ram block whose name is the empty string; in future it may mean they are not migrated at all. Use memory_region_init_ram() instead.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Note that this is a cross-version migration compatibility break for the "palmetto-bmc", "ast2500-evb" and "romulus-bmc" machines.

Migration does not work for these.

Well, at least we're not breaking anything :-)
Do you know why migration doesn't work?

A quick migration test shows that :

qemu-system-arm: Missing section footer for aspeed.timerctrl
qemu-system-arm: load of migration failed: Invalid argument

which is surprising, the state looks correct. I will dig in.

Thanks,

C.

    "aspeed.timerctrl (8)": {
        "ctrl": "0x00000003",
        "ctrl2": "0x00000000",
        "timers": [
            {
                "id": "0x00",
                "level": "0x00000000",
                "timer": "00 00 00 29 aa bd 88 44",
                "reload": "0xffffffff",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x01",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x02",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x03",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0xffffffff",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x04",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x05",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x06",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            },
            {
                "id": "0x07",
                "level": "0x00000000",
                "timer": "ff ff ff ff ff ff ff ff",
                "reload": "0x00000000",
                "match": [
                    "0x00000000",
                    "0x00000000"
                ]
            }
        ]
    },