[PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions

Philippe Mathieu-Daudé posted 32 patches 5 years, 8 months ago
Only 8 patches received!
There is a newer version of this series
[PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/arm/exynos4210.c | 3 +--
 hw/arm/mainstone.c  | 3 +--
 hw/arm/omap_sx1.c   | 6 ++----
 hw/arm/palm.c       | 3 +--
 hw/arm/spitz.c      | 3 +--
 hw/arm/stellaris.c  | 3 +--
 hw/arm/tosa.c       | 3 +--
 7 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 59a27bdd68..3af6502a5e 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -311,9 +311,8 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
                                 &s->chipid_mem);
 
     /* Internal ROM */
-    memory_region_init_ram(&s->irom_mem, NULL, "exynos4210.irom",
+    memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
                            EXYNOS4210_IROM_SIZE, &error_fatal);
-    memory_region_set_readonly(&s->irom_mem, true);
     memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
                                 &s->irom_mem);
     /* mirror of iROM */
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 6e64dfab50..05a806b422 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -125,9 +125,8 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
     /* Setup CPU & memory */
     mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
                       machine->cpu_type);
-    memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
+    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
                            &error_fatal);
-    memory_region_set_readonly(rom, true);
     memory_region_add_subregion(address_space_mem, 0, rom);
 
 #ifdef TARGET_WORDS_BIGENDIAN
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index be245714db..6c3fd1b271 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -126,9 +126,8 @@ static void sx1_init(MachineState *machine, const int version)
     mpu = omap310_mpu_init(dram, machine->cpu_type);
 
     /* External Flash (EMIFS) */
-    memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
+    memory_region_init_rom(flash, NULL, "omap_sx1.flash0-0", flash_size,
                            &error_fatal);
-    memory_region_set_readonly(flash, true);
     memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);
 
     memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val,
@@ -168,9 +167,8 @@ static void sx1_init(MachineState *machine, const int version)
     if ((version == 1) &&
             (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
         MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
-        memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0",
+        memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
                                flash1_size, &error_fatal);
-        memory_region_set_readonly(flash_1, true);
         memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
 
         memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 72eca8cc55..265d5891a6 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -206,9 +206,8 @@ static void palmte_init(MachineState *machine)
     mpu = omap310_mpu_init(dram, machine->cpu_type);
 
     /* External Flash (EMIFS) */
-    memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
+    memory_region_init_rom(flash, NULL, "palmte.flash", flash_size,
                            &error_fatal);
-    memory_region_set_readonly(flash, true);
     memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash);
 
     memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0",
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index e001088103..1d27399721 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -924,8 +924,7 @@ static void spitz_common_init(MachineState *machine,
 
     sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
 
-    memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
-    memory_region_set_readonly(rom, true);
+    memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
     memory_region_add_subregion(address_space_mem, 0, rom);
 
     /* Setup peripherals */
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 221a78674e..d136ba1a92 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -1300,9 +1300,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
     sram_size = ((board->dc0 >> 18) + 1) * 1024;
 
     /* Flash programming is done via the SCU, so pretend it is ROM.  */
-    memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
+    memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
                            &error_fatal);
-    memory_region_set_readonly(flash, true);
     memory_region_add_subregion(system_memory, 0, flash);
 
     memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size,
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 4d95a1f3e2..5dee2d76c6 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -226,8 +226,7 @@ static void tosa_init(MachineState *machine)
 
     mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
 
