* [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls
@ 2020-03-16 18:49 Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 01/25] memory: Correctly return alias region type Philippe Mathieu-Daudé
` (25 more replies)
0 siblings, 26 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
This series simplifies various memory API calls when creating
memory regions.
Most of the patches are generated with Coccinelle semantic
patches (provided).
Few more cleanups added while writting the patches have been
added.
v1 was 'Let devices own the MemoryRegion they create':
https://www.mail-archive.com/qemu-devel@nongnu.org/msg681960.html
Since v2:
- only keep generated/automatic patches
- add reviewers tags
Since v1:
- understood a bit more Peter Maydell comments regarding
how memory devices are migrated.
Philippe Mathieu-Daudé (25):
memory: Correctly return alias region type
memory: Simplify memory_region_init_rom_nomigrate() to ease review
scripts/cocci: Rename memory-region-{init-ram -> housekeeping}
scripts/cocci: Patch to replace memory_region_init_{ram,readonly ->
rom}
hw/arm: Use memory_region_init_rom() with read-only regions
hw/display: Use memory_region_init_rom() with read-only regions
hw/m68k: Use memory_region_init_rom() with read-only regions
hw/net: Use memory_region_init_rom() with read-only regions
hw/pci-host: Use memory_region_init_rom() with read-only regions
hw/ppc: Use memory_region_init_rom() with read-only regions
hw/riscv: Use memory_region_init_rom() with read-only regions
hw/sh4: Use memory_region_init_rom() with read-only regions
hw/sparc: Use memory_region_init_rom() with read-only regions
scripts/cocci: Patch to detect potential use of memory_region_init_rom
scripts/cocci: Patch to remove unnecessary
memory_region_set_readonly()
scripts/cocci: Patch to let devices own their MemoryRegions
hw/core: Let devices own the MemoryRegion they create
hw/display: Let devices own the MemoryRegion they create
hw/dma: Let devices own the MemoryRegion they create
hw/riscv: Let devices own the MemoryRegion they create
hw/char: Let devices own the MemoryRegion they create
hw/arm/stm32: Use memory_region_init_rom() with read-only regions
hw/ppc/ppc405: Use memory_region_init_rom() with read-only regions
hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias
hw/arm: Let devices own the MemoryRegion they create
.../memory-region-housekeeping.cocci | 159 ++++++++++++++++++
.../coccinelle/memory-region-init-ram.cocci | 38 -----
hw/arm/exynos4210.c | 14 +-
hw/arm/fsl-imx25.c | 10 +-
hw/arm/fsl-imx31.c | 6 +-
hw/arm/fsl-imx6.c | 6 +-
hw/arm/fsl-imx6ul.c | 9 +-
hw/arm/mainstone.c | 3 +-
hw/arm/msf2-soc.c | 6 +-
hw/arm/nrf51_soc.c | 2 +-
hw/arm/omap_sx1.c | 6 +-
hw/arm/palm.c | 3 +-
hw/arm/spitz.c | 3 +-
hw/arm/stellaris.c | 3 +-
hw/arm/stm32f205_soc.c | 11 +-
hw/arm/stm32f405_soc.c | 12 +-
hw/arm/tosa.c | 3 +-
hw/arm/xlnx-zynqmp.c | 11 +-
hw/char/serial.c | 7 +-
hw/core/platform-bus.c | 3 +-
hw/display/cg3.c | 5 +-
hw/display/g364fb.c | 3 +-
hw/display/macfb.c | 4 +-
hw/display/tcx.c | 5 +-
hw/dma/i8257.c | 2 +-
hw/dma/rc4030.c | 4 +-
hw/m68k/q800.c | 3 +-
hw/net/dp8393x.c | 5 +-
hw/pci-host/prep.c | 5 +-
hw/ppc/mac_newworld.c | 3 +-
hw/ppc/mac_oldworld.c | 3 +-
hw/ppc/ppc405_boards.c | 6 +-
hw/riscv/sifive_e.c | 9 +-
hw/riscv/sifive_u.c | 2 +-
hw/sh4/shix.c | 3 +-
hw/sparc/leon3.c | 3 +-
memory.c | 16 +-
MAINTAINERS | 1 +
38 files changed, 244 insertions(+), 153 deletions(-)
create mode 100644 scripts/coccinelle/memory-region-housekeeping.cocci
delete mode 100644 scripts/coccinelle/memory-region-init-ram.cocci
--
2.21.1
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v3 01/25] memory: Correctly return alias region type
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 02/25] memory: Simplify memory_region_init_rom_nomigrate() to ease review Philippe Mathieu-Daudé
` (24 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
Since memory region aliases are neither rom nor ram, they are
described as i/o, which is often incorrect. Return instead the
type of the original region we are aliasing.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
memory.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/memory.c b/memory.c
index 09be40edd2..3ea0afada9 100644
--- a/memory.c
+++ b/memory.c
@@ -2830,6 +2830,9 @@ void address_space_destroy(AddressSpace *as)
static const char *memory_region_type(MemoryRegion *mr)
{
+ if (mr->alias) {
+ return memory_region_type(mr->alias);
+ }
if (memory_region_is_ram_device(mr)) {
return "ramd";
} else if (memory_region_is_romd(mr)) {
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 02/25] memory: Simplify memory_region_init_rom_nomigrate() to ease review
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 01/25] memory: Correctly return alias region type Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 03/25] scripts/cocci: Rename memory-region-{init-ram -> housekeeping} Philippe Mathieu-Daudé
` (23 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Alistair Francis, Philippe Mathieu-Daudé
memory_region_init_rom_nomigrate() has the same content than
memory_region_init_ram_shared_nomigrate(), with setting the
readonly mode. The code is easier to review as creating a
readonly ram/shared/nomigrate region.
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
memory.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/memory.c b/memory.c
index 3ea0afada9..0ee43c60bd 100644
--- a/memory.c
+++ b/memory.c
@@ -1671,19 +1671,8 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr,
uint64_t size,
Error **errp)
{
- Error *err = NULL;
- memory_region_init(mr, owner, name, size);
- mr->ram = true;
+ memory_region_init_ram_shared_nomigrate(mr, owner, name, size, false, errp);
mr->readonly = true;
- mr->terminates = true;
- mr->destructor = memory_region_destructor_ram;
- mr->ram_block = qemu_ram_alloc(size, false, mr, &err);
- mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
- if (err) {
- mr->size = int128_zero();
- object_unparent(OBJECT(mr));
- error_propagate(errp, err);
- }
}
void memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 03/25] scripts/cocci: Rename memory-region-{init-ram -> housekeeping}
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 01/25] memory: Correctly return alias region type Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 02/25] memory: Simplify memory_region_init_rom_nomigrate() to ease review Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 04/25] scripts/cocci: Patch to replace memory_region_init_{ram, readonly -> rom} Philippe Mathieu-Daudé
` (22 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
As we are going to add various semantic changes related to the memory
region API, rename this script to be more generic.
Add a 'usage' header, and an entry in MAINTAINERS to avoid checkpatch
warning.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
...t-ram.cocci => memory-region-housekeeping.cocci} | 13 +++++++++++++
MAINTAINERS | 1 +
2 files changed, 14 insertions(+)
rename scripts/coccinelle/{memory-region-init-ram.cocci => memory-region-housekeeping.cocci} (84%)
diff --git a/scripts/coccinelle/memory-region-init-ram.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
similarity index 84%
rename from scripts/coccinelle/memory-region-init-ram.cocci
rename to scripts/coccinelle/memory-region-housekeeping.cocci
index d290150872..3699c1017e 100644
--- a/scripts/coccinelle/memory-region-init-ram.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -1,3 +1,16 @@
+/*
+ Usage:
+
+ spatch \
+ --macro-file scripts/cocci-macro-file.h \
+ --sp-file scripts/coccinelle/memory-region-housekeeping.cocci \
+ --keep-comments \
+ --in-place \
+ --dir .
+
+*/
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.
diff --git a/MAINTAINERS b/MAINTAINERS
index 32867bc636..e06ef9bb56 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2036,6 +2036,7 @@ F: include/exec/ramblock.h
F: memory.c
F: include/exec/memory-internal.h
F: exec.c
+F: scripts/coccinelle/memory-region-housekeeping.cocci
SPICE
M: Gerd Hoffmann <kraxel@redhat.com>
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 04/25] scripts/cocci: Patch to replace memory_region_init_{ram, readonly -> rom}
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 03/25] scripts/cocci: Rename memory-region-{init-ram -> housekeeping} Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 05/25] hw/arm: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
` (21 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
Add a semantic patch to replace memory_region_init_ram(readonly)
by memory_region_init_rom().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
.../memory-region-housekeeping.cocci | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 3699c1017e..ee3923d369 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -11,6 +11,24 @@
*/
+// Replace memory_region_init_ram(readonly) by memory_region_init_rom()
+@@
+expression E1, E2, E3, E4, E5;
+symbol true;
+@@
+(
+- memory_region_init_ram(E1, E2, E3, E4, E5);
++ memory_region_init_rom(E1, E2, E3, E4, E5);
+ ... WHEN != E1
+- memory_region_set_readonly(E1, true);
+|
+- memory_region_init_ram_nomigrate(E1, E2, E3, E4, E5);
++ memory_region_init_rom_nomigrate(E1, E2, E3, E4, E5);
+ ... WHEN != E1
+- memory_region_set_readonly(E1, true);
+)
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 05/25] hw/arm: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 04/25] scripts/cocci: Patch to replace memory_region_init_{ram, readonly -> rom} Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 06/25] hw/display: " Philippe Mathieu-Daudé
` (20 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Igor Mitsyanko, Peter Maydell, open list:Exynos,
Philippe Mathieu-Daudé
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 1042017086..6bc643651b 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -124,9 +124,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);
/* There are two 32MiB flash devices on the board */
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index de5ff447dc..57829b3744 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -131,9 +131,8 @@ static void sx1_init(MachineState *machine, const int version)
mpu = omap310_mpu_init(machine->ram, 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,
@@ -167,9 +166,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 99554bda19..97ca105d29 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -213,9 +213,8 @@ static void palmte_init(MachineState *machine)
mpu = omap310_mpu_init(machine->ram, 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 cbfa6934cf..c28d9b5ed7 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -929,8 +929,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
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 06/25] hw/display: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 05/25] hw/arm: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 07/25] hw/m68k: " Philippe Mathieu-Daudé
` (19 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Mark Cave-Ayland, Philippe Mathieu-Daudé
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/display/cg3.c | 5 ++---
hw/display/tcx.c | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 4fb67c6b1c..a1ede10394 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -287,9 +287,8 @@ static void cg3_initfn(Object *obj)
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
CG3State *s = CG3(obj);
- memory_region_init_ram_nomigrate(&s->rom, obj, "cg3.prom", FCODE_MAX_ROM_SIZE,
- &error_fatal);
- memory_region_set_readonly(&s->rom, true);
+ memory_region_init_rom_nomigrate(&s->rom, obj, "cg3.prom",
+ FCODE_MAX_ROM_SIZE, &error_fatal);
sysbus_init_mmio(sbd, &s->rom);
memory_region_init_io(&s->reg, obj, &cg3_reg_ops, s, "cg3.reg",
diff --git a/hw/display/tcx.c b/hw/display/tcx.c
index ca458f94fe..76de16e8ea 100644
--- a/hw/display/tcx.c
+++ b/hw/display/tcx.c
@@ -755,9 +755,8 @@ static void tcx_initfn(Object *obj)
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
TCXState *s = TCX(obj);
- memory_region_init_ram_nomigrate(&s->rom, obj, "tcx.prom", FCODE_MAX_ROM_SIZE,
- &error_fatal);
- memory_region_set_readonly(&s->rom, true);
+ memory_region_init_rom_nomigrate(&s->rom, obj, "tcx.prom",
+ FCODE_MAX_ROM_SIZE, &error_fatal);
sysbus_init_mmio(sbd, &s->rom);
/* 2/STIP : Stippler */
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 07/25] hw/m68k: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 06/25] hw/display: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 08/25] hw/net: " Philippe Mathieu-Daudé
` (18 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé, Laurent Vivier
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/m68k/q800.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index c5699f6f3e..81749e7ec6 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -399,13 +399,12 @@ static void q800_init(MachineState *machine)
uint8_t *ptr;
/* allocate and load BIOS */
rom = g_malloc(sizeof(*rom));
- memory_region_init_ram(rom, NULL, "m68k_mac.rom", MACROM_SIZE,
+ memory_region_init_rom(rom, NULL, "m68k_mac.rom", MACROM_SIZE,
&error_abort);
if (bios_name == NULL) {
bios_name = MACROM_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- memory_region_set_readonly(rom, true);
memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
/* Load MacROM binary */
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 08/25] hw/net: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 07/25] hw/m68k: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 09/25] hw/pci-host: " Philippe Mathieu-Daudé
` (17 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Jason Wang, Philippe Mathieu-Daudé
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/net/dp8393x.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 81fc13ee9f..1563c11b9e 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -986,13 +986,12 @@ static void dp8393x_realize(DeviceState *dev, Error **errp)
s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s);
- memory_region_init_ram(&s->prom, OBJECT(dev),
- "dp8393x-prom", SONIC_PROM_SIZE, &local_err);
+ memory_region_init_rom(&s->prom, OBJECT(dev), "dp8393x-prom",
+ SONIC_PROM_SIZE, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
- memory_region_set_readonly(&s->prom, true);
prom = memory_region_get_ram_ptr(&s->prom);
checksum = 0;
for (i = 0; i < 6; i++) {
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 09/25] hw/pci-host: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 08/25] hw/net: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 10/25] hw/ppc: " Philippe Mathieu-Daudé
` (16 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: open list:PReP, Peter Maydell, Hervé Poussineau,
Philippe Mathieu-Daudé, David Gibson
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/pci-host/prep.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index 1aff72bec6..1a02e9a670 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -325,9 +325,8 @@ static void raven_realize(PCIDevice *d, Error **errp)
d->config[0x0D] = 0x10; // latency_timer
d->config[0x34] = 0x00; // capabilities_pointer
- memory_region_init_ram_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZE,
- &error_fatal);
- memory_region_set_readonly(&s->bios, true);
+ memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZE,
+ &error_fatal);
memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),
&s->bios);
if (s->bios_name) {
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 10/25] hw/ppc: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 09/25] hw/pci-host: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 11/25] hw/riscv: " Philippe Mathieu-Daudé
` (15 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: open list:New World mac99, Peter Maydell, Mark Cave-Ayland,
Philippe Mathieu-Daudé, David Gibson
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/ppc/mac_newworld.c | 3 +--
hw/ppc/mac_oldworld.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index b8189bf7a4..b2ec372958 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -155,13 +155,12 @@ static void ppc_core99_init(MachineState *machine)
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
/* allocate and load BIOS */
- memory_region_init_ram(bios, NULL, "ppc_core99.bios", BIOS_SIZE,
+ memory_region_init_rom(bios, NULL, "ppc_core99.bios", BIOS_SIZE,
&error_fatal);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- memory_region_set_readonly(bios, true);
memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios);
/* Load OpenBIOS (ELF) */
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 440c406eb4..faaa165f3f 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -129,13 +129,12 @@ static void ppc_heathrow_init(MachineState *machine)
memory_region_add_subregion(sysmem, 0, machine->ram);
/* allocate and load BIOS */
- memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE,
+ memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE,
&error_fatal);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- memory_region_set_readonly(bios, true);
memory_region_add_subregion(sysmem, PROM_ADDR, bios);
/* Load OpenBIOS (ELF) */
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 11/25] hw/riscv: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 10/25] hw/ppc: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 12/25] hw/sh4: " Philippe Mathieu-Daudé
` (14 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, open list:RISC-V TCG CPUs, Sagar Karandikar,
Bastian Koppelmann, Alistair Francis, Palmer Dabbelt,
Philippe Mathieu-Daudé
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/riscv/sifive_e.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index a254cad489..a1974ef7be 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -208,9 +208,8 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
memmap[SIFIVE_E_PWM2].base, memmap[SIFIVE_E_PWM2].size);
/* Flash memory */
- memory_region_init_ram(&s->xip_mem, NULL, "riscv.sifive.e.xip",
- memmap[SIFIVE_E_XIP].size, &error_fatal);
- memory_region_set_readonly(&s->xip_mem, true);
+ memory_region_init_rom(&s->xip_mem, NULL, "riscv.sifive.e.xip",
+ memmap[SIFIVE_E_XIP].size, &error_fatal);
memory_region_add_subregion(sys_mem, memmap[SIFIVE_E_XIP].base,
&s->xip_mem);
}
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 12/25] hw/sh4: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 11/25] hw/riscv: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 13/25] hw/sparc: " Philippe Mathieu-Daudé
` (13 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Magnus Damm, Philippe Mathieu-Daudé,
Aurelien Jarno
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/sh4/shix.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/sh4/shix.c b/hw/sh4/shix.c
index 68b14ee5e7..f410c08883 100644
--- a/hw/sh4/shix.c
+++ b/hw/sh4/shix.c
@@ -53,8 +53,7 @@ static void shix_init(MachineState *machine)
cpu = SUPERH_CPU(cpu_create(machine->cpu_type));
/* Allocate memory space */
- memory_region_init_ram(rom, NULL, "shix.rom", 0x4000, &error_fatal);
- memory_region_set_readonly(rom, true);
+ memory_region_init_rom(rom, NULL, "shix.rom", 0x4000, &error_fatal);
memory_region_add_subregion(sysmem, 0x00000000, rom);
memory_region_init_ram(&sdram[0], NULL, "shix.sdram1", 0x01000000,
&error_fatal);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 13/25] hw/sparc: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 12/25] hw/sh4: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 14/25] scripts/cocci: Patch to detect potential use of memory_region_init_rom Philippe Mathieu-Daudé
` (12 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Mark Cave-Ayland, Fabien Chouteau, KONRAD Frederic,
Philippe Mathieu-Daudé, Artyom Tarasenko
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Reviewed-by: KONRAD Frederic <frederic.konrad@adacore.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/sparc/leon3.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 5fa58aa55f..8f024dab7b 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -255,8 +255,7 @@ static void leon3_generic_hw_init(MachineState *machine)
/* Allocate BIOS */
prom_size = 8 * MiB;
- memory_region_init_ram(prom, NULL, "Leon3.bios", prom_size, &error_fatal);
- memory_region_set_readonly(prom, true);
+ memory_region_init_rom(prom, NULL, "Leon3.bios", prom_size, &error_fatal);
memory_region_add_subregion(address_space_mem, LEON3_PROM_OFFSET, prom);
/* Load boot prom */
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 14/25] scripts/cocci: Patch to detect potential use of memory_region_init_rom
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 13/25] hw/sparc: " Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 15/25] scripts/cocci: Patch to remove unnecessary memory_region_set_readonly() Philippe Mathieu-Daudé
` (11 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
Add a semantic patch to detect potential replacement of
memory_region_init_ram(readonly) by memory_region_init_rom().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
.../memory-region-housekeeping.cocci | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index ee3923d369..9cdde71bb1 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -29,6 +29,25 @@ symbol true;
)
+@possible_memory_region_init_rom@
+expression E1, E2, E3, E4, E5;
+position p;
+@@
+(
+ memory_region_init_ram@p(E1, E2, E3, E4, E5);
+ ...
+ memory_region_set_readonly(E1, true);
+|
+ memory_region_init_ram_nomigrate@p(E1, E2, E3, E4, E5);
+ ...
+ memory_region_set_readonly(E1, true);
+)
+@script:python@
+p << possible_memory_region_init_rom.p;
+@@
+cocci.print_main("potential use of memory_region_init_rom*() in ", p)
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 15/25] scripts/cocci: Patch to remove unnecessary memory_region_set_readonly()
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 14/25] scripts/cocci: Patch to detect potential use of memory_region_init_rom Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 16/25] scripts/cocci: Patch to let devices own their MemoryRegions Philippe Mathieu-Daudé
` (10 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
Add a semantic patch to remove memory_region_set_readonly() calls
on ROM memory regions.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
.../coccinelle/memory-region-housekeeping.cocci | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 9cdde71bb1..5e6b31d8ba 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -48,6 +48,21 @@ p << possible_memory_region_init_rom.p;
cocci.print_main("potential use of memory_region_init_rom*() in ", p)
+// Do not call memory_region_set_readonly() on ROM alias
+@@
+expression ROM, E1, E2, E3, E4;
+expression ALIAS, E5, E6, E7, E8;
+@@
+(
+ memory_region_init_rom(ROM, E1, E2, E3, E4);
+|
+ memory_region_init_rom_nomigrate(ROM, E1, E2, E3, E4);
+)
+ ...
+ memory_region_init_alias(ALIAS, E5, E6, ROM, E7, E8);
+- memory_region_set_readonly(ALIAS, true);
+
+
// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
// code sequences with use of the new memory_region_init_ram function.
// Similarly for the _rom and _rom_device functions.
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 16/25] scripts/cocci: Patch to let devices own their MemoryRegions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 15/25] scripts/cocci: Patch to remove unnecessary memory_region_set_readonly() Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 17/25] hw/core: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
` (9 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
When a device creates a MemoryRegion without setting its ownership,
the MemoryRegion is added to the machine "/unattached" container in
the QOM tree.
Example with the Samsung SMDKC210 board:
$ arm-softmmu/qemu-system-arm -M smdkc210 -S -monitor stdio
(qemu) info qom-tree
/machine (smdkc210-machine)
/unattached (container)
/io[0] (qemu:memory-region)
/exynos4210.dram0[0] (qemu:memory-region)
/exynos4210.irom[0] (qemu:memory-region)
/exynos4210.iram[0] (qemu:memory-region)
/exynos4210.chipid[0] (qemu:memory-region)
...
/device[26] (exynos4210.uart)
/exynos4210.uart[0] (qemu:memory-region)
/soc (exynos4210)
^
\__ [*]
The irom/iram/chipid regions should go under 'soc' at [*].
Add a semantic patch to let the device own the memory region.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
.../memory-region-housekeeping.cocci | 56 +++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index 5e6b31d8ba..c768d8140a 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -101,3 +101,59 @@ expression ERRP;
+memory_region_init_rom_device(MR, NULL, OPS, OPAQUE, NAME, SIZE, ERRP);
...
-vmstate_register_ram_global(MR);
+
+
+// Device is owner
+@@
+typedef DeviceState;
+identifier device_fn, dev, obj;
+expression E1, E2, E3, E4, E5;
+@@
+static void device_fn(DeviceState *dev, ...)
+{
+ ...
+ Object *obj = OBJECT(dev);
+ <+...
+(
+- memory_region_init(E1, NULL, E2, E3);
++ memory_region_init(E1, obj, E2, E3);
+|
+- memory_region_init_io(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_io(E1, obj, E2, E3, E4, E5);
+|
+- memory_region_init_alias(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_alias(E1, obj, E2, E3, E4, E5);
+|
+- memory_region_init_rom(E1, NULL, E2, E3, E4);
++ memory_region_init_rom(E1, obj, E2, E3, E4);
+|
+- memory_region_init_ram_shared_nomigrate(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_ram_shared_nomigrate(E1, obj, E2, E3, E4, E5);
+)
+ ...+>
+}
+@@
+identifier device_fn, dev;
+expression E1, E2, E3, E4, E5;
+@@
+static void device_fn(DeviceState *dev, ...)
+{
+ <+...
+(
+- memory_region_init(E1, NULL, E2, E3);
++ memory_region_init(E1, OBJECT(dev), E2, E3);
+|
+- memory_region_init_io(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_io(E1, OBJECT(dev), E2, E3, E4, E5);
+|
+- memory_region_init_alias(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_alias(E1, OBJECT(dev), E2, E3, E4, E5);
+|
+- memory_region_init_rom(E1, NULL, E2, E3, E4);
++ memory_region_init_rom(E1, OBJECT(dev), E2, E3, E4);
+|
+- memory_region_init_ram_shared_nomigrate(E1, NULL, E2, E3, E4, E5);
++ memory_region_init_ram_shared_nomigrate(E1, OBJECT(dev), E2, E3, E4, E5);
+)
+ ...+>
+}
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 17/25] hw/core: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 16/25] scripts/cocci: Patch to let devices own their MemoryRegions Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 18/25] hw/display: " Philippe Mathieu-Daudé
` (8 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé
Avoid orphan memory regions being added in the /unattached QOM
container.
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/core/platform-bus.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 22c5f76dd0..d494e5cec1 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -187,7 +187,8 @@ static void platform_bus_realize(DeviceState *dev, Error **errp)
d = SYS_BUS_DEVICE(dev);
pbus = PLATFORM_BUS_DEVICE(dev);
- memory_region_init(&pbus->mmio, NULL, "platform bus", pbus->mmio_size);
+ memory_region_init(&pbus->mmio, OBJECT(dev), "platform bus",
+ pbus->mmio_size);
sysbus_init_mmio(d, &pbus->mmio);
pbus->used_irqs = bitmap_new(pbus->num_irqs);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 18/25] hw/display: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (16 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 17/25] hw/core: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
@ 2020-03-16 18:49 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 19/25] hw/dma: " Philippe Mathieu-Daudé
` (7 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:49 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé, Laurent Vivier
Avoid orphan memory regions being added in the /unattached QOM
container.
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/display/g364fb.c | 3 ++-
hw/display/macfb.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c
index 55185c95c6..adcba96e34 100644
--- a/hw/display/g364fb.c
+++ b/hw/display/g364fb.c
@@ -477,7 +477,8 @@ static void g364fb_init(DeviceState *dev, G364State *s)
s->con = graphic_console_init(dev, 0, &g364fb_ops, s);
- memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, s, "ctrl", 0x180000);
+ memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s,
+ "ctrl", 0x180000);
memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram",
s->vram_size, s->vram);
vmstate_register_ram(&s->mem_vram, dev);
diff --git a/hw/display/macfb.c b/hw/display/macfb.c
index 8bff16d535..b68faff4bb 100644
--- a/hw/display/macfb.c
+++ b/hw/display/macfb.c
@@ -362,8 +362,8 @@ static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp)
return;
}
- memory_region_init_io(&s->mem_ctrl, NULL, &macfb_ctrl_ops, s, "macfb-ctrl",
- 0x1000);
+ memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s,
+ "macfb-ctrl", 0x1000);
memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram",
MACFB_VRAM_SIZE, errp);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 19/25] hw/dma: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (17 preceding siblings ...)
2020-03-16 18:49 ` [PATCH v3 18/25] hw/display: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 20/25] hw/riscv: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Aleksandar Rikalo, Hervé Poussineau,
Philippe Mathieu-Daudé, Michael S. Tsirkin
Avoid orphan memory regions being added in the /unattached QOM
container.
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/dma/i8257.c | 2 +-
hw/dma/rc4030.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index bad8debae4..ef15c06d77 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -553,7 +553,7 @@ static void i8257_realize(DeviceState *dev, Error **errp)
I8257State *d = I8257(dev);
int i;
- memory_region_init_io(&d->channel_io, NULL, &channel_io_ops, d,
+ memory_region_init_io(&d->channel_io, OBJECT(dev), &channel_io_ops, d,
"dma-chan", 8 << d->dshift);
memory_region_add_subregion(isa_address_space_io(isa),
d->base, &d->channel_io);
diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
index 21e2c360ac..7434d274aa 100644
--- a/hw/dma/rc4030.c
+++ b/hw/dma/rc4030.c
@@ -679,9 +679,9 @@ static void rc4030_realize(DeviceState *dev, Error **errp)
s->periodic_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
rc4030_periodic_timer, s);
- memory_region_init_io(&s->iomem_chipset, NULL, &rc4030_ops, s,
+ memory_region_init_io(&s->iomem_chipset, o, &rc4030_ops, s,
"rc4030.chipset", 0x300);
- memory_region_init_io(&s->iomem_jazzio, NULL, &jazzio_ops, s,
+ memory_region_init_io(&s->iomem_jazzio, o, &jazzio_ops, s,
"rc4030.jazzio", 0x00001000);
memory_region_init_iommu(&s->dma_mr, sizeof(s->dma_mr),
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 20/25] hw/riscv: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (18 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 19/25] hw/dma: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` Alistair Francis
2020-03-16 18:50 ` [PATCH v3 21/25] hw/char: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
25 siblings, 1 reply; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, open list:RISC-V TCG CPUs, Sagar Karandikar,
Bastian Koppelmann, Alistair Francis, Palmer Dabbelt,
Philippe Mathieu-Daudé
Avoid orphan memory regions being added in the /unattached QOM
container.
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/riscv/sifive_e.c | 6 +++---
hw/riscv/sifive_u.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index a1974ef7be..646553a7c3 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -145,8 +145,8 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
&error_abort);
/* Mask ROM */
- memory_region_init_rom(&s->mask_rom, NULL, "riscv.sifive.e.mrom",
- memmap[SIFIVE_E_MROM].size, &error_fatal);
+ memory_region_init_rom(&s->mask_rom, OBJECT(dev), "riscv.sifive.e.mrom",
+ memmap[SIFIVE_E_MROM].size, &error_fatal);
memory_region_add_subregion(sys_mem,
memmap[SIFIVE_E_MROM].base, &s->mask_rom);
@@ -208,7 +208,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
memmap[SIFIVE_E_PWM2].base, memmap[SIFIVE_E_PWM2].size);
/* Flash memory */
- memory_region_init_rom(&s->xip_mem, NULL, "riscv.sifive.e.xip",
+ memory_region_init_rom(&s->xip_mem, OBJECT(dev), "riscv.sifive.e.xip",
memmap[SIFIVE_E_XIP].size, &error_fatal);
memory_region_add_subregion(sys_mem, memmap[SIFIVE_E_XIP].base,
&s->xip_mem);
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 156a003642..662d42a5a7 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -497,7 +497,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
&error_abort);
/* boot rom */
- memory_region_init_rom(mask_rom, NULL, "riscv.sifive.u.mrom",
+ memory_region_init_rom(mask_rom, OBJECT(dev), "riscv.sifive.u.mrom",
memmap[SIFIVE_U_MROM].size, &error_fatal);
memory_region_add_subregion(system_memory, memmap[SIFIVE_U_MROM].base,
mask_rom);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 21/25] hw/char: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (19 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 20/25] hw/riscv: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 22/25] hw/arm/stm32: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
` (4 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Philippe Mathieu-Daudé,
Marc-André Lureau, Michael S. Tsirkin
Avoid orphan memory regions being added in the /unattached QOM
container.
This commit was produced with the Coccinelle script
scripts/coccinelle/memory-region-housekeeping.cocci.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/char/serial.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index 9298881af9..2ab8b69e03 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -997,7 +997,7 @@ static void serial_io_realize(DeviceState *dev, Error **errp)
return;
}
- memory_region_init_io(&s->io, NULL, &serial_io_ops, s, "serial", 8);
+ memory_region_init_io(&s->io, OBJECT(dev), &serial_io_ops, s, "serial", 8);
sysbus_init_mmio(SYS_BUS_DEVICE(sio), &s->io);
sysbus_init_irq(SYS_BUS_DEVICE(sio), &s->irq);
}
@@ -1106,8 +1106,9 @@ static void serial_mm_realize(DeviceState *dev, Error **errp)
return;
}
- memory_region_init_io(&s->io, NULL, &serial_mm_ops[smm->endianness], smm,
- "serial", 8 << smm->regshift);
+ memory_region_init_io(&s->io, OBJECT(dev),
+ &serial_mm_ops[smm->endianness], smm, "serial",
+ 8 << smm->regshift);
sysbus_init_mmio(SYS_BUS_DEVICE(smm), &s->io);
sysbus_init_irq(SYS_BUS_DEVICE(smm), &smm->serial.irq);
}
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 22/25] hw/arm/stm32: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (20 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 21/25] hw/char: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 23/25] hw/ppc/ppc405: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Alistair Francis, Philippe Mathieu-Daudé,
open list:STM32F205
The scripts/coccinelle/memory-region-housekeeping.cocci reported:
* TODO [[view:./hw/arm/stm32f205_soc.c::face=ovl-face1::linb=96::colb=4::cole=26][potential use of memory_region_init_rom*() in ./hw/arm/stm32f205_soc.c::96]]
* TODO [[view:./hw/arm/stm32f405_soc.c::face=ovl-face1::linb=98::colb=4::cole=26][potential use of memory_region_init_rom*() in ./hw/arm/stm32f405_soc.c::98]]
We can indeed replace the memory_region_init_ram() and
memory_region_set_readonly() calls by memory_region_init_rom().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/stm32f205_soc.c | 4 +---
hw/arm/stm32f405_soc.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 627fd446f5..2de56275b7 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -93,12 +93,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
- memory_region_init_ram(flash, NULL, "STM32F205.flash", FLASH_SIZE,
+ memory_region_init_rom(flash, NULL, "STM32F205.flash", FLASH_SIZE,
&error_fatal);
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
flash, 0, FLASH_SIZE);
-
- memory_region_set_readonly(flash, true);
memory_region_set_readonly(flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index 9bcad97853..b8fca13f95 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -95,7 +95,7 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
Error *err = NULL;
int i;
- memory_region_init_ram(&s->flash, NULL, "STM32F405.flash", FLASH_SIZE,
+ memory_region_init_rom(&s->flash, NULL, "STM32F405.flash", FLASH_SIZE,
&err);
if (err != NULL) {
error_propagate(errp, err);
@@ -103,8 +103,6 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
}
memory_region_init_alias(&s->flash_alias, NULL, "STM32F405.flash.alias",
&s->flash, 0, FLASH_SIZE);
-
- memory_region_set_readonly(&s->flash, true);
memory_region_set_readonly(&s->flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 23/25] hw/ppc/ppc405: Use memory_region_init_rom() with read-only regions
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (21 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 22/25] hw/arm/stm32: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 24/25] hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias Philippe Mathieu-Daudé
` (2 subsequent siblings)
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: open list:ppc4xx, Peter Maydell, Philippe Mathieu-Daudé,
David Gibson
The scripts/coccinelle/memory-region-housekeeping.cocci reported:
* TODO [[view:./hw/ppc/ppc405_boards.c::face=ovl-face1::linb=195::colb=8::cole=30][potential use of memory_region_init_rom*() in ./hw/ppc/ppc405_boards.c::195]]
* TODO [[view:./hw/ppc/ppc405_boards.c::face=ovl-face1::linb=464::colb=8::cole=30][potential use of memory_region_init_rom*() in ./hw/ppc/ppc405_boards.c::464]]
We can indeed replace the memory_region_init_ram() and
memory_region_set_readonly() calls by memory_region_init_rom().
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/ppc/ppc405_boards.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index de93c40f1a..e6bffb9e1a 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -199,7 +199,7 @@ static void ref405ep_init(MachineState *machine)
#endif
{
bios = g_new(MemoryRegion, 1);
- memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE,
+ memory_region_init_rom(bios, NULL, "ef405ep.bios", BIOS_SIZE,
&error_fatal);
if (bios_name == NULL)
@@ -223,7 +223,6 @@ static void ref405ep_init(MachineState *machine)
/* Avoid an uninitialized variable warning */
bios_size = -1;
}
- memory_region_set_readonly(bios, true);
}
/* Register FPGA */
ref405ep_fpga_init(sysmem, 0xF0300000);
@@ -471,7 +470,7 @@ static void taihu_405ep_init(MachineState *machine)
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
bios = g_new(MemoryRegion, 1);
- memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
+ memory_region_init_rom(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
&error_fatal);
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
@@ -489,7 +488,6 @@ static void taihu_405ep_init(MachineState *machine)
error_report("Could not load PowerPC BIOS '%s'", bios_name);
exit(1);
}
- memory_region_set_readonly(bios, true);
}
/* Register Linux flash */
dinfo = drive_get(IF_PFLASH, 0, fl_idx);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 24/25] hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (22 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 23/25] hw/ppc/ppc405: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 25/25] hw/arm: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
2020-03-16 19:50 ` [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Aleksandar Markovic
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Igor Mitsyanko, Peter Maydell, Alistair Francis,
Philippe Mathieu-Daudé, open list:Exynos
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 | 1 -
hw/arm/stm32f205_soc.c | 1 -
hw/arm/stm32f405_soc.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 3af6502a5e..4e1fd7edb3 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -320,7 +320,6 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
&s->irom_mem,
0,
EXYNOS4210_IROM_SIZE);
- memory_region_set_readonly(&s->irom_alias_mem, true);
memory_region_add_subregion(system_mem, EXYNOS4210_IROM_MIRROR_BASE_ADDR,
&s->irom_alias_mem);
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 2de56275b7..6e93726d45 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -97,7 +97,6 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
&error_fatal);
memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
flash, 0, FLASH_SIZE);
- memory_region_set_readonly(flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
memory_region_add_subregion(system_memory, 0, flash_alias);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index b8fca13f95..d590cd040d 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -103,7 +103,6 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
}
memory_region_init_alias(&s->flash_alias, NULL, "STM32F405.flash.alias",
&s->flash, 0, FLASH_SIZE);
- memory_region_set_readonly(&s->flash_alias, true);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
memory_region_add_subregion(system_memory, 0, &s->flash_alias);
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 25/25] hw/arm: Let devices own the MemoryRegion they create
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (23 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 24/25] hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Philippe Mathieu-Daudé
2020-03-16 19:50 ` [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Aleksandar Markovic
25 siblings, 0 replies; 28+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-16 18:50 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis,
Subbaraya Sundeep, open list:Exynos, Peter Chubb, Joel Stanley,
Edgar E. Iglesias, Jean-Christophe Dubois,
Philippe Mathieu-Daudé
Avoid orphan memory regions being added in the /unattached QOM
container.
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 | 12 ++++++------
hw/arm/fsl-imx25.c | 10 +++++-----
hw/arm/fsl-imx31.c | 6 +++---
hw/arm/fsl-imx6.c | 6 +++---
hw/arm/fsl-imx6ul.c | 9 +++++----
hw/arm/msf2-soc.c | 6 +++---
hw/arm/nrf51_soc.c | 2 +-
hw/arm/stm32f205_soc.c | 8 ++++----
hw/arm/stm32f405_soc.c | 9 +++++----
hw/arm/xlnx-zynqmp.c | 11 +++++------
10 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 4e1fd7edb3..1f7253ef6f 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -305,20 +305,20 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
/*** Memory ***/
/* Chip-ID and OMR */
- memory_region_init_io(&s->chipid_mem, NULL, &exynos4210_chipid_and_omr_ops,
- NULL, "exynos4210.chipid", sizeof(chipid_and_omr));
+ memory_region_init_io(&s->chipid_mem, OBJECT(socdev),
+ &exynos4210_chipid_and_omr_ops, NULL,
+ "exynos4210.chipid", sizeof(chipid_and_omr));
memory_region_add_subregion(system_mem, EXYNOS4210_CHIPID_ADDR,
&s->chipid_mem);
/* Internal ROM */
- memory_region_init_rom(&s->irom_mem, NULL, "exynos4210.irom",
+ memory_region_init_rom(&s->irom_mem, OBJECT(socdev), "exynos4210.irom",
EXYNOS4210_IROM_SIZE, &error_fatal);
memory_region_add_subregion(system_mem, EXYNOS4210_IROM_BASE_ADDR,
&s->irom_mem);
/* mirror of iROM */
- memory_region_init_alias(&s->irom_alias_mem, NULL, "exynos4210.irom_alias",
- &s->irom_mem,
- 0,
+ memory_region_init_alias(&s->irom_alias_mem, OBJECT(socdev),
+ "exynos4210.irom_alias", &s->irom_mem, 0,
EXYNOS4210_IROM_SIZE);
memory_region_add_subregion(system_mem, EXYNOS4210_IROM_MIRROR_BASE_ADDR,
&s->irom_alias_mem);
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index a3f829f436..6f1a82ce3d 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -303,16 +303,16 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
}
/* initialize 2 x 16 KB ROM */
- memory_region_init_rom(&s->rom[0], NULL,
- "imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
+ memory_region_init_rom(&s->rom[0], OBJECT(dev), "imx25.rom0",
+ FSL_IMX25_ROM0_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
}
memory_region_add_subregion(get_system_memory(), FSL_IMX25_ROM0_ADDR,
&s->rom[0]);
- memory_region_init_rom(&s->rom[1], NULL,
- "imx25.rom1", FSL_IMX25_ROM1_SIZE, &err);
+ memory_region_init_rom(&s->rom[1], OBJECT(dev), "imx25.rom1",
+ FSL_IMX25_ROM1_SIZE, &err);
if (err) {
error_propagate(errp, err);
return;
@@ -331,7 +331,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
&s->iram);
/* internal RAM (128 KB) is aliased over 128 MB - 128 KB */
- memory_region_init_alias(&s->iram_alias, NULL, "imx25.iram_alias",
+ memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx25.iram_alias",
&s->iram, 0, FSL_IMX25_IRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(), FSL_IMX25_IRAM_ALIAS_ADDR,
&s->iram_alias);
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 55e90d104b..8472d2e911 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -206,7 +206,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
}
/* On a real system, the first 16k is a `secure boot rom' */
- memory_region_init_rom(&s->secure_rom, NULL, "imx31.secure_rom",
+ memory_region_init_rom(&s->secure_rom, OBJECT(dev), "imx31.secure_rom",
FSL_IMX31_SECURE_ROM_SIZE, &err);
if (err) {
error_propagate(errp, err);
@@ -216,7 +216,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
&s->secure_rom);
/* There is also a 16k ROM */
- memory_region_init_rom(&s->rom, NULL, "imx31.rom",
+ memory_region_init_rom(&s->rom, OBJECT(dev), "imx31.rom",
FSL_IMX31_ROM_SIZE, &err);
if (err) {
error_propagate(errp, err);
@@ -236,7 +236,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
&s->iram);
/* internal RAM (16 KB) is aliased over 256 MB - 16 KB */
- memory_region_init_alias(&s->iram_alias, NULL, "imx31.iram_alias",
+ memory_region_init_alias(&s->iram_alias, OBJECT(dev), "imx31.iram_alias",
&s->iram, 0, FSL_IMX31_IRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(), FSL_IMX31_IRAM_ALIAS_ADDR,
&s->iram_alias);
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index ecc62855f2..9c09f71435 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -405,7 +405,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
}
/* ROM memory */
- memory_region_init_rom(&s->rom, NULL, "imx6.rom",
+ memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom",
FSL_IMX6_ROM_SIZE, &err);
if (err) {
error_propagate(errp, err);
@@ -415,7 +415,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
&s->rom);
/* CAAM memory */
- memory_region_init_rom(&s->caam, NULL, "imx6.caam",
+ memory_region_init_rom(&s->caam, OBJECT(dev), "imx6.caam",
FSL_IMX6_CAAM_MEM_SIZE, &err);
if (err) {
error_propagate(errp, err);
@@ -435,7 +435,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
&s->ocram);
/* internal OCRAM (256 KB) is aliased over 1 MB */
- memory_region_init_alias(&s->ocram_alias, NULL, "imx6.ocram_alias",
+ memory_region_init_alias(&s->ocram_alias, OBJECT(dev), "imx6.ocram_alias",
&s->ocram, 0, FSL_IMX6_OCRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(), FSL_IMX6_OCRAM_ALIAS_ADDR,
&s->ocram_alias);
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
index c405b68d1d..f4a9ed6c4f 100644
--- a/hw/arm/fsl-imx6ul.c
+++ b/hw/arm/fsl-imx6ul.c
@@ -543,7 +543,7 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
/*
* ROM memory
*/
- memory_region_init_rom(&s->rom, NULL, "imx6ul.rom",
+ memory_region_init_rom(&s->rom, OBJECT(dev), "imx6ul.rom",
FSL_IMX6UL_ROM_SIZE, &error_abort);
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_ROM_ADDR,
&s->rom);
@@ -551,7 +551,7 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
/*
* CAAM memory
*/
- memory_region_init_rom(&s->caam, NULL, "imx6ul.caam",
+ memory_region_init_rom(&s->caam, OBJECT(dev), "imx6ul.caam",
FSL_IMX6UL_CAAM_MEM_SIZE, &error_abort);
memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_CAAM_MEM_ADDR,
&s->caam);
@@ -568,8 +568,9 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
/*
* internal OCRAM (128 KB) is aliased over 512 KB
*/
- memory_region_init_alias(&s->ocram_alias, NULL, "imx6ul.ocram_alias",
- &s->ocram, 0, FSL_IMX6UL_OCRAM_ALIAS_SIZE);
+ memory_region_init_alias(&s->ocram_alias, OBJECT(dev),
+ "imx6ul.ocram_alias", &s->ocram, 0,
+ FSL_IMX6UL_OCRAM_ALIAS_SIZE);
memory_region_add_subregion(get_system_memory(),
FSL_IMX6UL_OCRAM_ALIAS_ADDR, &s->ocram_alias);
}
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 8f84692e64..588d643b8d 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -96,7 +96,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);
MemoryRegion *sram = g_new(MemoryRegion, 1);
- memory_region_init_rom(nvm, NULL, "MSF2.eNVM", s->envm_size,
+ memory_region_init_rom(nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
&error_fatal);
/*
* On power-on, the eNVM region 0x60000000 is automatically
@@ -104,8 +104,8 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
* start address (0x0). We do not support remapping other eNVM,
* eSRAM and DDR regions by guest(via Sysreg) currently.
*/
- memory_region_init_alias(nvm_alias, NULL, "MSF2.eNVM",
- nvm, 0, s->envm_size);
+ memory_region_init_alias(nvm_alias, OBJECT(dev_soc), "MSF2.eNVM", nvm, 0,
+ s->envm_size);
memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);
memory_region_add_subregion(system_memory, 0, nvm_alias);
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 4817a76ae0..57eff63f0d 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -165,7 +165,7 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
}
/* STUB Peripherals */
- memory_region_init_io(&s->clock, NULL, &clock_ops, NULL,
+ memory_region_init_io(&s->clock, OBJECT(dev_soc), &clock_ops, NULL,
"nrf51_soc.clock", 0x1000);
memory_region_add_subregion_overlap(&s->container,
NRF51_IOMEM_BASE, &s->clock, -1);
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
index 6e93726d45..118c342559 100644
--- a/hw/arm/stm32f205_soc.c
+++ b/hw/arm/stm32f205_soc.c
@@ -93,10 +93,10 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
MemoryRegion *flash = g_new(MemoryRegion, 1);
MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
- memory_region_init_rom(flash, NULL, "STM32F205.flash", FLASH_SIZE,
- &error_fatal);
- memory_region_init_alias(flash_alias, NULL, "STM32F205.flash.alias",
- flash, 0, FLASH_SIZE);
+ memory_region_init_rom(flash, OBJECT(dev_soc), "STM32F205.flash",
+ FLASH_SIZE, &error_fatal);
+ memory_region_init_alias(flash_alias, OBJECT(dev_soc),
+ "STM32F205.flash.alias", flash, 0, FLASH_SIZE);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
memory_region_add_subregion(system_memory, 0, flash_alias);
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
index d590cd040d..4f10ce6176 100644
--- a/hw/arm/stm32f405_soc.c
+++ b/hw/arm/stm32f405_soc.c
@@ -95,14 +95,15 @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
Error *err = NULL;
int i;
- memory_region_init_rom(&s->flash, NULL, "STM32F405.flash", FLASH_SIZE,
- &err);
+ memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F405.flash",
+ FLASH_SIZE, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
- memory_region_init_alias(&s->flash_alias, NULL, "STM32F405.flash.alias",
- &s->flash, 0, FLASH_SIZE);
+ memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc),
+ "STM32F405.flash.alias", &s->flash, 0,
+ FLASH_SIZE);
memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash);
memory_region_add_subregion(system_memory, 0, &s->flash_alias);
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index cab0160ae9..49f1c8d0de 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -318,9 +318,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE;
- memory_region_init_alias(&s->ddr_ram_high, NULL,
- "ddr-ram-high", s->ddr_ram,
- ddr_low_size, ddr_high_size);
+ memory_region_init_alias(&s->ddr_ram_high, OBJECT(dev),
+ "ddr-ram-high", s->ddr_ram, ddr_low_size,
+ ddr_high_size);
memory_region_add_subregion(get_system_memory(),
XLNX_ZYNQMP_HIGH_RAM_START,
&s->ddr_ram_high);
@@ -330,9 +330,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
ddr_low_size = ram_size;
}
- memory_region_init_alias(&s->ddr_ram_low, NULL,
- "ddr-ram-low", s->ddr_ram,
- 0, ddr_low_size);
+ memory_region_init_alias(&s->ddr_ram_low, OBJECT(dev), "ddr-ram-low",
+ s->ddr_ram, 0, ddr_low_size);
memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low);
/* Create the four OCM banks */
--
2.21.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* Re: [PATCH v3 20/25] hw/riscv: Let devices own the MemoryRegion they create
2020-03-16 18:50 ` [PATCH v3 20/25] hw/riscv: " Philippe Mathieu-Daudé
@ 2020-03-16 18:50 ` Alistair Francis
0 siblings, 0 replies; 28+ messages in thread
From: Alistair Francis @ 2020-03-16 18:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, open list:RISC-V TCG CPUs, Sagar Karandikar,
Bastian Koppelmann, qemu-devel@nongnu.org Developers,
Alistair Francis, Paolo Bonzini, Palmer Dabbelt
On Mon, Mar 16, 2020 at 11:54 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Avoid orphan memory regions being added in the /unattached QOM
> container.
>
> This commit was produced with the Coccinelle script
> scripts/coccinelle/memory-region-housekeeping.cocci.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_e.c | 6 +++---
> hw/riscv/sifive_u.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
> index a1974ef7be..646553a7c3 100644
> --- a/hw/riscv/sifive_e.c
> +++ b/hw/riscv/sifive_e.c
> @@ -145,8 +145,8 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
> &error_abort);
>
> /* Mask ROM */
> - memory_region_init_rom(&s->mask_rom, NULL, "riscv.sifive.e.mrom",
> - memmap[SIFIVE_E_MROM].size, &error_fatal);
> + memory_region_init_rom(&s->mask_rom, OBJECT(dev), "riscv.sifive.e.mrom",
> + memmap[SIFIVE_E_MROM].size, &error_fatal);
> memory_region_add_subregion(sys_mem,
> memmap[SIFIVE_E_MROM].base, &s->mask_rom);
>
> @@ -208,7 +208,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
> memmap[SIFIVE_E_PWM2].base, memmap[SIFIVE_E_PWM2].size);
>
> /* Flash memory */
> - memory_region_init_rom(&s->xip_mem, NULL, "riscv.sifive.e.xip",
> + memory_region_init_rom(&s->xip_mem, OBJECT(dev), "riscv.sifive.e.xip",
> memmap[SIFIVE_E_XIP].size, &error_fatal);
> memory_region_add_subregion(sys_mem, memmap[SIFIVE_E_XIP].base,
> &s->xip_mem);
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 156a003642..662d42a5a7 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -497,7 +497,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
> &error_abort);
>
> /* boot rom */
> - memory_region_init_rom(mask_rom, NULL, "riscv.sifive.u.mrom",
> + memory_region_init_rom(mask_rom, OBJECT(dev), "riscv.sifive.u.mrom",
> memmap[SIFIVE_U_MROM].size, &error_fatal);
> memory_region_add_subregion(system_memory, memmap[SIFIVE_U_MROM].base,
> mask_rom);
> --
> 2.21.1
>
>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
` (24 preceding siblings ...)
2020-03-16 18:50 ` [PATCH v3 25/25] hw/arm: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
@ 2020-03-16 19:50 ` Aleksandar Markovic
25 siblings, 0 replies; 28+ messages in thread
From: Aleksandar Markovic @ 2020-03-16 19:50 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: Paolo Bonzini, QEMU Developers, Peter Maydell
On Mon, Mar 16, 2020 at 8:15 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> This series simplifies various memory API calls when creating
> memory regions.
>
> Most of the patches are generated with Coccinelle semantic
> patches (provided).
> Few more cleanups added while writting the patches have been
> added.
>
FWIW, for the whole series:
Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> v1 was 'Let devices own the MemoryRegion they create':
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg681960.html
>
> Since v2:
> - only keep generated/automatic patches
> - add reviewers tags
>
> Since v1:
> - understood a bit more Peter Maydell comments regarding
> how memory devices are migrated.
>
> Philippe Mathieu-Daudé (25):
> memory: Correctly return alias region type
> memory: Simplify memory_region_init_rom_nomigrate() to ease review
> scripts/cocci: Rename memory-region-{init-ram -> housekeeping}
> scripts/cocci: Patch to replace memory_region_init_{ram,readonly ->
> rom}
> hw/arm: Use memory_region_init_rom() with read-only regions
> hw/display: Use memory_region_init_rom() with read-only regions
> hw/m68k: Use memory_region_init_rom() with read-only regions
> hw/net: Use memory_region_init_rom() with read-only regions
> hw/pci-host: Use memory_region_init_rom() with read-only regions
> hw/ppc: Use memory_region_init_rom() with read-only regions
> hw/riscv: Use memory_region_init_rom() with read-only regions
> hw/sh4: Use memory_region_init_rom() with read-only regions
> hw/sparc: Use memory_region_init_rom() with read-only regions
> scripts/cocci: Patch to detect potential use of memory_region_init_rom
> scripts/cocci: Patch to remove unnecessary
> memory_region_set_readonly()
> scripts/cocci: Patch to let devices own their MemoryRegions
> hw/core: Let devices own the MemoryRegion they create
> hw/display: Let devices own the MemoryRegion they create
> hw/dma: Let devices own the MemoryRegion they create
> hw/riscv: Let devices own the MemoryRegion they create
> hw/char: Let devices own the MemoryRegion they create
> hw/arm/stm32: Use memory_region_init_rom() with read-only regions
> hw/ppc/ppc405: Use memory_region_init_rom() with read-only regions
> hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias
> hw/arm: Let devices own the MemoryRegion they create
>
> .../memory-region-housekeeping.cocci | 159 ++++++++++++++++++
> .../coccinelle/memory-region-init-ram.cocci | 38 -----
> hw/arm/exynos4210.c | 14 +-
> hw/arm/fsl-imx25.c | 10 +-
> hw/arm/fsl-imx31.c | 6 +-
> hw/arm/fsl-imx6.c | 6 +-
> hw/arm/fsl-imx6ul.c | 9 +-
> hw/arm/mainstone.c | 3 +-
> hw/arm/msf2-soc.c | 6 +-
> hw/arm/nrf51_soc.c | 2 +-
> hw/arm/omap_sx1.c | 6 +-
> hw/arm/palm.c | 3 +-
> hw/arm/spitz.c | 3 +-
> hw/arm/stellaris.c | 3 +-
> hw/arm/stm32f205_soc.c | 11 +-
> hw/arm/stm32f405_soc.c | 12 +-
> hw/arm/tosa.c | 3 +-
> hw/arm/xlnx-zynqmp.c | 11 +-
> hw/char/serial.c | 7 +-
> hw/core/platform-bus.c | 3 +-
> hw/display/cg3.c | 5 +-
> hw/display/g364fb.c | 3 +-
> hw/display/macfb.c | 4 +-
> hw/display/tcx.c | 5 +-
> hw/dma/i8257.c | 2 +-
> hw/dma/rc4030.c | 4 +-
> hw/m68k/q800.c | 3 +-
> hw/net/dp8393x.c | 5 +-
> hw/pci-host/prep.c | 5 +-
> hw/ppc/mac_newworld.c | 3 +-
> hw/ppc/mac_oldworld.c | 3 +-
> hw/ppc/ppc405_boards.c | 6 +-
> hw/riscv/sifive_e.c | 9 +-
> hw/riscv/sifive_u.c | 2 +-
> hw/sh4/shix.c | 3 +-
> hw/sparc/leon3.c | 3 +-
> memory.c | 16 +-
> MAINTAINERS | 1 +
> 38 files changed, 244 insertions(+), 153 deletions(-)
> create mode 100644 scripts/coccinelle/memory-region-housekeeping.cocci
> delete mode 100644 scripts/coccinelle/memory-region-init-ram.cocci
>
> --
> 2.21.1
>
>
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2020-03-16 19:51 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-16 18:49 [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 01/25] memory: Correctly return alias region type Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 02/25] memory: Simplify memory_region_init_rom_nomigrate() to ease review Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 03/25] scripts/cocci: Rename memory-region-{init-ram -> housekeeping} Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 04/25] scripts/cocci: Patch to replace memory_region_init_{ram, readonly -> rom} Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 05/25] hw/arm: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 06/25] hw/display: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 07/25] hw/m68k: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 08/25] hw/net: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 09/25] hw/pci-host: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 10/25] hw/ppc: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 11/25] hw/riscv: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 12/25] hw/sh4: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 13/25] hw/sparc: " Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 14/25] scripts/cocci: Patch to detect potential use of memory_region_init_rom Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 15/25] scripts/cocci: Patch to remove unnecessary memory_region_set_readonly() Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 16/25] scripts/cocci: Patch to let devices own their MemoryRegions Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 17/25] hw/core: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
2020-03-16 18:49 ` [PATCH v3 18/25] hw/display: " Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 19/25] hw/dma: " Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 20/25] hw/riscv: " Philippe Mathieu-Daudé
2020-03-16 18:50 ` Alistair Francis
2020-03-16 18:50 ` [PATCH v3 21/25] hw/char: " Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 22/25] hw/arm/stm32: Use memory_region_init_rom() with read-only regions Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 23/25] hw/ppc/ppc405: " Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 24/25] hw/arm: Remove unnecessary memory_region_set_readonly() on ROM alias Philippe Mathieu-Daudé
2020-03-16 18:50 ` [PATCH v3 25/25] hw/arm: Let devices own the MemoryRegion they create Philippe Mathieu-Daudé
2020-03-16 19:50 ` [PATCH v3 00/25] hw: Sanitize various MemoryRegion calls Aleksandar Markovic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).