-    memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
-    memory_region_set_readonly(rom, true);
+    memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
     memory_region_add_subregion(address_space_mem, 0, rom);
 
     tmio = tc6393xb_init(address_space_mem, 0x10000000,
-- 
2.21.1


Re: [PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions
Posted by Alistair Francis 5 years, 8 months ago
On Mon, Feb 24, 2020 at 12:51 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> This commit was produced with the Coccinelle script
> scripts/coccinelle/memory-region-housekeeping.cocci.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

This looks good for the ROM regions, for the flash regions this
doesn't change the current functionality but I'm not sure it's any
clearer.

Either way though:

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/exynos4210.c | 3 +--
>  hw/arm/mainstone.c  | 3 +--
>  hw/arm/omap_sx1.c   | 6 ++----
>  hw/arm/palm.c       | 3 +--
>  hw/arm/spitz.c      | 3 +--
>  hw/arm/stellaris.c  | 3 +--
>  hw/arm/tosa.c       | 3 +--
>  7 files changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> index 59a27bdd68..3af6502a5e 100644
> --- a/hw/arm/exynos4210.c
> +++ b/hw/arm/exynos4210.c
> @@ -311,9 +311,8 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
>                                  &s->chipid_mem);
>
>      /* Internal ROM */
> -    memory_region_init_ram(&s->irom_mem, NULL, "exynos4210.irom",
> +    memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
>                             EXYNOS4210_IROM_SIZE, &error_fatal);
> -    memory_region_set_readonly(&s->irom_mem, true);
>      memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
>                                  &s->irom_mem);
>      /* mirror of iROM */
> diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
> index 6e64dfab50..05a806b422 100644
> --- a/hw/arm/mainstone.c
> +++ b/hw/arm/mainstone.c
> @@ -125,9 +125,8 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
>      /* Setup CPU & memory */
>      mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
>                        machine->cpu_type);
> -    memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
> +    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
>                             &error_fatal);
> -    memory_region_set_readonly(rom, true);
>      memory_region_add_subregion(address_space_mem, 0, rom);
>
>  #ifdef TARGET_WORDS_BIGENDIAN
> diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
> index be245714db..6c3fd1b271 100644
> --- a/hw/arm/omap_sx1.c
> +++ b/hw/arm/omap_sx1.c
> @@ -126,9 +126,8 @@ static void sx1_init(MachineState *machine, const int version)
>      mpu = omap310_mpu_init(dram, machine->cpu_type);
>
>      /* External Flash (EMIFS) */
> -    memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
> +    memory_region_init_rom(flash, NULL, "omap_sx1.flash0-0", flash_size,
>                             &error_fatal);
> -    memory_region_set_readonly(flash, true);
>      memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);
>
>      memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val,
> @@ -168,9 +167,8 @@ static void sx1_init(MachineState *machine, const int version)
>      if ((version == 1) &&
>              (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
>          MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
> -        memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0",
> +        memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
>                                 flash1_size, &error_fatal);
> -        memory_region_set_readonly(flash_1, true);
>          memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
>
>          memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
> diff --git a/hw/arm/palm.c b/hw/arm/palm.c
> index 72eca8cc55..265d5891a6 100644
> --- a/hw/arm/palm.c
> +++ b/hw/arm/palm.c
> @@ -206,9 +206,8 @@ static void palmte_init(MachineState *machine)
>      mpu = omap310_mpu_init(dram, machine->cpu_type);
>
>      /* External Flash (EMIFS) */
> -    memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
> +    memory_region_init_rom(flash, NULL, "palmte.flash", flash_size,
>                             &error_fatal);
> -    memory_region_set_readonly(flash, true);
>      memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash);
>
>      memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0",
> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
> index e001088103..1d27399721 100644
> --- a/hw/arm/spitz.c
> +++ b/hw/arm/spitz.c
> @@ -924,8 +924,7 @@ static void spitz_common_init(MachineState *machine,
>
>      sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
>
> -    memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
> -    memory_region_set_readonly(rom, true);
> +    memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
>      memory_region_add_subregion(address_space_mem, 0, rom);
>
>      /* Setup peripherals */
> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> index 221a78674e..d136ba1a92 100644
> --- a/hw/arm/stellaris.c
> +++ b/hw/arm/stellaris.c
> @@ -1300,9 +1300,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>      sram_size = ((board->dc0 >> 18) + 1) * 1024;
>
>      /* Flash programming is done via the SCU, so pretend it is ROM.  */
> -    memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
> +    memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
>                             &error_fatal);
> -    memory_region_set_readonly(flash, true);
>      memory_region_add_subregion(system_memory, 0, flash);
>
>      memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size,
> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
> index 4d95a1f3e2..5dee2d76c6 100644
> --- a/hw/arm/tosa.c
> +++ b/hw/arm/tosa.c
> @@ -226,8 +226,7 @@ static void tosa_init(MachineState *machine)
>
>      mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
>
> -    memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
> -    memory_region_set_readonly(rom, true);
> +    memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
>      memory_region_add_subregion(address_space_mem, 0, rom);
>
>      tmio = tc6393xb_init(address_space_mem, 0x10000000,
> --
> 2.21.1
>
>

Re: [PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
On 2/24/20 10:20 PM, Alistair Francis wrote:
> On Mon, Feb 24, 2020 at 12:51 PM Philippe Mathieu-Daudé
> <philmd@redhat.com> wrote:
>>
>> This commit was produced with the Coccinelle script
>> scripts/coccinelle/memory-region-housekeeping.cocci.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> 
> This looks good for the ROM regions, for the flash regions this
> doesn't change the current functionality but I'm not sure it's any
> clearer.

Less code makes easier review.

These regions behave as ROM on the bus, any write to the address space 
is illegal (they are programmable via I/O registers in another address 
space).

> 
> Either way though:
> 
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Thanks, do you want me to improve the commit description?

> 
> Alistair
> 
>> ---
>>   hw/arm/exynos4210.c | 3 +--
>>   hw/arm/mainstone.c  | 3 +--
>>   hw/arm/omap_sx1.c   | 6 ++----
>>   hw/arm/palm.c       | 3 +--
>>   hw/arm/spitz.c      | 3 +--
>>   hw/arm/stellaris.c  | 3 +--
>>   hw/arm/tosa.c       | 3 +--
>>   7 files changed, 8 insertions(+), 16 deletions(-)
>>
>> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
>> index 59a27bdd68..3af6502a5e 100644
>> --- a/hw/arm/exynos4210.c
>> +++ b/hw/arm/exynos4210.c
>> @@ -311,9 +311,8 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
>>                                   &s->chipid_mem);
>>
>>       /* Internal ROM */
>> -    memory_region_init_ram(&s->irom_mem, NULL, "exynos4210.irom",
>> +    memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
>>                              EXYNOS4210_IROM_SIZE, &error_fatal);
>> -    memory_region_set_readonly(&s->irom_mem, true);
>>       memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
>>                                   &s->irom_mem);
>>       /* mirror of iROM */
>> diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
>> index 6e64dfab50..05a806b422 100644
>> --- a/hw/arm/mainstone.c
>> +++ b/hw/arm/mainstone.c
>> @@ -125,9 +125,8 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
>>       /* Setup CPU & memory */
>>       mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
>>                         machine->cpu_type);
>> -    memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
>> +    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
>>                              &error_fatal);
>> -    memory_region_set_readonly(rom, true);
>>       memory_region_add_subregion(address_space_mem, 0, rom);
>>
>>   #ifdef TARGET_WORDS_BIGENDIAN
>> diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
>> index be245714db..6c3fd1b271 100644
>> --- a/hw/arm/omap_sx1.c
>> +++ b/hw/arm/omap_sx1.c
>> @@ -126,9 +126,8 @@ static void sx1_init(MachineState *machine, const int version)
>>       mpu = omap310_mpu_init(dram, machine->cpu_type);
>>
>>       /* External Flash (EMIFS) */
>> -    memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
>> +    memory_region_init_rom(flash, NULL, "omap_sx1.flash0-0", flash_size,
>>                              &error_fatal);
>> -    memory_region_set_readonly(flash, true);
>>       memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);
>>
>>       memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val,
>> @@ -168,9 +167,8 @@ static void sx1_init(MachineState *machine, const int version)
>>       if ((version == 1) &&
>>               (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
>>           MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
>> -        memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0",
>> +        memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
>>                                  flash1_size, &error_fatal);
>> -        memory_region_set_readonly(flash_1, true);
>>           memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
>>
>>           memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
>> diff --git a/hw/arm/palm.c b/hw/arm/palm.c
>> index 72eca8cc55..265d5891a6 100644
>> --- a/hw/arm/palm.c
>> +++ b/hw/arm/palm.c
>> @@ -206,9 +206,8 @@ static void palmte_init(MachineState *machine)
>>       mpu = omap310_mpu_init(dram, machine->cpu_type);
>>
>>       /* External Flash (EMIFS) */
>> -    memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
>> +    memory_region_init_rom(flash, NULL, "palmte.flash", flash_size,
>>                              &error_fatal);
>> -    memory_region_set_readonly(flash, true);
>>       memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash);
>>
>>       memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0",
>> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
>> index e001088103..1d27399721 100644
>> --- a/hw/arm/spitz.c
>> +++ b/hw/arm/spitz.c
>> @@ -924,8 +924,7 @@ static void spitz_common_init(MachineState *machine,
>>
>>       sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
>>
>> -    memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
>> -    memory_region_set_readonly(rom, true);
>> +    memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
>>       memory_region_add_subregion(address_space_mem, 0, rom);
>>
>>       /* Setup peripherals */
>> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
>> index 221a78674e..d136ba1a92 100644
>> --- a/hw/arm/stellaris.c
>> +++ b/hw/arm/stellaris.c
>> @@ -1300,9 +1300,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
>>       sram_size = ((board->dc0 >> 18) + 1) * 1024;
>>
>>       /* Flash programming is done via the SCU, so pretend it is ROM.  */
>> -    memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
>> +    memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
>>                              &error_fatal);
>> -    memory_region_set_readonly(flash, true);
>>       memory_region_add_subregion(system_memory, 0, flash);
>>
>>       memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size,
>> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
>> index 4d95a1f3e2..5dee2d76c6 100644
>> --- a/hw/arm/tosa.c
>> +++ b/hw/arm/tosa.c
>> @@ -226,8 +226,7 @@ static void tosa_init(MachineState *machine)
>>
>>       mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
>>
>> -    memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
>> -    memory_region_set_readonly(rom, true);
>> +    memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
>>       memory_region_add_subregion(address_space_mem, 0, rom);
>>
>>       tmio = tc6393xb_init(address_space_mem, 0x10000000,
>> --
>> 2.21.1
>>
>>
> 


Re: [PATCH v2 05/32] hw/arm: Use memory_region_init_rom() with read-only regions
Posted by Alistair Francis 5 years, 8 months ago
On Tue, Feb 25, 2020 at 2:02 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> On 2/24/20 10:20 PM, Alistair Francis wrote:
> > On Mon, Feb 24, 2020 at 12:51 PM Philippe Mathieu-Daudé
> > <philmd@redhat.com> wrote:
> >>
> >> This commit was produced with the Coccinelle script
> >> scripts/coccinelle/memory-region-housekeeping.cocci.
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >
> > This looks good for the ROM regions, for the flash regions this
> > doesn't change the current functionality but I'm not sure it's any
> > clearer.
>
> Less code makes easier review.
>
> These regions behave as ROM on the bus, any write to the address space
> is illegal (they are programmable via I/O registers in another address
> space).

Good point.

>
> >
> > Either way though:
> >
> > Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
>
> Thanks, do you want me to improve the commit description?

Nope, it's fine :)

Alistair

>
> >
> > Alistair
> >
> >> ---
> >>   hw/arm/exynos4210.c | 3 +--
> >>   hw/arm/mainstone.c  | 3 +--
> >>   hw/arm/omap_sx1.c   | 6 ++----
> >>   hw/arm/palm.c       | 3 +--
> >>   hw/arm/spitz.c      | 3 +--
> >>   hw/arm/stellaris.c  | 3 +--
> >>   hw/arm/tosa.c       | 3 +--
> >>   7 files changed, 8 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> >> index 59a27bdd68..3af6502a5e 100644
> >> --- a/hw/arm/exynos4210.c
> >> +++ b/hw/arm/exynos4210.c
> >> @@ -311,9 +311,8 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
> >>                                   &s->chipid_mem);
> >>
> >>       /* Internal ROM */
> >> -    memory_region_init_ram(&s->irom_mem, NULL, "exynos4210.irom",
> >> +    memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
> >>                              EXYNOS4210_IROM_SIZE, &error_fatal);
> >> -    memory_region_set_readonly(&s->irom_mem, true);
> >>       memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
> >>                                   &s->irom_mem);
> >>       /* mirror of iROM */
> >> diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
> >> index 6e64dfab50..05a806b422 100644
> >> --- a/hw/arm/mainstone.c
> >> +++ b/hw/arm/mainstone.c
> >> @@ -125,9 +125,8 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
> >>       /* Setup CPU & memory */
> >>       mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
> >>                         machine->cpu_type);
> >> -    memory_region_init_ram(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
> >> +    memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
> >>                              &error_fatal);
> >> -    memory_region_set_readonly(rom, true);
> >>       memory_region_add_subregion(address_space_mem, 0, rom);
> >>
> >>   #ifdef TARGET_WORDS_BIGENDIAN
> >> diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
> >> index be245714db..6c3fd1b271 100644
> >> --- a/hw/arm/omap_sx1.c
> >> +++ b/hw/arm/omap_sx1.c
> >> @@ -126,9 +126,8 @@ static void sx1_init(MachineState *machine, const int version)
> >>       mpu = omap310_mpu_init(dram, machine->cpu_type);
> >>
> >>       /* External Flash (EMIFS) */
> >> -    memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
> >> +    memory_region_init_rom(flash, NULL, "omap_sx1.flash0-0", flash_size,
> >>                              &error_fatal);
> >> -    memory_region_set_readonly(flash, true);
> >>       memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);
> >>
> >>       memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val,
> >> @@ -168,9 +167,8 @@ static void sx1_init(MachineState *machine, const int version)
> >>       if ((version == 1) &&
> >>               (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
> >>           MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
> >> -        memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0",
> >> +        memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
> >>                                  flash1_size, &error_fatal);
> >> -        memory_region_set_readonly(flash_1, true);
> >>           memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
> >>
> >>           memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
> >> diff --git a/hw/arm/palm.c b/hw/arm/palm.c
> >> index 72eca8cc55..265d5891a6 100644
> >> --- a/hw/arm/palm.c
> >> +++ b/hw/arm/palm.c
> >> @@ -206,9 +206,8 @@ static void palmte_init(MachineState *machine)
> >>       mpu = omap310_mpu_init(dram, machine->cpu_type);
> >>
> >>       /* External Flash (EMIFS) */
> >> -    memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
> >> +    memory_region_init_rom(flash, NULL, "palmte.flash", flash_size,
> >>                              &error_fatal);
> >> -    memory_region_set_readonly(flash, true);
> >>       memory_region_add_subregion(address_space_mem, OMAP_CS0_BASE, flash);
> >>
> >>       memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "palmte-cs0",
> >> diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
> >> index e001088103..1d27399721 100644
> >> --- a/hw/arm/spitz.c
> >> +++ b/hw/arm/spitz.c
> >> @@ -924,8 +924,7 @@ static void spitz_common_init(MachineState *machine,
> >>
> >>       sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
> >>
> >> -    memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
> >> -    memory_region_set_readonly(rom, true);
> >> +    memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
> >>       memory_region_add_subregion(address_space_mem, 0, rom);
> >>
> >>       /* Setup peripherals */
> >> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> >> index 221a78674e..d136ba1a92 100644
> >> --- a/hw/arm/stellaris.c
> >> +++ b/hw/arm/stellaris.c
> >> @@ -1300,9 +1300,8 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
> >>       sram_size = ((board->dc0 >> 18) + 1) * 1024;
> >>
> >>       /* Flash programming is done via the SCU, so pretend it is ROM.  */
> >> -    memory_region_init_ram(flash, NULL, "stellaris.flash", flash_size,
> >> +    memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
> >>                              &error_fatal);
> >> -    memory_region_set_readonly(flash, true);
> >>       memory_region_add_subregion(system_memory, 0, flash);
> >>
> >>       memory_region_init_ram(sram, NULL, "stellaris.sram", sram_size,
> >> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
> >> index 4d95a1f3e2..5dee2d76c6 100644
> >> --- a/hw/arm/tosa.c
> >> +++ b/hw/arm/tosa.c
> >> @@ -226,8 +226,7 @@ static void tosa_init(MachineState *machine)
> >>
> >>       mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
> >>
> >> -    memory_region_init_ram(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
> >> -    memory_region_set_readonly(rom, true);
> >> +    memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
> >>       memory_region_add_subregion(address_space_mem, 0, rom);
> >>
> >>       tmio = tc6393xb_init(address_space_mem, 0x10000000,
> >> --
> >> 2.21.1
> >>
> >>
> >
>