Skip to contentSkip to conversation

hw: Let the machine be the owner of the system memory

PATCH Superseded Philippe Mathieu-Daudé 11 participants 78 messages Oct 20, 2019 – Feb 3, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover hw: Let the machine be the owner of the system memory

Hi,

This series is based on Igor's "eliminate remaining places that abuse memory_region_allocate_system_memory()":
https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg01601.html

It is quite simple, we enforce all machines to be the QOM owner of the system memory.

This changes the memory tree from:

(qemu) info mtree -o
memory-region: pc.ram

    0000000000000000-0000000007ffffff (prio 0, ram): pc.ram parent:{obj path=/machine/unattached}

to:

(qemu) info mtree -o
memory-region: pc.ram

    0000000000000000-0000000007ffffff (prio 0, ram): pc.ram owner:{obj path=/machine}

Few patches are required to clean the codebase first, to unify the creation of the system memory in the board/machine code. Mostly some old ARM machines (pre-QOM) were affected.

Please review (as a generic codebase cleanup).

Regards,

Phil.

Based-on: <[email protected]>

Philippe Mathieu-Daudé (21):
hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board
hw/arm/omap2: Create the RAM in the board
hw/arm/omap1: Create the RAM in the board
hw/arm/digic4: Inline digic4_board_setup_ram() function
hw: Drop QOM ownership on memory_region_allocate_system_memory() calls hw/alpha/dp264: Create the RAM in the board
hw: Let memory_region_allocate_system_memory take MachineState
argument
hw/core: Let the machine be the owner of the system memory hw/alpha: Let the machine be the owner of the system memory hw/arm: Let the machine be the owner of the system memory hw/cris: Let the machine be the owner of the system memory hw/hppa: Let the machine be the owner of the system memory hw/i386: Let the machine be the owner of the system memory hw/lm32: Let the machine be the owner of the system memory hw/m68k: Let the machine be the owner of the system memory hw/mips: Let the machine be the owner of the system memory hw/ppc: Let the machine be the owner of the system memory hw/sparc: Let the machine be the owner of the system memory hw/core: Assert memory_region_allocate_system_memory has machine owner

 hw/alpha/alpha_sys.h      |  2 +-
 hw/alpha/dp264.c          | 11 ++++++++++-
 hw/alpha/typhoon.c        |  9 +--------
 hw/arm/aspeed.c           |  2 +-
 hw/arm/collie.c           |  8 ++++++--
 hw/arm/cubieboard.c       |  2 +-
 hw/arm/digic_boards.c     | 14 +++++---------
 hw/arm/highbank.c         |  3 ++-
 hw/arm/imx25_pdk.c        |  2 +-
 hw/arm/integratorcp.c     |  2 +-
 hw/arm/kzm.c              |  2 +-
 hw/arm/mcimx6ul-evk.c     |  2 +-
 hw/arm/mcimx7d-sabre.c    |  2 +-
 hw/arm/mps2-tz.c          |  5 +++--
 hw/arm/mps2.c             |  5 +++--
 hw/arm/musicpal.c         |  2 +-
 hw/arm/nseries.c          | 10 +++++++---
 hw/arm/omap1.c            | 12 +++++-------
 hw/arm/omap2.c            | 13 +++++--------
 hw/arm/omap_sx1.c         |  8 ++++++--
 hw/arm/palm.c             |  8 ++++++--
 hw/arm/raspi.c            |  2 +-
 hw/arm/sabrelite.c        |  2 +-
 hw/arm/sbsa-ref.c         |  2 +-
 hw/arm/strongarm.c        |  7 +------
 hw/arm/strongarm.h        |  4 +---
 hw/arm/versatilepb.c      |  2 +-
 hw/arm/vexpress.c         |  4 ++--
 hw/arm/virt.c             |  2 +-
 hw/arm/xilinx_zynq.c      |  5 +++--
 hw/arm/xlnx-versal-virt.c |  2 +-
 hw/arm/xlnx-zcu102.c      |  2 +-
 hw/core/null-machine.c    |  2 +-
 hw/core/numa.c            |  9 +++++----
 hw/cris/axis_dev88.c      |  2 +-
 hw/hppa/machine.c         |  2 +-
 hw/i386/pc.c              |  2 +-
 hw/lm32/lm32_boards.c     |  4 ++--
 hw/lm32/milkymist.c       |  2 +-
 hw/m68k/an5206.c          |  2 +-
 hw/m68k/mcf5208.c         |  2 +-
 hw/m68k/next-cube.c       |  2 +-
 hw/mips/boston.c          |  2 +-
 hw/mips/mips_fulong2e.c   |  3 ++-
 hw/mips/mips_jazz.c       |  2 +-
 hw/mips/mips_malta.c      |  2 +-
 hw/mips/mips_mipssim.c    |  2 +-
 hw/mips/mips_r4k.c        |  3 ++-
 hw/ppc/e500.c             |  3 ++-
 hw/ppc/mac_newworld.c     |  3 ++-
 hw/ppc/mac_oldworld.c     |  2 +-
 hw/ppc/pnv.c              |  2 +-
 hw/ppc/ppc405_boards.c    |  6 +++---
 hw/ppc/prep.c             |  3 ++-
 hw/ppc/spapr.c            |  2 +-
 hw/ppc/virtex_ml507.c     |  2 +-
 hw/sparc/leon3.c          |  2 +-
 hw/sparc/sun4m.c          |  2 +-
 include/hw/arm/omap.h     | 10 +++-------
 include/hw/boards.h       |  6 ++++--
 60 files changed, 127 insertions(+), 117 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/21 hw/arm/xilinx_zynq: Use the IEC binary prefix definitions

IEC binary prefixes ease code review: the unit is explicit.

---
 hw/arm/xilinx_zynq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/xilinx_zynq.c +2 -1
index c14774e542..3a0fa5b23f 100644
@@ -16,6 +16,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -194,7 +195,7 @@ static void zynq_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0, ext_ram);
 
     /* 256K of on-chip memory */
-    memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
+    memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * KiB,
                            &error_fatal);
     memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/21
#3 lore raw

Re: [PATCH 01/21] hw/arm/xilinx_zynq: Use the IEC binary prefix definitions

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Alistair

Quoted 29 lines
---
 hw/arm/xilinx_zynq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/xilinx_zynq.c +2 -2
index c14774e542..3a0fa5b23f 100644
@@ -16,6 +16,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "cpu.h"
 #include "hw/sysbus.h"
@@ -194,7 +195,7 @@ static void zynq_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0, ext_ram);
 
     /* 256K of on-chip memory */
-    memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 << 10,
+    memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * KiB,
                            &error_fatal);
     memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
 
--

2.21.0

#4 lore raw

PATCH 2/21 hw/arm/mps2: Use the IEC binary prefix definitions

In reply to Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

---
 hw/arm/mps2-tz.c | 3 ++-
 hw/arm/mps2.c    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/arm/mps2-tz.c +2 -1
index 6b24aaacde..f8b620bcc6 100644
@@ -38,6 +38,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/arm/boot.h"
@@ -458,7 +459,7 @@ static void mps2tz_common_init(MachineState *machine)
      * call the 16MB our "system memory", as it's the largest lump.
      */
     memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 0x01000000);
+                                         NULL, "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x80000000, &mms->psram);
 
     /* The overflow IRQs for all UARTs are ORed together.
hw/arm/mps2.c +2 -1
index 10efff36b2..d002b126d3 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/arm/boot.h"
@@ -146,7 +147,7 @@ static void mps2_common_init(MachineState *machine)
      * zbt_boot_ctrl is always zero).
      */
     memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 0x1000000);
+                                         NULL, "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
 
     switch (mmc->fpga_type) {
Signature · 1 line
2.21.0
Reviewed-by on v1 2/21
#6 lore raw

Re: [PATCH 02/21] hw/arm/mps2: Use the IEC binary prefix definitions

In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

IEC binary prefixes ease code review: the unit is explicit.

Alistair

Quoted 51 lines
---
 hw/arm/mps2-tz.c | 3 ++-
 hw/arm/mps2.c    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/arm/mps2-tz.c +2 -1
index 6b24aaacde..f8b620bcc6 100644
@@ -38,6 +38,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/arm/boot.h"
@@ -458,7 +459,7 @@ static void mps2tz_common_init(MachineState *machine)
      * call the 16MB our "system memory", as it's the largest lump.
      */
     memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 0x01000000);
+                                         NULL, "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x80000000, &mms->psram);
 
     /* The overflow IRQs for all UARTs are ORed together.
hw/arm/mps2.c +2 -2
index 10efff36b2..d002b126d3 100644
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/arm/boot.h"
@@ -146,7 +147,7 @@ static void mps2_common_init(MachineState *machine)
      * zbt_boot_ctrl is always zero).
      */
     memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 0x1000000);
+                                         NULL, "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
 
     switch (mmc->fpga_type) {
--

2.21.0

#7 lore raw

PATCH 3/21 hw/arm/collie: Create the RAM in the board

In reply to Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the SA1110 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/collie.c    | 8 ++++++--
 hw/arm/strongarm.c | 7 +------
 hw/arm/strongarm.h | 4 +---
 3 files changed, 8 insertions(+), 11 deletions(-)
hw/arm/collie.c +6 -2
index b1288ccea8..970a4405cc 100644
@@ -27,9 +27,13 @@ static void collie_init(MachineState *machine)
 {
     StrongARMState *s;
     DriveInfo *dinfo;
-    MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);
 
-    s = sa1110_init(sysmem, collie_binfo.ram_size, machine->cpu_type);
+    s = sa1110_init(machine->cpu_type);
+
+    memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram",
+                                         collie_binfo.ram_size);
+    memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
hw/arm/strongarm.c +1 -6
index dc65d88a65..6bee034914 100644
@@ -1586,8 +1586,7 @@ static const TypeInfo strongarm_ssp_info = {
 };
 
 /* Main CPU functions */
-StrongARMState *sa1110_init(MemoryRegion *sysmem,
-                            unsigned int sdram_size, const char *cpu_type)
+StrongARMState *sa1110_init(const char *cpu_type)
 {
     StrongARMState *s;
     int i;
@@ -1601,10 +1600,6 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem,
 
     s->cpu = ARM_CPU(cpu_create(cpu_type));
 
-    memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
-                                         sdram_size);
-    memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
-
     s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
hw/arm/strongarm.h +1 -3
index e98840b461..192821f6aa 100644
@@ -55,7 +55,6 @@ enum {
 
 typedef struct {
     ARMCPU *cpu;
-    MemoryRegion sdram;
     DeviceState *pic;
     DeviceState *gpio;
     DeviceState *ppc;
@@ -63,7 +62,6 @@ typedef struct {
     SSIBus *ssp_bus;
 } StrongARMState;
 
-StrongARMState *sa1110_init(MemoryRegion *sysmem,
-                            unsigned int sdram_size, const char *rev);
+StrongARMState *sa1110_init(const char *cpu_type);
 
 #endif
Signature · 1 line
2.21.0
Reviewed-by on v1 3/21
#8 lore raw

Re: [PATCH 03/21] hw/arm/collie: Create the RAM in the board

Quoted 10 lines · Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the SA1110 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/collie.c    | 8 ++++++--
 hw/arm/strongarm.c | 7 +------
 hw/arm/strongarm.h | 4 +---
 3 files changed, 8 insertions(+), 11 deletions(-)

r~

Reviewed-by on v1 3/21
#9 lore raw

Re: [PATCH 03/21] hw/arm/collie: Create the RAM in the board

In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the SA1110 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

Alistair

Quoted 76 lines
---
 hw/arm/collie.c    | 8 ++++++--
 hw/arm/strongarm.c | 7 +------
 hw/arm/strongarm.h | 4 +---
 3 files changed, 8 insertions(+), 11 deletions(-)
hw/arm/collie.c +6 -2
index b1288ccea8..970a4405cc 100644
@@ -27,9 +27,13 @@ static void collie_init(MachineState *machine)
 {
     StrongARMState *s;
     DriveInfo *dinfo;
-    MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);
 
-    s = sa1110_init(sysmem, collie_binfo.ram_size, machine->cpu_type);
+    s = sa1110_init(machine->cpu_type);
+
+    memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram",
+                                         collie_binfo.ram_size);
+    memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
hw/arm/strongarm.c +1 -6
index dc65d88a65..6bee034914 100644
@@ -1586,8 +1586,7 @@ static const TypeInfo strongarm_ssp_info = {
 };
 
 /* Main CPU functions */
-StrongARMState *sa1110_init(MemoryRegion *sysmem,
-                            unsigned int sdram_size, const char *cpu_type)
+StrongARMState *sa1110_init(const char *cpu_type)
 {
     StrongARMState *s;
     int i;
@@ -1601,10 +1600,6 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem,
 
     s->cpu = ARM_CPU(cpu_create(cpu_type));
 
-    memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
-                                         sdram_size);
-    memory_region_add_subregion(sysmem, SA_SDCS0, &s->sdram);
-
     s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ),
                     qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_FIQ),
hw/arm/strongarm.h +1 -4
index e98840b461..192821f6aa 100644
@@ -55,7 +55,6 @@ enum {
 
 typedef struct {
     ARMCPU *cpu;
-    MemoryRegion sdram;
     DeviceState *pic;
     DeviceState *gpio;
     DeviceState *ppc;
@@ -63,7 +62,6 @@ typedef struct {
     SSIBus *ssp_bus;
 } StrongARMState;
 
-StrongARMState *sa1110_init(MemoryRegion *sysmem,
-                            unsigned int sdram_size, const char *rev);
+StrongARMState *sa1110_init(const char *cpu_type);
 
 #endif
--

2.21.0

#10 lore raw

PATCH 4/21 hw/arm/omap2: Create the RAM in the board

In reply to Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the OMAP2420 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/nseries.c      | 10 +++++++---
 hw/arm/omap2.c        | 13 +++++--------
 include/hw/arm/omap.h |  4 +---
 3 files changed, 13 insertions(+), 14 deletions(-)
hw/arm/nseries.c +7 -3
index a36971d39a..11f2c193f3 100644
@@ -1311,11 +1311,15 @@ static int n810_atag_setup(const struct arm_boot_info *info, void *p)
 static void n8x0_init(MachineState *machine,
                       struct arm_boot_info *binfo, int model)
 {
-    MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);
     struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
-    int sdram_size = binfo->ram_size;
+    uint64_t sdram_size = binfo->ram_size;
 
-    s->mpu = omap2420_mpu_init(sysmem, sdram_size, machine->cpu_type);
+    memory_region_allocate_system_memory(sdram, NULL, "omap2.dram",
+                                         sdram_size);
+    memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, sdram);
+
+    s->mpu = omap2420_mpu_init(sdram, machine->cpu_type);
 
     /* Setup peripherals
      *
hw/arm/omap2.c +5 -8
index bd7ddff983..457f152bac 100644
@@ -22,6 +22,7 @@
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "cpu.h"
+#include "exec/address-spaces.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/qtest.h"
 #include "sysemu/reset.h"
@@ -2276,8 +2277,7 @@ static const struct dma_irq_map omap2_dma_irq_map[] = {
     { 0, OMAP_INT_24XX_SDMA_IRQ3 },
 };
 
-struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
-                unsigned long sdram_size,
+struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sdram,
                 const char *cpu_type)
 {
     struct omap_mpu_state_s *s = g_new0(struct omap_mpu_state_s, 1);
@@ -2286,11 +2286,11 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     int i;
     SysBusDevice *busdev;
     struct omap_target_agent_s *ta;
+    MemoryRegion *sysmem = get_system_memory();
 
     /* Core */
     s->mpu_model = omap2420;
     s->cpu = ARM_CPU(cpu_create(cpu_type));
-    s->sdram_size = sdram_size;
     s->sram_size = OMAP242X_SRAM_SIZE;
 
     s->wakeup = qemu_allocate_irq(omap_mpu_wakeup, s, 0);
@@ -2299,9 +2299,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     omap_clk_init(s);
 
     /* Memory-mapped stuff */
-    memory_region_allocate_system_memory(&s->sdram, NULL, "omap2.dram",
-                                         s->sdram_size);
-    memory_region_add_subregion(sysmem, OMAP2_Q2_BASE, &s->sdram);
     memory_region_init_ram(&s->sram, NULL, "omap2.sram", s->sram_size,
                            &error_fatal);
     memory_region_add_subregion(sysmem, OMAP2_SRAM_BASE, &s->sram);
@@ -2338,8 +2335,8 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     s->port->addr_valid = omap2_validate_addr;
 
     /* Register SDRAM and SRAM ports for fast DMA transfers.  */
-    soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sdram),
-                         OMAP2_Q2_BASE, s->sdram_size);
+    soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(sdram),
+                         OMAP2_Q2_BASE, memory_region_size(sdram));
     soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->sram),
                          OMAP2_SRAM_BASE, s->sram_size);
 
include/hw/arm/omap.h +1 -3
index 2fda996648..763d8eab4f 100644
@@ -824,7 +824,6 @@ struct omap_mpu_state_s {
     MemoryRegion tap_iomem;
     MemoryRegion imif_ram;
     MemoryRegion emiff_ram;
-    MemoryRegion sdram;
     MemoryRegion sram;
 
     struct omap_dma_port_if_s {
@@ -938,8 +937,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
                 const char *core);
 
 /* omap2.c */
-struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
-                unsigned long sdram_size,
+struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sdram,
                 const char *core);
 
 uint32_t omap_badwidth_read8(void *opaque, hwaddr addr);
Signature · 1 line
2.21.0
Reviewed-by on v1 4/21
#11 lore raw

Re: [PATCH 04/21] hw/arm/omap2: Create the RAM in the board

Quoted 5 lines · Philippe Mathieu-Daudé

static void n8x0_init(MachineState *machine,
struct arm_boot_info *binfo, int model)
{

hw/arm/nseries.c +1 -1
-    MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);

hw/arm/nseries.c static int n810_atag_setup(const struct arm_boot_info *info, void *p) · line 1322

Quoted 10 lines
hw/arm/nseries.c +6 -2
     struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
-    int sdram_size = binfo->ram_size;
+    uint64_t sdram_size = binfo->ram_size;
 
-    s->mpu = omap2420_mpu_init(sysmem, sdram_size, machine->cpu_type);
+    memory_region_allocate_system_memory(sdram, NULL, "omap2.dram",
+                                         sdram_size);
+    memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, sdram);
+
+    s->mpu = omap2420_mpu_init(sdram, machine->cpu_type);

Any reason not to put the MemoryRegion in to the n800_s structure?

Otherwise,

r~

#12 lore raw

Re: [PATCH 04/21] hw/arm/omap2: Create the RAM in the board

Quoted 10 lines · Richard Henderson
Quoted 9 lines · Philippe Mathieu-Daudé

static void n8x0_init(MachineState *machine,
struct arm_boot_info *binfo, int model)
{

hw/arm/nseries.c +2 -2
-    MemoryRegion *sysmem = get_system_memory();
+    MemoryRegion *sdram = g_new(MemoryRegion, 1);
      struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
-    int sdram_size = binfo->ram_size;
+    uint64_t sdram_size = binfo->ram_size;
Quoted 8 lines

hw/arm/nseries.c static int n810_atag_setup(const struct arm_boot_info *info, void *p) · line 1322

Quoted 6 lines
hw/arm/nseries.c +5 -1
-    s->mpu = omap2420_mpu_init(sysmem, sdram_size, machine->cpu_type);
+    memory_region_allocate_system_memory(sdram, NULL, "omap2.dram",
+                                         sdram_size);
+    memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, sdram);
+
+    s->mpu = omap2420_mpu_init(sdram, machine->cpu_type);

Any reason not to put the MemoryRegion in to the n800_s structure?

Ah yes, better to keep it in n800_s in case we ever QOM'ify this SoC. I'll do.

Quoted 2 lines

Otherwise,

Thanks :)

#13 lore raw

PATCH 5/21 hw/arm/omap1: Create the RAM in the board

In reply to Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the OMAP310 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/omap1.c        | 12 +++++-------
 hw/arm/omap_sx1.c     |  8 ++++++--
 hw/arm/palm.c         |  8 ++++++--
 include/hw/arm/omap.h |  6 ++----
 4 files changed, 19 insertions(+), 15 deletions(-)
hw/arm/omap1.c +5 -7
index 0400593805..6ce038a453 100644
@@ -23,6 +23,7 @@
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
+#include "exec/address-spaces.h"
 #include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/irq.h"
@@ -3858,8 +3859,7 @@ static int omap_validate_tipb_mpui_addr(struct omap_mpu_state_s *s,
     return range_covers_byte(0xe1010000, 0xe1020004 - 0xe1010000, addr);
 }
 
-struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
-                unsigned long sdram_size,
+struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *dram,
                 const char *cpu_type)
 {
     int i;
@@ -3867,11 +3867,12 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     qemu_irq dma_irqs[6];
     DriveInfo *dinfo;
     SysBusDevice *busdev;
+    MemoryRegion *system_memory = get_system_memory();
 
     /* Core */
     s->mpu_model = omap310;
     s->cpu = ARM_CPU(cpu_create(cpu_type));
-    s->sdram_size = sdram_size;
+    s->sdram_size = memory_region_size(dram);
     s->sram_size = OMAP15XX_SRAM_SIZE;
 
     s->wakeup = qemu_allocate_irq(omap_mpu_wakeup, s, 0);
@@ -3880,9 +3881,6 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     omap_clk_init(s);
 
     /* Memory-mapped stuff */
-    memory_region_allocate_system_memory(&s->emiff_ram, NULL, "omap1.dram",
-                                         s->sdram_size);
-    memory_region_add_subregion(system_memory, OMAP_EMIFF_BASE, &s->emiff_ram);
     memory_region_init_ram(&s->imif_ram, NULL, "omap1.sram", s->sram_size,
                            &error_fatal);
     memory_region_add_subregion(system_memory, OMAP_IMIF_BASE, &s->imif_ram);
@@ -3925,7 +3923,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     s->port[tipb_mpui].addr_valid = omap_validate_tipb_mpui_addr;
 
     /* Register SDRAM and SRAM DMA ports for fast transfers.  */
-    soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->emiff_ram),
+    soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(dram),
                          OMAP_EMIFF_BASE, s->sdram_size);
     soc_dma_port_add_mem(s->dma, memory_region_get_ram_ptr(&s->imif_ram),
                          OMAP_IMIF_BASE, s->sram_size);
hw/arm/omap_sx1.c +6 -2
index c071197be7..be245714db 100644
@@ -103,6 +103,7 @@ static void sx1_init(MachineState *machine, const int version)
 {
     struct omap_mpu_state_s *mpu;
     MemoryRegion *address_space = get_system_memory();
+    MemoryRegion *dram = g_new(MemoryRegion, 1);
     MemoryRegion *flash = g_new(MemoryRegion, 1);
     MemoryRegion *cs = g_new(MemoryRegion, 4);
     static uint32_t cs0val = 0x00213090;
@@ -118,8 +119,11 @@ static void sx1_init(MachineState *machine, const int version)
         flash_size = flash2_size;
     }
 
-    mpu = omap310_mpu_init(address_space, sx1_binfo.ram_size,
-                           machine->cpu_type);
+    memory_region_allocate_system_memory(dram, NULL, "omap1.dram",
+                                         sx1_binfo.ram_size);
+    memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, dram);
+
+    mpu = omap310_mpu_init(dram, machine->cpu_type);
 
     /* External Flash (EMIFS) */
     memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size,
hw/arm/palm.c +6 -2
index 02a3a82b9b..72eca8cc55 100644
@@ -190,16 +190,20 @@ static void palmte_init(MachineState *machine)
     MemoryRegion *address_space_mem = get_system_memory();
     struct omap_mpu_state_s *mpu;
     int flash_size = 0x00800000;
-    int sdram_size = palmte_binfo.ram_size;
     static uint32_t cs0val = 0xffffffff;
     static uint32_t cs1val = 0x0000e1a0;
     static uint32_t cs2val = 0x0000e1a0;
     static uint32_t cs3val = 0xe1a0e1a0;
     int rom_size, rom_loaded = 0;
+    MemoryRegion *dram = g_new(MemoryRegion, 1);
     MemoryRegion *flash = g_new(MemoryRegion, 1);
     MemoryRegion *cs = g_new(MemoryRegion, 4);
 
-    mpu = omap310_mpu_init(address_space_mem, sdram_size, machine->cpu_type);
+    memory_region_allocate_system_memory(dram, NULL, "omap1.dram",
+                                         palmte_binfo.ram_size);
+    memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, dram);
+
+    mpu = omap310_mpu_init(dram, machine->cpu_type);
 
     /* External Flash (EMIFS) */
     memory_region_init_ram(flash, NULL, "palmte.flash", flash_size,
include/hw/arm/omap.h +2 -4
index 763d8eab4f..f3aa670036 100644
@@ -823,7 +823,6 @@ struct omap_mpu_state_s {
     MemoryRegion mpui_io_iomem;
     MemoryRegion tap_iomem;
     MemoryRegion imif_ram;
-    MemoryRegion emiff_ram;
     MemoryRegion sram;
 
     struct omap_dma_port_if_s {
@@ -835,7 +834,7 @@ struct omap_mpu_state_s {
                         hwaddr addr);
     } port[__omap_dma_port_last];
 
-    unsigned long sdram_size;
+    uint64_t sdram_size;
     unsigned long sram_size;
 
     /* MPUI-TIPB peripherals */
@@ -932,8 +931,7 @@ struct omap_mpu_state_s {
 };
 
 /* omap1.c */
-struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
-                unsigned long sdram_size,
+struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *sdram,
                 const char *core);
 
 /* omap2.c */
Signature · 1 line
2.21.0
Reviewed-by on v1 5/21
#14 lore raw

Re: [PATCH 05/21] hw/arm/omap1: Create the RAM in the board

Quoted 11 lines · Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the OMAP310 SoC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/omap1.c        | 12 +++++-------
 hw/arm/omap_sx1.c     |  8 ++++++--
 hw/arm/palm.c         |  8 ++++++--
 include/hw/arm/omap.h |  6 ++----
 4 files changed, 19 insertions(+), 15 deletions(-)

r~

#15 lore raw

PATCH 6/21 hw/arm/digic4: Inline digic4_board_setup_ram() function

In reply to Philippe Mathieu-Daudé

Having the RAM creation code in a separate function is not very helpful. Move this code directly inside the board_init() function, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/digic_boards.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
hw/arm/digic_boards.c +2 -7
index 304e4d1a29..ef3fc2b6a5 100644
@@ -53,12 +53,6 @@ typedef struct DigicBoard {
     const char *rom1_def_filename;
 } DigicBoard;
 
-static void digic4_board_setup_ram(DigicBoardState *s, hwaddr ram_size)
-{
-    memory_region_allocate_system_memory(&s->ram, NULL, "ram", ram_size);
-    memory_region_add_subregion(get_system_memory(), 0, &s->ram);
-}
-
 static void digic4_board_init(DigicBoard *board)
 {
     Error *err = NULL;
@@ -72,7 +66,8 @@ static void digic4_board_init(DigicBoard *board)
         exit(1);
     }
 
-    digic4_board_setup_ram(s, board->ram_size);
+    memory_region_allocate_system_memory(&s->ram, NULL, "ram", board->ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &s->ram);
 
     if (board->add_rom0) {
         board->add_rom0(s, DIGIC4_ROM0_BASE, board->rom0_def_filename);
Signature · 1 line
2.21.0
Reviewed-by on v1 6/21
#16 lore raw

Re: [PATCH 06/21] hw/arm/digic4: Inline digic4_board_setup_ram() function

Quoted 9 lines · Philippe Mathieu-Daudé

Having the RAM creation code in a separate function is not very helpful. Move this code directly inside the board_init() function, this will later allow the board to have the QOM ownership of the RAM.

---
 hw/arm/digic_boards.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

r~

Reviewed-by on v1 6/21
#17 lore raw

Re: [PATCH 06/21] hw/arm/digic4: Inline digic4_board_setup_ram() function

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Having the RAM creation code in a separate function is not very helpful. Move this code directly inside the board_init() function, this will later allow the board to have the QOM ownership of the RAM.

Alistair

Quoted 35 lines
---
 hw/arm/digic_boards.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
hw/arm/digic_boards.c +2 -8
index 304e4d1a29..ef3fc2b6a5 100644
@@ -53,12 +53,6 @@ typedef struct DigicBoard {
     const char *rom1_def_filename;
 } DigicBoard;
 
-static void digic4_board_setup_ram(DigicBoardState *s, hwaddr ram_size)
-{
-    memory_region_allocate_system_memory(&s->ram, NULL, "ram", ram_size);
-    memory_region_add_subregion(get_system_memory(), 0, &s->ram);
-}
-
 static void digic4_board_init(DigicBoard *board)
 {
     Error *err = NULL;
@@ -72,7 +66,8 @@ static void digic4_board_init(DigicBoard *board)
         exit(1);
     }
 
-    digic4_board_setup_ram(s, board->ram_size);
+    memory_region_allocate_system_memory(&s->ram, NULL, "ram", board->ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &s->ram);
 
     if (board->add_rom0) {
         board->add_rom0(s, DIGIC4_ROM0_BASE, board->rom0_def_filename);
--

2.21.0

#18 lore raw

PATCH 7/21 hw: Drop QOM ownership on memory_region_allocate_system_memory() calls

In reply to Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() calls are in the board_init() code. From the 58 calls in the repository, only 4 set the 'owner' parameter. It is obvious we want the Machine to be the owner of the RAM, so we want to use OBJECT(machine) as owner. We can simplify a bit by passing MachineState to memory_region_allocate_system_memory(). In preparation of this refactor, first drop the 'owner' argument from these 4 uses.

  $ git grep memory_region_allocate_system_memory hw/ | wc -l
  58
---
 hw/alpha/typhoon.c | 2 +-
 hw/arm/raspi.c     | 2 +-
 hw/hppa/machine.c  | 2 +-
 hw/sparc/sun4m.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
hw/alpha/typhoon.c +1 -1
index 179e1f7658..8489ec335c 100644
@@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
        but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram",
+    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
                                          ram_size);
     memory_region_add_subregion(addr_space, 0, &s->ram_region);
 
hw/arm/raspi.c +1 -1
index 615d755879..f76b6eaad3 100644
@@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version)
                             &error_abort, NULL);
 
     /* Allocate and map RAM */
-    memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",
+    memory_region_allocate_system_memory(&s->ram, NULL, "ram",
                                          machine->ram_size);
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0);
hw/hppa/machine.c +1 -1
index 953d454f48..dbe1ff0fe5 100644
@@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Main memory region. */
     ram_region = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram_region, OBJECT(machine),
+    memory_region_allocate_system_memory(ram_region, NULL,
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
hw/sparc/sun4m.c +1 -1
index 6c5a17a020..0bb7524655 100644
@@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp)
     RamDevice *d = SUN4M_RAM(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
-    memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram",
+    memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram",
                                          d->size);
     sysbus_init_mmio(sbd, &d->ram);
 }
Signature · 1 line
2.21.0
Reviewed-by on v1 7/21
#19 lore raw

Re: [PATCH 07/21] hw: Drop QOM ownership on memory_region_allocate_system_memory() calls

Quoted 9 lines · Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() calls are in the board_init() code. From the 58 calls in the repository, only 4 set the 'owner' parameter. It is obvious we want the Machine to be the owner of the RAM, so we want to use OBJECT(machine) as owner. We can simplify a bit by passing MachineState to memory_region_allocate_system_memory(). In preparation of this refactor, first drop the 'owner' argument from these 4 uses.

Quoted 4 lines
  $ git grep memory_region_allocate_system_memory hw/ | wc -l
  58

Alistair

Quoted 63 lines
---
 hw/alpha/typhoon.c | 2 +-
 hw/arm/raspi.c     | 2 +-
 hw/hppa/machine.c  | 2 +-
 hw/sparc/sun4m.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
hw/alpha/typhoon.c +1 -1
index 179e1f7658..8489ec335c 100644
@@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
        but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram",
+    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
                                          ram_size);
     memory_region_add_subregion(addr_space, 0, &s->ram_region);
 
hw/arm/raspi.c +1 -1
index 615d755879..f76b6eaad3 100644
@@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version)
                             &error_abort, NULL);
 
     /* Allocate and map RAM */
-    memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",
+    memory_region_allocate_system_memory(&s->ram, NULL, "ram",
                                          machine->ram_size);
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0);
hw/hppa/machine.c +1 -1
index 953d454f48..dbe1ff0fe5 100644
@@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Main memory region. */
     ram_region = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram_region, OBJECT(machine),
+    memory_region_allocate_system_memory(ram_region, NULL,
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
hw/sparc/sun4m.c +1 -2
index 6c5a17a020..0bb7524655 100644
@@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp)
     RamDevice *d = SUN4M_RAM(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
-    memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram",
+    memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram",
                                          d->size);
     sysbus_init_mmio(sbd, &d->ram);
 }
--

2.21.0

Reviewed-by
#20 lore raw

Re: [PATCH 07/21] hw: Drop QOM ownership on memory_region_allocate_system_memory() calls

Quoted 12 lines · Alistair Francis
Quoted 9 lines · Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() calls are in the board_init() code. From the 58 calls in the repository, only 4 set the 'owner' parameter. It is obvious we want the Machine to be the owner of the RAM, so we want to use OBJECT(machine) as owner. We can simplify a bit by passing MachineState to memory_region_allocate_system_memory(). In preparation of this refactor, first drop the 'owner' argument from these 4 uses.

Quoted 6 lines
Quoted 4 lines
  $ git grep memory_region_allocate_system_memory hw/ | wc -l
  58
Quoted 66 lines

Alistair

Quoted 63 lines
---
 hw/alpha/typhoon.c | 2 +-
 hw/arm/raspi.c     | 2 +-
 hw/hppa/machine.c  | 2 +-
 hw/sparc/sun4m.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
hw/alpha/typhoon.c +1 -1
index 179e1f7658..8489ec335c 100644
@@ -851,7 +851,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
        but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram",
+    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
                                          ram_size);
     memory_region_add_subregion(addr_space, 0, &s->ram_region);
 
hw/arm/raspi.c +1 -1
index 615d755879..f76b6eaad3 100644
@@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version)
                             &error_abort, NULL);
 
     /* Allocate and map RAM */
-    memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram",
+    memory_region_allocate_system_memory(&s->ram, NULL, "ram",
                                          machine->ram_size);
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0);
hw/hppa/machine.c +1 -1
index 953d454f48..dbe1ff0fe5 100644
@@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Main memory region. */
     ram_region = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram_region, OBJECT(machine),
+    memory_region_allocate_system_memory(ram_region, NULL,
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
hw/sparc/sun4m.c +1 -2
index 6c5a17a020..0bb7524655 100644
@@ -788,7 +788,7 @@ static void ram_realize(DeviceState *dev, Error **errp)
     RamDevice *d = SUN4M_RAM(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
-    memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram",
+    memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram",
                                          d->size);
     sysbus_init_mmio(sbd, &d->ram);
 }
--

2.21.0

Signature · 4 lines
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
#21 lore raw

PATCH 8/21 hw/alpha/dp264: Create the RAM in the board

In reply to Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the Tyohoon northbridge ASIC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
checkpatch complains:

ERROR: spaces required around that '*' (ctx:WxV) #10: FILE: hw/alpha/alpha_sys.h:13:
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],

                                                       ^
---
 hw/alpha/alpha_sys.h |  2 +-
 hw/alpha/dp264.c     | 11 ++++++++++-
 hw/alpha/typhoon.c   |  9 +--------
 3 files changed, 12 insertions(+), 10 deletions(-)
hw/alpha/alpha_sys.h +1 -1
index 4e127a6de8..17f97e1bfe 100644
@@ -10,7 +10,7 @@
 #include "hw/i386/pc.h"
 
 
-PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4],
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],
                      pci_map_irq_fn);
 
 /* alpha_pci.c.  */
hw/alpha/dp264.c +10 -1
index 51feee8558..ddc249261c 100644
@@ -62,6 +62,7 @@ static void clipper_init(MachineState *machine)
     uint64_t palcode_entry, palcode_low, palcode_high;
     uint64_t kernel_entry, kernel_low, kernel_high;
     unsigned int smp_cpus = machine->smp.cpus;
+    MemoryRegion ram_region;
 
     /* Create up to 4 cpus.  */
     memset(cpus, 0, sizeof(cpus));
@@ -73,8 +74,16 @@ static void clipper_init(MachineState *machine)
     cpus[0]->env.trap_arg1 = 0;
     cpus[0]->env.trap_arg2 = smp_cpus;
 
+    /*
+     * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
+     * but the address space hole reserved at this point is 8TB.
+     */
+    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+                                         ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &ram_region);
+
     /* Init the chipset.  */
-    pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus,
+    pci_bus = typhoon_init(&isa_bus, &rtc_irq, cpus,
                            clipper_pci_map_irq);
 
     /* Since we have an SRM-compatible PALcode, use the SRM epoch.  */
hw/alpha/typhoon.c +1 -8
index 8489ec335c..12589ef331 100644
@@ -58,7 +58,6 @@ typedef struct TyphoonState {
     TyphoonCchip cchip;
     TyphoonPchip pchip;
     MemoryRegion dchip_region;
-    MemoryRegion ram_region;
 } TyphoonState;
 
 /* Called when one of DRIR or DIM changes.  */
@@ -817,7 +816,7 @@ static void typhoon_alarm_timer(void *opaque)
     cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER);
 }
 
-PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
+PCIBus *typhoon_init(ISABus **isa_bus,
                      qemu_irq *p_rtc_irq,
                      AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
 {
@@ -849,12 +848,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     *p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
 
-    /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
-       but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
-                                         ram_size);
-    memory_region_add_subregion(addr_space, 0, &s->ram_region);
-
     /* TIGbus, 0x801.0000.0000, 1GB.  */
     /* ??? The TIGbus is used for delivering interrupts, and access to
        the flash ROM.  I'm not sure that we need to implement it at all.  */
Signature · 1 line
2.21.0
#22 lore raw

Re: [PATCH 08/21] hw/alpha/dp264: Create the RAM in the board

Quoted 36 lines · Philippe Mathieu-Daudé

The SDRAM is incorrectly created in the Tyohoon northbridge ASIC. Move its creation in the board code, this will later allow the board to have the QOM ownership of the RAM.

---
checkpatch complains:

ERROR: spaces required around that '*' (ctx:WxV) #10: FILE: hw/alpha/alpha_sys.h:13:
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],

                                                        ^
---
  hw/alpha/alpha_sys.h |  2 +-
  hw/alpha/dp264.c     | 11 ++++++++++-
  hw/alpha/typhoon.c   |  9 +--------
  3 files changed, 12 insertions(+), 10 deletions(-)
hw/alpha/alpha_sys.h +1 -1
index 4e127a6de8..17f97e1bfe 100644
@@ -10,7 +10,7 @@
  #include "hw/i386/pc.h"
 
 
-PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4],
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],
                       pci_map_irq_fn);
 
  /* alpha_pci.c.  */
hw/alpha/dp264.c +0 -0
index 51feee8558..ddc249261c 100644

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 65

Quoted 4 lines
hw/alpha/dp264.c +1 -0
@@ -62,6 +62,7 @@ static void clipper_init(MachineState *machine)
      uint64_t palcode_entry, palcode_low, palcode_high;
      uint64_t kernel_entry, kernel_low, kernel_high;
      unsigned int smp_cpus = machine->smp.cpus;
+    MemoryRegion ram_region;

This is incorrect, this variable should be in .heap, not stack.

Quoted 56 lines
hw/alpha/dp264.c +9 -1
      /* Create up to 4 cpus.  */
      memset(cpus, 0, sizeof(cpus));
@@ -73,8 +74,16 @@ static void clipper_init(MachineState *machine)
      cpus[0]->env.trap_arg1 = 0;
      cpus[0]->env.trap_arg2 = smp_cpus;
 
+    /*
+     * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
+     * but the address space hole reserved at this point is 8TB.
+     */
+    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+                                         ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &ram_region);
+
      /* Init the chipset.  */
-    pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus,
+    pci_bus = typhoon_init(&isa_bus, &rtc_irq, cpus,
                             clipper_pci_map_irq);
 
      /* Since we have an SRM-compatible PALcode, use the SRM epoch.  */
hw/alpha/typhoon.c +1 -8
index 8489ec335c..12589ef331 100644
@@ -58,7 +58,6 @@ typedef struct TyphoonState {
      TyphoonCchip cchip;
      TyphoonPchip pchip;
      MemoryRegion dchip_region;
-    MemoryRegion ram_region;
  } TyphoonState;
 
  /* Called when one of DRIR or DIM changes.  */
@@ -817,7 +816,7 @@ static void typhoon_alarm_timer(void *opaque)
      cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER);
  }
 
-PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
+PCIBus *typhoon_init(ISABus **isa_bus,
                       qemu_irq *p_rtc_irq,
                       AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
  {
@@ -849,12 +848,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
      *p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
 
-    /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
-       but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
-                                         ram_size);
-    memory_region_add_subregion(addr_space, 0, &s->ram_region);
-
      /* TIGbus, 0x801.0000.0000, 1GB.  */
      /* ??? The TIGbus is used for delivering interrupts, and access to
         the flash ROM.  I'm not sure that we need to implement it at all.  */
#23 lore raw

Re: [PATCH 08/21] hw/alpha/dp264: Create the RAM in the board

In reply to Philippe Mathieu-Daudé

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 83

Quoted 11 lines · Philippe Mathieu-Daudé
hw/alpha/dp264.c +7 -0
@@ -73,8 +74,16 @@ static void clipper_init(MachineState *machine)
     cpus[0]->env.trap_arg1 = 0;
     cpus[0]->env.trap_arg2 = smp_cpus;
 
+    /*
+     * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
+     * but the address space hole reserved at this point is 8TB.
+     */
+    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+                                         ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &ram_region);

The thing that I don't like about this is that ...

hw/alpha/typhoon.c PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, · line 853

Quoted 13 lines
hw/alpha/typhoon.c +0 -6
@@ -849,12 +848,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     *p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
 
-    /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
-       but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
-                                         ram_size);
-    memory_region_add_subregion(addr_space, 0, &s->ram_region);
-
     /* TIGbus, 0x801.0000.0000, 1GB.  */
     /* ??? The TIGbus is used for delivering interrupts, and access to
        the flash ROM.  I'm not sure that we need to implement it at all.  */

... previously, it was clear that Typhoon owns the entire address space layout.
With this moved to dp264.c, the "address space hole" comment is out of context
and makes no sense.

Would it be too weird to pass in a MemoryRegion* to typhoon_init and leave the memory_region_add_subregion() call where it is?

r~

#24 lore raw

Re: [PATCH 08/21] hw/alpha/dp264: Create the RAM in the board

Quoted 33 lines · Richard Henderson

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 83

Quoted 11 lines · Philippe Mathieu-Daudé
hw/alpha/dp264.c +7 -0
@@ -73,8 +74,16 @@ static void clipper_init(MachineState *machine)
      cpus[0]->env.trap_arg1 = 0;
      cpus[0]->env.trap_arg2 = smp_cpus;
 
+    /*
+     * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
+     * but the address space hole reserved at this point is 8TB.
+     */
+    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+                                         ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, &ram_region);

The thing that I don't like about this is that ...

hw/alpha/typhoon.c PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, · line 853

Quoted 13 lines
hw/alpha/typhoon.c +0 -6
@@ -849,12 +848,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
      *p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
 
-    /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
-       but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, NULL, "ram",
-                                         ram_size);
-    memory_region_add_subregion(addr_space, 0, &s->ram_region);
-
      /* TIGbus, 0x801.0000.0000, 1GB.  */
      /* ??? The TIGbus is used for delivering interrupts, and access to
         the flash ROM.  I'm not sure that we need to implement it at all.  */

... previously, it was clear that Typhoon owns the entire address space layout.
With this moved to dp264.c, the "address space hole" comment is out of context
and makes no sense.

Quoted 2 lines

Would it be too weird to pass in a MemoryRegion* to typhoon_init and leave the memory_region_add_subregion() call where it is?

Yes, this will also better match the hardware.
I have a WiP series that first QOM'ify the CY82C693UB southbridge then the Typhoon northbridge and pass the DRAM MemoryRegion* as a link, so in the non-QOM form your suggestion is the same. I'll do your change.

#25 lore raw

PATCH 9/21 hw: Let memory_region_allocate_system_memory take MachineState argument

In reply to Philippe Mathieu-Daudé

All the codebase calls memory_region_allocate_system_memory() with a NULL 'owner' from the board_init() function.
Let pass a MachineState argument, and enforce the QOM ownership of the system memory.

---
 hw/core/numa.c      | 11 +++++++----
 include/hw/boards.h |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)
hw/core/numa.c +7 -4
index 038c96d4ab..2e29e4bfe0 100644
@@ -520,21 +520,24 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
     vmstate_register_ram_global(mr);
 }
 
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size)
 {
     uint64_t addr = 0;
     int i;
-    MachineState *ms = MACHINE(qdev_get_machine());
+
+    if (!ms) {
+        ms = MACHINE(qdev_get_machine());
+    }
 
     if (ms->numa_state == NULL ||
         ms->numa_state->num_nodes == 0 || !have_memdevs) {
-        allocate_system_memory_nonnuma(mr, owner, name, ram_size);
+        allocate_system_memory_nonnuma(mr, OBJECT(ms), name, ram_size);
         return;
     }
 
-    memory_region_init(mr, owner, name, ram_size);
+    memory_region_init(mr, OBJECT(ms), name, ram_size);
     for (i = 0; i < ms->numa_state->num_nodes; i++) {
         uint64_t size = ms->numa_state->nodes[i].node_mem;
         HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
include/hw/boards.h +4 -2
index de45087f34..3b6cb82b6c 100644
@@ -14,7 +14,7 @@
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
- * @owner: the object that tracks the region's reference count
+ * @ms: the #MachineState object that own the system memory
  * @name: name of the memory region
  * @ram_size: size of the region in bytes
  *
@@ -38,8 +38,10 @@
  * Smaller pieces of memory (display RAM, static RAMs, etc) don't need
  * to be backed via the -mem-path memory backend and can simply
  * be created via memory_region_init_ram().
+ *
+ * The #MachineState object will track the region's reference count.
  */
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size);
 
Signature · 1 line
2.21.0
#26 lore raw

Re: [PATCH 09/21] hw: Let memory_region_allocate_system_memory take MachineState argument

Quoted 2 lines · Philippe Mathieu-Daudé

All the codebase calls memory_region_allocate_system_memory() with a NULL 'owner' from the board_init() function.

It's a little bit weird that you first changed the owner to NULL in patch 7, just to change the type of the parameter here and then change the parameter back to the machine afterwards. I think I'd rather squash pash 7 (and the follow-up patches like 14) into this one here - it's just four files that need to be adapted, so I think that's still fine, and finally that's less churn to be reviewed.

Quoted 2 lines

Let pass a MachineState argument, and enforce the QOM ownership of the system memory.

BTW, good idea!

Quoted 44 lines
---
 hw/core/numa.c      | 11 +++++++----
 include/hw/boards.h |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)
hw/core/numa.c +7 -4
index 038c96d4ab..2e29e4bfe0 100644
@@ -520,21 +520,24 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
     vmstate_register_ram_global(mr);
 }
 
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size)
 {
     uint64_t addr = 0;
     int i;
-    MachineState *ms = MACHINE(qdev_get_machine());
+
+    if (!ms) {
+        ms = MACHINE(qdev_get_machine());
+    }
 
     if (ms->numa_state == NULL ||
         ms->numa_state->num_nodes == 0 || !have_memdevs) {
-        allocate_system_memory_nonnuma(mr, owner, name, ram_size);
+        allocate_system_memory_nonnuma(mr, OBJECT(ms), name, ram_size);
         return;
     }
 
-    memory_region_init(mr, owner, name, ram_size);
+    memory_region_init(mr, OBJECT(ms), name, ram_size);
     for (i = 0; i < ms->numa_state->num_nodes; i++) {
         uint64_t size = ms->numa_state->nodes[i].node_mem;
         HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
include/hw/boards.h +0 -0
index de45087f34..3b6cb82b6c 100644

include/hw/boards.h line 17

Quoted 5 lines
include/hw/boards.h +1 -1
@@ -14,7 +14,7 @@
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
- * @owner: the object that tracks the region's reference count
+ * @ms: the #MachineState object that own the system memory

s/own/owns/

Quoted 6 lines
include/hw/boards.h +0 -0
  * @name: name of the memory region
  * @ram_size: size of the region in bytes
  *
@@ -38,8 +38,10 @@
  * Smaller pieces of memory (display RAM, static RAMs, etc) don't need

include/hw/boards.h line 47

Quoted 10 lines
include/hw/boards.h +3 -1
  * to be backed via the -mem-path memory backend and can simply
  * be created via memory_region_init_ram().
+ *
+ * The #MachineState object will track the region's reference count.
  */
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size);
 

Thomas

#27 lore raw

Re: [PATCH 09/21] hw: Let memory_region_allocate_system_memory take MachineState argument

Quoted 10 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé

All the codebase calls memory_region_allocate_system_memory() with a NULL 'owner' from the board_init() function.

It's a little bit weird that you first changed the owner to NULL in patch 7, just to change the type of the parameter here and then change the parameter back to the machine afterwards. I think I'd rather squash pash 7 (and the follow-up patches like 14) into this one here - it's just four files that need to be adapted, so I think that's still fine, and finally that's less churn to be reviewed.

I haven't thought of it and like your suggestion :)

Quoted 4 lines
Quoted 2 lines

Let pass a MachineState argument, and enforce the QOM ownership of the system memory.

BTW, good idea!

Thanks :)

Quoted 72 lines
Quoted 45 lines
---
  hw/core/numa.c      | 11 +++++++----
  include/hw/boards.h |  6 ++++--
  2 files changed, 11 insertions(+), 6 deletions(-)
hw/core/numa.c +7 -4
index 038c96d4ab..2e29e4bfe0 100644
@@ -520,21 +520,24 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
      vmstate_register_ram_global(mr);
  }
 
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                            const char *name,
                                            uint64_t ram_size)
  {
      uint64_t addr = 0;
      int i;
-    MachineState *ms = MACHINE(qdev_get_machine());
+
+    if (!ms) {
+        ms = MACHINE(qdev_get_machine());
+    }
 
      if (ms->numa_state == NULL ||
          ms->numa_state->num_nodes == 0 || !have_memdevs) {
-        allocate_system_memory_nonnuma(mr, owner, name, ram_size);
+        allocate_system_memory_nonnuma(mr, OBJECT(ms), name, ram_size);
          return;
      }
 
-    memory_region_init(mr, owner, name, ram_size);
+    memory_region_init(mr, OBJECT(ms), name, ram_size);
      for (i = 0; i < ms->numa_state->num_nodes; i++) {
          uint64_t size = ms->numa_state->nodes[i].node_mem;
          HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
include/hw/boards.h +0 -0
index de45087f34..3b6cb82b6c 100644

include/hw/boards.h line 17

Quoted 5 lines
include/hw/boards.h +1 -1
@@ -14,7 +14,7 @@
  /**
   * memory_region_allocate_system_memory - Allocate a board's main memory
   * @mr: the #MemoryRegion to be initialized
- * @owner: the object that tracks the region's reference count
+ * @ms: the #MachineState object that own the system memory

s/own/owns/

Quoted 6 lines
include/hw/boards.h +0 -0
   * @name: name of the memory region
   * @ram_size: size of the region in bytes
   *
@@ -38,8 +38,10 @@
   * Smaller pieces of memory (display RAM, static RAMs, etc) don't need

include/hw/boards.h line 47

Quoted 10 lines
include/hw/boards.h +3 -1
   * to be backed via the -mem-path memory backend and can simply
   * be created via memory_region_init_ram().
+ *
+ * The #MachineState object will track the region's reference count.
   */
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                            const char *name,
                                            uint64_t ram_size);
 

Thomas

Reviewed-by on v1 9/21
#28 lore raw

Re: [PATCH 09/21] hw: Let memory_region_allocate_system_memory take MachineState argument

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

All the codebase calls memory_region_allocate_system_memory() with a NULL 'owner' from the board_init() function.
Let pass a MachineState argument, and enforce the QOM ownership of the system memory.

Alistair

Quoted 67 lines
---
 hw/core/numa.c      | 11 +++++++----
 include/hw/boards.h |  6 ++++--
 2 files changed, 11 insertions(+), 6 deletions(-)
hw/core/numa.c +7 -4
index 038c96d4ab..2e29e4bfe0 100644
@@ -520,21 +520,24 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
     vmstate_register_ram_global(mr);
 }
 
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size)
 {
     uint64_t addr = 0;
     int i;
-    MachineState *ms = MACHINE(qdev_get_machine());
+
+    if (!ms) {
+        ms = MACHINE(qdev_get_machine());
+    }
 
     if (ms->numa_state == NULL ||
         ms->numa_state->num_nodes == 0 || !have_memdevs) {
-        allocate_system_memory_nonnuma(mr, owner, name, ram_size);
+        allocate_system_memory_nonnuma(mr, OBJECT(ms), name, ram_size);
         return;
     }
 
-    memory_region_init(mr, owner, name, ram_size);
+    memory_region_init(mr, OBJECT(ms), name, ram_size);
     for (i = 0; i < ms->numa_state->num_nodes; i++) {
         uint64_t size = ms->numa_state->nodes[i].node_mem;
         HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
include/hw/boards.h +4 -3
index de45087f34..3b6cb82b6c 100644
@@ -14,7 +14,7 @@
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
- * @owner: the object that tracks the region's reference count
+ * @ms: the #MachineState object that own the system memory
  * @name: name of the memory region
  * @ram_size: size of the region in bytes
  *
@@ -38,8 +38,10 @@
  * Smaller pieces of memory (display RAM, static RAMs, etc) don't need
  * to be backed via the -mem-path memory backend and can simply
  * be created via memory_region_init_ram().
+ *
+ * The #MachineState object will track the region's reference count.
  */
-void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
+void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
                                           const char *name,
                                           uint64_t ram_size);
 
--

2.21.0

#29 lore raw

PATCH 10/21 hw/core: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/core/null-machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/null-machine.c +1 -1
index 1aa0a9a01a..16546c8140 100644
@@ -35,7 +35,7 @@ static void machine_none_init(MachineState *mch)
     if (mch->ram_size) {
         MemoryRegion *ram = g_new(MemoryRegion, 1);
 
-        memory_region_allocate_system_memory(ram, NULL, "ram", mch->ram_size);
+        memory_region_allocate_system_memory(ram, mch, "ram", mch->ram_size);
         memory_region_add_subregion(get_system_memory(), 0, ram);
     }
 
Signature · 1 line
2.21.0
Reviewed-by on v1 10/21
#30 lore raw

Re: [PATCH 10/21] hw/core: Let the machine be the owner of the system memory

Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 21 lines
---
 hw/core/null-machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/null-machine.c +1 -2
index 1aa0a9a01a..16546c8140 100644
@@ -35,7 +35,7 @@ static void machine_none_init(MachineState *mch)
     if (mch->ram_size) {
         MemoryRegion *ram = g_new(MemoryRegion, 1);
 
-        memory_region_allocate_system_memory(ram, NULL, "ram", mch->ram_size);
+        memory_region_allocate_system_memory(ram, mch, "ram", mch->ram_size);
         memory_region_add_subregion(get_system_memory(), 0, ram);
     }
 
--

2.21.0

#31 lore raw

PATCH 11/21 hw/alpha: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/alpha/dp264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/alpha/dp264.c +1 -1
index ddc249261c..5696b1e79b 100644
@@ -78,7 +78,7 @@ static void clipper_init(MachineState *machine)
      * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
      * but the address space hole reserved at this point is 8TB.
      */
-    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+    memory_region_allocate_system_memory(&ram_region, machine, "ram",
                                          ram_size);
     memory_region_add_subregion(get_system_memory(), 0, &ram_region);
 
Signature · 1 line
2.21.0
#32 lore raw

Re: [PATCH 11/21] hw/alpha: Let the machine be the owner of the system memory

Quoted 11 lines · Philippe Mathieu-Daudé
---
 hw/alpha/dp264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/alpha/dp264.c +0 -0
index ddc249261c..5696b1e79b 100644

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 84

Quoted 8 lines
hw/alpha/dp264.c +1 -1
@@ -78,7 +78,7 @@ static void clipper_init(MachineState *machine)
      * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
      * but the address space hole reserved at this point is 8TB.
      */
-    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+    memory_region_allocate_system_memory(&ram_region, machine, "ram",
                                          ram_size);
     memory_region_add_subregion(get_system_memory(), 0, &ram_region);
 

I take it this squishes into the squish of patches 7+9?

r~

#33 lore raw

Re: [PATCH 11/21] hw/alpha: Let the machine be the owner of the system memory

Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé
---
 hw/alpha/dp264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
hw/alpha/dp264.c +0 -0
index ddc249261c..5696b1e79b 100644

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 84

Quoted 8 lines
hw/alpha/dp264.c +1 -1
@@ -78,7 +78,7 @@ static void clipper_init(MachineState *machine)
      * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
      * but the address space hole reserved at this point is 8TB.
      */
-    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+    memory_region_allocate_system_memory(&ram_region, machine, "ram",
                                          ram_size);
     memory_region_add_subregion(get_system_memory(), 0, &ram_region);
 

I take it this squishes into the squish of patches 7+9?

Ah, no, it was the TyphoonState that had owned the ram prior to patch 7.

r~

#34 lore raw

Re: [PATCH 11/21] hw/alpha: Let the machine be the owner of the system memory

Quoted 24 lines · Richard Henderson
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Philippe Mathieu-Daudé
---
  hw/alpha/dp264.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
Quoted 6 lines
hw/alpha/dp264.c +0 -0
index ddc249261c..5696b1e79b 100644

hw/alpha/dp264.c static void clipper_init(MachineState *machine) · line 84

Quoted 8 lines
hw/alpha/dp264.c +1 -1
@@ -78,7 +78,7 @@ static void clipper_init(MachineState *machine)
       * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
       * but the address space hole reserved at this point is 8TB.
       */
-    memory_region_allocate_system_memory(&ram_region, NULL, "ram",
+    memory_region_allocate_system_memory(&ram_region, machine, "ram",
                                           ram_size);
      memory_region_add_subregion(get_system_memory(), 0, &ram_region);
 

I take it this squishes into the squish of patches 7+9?

Quoted 1 line

Ah, no, it was the TyphoonState that had owned the ram prior to patch 7.

Indeed, I'll squash them and document in the commit description that I dropped Typhoon ownership. I'm not sure what's best here, keep it unassigned until patch #11 (this), or reassign to OBJECT(machine).

New squashed patch is:

-- 8< --

hw/alpha/alpha_sys.h +1 -1
index 4e127a6de8..17f97e1bfe 100644
@@ -10,7 +10,7 @@
 #include "hw/i386/pc.h"
 
 
-PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4],
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],
                      pci_map_irq_fn);
 
 /* alpha_pci.c.  */
hw/alpha/dp264.c +9 -1
index 51feee8558..a93a476531 100644
@@ -62,6 +62,7 @@ static void clipper_init(MachineState *machine)
     uint64_t palcode_entry, palcode_low, palcode_high;
     uint64_t kernel_entry, kernel_low, kernel_high;
     unsigned int smp_cpus = machine->smp.cpus;
+    MemoryRegion *ram = g_new(MemoryRegion, 1);
 
     /* Create up to 4 cpus.  */
     memset(cpus, 0, sizeof(cpus));
@@ -73,8 +74,15 @@ static void clipper_init(MachineState *machine)
     cpus[0]->env.trap_arg1 = 0;
     cpus[0]->env.trap_arg2 = smp_cpus;
 
+    /*
+     * Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
+     * but the address space hole reserved at this point is 8TB.
+     */
+    memory_region_allocate_system_memory(ram, OBJECT(machine), "ram", ram_size);
+    memory_region_add_subregion(get_system_memory(), 0, ram);
+
     /* Init the chipset.  */
-    pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus,
+    pci_bus = typhoon_init(&isa_bus, &rtc_irq, cpus,
                            clipper_pci_map_irq);
 
     /* Since we have an SRM-compatible PALcode, use the SRM epoch.  */
hw/alpha/typhoon.c +1 -8
index 179e1f7658..12589ef331 100644
@@ -58,7 +58,6 @@ typedef struct TyphoonState {
     TyphoonCchip cchip;
     TyphoonPchip pchip;
     MemoryRegion dchip_region;
-    MemoryRegion ram_region;
 } TyphoonState;
 
 /* Called when one of DRIR or DIM changes.  */
@@ -817,7 +816,7 @@ static void typhoon_alarm_timer(void *opaque)
     cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER);
 }
 
-PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
+PCIBus *typhoon_init(ISABus **isa_bus,
                      qemu_irq *p_rtc_irq,
                      AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
 {
@@ -849,12 +848,6 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus,
 
     *p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
 
-    /* Main memory region, 0x00.0000.0000.  Real hardware supports 32GB,
-       but the address space hole reserved at this point is 8TB.  */
-    memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram",
-                                         ram_size);
-    memory_region_add_subregion(addr_space, 0, &s->ram_region);
-
     /* TIGbus, 0x801.0000.0000, 1GB.  */
     /* ??? The TIGbus is used for delivering interrupts, and access to
        the flash ROM.  I'm not sure that we need to implement it at 

all. */
---

#35 lore raw

PATCH 12/21 hw/arm: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/arm/aspeed.c           | 2 +-
 hw/arm/collie.c           | 2 +-
 hw/arm/cubieboard.c       | 2 +-
 hw/arm/digic_boards.c     | 7 ++++---
 hw/arm/highbank.c         | 3 ++-
 hw/arm/imx25_pdk.c        | 2 +-
 hw/arm/integratorcp.c     | 2 +-
 hw/arm/kzm.c              | 2 +-
 hw/arm/mcimx6ul-evk.c     | 2 +-
 hw/arm/mcimx7d-sabre.c    | 2 +-
 hw/arm/mps2-tz.c          | 4 ++--
 hw/arm/mps2.c             | 4 ++--
 hw/arm/musicpal.c         | 2 +-
 hw/arm/nseries.c          | 2 +-
 hw/arm/omap_sx1.c         | 2 +-
 hw/arm/palm.c             | 2 +-
 hw/arm/raspi.c            | 2 +-
 hw/arm/sabrelite.c        | 2 +-
 hw/arm/sbsa-ref.c         | 2 +-
 hw/arm/versatilepb.c      | 2 +-
 hw/arm/vexpress.c         | 4 ++--
 hw/arm/virt.c             | 2 +-
 hw/arm/xilinx_zynq.c      | 2 +-
 hw/arm/xlnx-versal-virt.c | 2 +-
 hw/arm/xlnx-zcu102.c      | 2 +-
 25 files changed, 32 insertions(+), 30 deletions(-)
hw/arm/aspeed.c +1 -1
index 52993f84b4..f2a52e1ade 100644
@@ -212,7 +212,7 @@ static void aspeed_board_init(MachineState *machine,
     ram_size = object_property_get_uint(OBJECT(&bmc->soc), "ram-size",
                                         &error_abort);
 
-    memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
+    memory_region_allocate_system_memory(&bmc->ram, machine, "ram", ram_size);
     memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram);
     memory_region_add_subregion(get_system_memory(),
                                 sc->memmap[ASPEED_SDRAM],
hw/arm/collie.c +1 -1
index 970a4405cc..632531a88d 100644
@@ -31,7 +31,7 @@ static void collie_init(MachineState *machine)
 
     s = sa1110_init(machine->cpu_type);
 
-    memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram",
+    memory_region_allocate_system_memory(sdram, machine, "strongarm.sdram",
                                          collie_binfo.ram_size);
     memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram);
 
hw/arm/cubieboard.c +1 -1
index 6dc2f1d6b6..b76ad7ef69 100644
@@ -65,7 +65,7 @@ static void cubieboard_init(MachineState *machine)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(&s->sdram, NULL, "cubieboard.ram",
+    memory_region_allocate_system_memory(&s->sdram, machine, "cubieboard.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
                                 &s->sdram);
hw/arm/digic_boards.c +4 -3
index ef3fc2b6a5..f3d1febe87 100644
@@ -53,7 +53,7 @@ typedef struct DigicBoard {
     const char *rom1_def_filename;
 } DigicBoard;
 
-static void digic4_board_init(DigicBoard *board)
+static void digic4_board_init(MachineState *machine, DigicBoard *board)
 {
     Error *err = NULL;
 
@@ -66,7 +66,8 @@ static void digic4_board_init(DigicBoard *board)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "ram", board->ram_size);
+    memory_region_allocate_system_memory(&s->ram, machine, "ram",
+                                         board->ram_size);
     memory_region_add_subregion(get_system_memory(), 0, &s->ram);
 
     if (board->add_rom0) {
@@ -142,7 +143,7 @@ static DigicBoard digic4_board_canon_a1100 = {
 
 static void canon_a1100_init(MachineState *machine)
 {
-    digic4_board_init(&digic4_board_canon_a1100);
+    digic4_board_init(machine, &digic4_board_canon_a1100);
 }
 
 static void canon_a1100_machine_init(MachineClass *mc)
hw/arm/highbank.c +2 -1
index f1724d6929..57e549ec00 100644
@@ -290,7 +290,8 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
 
     sysmem = get_system_memory();
     dram = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(dram, NULL, "highbank.dram", ram_size);
+    memory_region_allocate_system_memory(dram, machine, "highbank.dram",
+                                         ram_size);
     /* SDRAM at address zero.  */
     memory_region_add_subregion(sysmem, 0, dram);
 
hw/arm/imx25_pdk.c +1 -1
index c76fc2bd94..e88d325e10 100644
@@ -84,7 +84,7 @@ static void imx25_pdk_init(MachineState *machine)
         machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE;
     }
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "imx25.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), FSL_IMX25_SDRAM0_ADDR,
                                 &s->ram);
hw/arm/integratorcp.c +1 -1
index 524970840d..a8053be396 100644
@@ -605,7 +605,7 @@ static void integratorcp_init(MachineState *machine)
 
     cpu = ARM_CPU(cpuobj);
 
-    memory_region_allocate_system_memory(ram, NULL, "integrator.ram",
+    memory_region_allocate_system_memory(ram, machine, "integrator.ram",
                                          ram_size);
     /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash.  */
     /* ??? RAM should repeat to fill physical memory space.  */
hw/arm/kzm.c +1 -1
index 1d5ef289d5..e81bd8e0dc 100644
@@ -84,7 +84,7 @@ static void kzm_init(MachineState *machine)
         machine->ram_size = FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE;
     }
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "kzm.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR,
                                 &s->ram);
hw/arm/mcimx6ul-evk.c +1 -1
index e90b393a44..95653db599 100644
@@ -48,7 +48,7 @@ static void mcimx6ul_evk_init(MachineState *machine)
 
     object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "mcimx6ul-evk.ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "mcimx6ul-evk.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(),
                                 FSL_IMX6UL_MMDC_ADDR, &s->ram);
hw/arm/mcimx7d-sabre.c +1 -1
index 0d1f62d30a..d535a119f7 100644
@@ -50,7 +50,7 @@ static void mcimx7d_sabre_init(MachineState *machine)
                             TYPE_FSL_IMX7, &error_fatal, NULL);
     object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal);
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "mcimx7d-sabre.ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "mcimx7d-sabre.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(),
                                 FSL_IMX7_MMDC_ADDR, &s->ram);
hw/arm/mps2-tz.c +2 -2
index f8b620bcc6..96fe815361 100644
@@ -458,8 +458,8 @@ static void mps2tz_common_init(MachineState *machine)
      * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily
      * call the 16MB our "system memory", as it's the largest lump.
      */
-    memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 16 * MiB);
+    memory_region_allocate_system_memory(&mms->psram, machine,
+                                         "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x80000000, &mms->psram);
 
     /* The overflow IRQs for all UARTs are ORed together.
hw/arm/mps2.c +2 -2
index d002b126d3..4687bc7ed1 100644
@@ -146,8 +146,8 @@ static void mps2_common_init(MachineState *machine)
      * This is of no use for QEMU so we don't implement it (as if
      * zbt_boot_ctrl is always zero).
      */
-    memory_region_allocate_system_memory(&mms->psram,
-                                         NULL, "mps.ram", 16 * MiB);
+    memory_region_allocate_system_memory(&mms->psram, machine,
+                                         "mps.ram", 16 * MiB);
     memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
 
     switch (mmc->fpga_type) {
hw/arm/musicpal.c +1 -1
index f68a399a98..2a2c7b3abf 100644
@@ -1596,7 +1596,7 @@ static void musicpal_init(MachineState *machine)
     cpu = ARM_CPU(cpu_create(machine->cpu_type));
 
     /* For now we use a fixed - the original - RAM size */
-    memory_region_allocate_system_memory(ram, NULL, "musicpal.ram",
+    memory_region_allocate_system_memory(ram, machine, "musicpal.ram",
                                          MP_RAM_DEFAULT_SIZE);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
hw/arm/nseries.c +1 -1
index 11f2c193f3..8ab30fde24 100644
@@ -1315,7 +1315,7 @@ static void n8x0_init(MachineState *machine,
     struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s));
     uint64_t sdram_size = binfo->ram_size;
 
-    memory_region_allocate_system_memory(sdram, NULL, "omap2.dram",
+    memory_region_allocate_system_memory(sdram, machine, "omap2.dram",
                                          sdram_size);
     memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, sdram);
 
hw/arm/omap_sx1.c +1 -1
index be245714db..26f4e1834b 100644
@@ -119,7 +119,7 @@ static void sx1_init(MachineState *machine, const int version)
         flash_size = flash2_size;
     }
 
-    memory_region_allocate_system_memory(dram, NULL, "omap1.dram",
+    memory_region_allocate_system_memory(dram, machine, "omap1.dram",
                                          sx1_binfo.ram_size);
     memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, dram);
 
hw/arm/palm.c +1 -1
index 72eca8cc55..dceb4ab6a8 100644
@@ -199,7 +199,7 @@ static void palmte_init(MachineState *machine)
     MemoryRegion *flash = g_new(MemoryRegion, 1);
     MemoryRegion *cs = g_new(MemoryRegion, 4);
 
-    memory_region_allocate_system_memory(dram, NULL, "omap1.dram",
+    memory_region_allocate_system_memory(dram, machine, "omap1.dram",
                                          palmte_binfo.ram_size);
     memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, dram);
 
hw/arm/raspi.c +1 -1
index f76b6eaad3..6f1520bad6 100644
@@ -182,7 +182,7 @@ static void raspi_init(MachineState *machine, int version)
                             &error_abort, NULL);
 
     /* Allocate and map RAM */
-    memory_region_allocate_system_memory(&s->ram, NULL, "ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "ram",
                                          machine->ram_size);
     /* FIXME: Remove when we have custom CPU address space support */
     memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0);
hw/arm/sabrelite.c +1 -1
index 96cc455c5c..dfeffcb2a7 100644
@@ -64,7 +64,7 @@ static void sabrelite_init(MachineState *machine)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(&s->ram, NULL, "sabrelite.ram",
+    memory_region_allocate_system_memory(&s->ram, machine, "sabrelite.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
                                 &s->ram);
hw/arm/sbsa-ref.c +1 -1
index 27046cc284..1d4db8d7fd 100644
@@ -687,7 +687,7 @@ static void sbsa_ref_init(MachineState *machine)
         object_unref(cpuobj);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
+    memory_region_allocate_system_memory(ram, machine, "sbsa-ref.ram",
                                          machine->ram_size);
     memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
 
hw/arm/versatilepb.c +1 -1
index e86af01537..5cde8e3677 100644
@@ -220,7 +220,7 @@ static void versatile_init(MachineState *machine, int board_id)
 
     cpu = ARM_CPU(cpuobj);
 
-    memory_region_allocate_system_memory(ram, NULL, "versatile.ram",
+    memory_region_allocate_system_memory(ram, machine, "versatile.ram",
                                          machine->ram_size);
     /* ??? RAM should repeat to fill physical memory space.  */
     /* SDRAM at address zero.  */
hw/arm/vexpress.c +2 -2
index 4673a88a8d..b97770cc68 100644
@@ -283,7 +283,7 @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
         exit(1);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem",
+    memory_region_allocate_system_memory(ram, machine, "vexpress.highmem",
                                          ram_size);
     low_ram_size = ram_size;
     if (low_ram_size > 0x4000000) {
@@ -375,7 +375,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
         }
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem",
+    memory_region_allocate_system_memory(ram, machine, "vexpress.highmem",
                                          ram_size);
     /* RAM is from 0x80000000 upwards; there is no low-memory alias for it. */
     memory_region_add_subregion(sysmem, 0x80000000, ram);
hw/arm/virt.c +1 -1
index d4bedc2607..917d5549c1 100644
@@ -1702,7 +1702,7 @@ static void machvirt_init(MachineState *machine)
         }
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
+    memory_region_allocate_system_memory(ram, machine, "mach-virt.ram",
                                          machine->ram_size);
     memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
     if (machine->device_memory) {
hw/arm/xilinx_zynq.c +1 -1
index 3a0fa5b23f..abb3162cfc 100644
@@ -190,7 +190,7 @@ static void zynq_init(MachineState *machine)
     }
 
     /* DDR remapped to address zero.  */
-    memory_region_allocate_system_memory(ext_ram, NULL, "zynq.ext_ram",
+    memory_region_allocate_system_memory(ext_ram, machine, "zynq.ext_ram",
                                          ram_size);
     memory_region_add_subregion(address_space_mem, 0, ext_ram);
 
hw/arm/xlnx-versal-virt.c +1 -1
index 462493c467..565a52bdab 100644
@@ -414,7 +414,7 @@ static void versal_virt_init(MachineState *machine)
         psci_conduit = QEMU_PSCI_CONDUIT_SMC;
     }
 
-    memory_region_allocate_system_memory(&s->mr_ddr, NULL, "ddr",
+    memory_region_allocate_system_memory(&s->mr_ddr, machine, "ddr",
                                          machine->ram_size);
 
     sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc,
hw/arm/xlnx-zcu102.c +1 -1
index 53cfe7c1f1..0de41adb75 100644
@@ -87,7 +87,7 @@ static void xlnx_zcu102_init(MachineState *machine)
                  ram_size);
     }
 
-    memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram",
+    memory_region_allocate_system_memory(&s->ddr_ram, machine, "ddr-ram",
                                          ram_size);
 
     object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc),
Signature · 1 line
2.21.0
#36 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Quoted 5 lines · Philippe Mathieu-Daudé

---

 hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

thanks
-- PMM

#37 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Quoted 5 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

---

Quoted 7 lines
Quoted 1 line
  hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

It seems to still works:

$ make check-qtest-aarch64 V=1
QTEST_QEMU_BINARY=aarch64-softmmu/qemu-system-aarch64 QTEST_QEMU_IMG=qemu-img tests/migration-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="migration-test"
PASS 1 migration-test /aarch64/migration/deprecated
PASS 2 migration-test /aarch64/migration/bad_dest
PASS 3 migration-test /aarch64/migration/fd_proto
PASS 4 migration-test /aarch64/migration/validate_uuid
PASS 5 migration-test /aarch64/migration/validate_uuid_error
PASS 6 migration-test /aarch64/migration/validate_uuid_src_not_set
PASS 7 migration-test /aarch64/migration/validate_uuid_dst_not_set
PASS 8 migration-test /aarch64/migration/auto_converge
PASS 9 migration-test /aarch64/migration/postcopy/unix
PASS 10 migration-test /aarch64/migration/postcopy/recovery
PASS 11 migration-test /aarch64/migration/precopy/unix
PASS 12 migration-test /aarch64/migration/precopy/tcp
PASS 13 migration-test /aarch64/migration/xbzrle/unix

This test migrate the virt machine.

Is this enough?

Regards,

Phil.

#38 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

---

Quoted 7 lines
Quoted 1 line
  hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

Quoted 7 lines

It seems to still works:

$ make check-qtest-aarch64 V=1

This test migrate the virt machine.

Is this enough?

No, you need to test migration from a QEMU binary without this patchset to a QEMU binary that has it. Otherwise you're only checking that the new version can migrate from itself to itself. I find the easiest way to test this is just to use the 'savevm' command to save a state snapshot to a qcow2 disk image while running the old binary, and then run 'loadvm' with the new binary and check it restored OK.

thanks
-- PMM

#39 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Cc'ing Paolo/David.

Quoted 24 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

---

Quoted 7 lines
Quoted 1 line
   hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

Quoted 7 lines

It seems to still works:

$ make check-qtest-aarch64 V=1

This test migrate the virt machine.

Is this enough?

Quoted 7 lines

No, you need to test migration from a QEMU binary without this patchset to a QEMU binary that has it. Otherwise you're only checking that the new version can migrate from itself to itself. I find the easiest way to test this is just to use the 'savevm' command to save a state snapshot to a qcow2 disk image while running the old binary, and then run 'loadvm' with the new binary and check it restored OK.

I did not think if this case.

I followed your blog post [*] and tested the migration works OK.

Paolo, now thinking about regular testing, we should add this testing to patchew too. Something like:

- when mainstream/master is updated, patchew build QEMU (it should be already mostly ccached) and generate some vm dumps with 'savevm'.

- build/test the series

- if series succeeded testing, run 'loadvm' tests

[*] https://translatedcode.wordpress.com/2015/07/06/tricks-for-debugging-qemu-savevm-snapshots/

#40 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Quoted 42 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:

Cc'ing Paolo/David.

Quoted 24 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

---

Quoted 7 lines
Quoted 1 line
   hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

Quoted 7 lines

It seems to still works:

$ make check-qtest-aarch64 V=1

This test migrate the virt machine.

Is this enough?

Quoted 7 lines

No, you need to test migration from a QEMU binary without this patchset to a QEMU binary that has it. Otherwise you're only checking that the new version can migrate from itself to itself. I find the easiest way to test this is just to use the 'savevm' command to save a state snapshot to a qcow2 disk image while running the old binary, and then run 'loadvm' with the new binary and check it restored OK.

I did not think if this case.

I followed your blog post [*] and tested the migration works OK.

Paolo, now thinking about regular testing, we should add this testing to patchew too. Something like:

Quoted 8 lines

- when mainstream/master is updated, patchew build QEMU (it should be already mostly ccached) and generate some vm dumps with 'savevm'.

- build/test the series

- if series succeeded testing, run 'loadvm' tests

[*] https://translatedcode.wordpress.com/2015/07/06/tricks-for-debugging-qemu-savevm-snapshots/

Avocado certainly already has an option for specifying source and destination qemu separately; I've used that for testing cross version in the past.

The challenge is finding a command line/set of devices for each architecture that's expected to be stable.
You want a command line with as big a set of devices as possible (for coverage) yet really is tied to machine type.

Dave

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

#41 lore raw

Re: [PATCH 12/21] hw/arm: Let the machine be the owner of the system memory

Cc'ing avocado-devel for test idea.

Quoted 66 lines · Dr. David Alan Gilbert
Quoted 42 lines · * Philippe Mathieu-Daudé ([email protected]) wrote:

Cc'ing Paolo/David.

Quoted 24 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Peter Maydell
Quoted 3 lines · Philippe Mathieu-Daudé

---

Quoted 7 lines
Quoted 1 line
   hw/arm/virt.c             | 2 +-

I think from a quick code scan that this is ok, but did you test that migration compat from old to new still works? I vaguely recall that there are some cases when adding an owner to a memory region changes the name string used for identifying the ramblock in migration.

Quoted 7 lines

It seems to still works:

$ make check-qtest-aarch64 V=1

This test migrate the virt machine.

Is this enough?

Quoted 7 lines

No, you need to test migration from a QEMU binary without this patchset to a QEMU binary that has it. Otherwise you're only checking that the new version can migrate from itself to itself. I find the easiest way to test this is just to use the 'savevm' command to save a state snapshot to a qcow2 disk image while running the old binary, and then run 'loadvm' with the new binary and check it restored OK.

I did not think if this case.

I followed your blog post [*] and tested the migration works OK.

Paolo, now thinking about regular testing, we should add this testing to patchew too. Something like:

Quoted 8 lines

- when mainstream/master is updated, patchew build QEMU (it should be already mostly ccached) and generate some vm dumps with 'savevm'.

- build/test the series

- if series succeeded testing, run 'loadvm' tests

[*] https://translatedcode.wordpress.com/2015/07/06/tricks-for-debugging-qemu-savevm-snapshots/

Avocado certainly already has an option for specifying source and destination qemu separately; I've used that for testing cross version in the past.

The challenge is finding a command line/set of devices for each architecture that's expected to be stable.
You want a command line with as big a set of devices as possible (for coverage) yet really is tied to machine type.

Dave

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

#42 lore raw

PATCH 13/21 hw/cris: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/cris/axis_dev88.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/cris/axis_dev88.c +1 -1
index 940c7dd122..faa7058733 100644
@@ -270,7 +270,7 @@ void axisdev88_init(MachineState *machine)
     env = &cpu->env;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(phys_ram, NULL, "axisdev88.ram",
+    memory_region_allocate_system_memory(phys_ram, machine, "axisdev88.ram",
                                          ram_size);
     memory_region_add_subregion(address_space_mem, 0x40000000, phys_ram);
 
Signature · 1 line
2.21.0
Reviewed-by on v1 13/21
#44 lore raw

Re: [PATCH 13/21] hw/cris: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 21 lines
---
 hw/cris/axis_dev88.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/cris/axis_dev88.c +1 -2
index 940c7dd122..faa7058733 100644
@@ -270,7 +270,7 @@ void axisdev88_init(MachineState *machine)
     env = &cpu->env;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(phys_ram, NULL, "axisdev88.ram",
+    memory_region_allocate_system_memory(phys_ram, machine, "axisdev88.ram",
                                          ram_size);
     memory_region_add_subregion(address_space_mem, 0x40000000, phys_ram);
 
--

2.21.0

#45 lore raw

PATCH 14/21 hw/hppa: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/hppa/machine.c +1 -1
index dbe1ff0fe5..6703bfd351 100644
@@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Main memory region. */
     ram_region = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram_region, NULL,
+    memory_region_allocate_system_memory(ram_region, machine,
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
Signature · 1 line
2.21.0
Reviewed-by on v1 14/21
#47 lore raw

Re: [PATCH 14/21] hw/hppa: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 21 lines
---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/hppa/machine.c +1 -2
index dbe1ff0fe5..6703bfd351 100644
@@ -96,7 +96,7 @@ static void machine_hppa_init(MachineState *machine)
 
     /* Main memory region. */
     ram_region = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram_region, NULL,
+    memory_region_allocate_system_memory(ram_region, machine,
                                          "ram", ram_size);
     memory_region_add_subregion(addr_space, 0, ram_region);
 
--

2.21.0

#48 lore raw

PATCH 15/21 hw/i386: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/i386/pc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc.c +1 -1
index 4b1904237e..3414dc423a 100644
@@ -1655,7 +1655,7 @@ void pc_memory_init(PCMachineState *pcms,
      * with older qemus that used qemu_ram_alloc().
      */
     ram = g_malloc(sizeof(*ram));
-    memory_region_allocate_system_memory(ram, NULL, "pc.ram",
+    memory_region_allocate_system_memory(ram, machine, "pc.ram",
                                          machine->ram_size);
     *ram_memory = ram;
     ram_below_4g = g_malloc(sizeof(*ram_below_4g));
Signature · 1 line
2.21.0
Reviewed-by on v1 15/21
#50 lore raw

Re: [PATCH 15/21] hw/i386: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 21 lines
---
 hw/i386/pc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc.c +1 -2
index 4b1904237e..3414dc423a 100644
@@ -1655,7 +1655,7 @@ void pc_memory_init(PCMachineState *pcms,
      * with older qemus that used qemu_ram_alloc().
      */
     ram = g_malloc(sizeof(*ram));
-    memory_region_allocate_system_memory(ram, NULL, "pc.ram",
+    memory_region_allocate_system_memory(ram, machine, "pc.ram",
                                          machine->ram_size);
     *ram_memory = ram;
     ram_below_4g = g_malloc(sizeof(*ram_below_4g));
--

2.21.0

#51 lore raw

PATCH 16/21 hw/lm32: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/lm32/lm32_boards.c | 4 ++--
 hw/lm32/milkymist.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/lm32/lm32_boards.c +2 -2
index 5ae308bfcf..50b607e0cc 100644
@@ -107,7 +107,7 @@ static void lm32_evr_init(MachineState *machine)
 
     reset_info->flash_base = flash_base;
 
-    memory_region_allocate_system_memory(phys_ram, NULL, "lm32_evr.sdram",
+    memory_region_allocate_system_memory(phys_ram, machine, "lm32_evr.sdram",
                                          ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
@@ -200,7 +200,7 @@ static void lm32_uclinux_init(MachineState *machine)
 
     reset_info->flash_base = flash_base;
 
-    memory_region_allocate_system_memory(phys_ram, NULL,
+    memory_region_allocate_system_memory(phys_ram, machine,
                                          "lm32_uclinux.sdram", ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
hw/lm32/milkymist.c +1 -1
index 460d322de5..ee2eb1877e 100644
@@ -116,7 +116,7 @@ milkymist_init(MachineState *machine)
 
     cpu_lm32_set_phys_msb_ignore(env, 1);
 
-    memory_region_allocate_system_memory(phys_sdram, NULL, "milkymist.sdram",
+    memory_region_allocate_system_memory(phys_sdram, machine, "milkymist.sdram",
                                          sdram_size);
     memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
 
Signature · 1 line
2.21.0
Reviewed-by on v1 16/21
#53 lore raw

Re: [PATCH 16/21] hw/lm32: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 44 lines
---
 hw/lm32/lm32_boards.c | 4 ++--
 hw/lm32/milkymist.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/lm32/lm32_boards.c +2 -2
index 5ae308bfcf..50b607e0cc 100644
@@ -107,7 +107,7 @@ static void lm32_evr_init(MachineState *machine)
 
     reset_info->flash_base = flash_base;
 
-    memory_region_allocate_system_memory(phys_ram, NULL, "lm32_evr.sdram",
+    memory_region_allocate_system_memory(phys_ram, machine, "lm32_evr.sdram",
                                          ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
@@ -200,7 +200,7 @@ static void lm32_uclinux_init(MachineState *machine)
 
     reset_info->flash_base = flash_base;
 
-    memory_region_allocate_system_memory(phys_ram, NULL,
+    memory_region_allocate_system_memory(phys_ram, machine,
                                          "lm32_uclinux.sdram", ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
hw/lm32/milkymist.c +1 -2
index 460d322de5..ee2eb1877e 100644
@@ -116,7 +116,7 @@ milkymist_init(MachineState *machine)
 
     cpu_lm32_set_phys_msb_ignore(env, 1);
 
-    memory_region_allocate_system_memory(phys_sdram, NULL, "milkymist.sdram",
+    memory_region_allocate_system_memory(phys_sdram, machine, "milkymist.sdram",
                                          sdram_size);
     memory_region_add_subregion(address_space_mem, sdram_base, phys_sdram);
 
--

2.21.0

#54 lore raw

PATCH 17/21 hw/m68k: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/m68k/an5206.c    | 2 +-
 hw/m68k/mcf5208.c   | 2 +-
 hw/m68k/next-cube.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/m68k/an5206.c +1 -1
index 54ccbe1a82..fb045c2436 100644
@@ -46,7 +46,7 @@ static void an5206_init(MachineState *machine)
     env->rambar0 = AN5206_RAMBAR_ADDR | 1;
 
     /* DRAM at address zero */
-    memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "an5206.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     /* Internal SRAM.  */
hw/m68k/mcf5208.c +1 -1
index 34d34eba17..8e8c8ef349 100644
@@ -248,7 +248,7 @@ static void mcf5208evb_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0x00000000, rom);
 
     /* DRAM at 0x40000000 */
-    memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mcf5208.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0x40000000, ram);
 
     /* Internal SRAM.  */
hw/m68k/next-cube.c +1 -1
index e5343348d0..6aed9376f3 100644
@@ -893,7 +893,7 @@ static void next_cube_init(MachineState *machine)
     memcpy(ns->rtc.ram, rtc_ram2, 32);
 
     /* 64MB RAM starting at 0x04000000  */
-    memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "next.ram", ram_size);
     memory_region_add_subregion(sysmem, 0x04000000, ram);
 
     /* Framebuffer */
Signature · 1 line
2.21.0
Reviewed-by on v1 17/21
#55 lore raw

Re: [PATCH 17/21] hw/m68k: Let the machine be the owner of the system memory

Quoted 39 lines · Philippe Mathieu-Daudé
---
 hw/m68k/an5206.c    | 2 +-
 hw/m68k/mcf5208.c   | 2 +-
 hw/m68k/next-cube.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/m68k/an5206.c +1 -1
index 54ccbe1a82..fb045c2436 100644
@@ -46,7 +46,7 @@ static void an5206_init(MachineState *machine)
     env->rambar0 = AN5206_RAMBAR_ADDR | 1;
 
     /* DRAM at address zero */
-    memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "an5206.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     /* Internal SRAM.  */
hw/m68k/mcf5208.c +1 -1
index 34d34eba17..8e8c8ef349 100644
@@ -248,7 +248,7 @@ static void mcf5208evb_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0x00000000, rom);
 
     /* DRAM at 0x40000000 */
-    memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mcf5208.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0x40000000, ram);
 
     /* Internal SRAM.  */
hw/m68k/next-cube.c +0 -0
index e5343348d0..6aed9376f3 100644

hw/m68k/next-cube.c static void next_cube_init(MachineState *machine) · line 899

Quoted 8 lines
hw/m68k/next-cube.c +1 -1
@@ -893,7 +893,7 @@ static void next_cube_init(MachineState *machine)
     memcpy(ns->rtc.ram, rtc_ram2, 32);
 
     /* 64MB RAM starting at 0x04000000  */
-    memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "next.ram", ram_size);
     memory_region_add_subregion(sysmem, 0x04000000, ram);
 
     /* Framebuffer */
Reviewed-by on v1 17/21
#57 lore raw

Re: [PATCH 17/21] hw/m68k: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Alistair

Quoted 49 lines
---
 hw/m68k/an5206.c    | 2 +-
 hw/m68k/mcf5208.c   | 2 +-
 hw/m68k/next-cube.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/m68k/an5206.c +1 -1
index 54ccbe1a82..fb045c2436 100644
@@ -46,7 +46,7 @@ static void an5206_init(MachineState *machine)
     env->rambar0 = AN5206_RAMBAR_ADDR | 1;
 
     /* DRAM at address zero */
-    memory_region_allocate_system_memory(ram, NULL, "an5206.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "an5206.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     /* Internal SRAM.  */
hw/m68k/mcf5208.c +1 -1
index 34d34eba17..8e8c8ef349 100644
@@ -248,7 +248,7 @@ static void mcf5208evb_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, 0x00000000, rom);
 
     /* DRAM at 0x40000000 */
-    memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mcf5208.ram", ram_size);
     memory_region_add_subregion(address_space_mem, 0x40000000, ram);
 
     /* Internal SRAM.  */
hw/m68k/next-cube.c +1 -2
index e5343348d0..6aed9376f3 100644
@@ -893,7 +893,7 @@ static void next_cube_init(MachineState *machine)
     memcpy(ns->rtc.ram, rtc_ram2, 32);
 
     /* 64MB RAM starting at 0x04000000  */
-    memory_region_allocate_system_memory(ram, NULL, "next.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "next.ram", ram_size);
     memory_region_add_subregion(sysmem, 0x04000000, ram);
 
     /* Framebuffer */
--

2.21.0

#58 lore raw

PATCH 18/21 hw/mips: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/mips/boston.c        | 2 +-
 hw/mips/mips_fulong2e.c | 3 ++-
 hw/mips/mips_jazz.c     | 2 +-
 hw/mips/mips_malta.c    | 2 +-
 hw/mips/mips_mipssim.c  | 2 +-
 hw/mips/mips_r4k.c      | 3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)
hw/mips/boston.c +1 -1
index ca7d813a52..8445fee0f1 100644
@@ -474,7 +474,7 @@ static void boston_mach_init(MachineState *machine)
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     ddr = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
+    memory_region_allocate_system_memory(ddr, machine, "boston.ddr",
                                          machine->ram_size);
     memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0);
 
hw/mips/mips_fulong2e.c +2 -1
index cf537dd7e6..d5a5cef619 100644
@@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState *machine)
     ram_size = 256 * MiB;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine,
+                                         "fulong2e.ram", ram_size);
     memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE,
                            &error_fatal);
     memory_region_set_readonly(bios, true);
hw/mips/mips_jazz.c +1 -1
index 8d010a0b6e..88b125855f 100644
@@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState *machine,
     cc->do_transaction_failed = mips_jazz_do_transaction_failed;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram",
+    memory_region_allocate_system_memory(ram, machine, "mips_jazz.ram",
                                          machine->ram_size);
     memory_region_add_subregion(address_space, 0, ram);
 
hw/mips/mips_malta.c +1 -1
index 4d9c64b36a..af56a29ccb 100644
@@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState *machine)
     }
 
     /* register RAM at high address where it is undisturbed by IO */
-    memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
+    memory_region_allocate_system_memory(ram_high, machine, "mips_malta.ram",
                                          ram_size);
     memory_region_add_subregion(system_memory, 0x80000000, ram_high);
 
hw/mips/mips_mipssim.c +1 -1
index 282bbecb24..c1933231e2 100644
@@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* Allocate RAM. */
-    memory_region_allocate_system_memory(ram, NULL, "mips_mipssim.ram",
+    memory_region_allocate_system_memory(ram, machine, "mips_mipssim.ram",
                                          ram_size);
     memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE,
                            &error_fatal);
hw/mips/mips_r4k.c +2 -1
index bc0be26544..59f8cacfb6 100644
@@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                      " maximum 256MB", ram_size / MiB);
         exit(1);
     }
-    memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mips_r4k.ram",
+                                         ram_size);
 
     memory_region_add_subregion(address_space_mem, 0, ram);
 
Signature · 1 line
2.21.0
#59 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 11 lines · Philippe Mathieu-Daudé
---
 hw/mips/boston.c        | 2 +-
 hw/mips/mips_fulong2e.c | 3 ++-
 hw/mips/mips_jazz.c     | 2 +-
 hw/mips/mips_malta.c    | 2 +-
 hw/mips/mips_mipssim.c  | 2 +-
 hw/mips/mips_r4k.c      | 3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)

Philippe, can this patch be applied independently (on other patches of this series)?

Thanks,
A.

Quoted 90 lines
hw/mips/boston.c +1 -1
index ca7d813a52..8445fee0f1 100644
@@ -474,7 +474,7 @@ static void boston_mach_init(MachineState *machine)
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     ddr = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
+    memory_region_allocate_system_memory(ddr, machine, "boston.ddr",
                                          machine->ram_size);
     memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0);
 
hw/mips/mips_fulong2e.c +2 -1
index cf537dd7e6..d5a5cef619 100644
@@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState *machine)
     ram_size = 256 * MiB;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram",
 ram_size);
+    memory_region_allocate_system_memory(ram, machine,
+                                         "fulong2e.ram", ram_size);
     memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE,
                            &error_fatal);
     memory_region_set_readonly(bios, true);
hw/mips/mips_jazz.c +1 -1
index 8d010a0b6e..88b125855f 100644
@@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState *machine,
     cc->do_transaction_failed = mips_jazz_do_transaction_failed;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram",
+    memory_region_allocate_system_memory(ram, machine, "mips_jazz.ram",
                                          machine->ram_size);
     memory_region_add_subregion(address_space, 0, ram);
 
hw/mips/mips_malta.c +1 -1
index 4d9c64b36a..af56a29ccb 100644
@@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState *machine)
     }
 
     /* register RAM at high address where it is undisturbed by IO */
-    memory_region_allocate_system_memory(ram_high, NULL,
 "mips_malta.ram",
+    memory_region_allocate_system_memory(ram_high, machine,
 "mips_malta.ram",
                                          ram_size);
     memory_region_add_subregion(system_memory, 0x80000000, ram_high);
hw/mips/mips_mipssim.c +1 -1
index 282bbecb24..c1933231e2 100644
@@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* Allocate RAM. */
-    memory_region_allocate_system_memory(ram, NULL, "mips_mipssim.ram",
+    memory_region_allocate_system_memory(ram, machine,
 "mips_mipssim.ram",
                                          ram_size);
     memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE,
                            &error_fatal);
hw/mips/mips_r4k.c +2 -2
index bc0be26544..59f8cacfb6 100644
@@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                      " maximum 256MB", ram_size / MiB);
         exit(1);
     }
-    memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram",
 ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mips_r4k.ram",
+                                         ram_size);
 
     memory_region_add_subregion(address_space_mem, 0, ram);
 
--

2.21.0

#60 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Hi Aleksandar,

Quoted 16 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

<mailto:[email protected]>>
---
 hw/mips/boston.c        | 2 +- hw/mips/mips_fulong2e.c | 3 ++- hw/mips/mips_jazz.c     | 2 +- hw/mips/mips_malta.c    | 2 +- hw/mips/mips_mipssim.c  | 2 +- hw/mips/mips_r4k.c      | 3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)

Quoted 1 line

Philippe, can this patch be applied independently (on other patches of this series)?

Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

I rather expect this series goes as a whole via the machine-next tree.

Do you mind giving your Acked-by tag to this patch?

Thanks,

Phil.

Quoted 93 lines

    diff --git a/hw/mips/boston.c b/hw/mips/boston.c
    index ca7d813a52..8445fee0f1 100644
    --- a/hw/mips/boston.c
    +++ b/hw/mips/boston.c
    @@ -474,7 +474,7 @@ static void boston_mach_init(MachineState *machine)
          memory_region_add_subregion_overlap(sys_mem, 0x18000000,
    flash, 0);

          ddr = g_new(MemoryRegion, 1);
    -    memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
    +    memory_region_allocate_system_memory(ddr, machine, "boston.ddr",
                                               machine->ram_size);
          memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0);

    diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
    index cf537dd7e6..d5a5cef619 100644
    --- a/hw/mips/mips_fulong2e.c
    +++ b/hw/mips/mips_fulong2e.c
    @@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState
    *machine)
          ram_size = 256 * MiB;

          /* allocate RAM */
    -    memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram",
    ram_size);
    +    memory_region_allocate_system_memory(ram, machine,
    +                                         "fulong2e.ram", ram_size);
          memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE,
                                 &error_fatal);
          memory_region_set_readonly(bios, true);
    diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
    index 8d010a0b6e..88b125855f 100644
    --- a/hw/mips/mips_jazz.c
    +++ b/hw/mips/mips_jazz.c
    @@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState *machine,
          cc->do_transaction_failed = mips_jazz_do_transaction_failed;

          /* allocate RAM */
    -    memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram",
    +    memory_region_allocate_system_memory(ram, machine, "mips_jazz.ram",
                                               machine->ram_size);
          memory_region_add_subregion(address_space, 0, ram);

    diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
    index 4d9c64b36a..af56a29ccb 100644
    --- a/hw/mips/mips_malta.c
    +++ b/hw/mips/mips_malta.c
    @@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState *machine)
          }

          /* register RAM at high address where it is undisturbed by IO */
    -    memory_region_allocate_system_memory(ram_high, NULL,
    "mips_malta.ram",
    +    memory_region_allocate_system_memory(ram_high, machine,
    "mips_malta.ram",
                                               ram_size);
          memory_region_add_subregion(system_memory, 0x80000000, ram_high);

    diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c
    index 282bbecb24..c1933231e2 100644
    --- a/hw/mips/mips_mipssim.c
    +++ b/hw/mips/mips_mipssim.c
    @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
          qemu_register_reset(main_cpu_reset, reset_info);

          /* Allocate RAM. */
    -    memory_region_allocate_system_memory(ram, NULL, "mips_mipssim.ram",
    +    memory_region_allocate_system_memory(ram, machine,
    "mips_mipssim.ram",
                                               ram_size);
          memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE,
                                 &error_fatal);
    diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
    index bc0be26544..59f8cacfb6 100644
    --- a/hw/mips/mips_r4k.c
    +++ b/hw/mips/mips_r4k.c
    @@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                           " maximum 256MB", ram_size / MiB);
              exit(1);
          }
    -    memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram",
    ram_size);
    +    memory_region_allocate_system_memory(ram, machine, "mips_r4k.ram",
    +                                         ram_size);

          memory_region_add_subregion(address_space_mem, 0, ram);

    -- 
    2.21.0
#61 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 25 lines · Philippe Mathieu-Daudé

Hi Aleksandar,

Quoted 17 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

    Signed-off-by: Philippe Mathieu-Daudé <[email protected]
    <mailto:[email protected]>>
    ---
      hw/mips/boston.c        | 2 +-
      hw/mips/mips_fulong2e.c | 3 ++-
      hw/mips/mips_jazz.c     | 2 +-
      hw/mips/mips_malta.c    | 2 +-
      hw/mips/mips_mipssim.c  | 2 +-
      hw/mips/mips_r4k.c      | 3 ++-
      6 files changed, 8 insertions(+), 6 deletions(-)
Quoted 3 lines

Philippe, can this patch be applied independently (on other patches of this series)?

Quoted 10 lines

Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

I rather expect this series goes as a whole via the machine-next tree.

Do you mind giving your Acked-by tag to this patch?

I can't, sorry, for MIPS target, we don't accept patches with empty commit messages.

A.

Quoted 104 lines

Thanks,

Phil.

Quoted 99 lines
    diff --git a/hw/mips/boston.c b/hw/mips/boston.c
    index ca7d813a52..8445fee0f1 100644
    --- a/hw/mips/boston.c
    +++ b/hw/mips/boston.c
    @@ -474,7 +474,7 @@ static void boston_mach_init(MachineState
*machine)
          memory_region_add_subregion_overlap(sys_mem, 0x18000000,
    flash, 0);

          ddr = g_new(MemoryRegion, 1);
    -    memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
    +    memory_region_allocate_system_memory(ddr, machine, "boston.ddr",
                                               machine->ram_size);
          memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr,

0);

    diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
    index cf537dd7e6..d5a5cef619 100644
    --- a/hw/mips/mips_fulong2e.c
    +++ b/hw/mips/mips_fulong2e.c
    @@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState
    *machine)
          ram_size = 256 * MiB;

          /* allocate RAM */
    -    memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram",
    ram_size);
    +    memory_region_allocate_system_memory(ram, machine,
    +                                         "fulong2e.ram", ram_size);
          memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE,
                                 &error_fatal);
          memory_region_set_readonly(bios, true);
    diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
    index 8d010a0b6e..88b125855f 100644
    --- a/hw/mips/mips_jazz.c
    +++ b/hw/mips/mips_jazz.c
    @@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState *machine,
          cc->do_transaction_failed = mips_jazz_do_transaction_failed;

          /* allocate RAM */
    -    memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram",
    +    memory_region_allocate_system_memory(ram, machine,
"mips_jazz.ram",
                                               machine->ram_size);
          memory_region_add_subregion(address_space, 0, ram);

    diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
    index 4d9c64b36a..af56a29ccb 100644
    --- a/hw/mips/mips_malta.c
    +++ b/hw/mips/mips_malta.c
    @@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState *machine)
          }

          /* register RAM at high address where it is undisturbed by IO */
    -    memory_region_allocate_system_memory(ram_high, NULL,
    "mips_malta.ram",
    +    memory_region_allocate_system_memory(ram_high, machine,
    "mips_malta.ram",
                                               ram_size);
          memory_region_add_subregion(system_memory, 0x80000000,

ram_high);

    diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c
    index 282bbecb24..c1933231e2 100644
    --- a/hw/mips/mips_mipssim.c
    +++ b/hw/mips/mips_mipssim.c
    @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
          qemu_register_reset(main_cpu_reset, reset_info);

          /* Allocate RAM. */
    -    memory_region_allocate_system_memory(ram, NULL,

"mips_mipssim.ram",
+ memory_region_allocate_system_memory(ram, machine,
"mips_mipssim.ram",
ram_size);
memory_region_init_ram(bios, NULL, "mips_mipssim.bios",
BIOS_SIZE,

                                 &error_fatal);
    diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
    index bc0be26544..59f8cacfb6 100644
    --- a/hw/mips/mips_r4k.c
    +++ b/hw/mips/mips_r4k.c
    @@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                           " maximum 256MB", ram_size / MiB);
              exit(1);
          }
    -    memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram",
    ram_size);
    +    memory_region_allocate_system_memory(ram, machine,
"mips_r4k.ram",
    +                                         ram_size);

          memory_region_add_subregion(address_space_mem, 0, ram);

    --     2.21.0
#62 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 35 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

Hi Aleksandar,

On 10/21/19 8:25 AM, Aleksandar Markovic wrote:

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:

<mailto:[email protected]>
    <mailto:[email protected] <mailto:[email protected]>>>
    ---
      hw/mips/boston.c        | 2 +- hw/mips/mips_fulong2e.c | 3 ++- hw/mips/mips_jazz.c     | 2 +- hw/mips/mips_malta.c    | 2 +- hw/mips/mips_mipssim.c  | 2 +- hw/mips/mips_r4k.c      | 3 ++-
      6 files changed, 8 insertions(+), 6 deletions(-)

Philippe, can this patch be applied independently (on other patches of this series)?

Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

Quoted 7 lines

I rather expect this series goes as a whole via the machine-next tree.

Do you mind giving your Acked-by tag to this patch?

I can't, sorry, for MIPS target, we don't accept patches with empty commit messages.

I see, I'v been wondering what to do, if simply repeating the patch subject or the cover, but since the series applies to all targets, this seems overkill. I think I'll simply repeat the subject then.

Quoted 118 lines

A.

    Thanks,

    Phil.



             diff --git a/hw/mips/boston.c b/hw/mips/boston.c
             index ca7d813a52..8445fee0f1 100644
             --- a/hw/mips/boston.c
             +++ b/hw/mips/boston.c
             @@ -474,7 +474,7 @@ static void
        boston_mach_init(MachineState *machine)
                   memory_region_add_subregion_overlap(sys_mem, 0x18000000,
             flash, 0);

                   ddr = g_new(MemoryRegion, 1);
             -    memory_region_allocate_system_memory(ddr, NULL,
        "boston.ddr",
             +    memory_region_allocate_system_memory(ddr, machine,
        "boston.ddr",
                                                        machine->ram_size);
                   memory_region_add_subregion_overlap(sys_mem,
        0x80000000, ddr, 0);

             diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
             index cf537dd7e6..d5a5cef619 100644
             --- a/hw/mips/mips_fulong2e.c
             +++ b/hw/mips/mips_fulong2e.c
             @@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState
             *machine)
                   ram_size = 256 * MiB;

                   /* allocate RAM */
             -    memory_region_allocate_system_memory(ram, NULL,
        "fulong2e.ram",
             ram_size);
             +    memory_region_allocate_system_memory(ram, machine,
             +                                         "fulong2e.ram",
        ram_size);
                   memory_region_init_ram(bios, NULL, "fulong2e.bios",
        BIOS_SIZE,
                                          &error_fatal);
                   memory_region_set_readonly(bios, true);
             diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
             index 8d010a0b6e..88b125855f 100644
             --- a/hw/mips/mips_jazz.c
             +++ b/hw/mips/mips_jazz.c
             @@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState
        *machine,
                   cc->do_transaction_failed =
        mips_jazz_do_transaction_failed;

                   /* allocate RAM */
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_jazz.ram",
             +    memory_region_allocate_system_memory(ram, machine,
        "mips_jazz.ram",
                                                        machine->ram_size);
                   memory_region_add_subregion(address_space, 0, ram);

             diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
             index 4d9c64b36a..af56a29ccb 100644
             --- a/hw/mips/mips_malta.c
             +++ b/hw/mips/mips_malta.c
             @@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState
        *machine)
                   }

                   /* register RAM at high address where it is
        undisturbed by IO */
             -    memory_region_allocate_system_memory(ram_high, NULL,
             "mips_malta.ram",
             +    memory_region_allocate_system_memory(ram_high, machine,
             "mips_malta.ram",
                                                        ram_size);
                   memory_region_add_subregion(system_memory,
        0x80000000, ram_high);

             diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c
             index 282bbecb24..c1933231e2 100644
             --- a/hw/mips/mips_mipssim.c
             +++ b/hw/mips/mips_mipssim.c
             @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
                   qemu_register_reset(main_cpu_reset, reset_info);

                   /* Allocate RAM. */
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_mipssim.ram",
             +    memory_region_allocate_system_memory(ram, machine,
             "mips_mipssim.ram",
                                                        ram_size);
                   memory_region_init_ram(bios, NULL,
        "mips_mipssim.bios", BIOS_SIZE,
                                          &error_fatal);
             diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
             index bc0be26544..59f8cacfb6 100644
             --- a/hw/mips/mips_r4k.c
             +++ b/hw/mips/mips_r4k.c
             @@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                                    " maximum 256MB", ram_size / MiB);
                       exit(1);
                   }
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_r4k.ram",
             ram_size);
             +    memory_region_allocate_system_memory(ram, machine,
        "mips_r4k.ram",
             +                                         ram_size);

                   memory_region_add_subregion(address_space_mem, 0, ram);

             --     2.21.0
#63 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 44 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

Hi Aleksandar,

On 10/21/19 8:25 AM, Aleksandar Markovic wrote:

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:

<mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>>
---
hw/mips/boston.c | 2 +-
hw/mips/mips_fulong2e.c | 3 ++-
hw/mips/mips_jazz.c | 2 +-
hw/mips/mips_malta.c | 2 +-
hw/mips/mips_mipssim.c | 2 +-
hw/mips/mips_r4k.c | 3 ++-
6 files changed, 8 insertions(+), 6 deletions(-)

Philippe, can this patch be applied independently (on other patches of this series)?

Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

I rather expect this series goes as a whole via the machine-next tree.

Do you mind giving your Acked-by tag to this patch?

Quoted 9 lines
Quoted 3 lines

I can't, sorry, for MIPS target, we don't accept patches with empty commit messages.

I see, I'v been wondering what to do, if simply repeating the patch subject or the cover, but since the series applies to all targets, this seems overkill. I think I'll simply repeat the subject then.

Can't you at least add a sentence on why is this needed, or what is achieved?

Thanks,

A.

Quoted 125 lines
Quoted 125 lines

A.

    Thanks,

    Phil.



             diff --git a/hw/mips/boston.c b/hw/mips/boston.c
             index ca7d813a52..8445fee0f1 100644
             --- a/hw/mips/boston.c
             +++ b/hw/mips/boston.c
             @@ -474,7 +474,7 @@ static void
        boston_mach_init(MachineState *machine)
                   memory_region_add_subregion_overlap(sys_mem,
0x18000000,
             flash, 0);

                   ddr = g_new(MemoryRegion, 1);
             -    memory_region_allocate_system_memory(ddr, NULL,
        "boston.ddr",
             +    memory_region_allocate_system_memory(ddr, machine,
        "boston.ddr",
machine->ram_size);
                   memory_region_add_subregion_overlap(sys_mem,
        0x80000000, ddr, 0);

             diff --git a/hw/mips/mips_fulong2e.c
b/hw/mips/mips_fulong2e.c
             index cf537dd7e6..d5a5cef619 100644
             --- a/hw/mips/mips_fulong2e.c
             +++ b/hw/mips/mips_fulong2e.c
             @@ -318,7 +318,8 @@ static void
mips_fulong2e_init(MachineState
             *machine)
                   ram_size = 256 * MiB;

                   /* allocate RAM */
             -    memory_region_allocate_system_memory(ram, NULL,
        "fulong2e.ram",
             ram_size);
             +    memory_region_allocate_system_memory(ram, machine,
             +                                         "fulong2e.ram",
        ram_size);
                   memory_region_init_ram(bios, NULL, "fulong2e.bios",
        BIOS_SIZE,
                                          &error_fatal);
                   memory_region_set_readonly(bios, true);
             diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
             index 8d010a0b6e..88b125855f 100644
             --- a/hw/mips/mips_jazz.c
             +++ b/hw/mips/mips_jazz.c
             @@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState
        *machine,
                   cc->do_transaction_failed =
        mips_jazz_do_transaction_failed;

                   /* allocate RAM */
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_jazz.ram",
             +    memory_region_allocate_system_memory(ram, machine,
        "mips_jazz.ram",
machine->ram_size);
                   memory_region_add_subregion(address_space, 0, ram);

             diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
             index 4d9c64b36a..af56a29ccb 100644
             --- a/hw/mips/mips_malta.c
             +++ b/hw/mips/mips_malta.c
             @@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState
        *machine)
                   }

                   /* register RAM at high address where it is
        undisturbed by IO */
             -    memory_region_allocate_system_memory(ram_high, NULL,
             "mips_malta.ram",
             +    memory_region_allocate_system_memory(ram_high, machine,
             "mips_malta.ram",
                                                        ram_size);
                   memory_region_add_subregion(system_memory,
        0x80000000, ram_high);

             diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c
             index 282bbecb24..c1933231e2 100644
             --- a/hw/mips/mips_mipssim.c
             +++ b/hw/mips/mips_mipssim.c
             @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
                   qemu_register_reset(main_cpu_reset, reset_info);

                   /* Allocate RAM. */
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_mipssim.ram",
             +    memory_region_allocate_system_memory(ram, machine,
             "mips_mipssim.ram",
                                                        ram_size);
                   memory_region_init_ram(bios, NULL,
        "mips_mipssim.bios", BIOS_SIZE,
                                          &error_fatal);
             diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
             index bc0be26544..59f8cacfb6 100644
             --- a/hw/mips/mips_r4k.c
             +++ b/hw/mips/mips_r4k.c
             @@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                                    " maximum 256MB", ram_size / MiB);
                       exit(1);
                   }
             -    memory_region_allocate_system_memory(ram, NULL,
        "mips_r4k.ram",
             ram_size);
             +    memory_region_allocate_system_memory(ram, machine,
        "mips_r4k.ram",
             +                                         ram_size);

                   memory_region_add_subregion(address_space_mem, 0,

ram);

             --     2.21.0
#64 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 57 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

On 10/21/19 12:56 PM, Aleksandar Markovic wrote:

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:

    Hi Aleksandar,

    On 10/21/19 8:25 AM, Aleksandar Markovic wrote:

        On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>
        <mailto:[email protected] <mailto:[email protected]>
<mailto:[email protected] <mailto:[email protected]>>>> wrote:

             Signed-off-by: Philippe Mathieu-Daudé
<[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>> <mailto:[email protected]
<mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>>>
             ---
               hw/mips/boston.c        | 2 +- hw/mips/mips_fulong2e.c | 3 ++- hw/mips/mips_jazz.c     | 2 +- hw/mips/mips_malta.c    | 2 +- hw/mips/mips_mipssim.c  | 2 +- hw/mips/mips_r4k.c      | 3 ++-
               6 files changed, 8 insertions(+), 6 deletions(-)

        Philippe, can this patch be applied independently (on other patches of this series)?

    Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

    I rather expect this series goes as a whole via the
machine-next
    tree.

    Do you mind giving your Acked-by tag to this patch?

I can't, sorry, for MIPS target, we don't accept patches with empty commit messages.

Quoted 6 lines

I see, I'v been wondering what to do, if simply repeating the patch subject or the cover, but since the series applies to all targets, this seems overkill. I think I'll simply repeat the subject then.

Can't you at least add a sentence on why is this needed, or what is achieved?

You are alright, I'll do.

Quoted 146 lines

Thanks,

A.

        A.


             Thanks,

             Phil.



                      diff --git a/hw/mips/boston.c b/hw/mips/boston.c
                      index ca7d813a52..8445fee0f1 100644
                      --- a/hw/mips/boston.c
                      +++ b/hw/mips/boston.c
                      @@ -474,7 +474,7 @@ static void
                 boston_mach_init(MachineState *machine)
                            memory_region_add_subregion_overlap(sys_mem,
        0x18000000,
                      flash, 0);

                            ddr = g_new(MemoryRegion, 1);
                      -    memory_region_allocate_system_memory(ddr, NULL,
                 "boston.ddr",
                      +    memory_region_allocate_system_memory(ddr,
        machine,
                 "boston.ddr",
                                                                
        machine->ram_size);
                            memory_region_add_subregion_overlap(sys_mem,
                 0x80000000, ddr, 0);

                      diff --git a/hw/mips/mips_fulong2e.c
        b/hw/mips/mips_fulong2e.c
                      index cf537dd7e6..d5a5cef619 100644
                      --- a/hw/mips/mips_fulong2e.c
                      +++ b/hw/mips/mips_fulong2e.c
                      @@ -318,7 +318,8 @@ static void
        mips_fulong2e_init(MachineState
                      *machine)
                            ram_size = 256 * MiB;

                            /* allocate RAM */
                      -    memory_region_allocate_system_memory(ram, NULL,
                 "fulong2e.ram",
                      ram_size);
                      +    memory_region_allocate_system_memory(ram,
        machine,
                      +                                       
          "fulong2e.ram",
                 ram_size);
                            memory_region_init_ram(bios, NULL,
        "fulong2e.bios",
                 BIOS_SIZE,
                                                   &error_fatal);
                            memory_region_set_readonly(bios, true);
                      diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
                      index 8d010a0b6e..88b125855f 100644
                      --- a/hw/mips/mips_jazz.c
                      +++ b/hw/mips/mips_jazz.c
                      @@ -188,7 +188,7 @@ static void
        mips_jazz_init(MachineState
                 *machine,
                            cc->do_transaction_failed =
                 mips_jazz_do_transaction_failed;

                            /* allocate RAM */
                      -    memory_region_allocate_system_memory(ram, NULL,
                 "mips_jazz.ram",
                      +    memory_region_allocate_system_memory(ram,
        machine,
                 "mips_jazz.ram",
                                                                
        machine->ram_size);
                            memory_region_add_subregion(address_space,
        0, ram);

                      diff --git a/hw/mips/mips_malta.c
        b/hw/mips/mips_malta.c
                      index 4d9c64b36a..af56a29ccb 100644
                      --- a/hw/mips/mips_malta.c
                      +++ b/hw/mips/mips_malta.c
                      @@ -1267,7 +1267,7 @@ void
        mips_malta_init(MachineState
                 *machine)
                            }

                            /* register RAM at high address where it is
                 undisturbed by IO */
                      -   
        memory_region_allocate_system_memory(ram_high, NULL,
                      "mips_malta.ram",
                      +   
        memory_region_allocate_system_memory(ram_high, machine,
                      "mips_malta.ram",
                                                                 ram_size);
                            memory_region_add_subregion(system_memory,
                 0x80000000, ram_high);

                      diff --git a/hw/mips/mips_mipssim.c
        b/hw/mips/mips_mipssim.c
                      index 282bbecb24..c1933231e2 100644
                      --- a/hw/mips/mips_mipssim.c
                      +++ b/hw/mips/mips_mipssim.c
                      @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState
        *machine)
                            qemu_register_reset(main_cpu_reset, reset_info);

                            /* Allocate RAM. */
                      -    memory_region_allocate_system_memory(ram, NULL,
                 "mips_mipssim.ram",
                      +    memory_region_allocate_system_memory(ram,
        machine,
                      "mips_mipssim.ram",
                                                                 ram_size);
                            memory_region_init_ram(bios, NULL,
                 "mips_mipssim.bios", BIOS_SIZE,
                                                   &error_fatal);
                      diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
                      index bc0be26544..59f8cacfb6 100644
                      --- a/hw/mips/mips_r4k.c
                      +++ b/hw/mips/mips_r4k.c
                      @@ -203,7 +203,8 @@ void
        mips_r4k_init(MachineState *machine)
                                             " maximum 256MB", ram_size
        / MiB);
                                exit(1);
                            }
                      -    memory_region_allocate_system_memory(ram, NULL,
                 "mips_r4k.ram",
                      ram_size);
                      +    memory_region_allocate_system_memory(ram,
        machine,
                 "mips_r4k.ram",
                      +                                         ram_size);

                          
          memory_region_add_subregion(address_space_mem, 0, ram);

                      --     2.21.0
#65 lore raw

Re: [PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

Quoted 66 lines · Philippe Mathieu-Daudé
Quoted 64 lines · Aleksandar Markovic

On Monday, October 21, 2019, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:

    On 10/21/19 12:56 PM, Aleksandar Markovic wrote:



        On Monday, October 21, 2019, Philippe Mathieu-Daudé
        <[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>> wrote:

             Hi Aleksandar,

             On 10/21/19 8:25 AM, Aleksandar Markovic wrote:



                 On Monday, October 21, 2019, Philippe Mathieu-Daudé
                 <[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>
                 <mailto:[email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>>> wrote:

                      Signed-off-by: Philippe Mathieu-Daudé
        <[email protected] <mailto:[email protected]>
                 <mailto:[email protected] <mailto:[email protected]>>
                      <mailto:[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>>
                      ---
                        hw/mips/boston.c        | 2 +-
                        hw/mips/mips_fulong2e.c | 3 ++-
                        hw/mips/mips_jazz.c     | 2 +-
                        hw/mips/mips_malta.c    | 2 +-
                        hw/mips/mips_mipssim.c  | 2 +-
                        hw/mips/mips_r4k.c      | 3 ++-
                        6 files changed, 8 insertions(+), 6 deletions(-)


                 Philippe, can this patch be applied independently (on

other
patches of this series)?

Unfortunately not because patch #9 changed the prototype of memory_region_allocate_system_memory() so this patch alone won't build.

I rather expect this series goes as a whole via the
machine-next
tree.

Do you mind giving your Acked-by tag to this patch?

I can't, sorry, for MIPS target, we don't accept patches with empty commit messages.

I see, I'v been wondering what to do, if simply repeating the patch subject or the cover, but since the series applies to all targets, this seems overkill. I think I'll simply repeat the subject then.

Quoted 5 lines
Quoted 3 lines

Can't you at least add a sentence on why is this needed, or what is achieved?

You are alright, I'll do.

Cool, I'd appreciate it very much.

A.

Quoted 157 lines
Quoted 157 lines

Thanks,

A.

        A.


             Thanks,

             Phil.



                      diff --git a/hw/mips/boston.c b/hw/mips/boston.c
                      index ca7d813a52..8445fee0f1 100644
                      --- a/hw/mips/boston.c
                      +++ b/hw/mips/boston.c
                      @@ -474,7 +474,7 @@ static void
                 boston_mach_init(MachineState *machine)
                            memory_region_add_subregion_overlap(sys_mem,
        0x18000000,
                      flash, 0);

                            ddr = g_new(MemoryRegion, 1);
                      -    memory_region_allocate_system_memory(ddr,
NULL,
                 "boston.ddr",
                      +    memory_region_allocate_system_memory(ddr,
        machine,
                 "boston.ddr",
machine->ram_size);
                            memory_region_add_subregion_overlap(sys_mem,
                 0x80000000, ddr, 0);

                      diff --git a/hw/mips/mips_fulong2e.c
        b/hw/mips/mips_fulong2e.c
                      index cf537dd7e6..d5a5cef619 100644
                      --- a/hw/mips/mips_fulong2e.c
                      +++ b/hw/mips/mips_fulong2e.c
                      @@ -318,7 +318,8 @@ static void
        mips_fulong2e_init(MachineState
                      *machine)
                            ram_size = 256 * MiB;

                            /* allocate RAM */
                      -    memory_region_allocate_system_memory(ram,
NULL,
                 "fulong2e.ram",
                      ram_size);
                      +    memory_region_allocate_system_memory(ram,
        machine,
                      +
 "fulong2e.ram",
                 ram_size);
                            memory_region_init_ram(bios, NULL,
        "fulong2e.bios",
                 BIOS_SIZE,
                                                   &error_fatal);
                            memory_region_set_readonly(bios, true);
                      diff --git a/hw/mips/mips_jazz.c
b/hw/mips/mips_jazz.c
                      index 8d010a0b6e..88b125855f 100644
                      --- a/hw/mips/mips_jazz.c
                      +++ b/hw/mips/mips_jazz.c
                      @@ -188,7 +188,7 @@ static void
        mips_jazz_init(MachineState
                 *machine,
                            cc->do_transaction_failed =
                 mips_jazz_do_transaction_failed;

                            /* allocate RAM */
                      -    memory_region_allocate_system_memory(ram,
NULL,
                 "mips_jazz.ram",
                      +    memory_region_allocate_system_memory(ram,
        machine,
                 "mips_jazz.ram",
machine->ram_size);
                            memory_region_add_subregion(address_space,
        0, ram);

                      diff --git a/hw/mips/mips_malta.c
        b/hw/mips/mips_malta.c
                      index 4d9c64b36a..af56a29ccb 100644
                      --- a/hw/mips/mips_malta.c
                      +++ b/hw/mips/mips_malta.c
                      @@ -1267,7 +1267,7 @@ void
        mips_malta_init(MachineState
                 *machine)
                            }

                            /* register RAM at high address where it is
                 undisturbed by IO */
                      -           memory_region_allocate_system_memory(ram_high,

NULL,
"mips_malta.ram",
+ memory_region_allocate_system_memory(ram_high,
machine,

                      "mips_malta.ram",
ram_size);
                            memory_region_add_subregion(system_memory,
                 0x80000000, ram_high);

                      diff --git a/hw/mips/mips_mipssim.c
        b/hw/mips/mips_mipssim.c
                      index 282bbecb24..c1933231e2 100644
                      --- a/hw/mips/mips_mipssim.c
                      +++ b/hw/mips/mips_mipssim.c
                      @@ -166,7 +166,7 @@ mips_mipssim_init(MachineState
        *machine)
                            qemu_register_reset(main_cpu_reset,

reset_info);

/* Allocate RAM. */
- memory_region_allocate_system_memory(ram,
NULL,

                 "mips_mipssim.ram",
                      +    memory_region_allocate_system_memory(ram,
        machine,
                      "mips_mipssim.ram",
ram_size);
                            memory_region_init_ram(bios, NULL,
                 "mips_mipssim.bios", BIOS_SIZE,
                                                   &error_fatal);
                      diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
                      index bc0be26544..59f8cacfb6 100644
                      --- a/hw/mips/mips_r4k.c
                      +++ b/hw/mips/mips_r4k.c
                      @@ -203,7 +203,8 @@ void
        mips_r4k_init(MachineState *machine)
                                             " maximum 256MB", ram_size
        / MiB);
                                exit(1);
                            }
                      -    memory_region_allocate_system_memory(ram,
NULL,
                 "mips_r4k.ram",
                      ram_size);
                      +    memory_region_allocate_system_memory(ram,
        machine,
                 "mips_r4k.ram",
                      +                                         ram_size);

                                    memory_region_add_subregion(address_space_mem,

0, ram);

                      --     2.21.0
Reviewed-by on v1 18/21
#66 lore raw

Re: [EXTERNAL][PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 9 lines
---
 hw/mips/boston.c        | 2 +-
 hw/mips/mips_fulong2e.c | 3 ++-
 hw/mips/mips_jazz.c     | 2 +-
 hw/mips/mips_malta.c    | 2 +-
 hw/mips/mips_mipssim.c  | 2 +-
 hw/mips/mips_r4k.c      | 3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)

When the commit message is completed:

________________________________________
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Monday, October 21, 2019 12:56 AM
To: Paolo Bonzini; Igor Mammedov; [email protected]; Markus Armbruster; Eduardo Habkost
Cc: Thomas Huth; Antony Pavlov; Michael Walle; David Gibson; [email protected]; KONRAD Frederic; Cédric Le Goater; Fabien Chouteau; Andrey Smirnov; Joel Stanley; Peter Chubb; Andrew Jeffery; Helge Deller; Aurelien Jarno; Jean-Christophe Dubois; Jan Kiszka; Paul Burton; [email protected]; Hervé Poussineau; Andrew Baumann; Mark Cave-Ayland; Beniamino Galvani; Artyom Tarasenko; Edgar E. Iglesias; Leif Lindholm; Aleksandar Markovic; Michael S. Tsirkin; Radoslaw Biernacki; Rob Herring; Richard Henderson; Alistair Francis; Andrzej Zaborowski; Marcel Apfelbaum; Philippe Mathieu-Daudé; Aleksandar Rikalo; Peter Maydell
Subject: [EXTERNAL][PATCH 18/21] hw/mips: Let the machine be the owner of the system memory

---
 hw/mips/boston.c        | 2 +-
 hw/mips/mips_fulong2e.c | 3 ++-
 hw/mips/mips_jazz.c     | 2 +-
 hw/mips/mips_malta.c    | 2 +-
 hw/mips/mips_mipssim.c  | 2 +-
 hw/mips/mips_r4k.c      | 3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)
hw/mips/boston.c +1 -1
index ca7d813a52..8445fee0f1 100644
@@ -474,7 +474,7 @@ static void boston_mach_init(MachineState *machine)
     memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
 
     ddr = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ddr, NULL, "boston.ddr",
+    memory_region_allocate_system_memory(ddr, machine, "boston.ddr",
                                          machine->ram_size);
     memory_region_add_subregion_overlap(sys_mem, 0x80000000, ddr, 0);
 
hw/mips/mips_fulong2e.c +2 -1
index cf537dd7e6..d5a5cef619 100644
@@ -318,7 +318,8 @@ static void mips_fulong2e_init(MachineState *machine)
     ram_size = 256 * MiB;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine,
+                                         "fulong2e.ram", ram_size);
     memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE,
                            &error_fatal);
     memory_region_set_readonly(bios, true);
hw/mips/mips_jazz.c +1 -1
index 8d010a0b6e..88b125855f 100644
@@ -188,7 +188,7 @@ static void mips_jazz_init(MachineState *machine,
     cc->do_transaction_failed = mips_jazz_do_transaction_failed;
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram",
+    memory_region_allocate_system_memory(ram, machine, "mips_jazz.ram",
                                          machine->ram_size);
     memory_region_add_subregion(address_space, 0, ram);
 
hw/mips/mips_malta.c +1 -1
index 4d9c64b36a..af56a29ccb 100644
@@ -1267,7 +1267,7 @@ void mips_malta_init(MachineState *machine)
     }
 
     /* register RAM at high address where it is undisturbed by IO */
-    memory_region_allocate_system_memory(ram_high, NULL, "mips_malta.ram",
+    memory_region_allocate_system_memory(ram_high, machine, "mips_malta.ram",
                                          ram_size);
     memory_region_add_subregion(system_memory, 0x80000000, ram_high);
 
hw/mips/mips_mipssim.c +1 -1
index 282bbecb24..c1933231e2 100644
@@ -166,7 +166,7 @@ mips_mipssim_init(MachineState *machine)
     qemu_register_reset(main_cpu_reset, reset_info);
 
     /* Allocate RAM. */
-    memory_region_allocate_system_memory(ram, NULL, "mips_mipssim.ram",
+    memory_region_allocate_system_memory(ram, machine, "mips_mipssim.ram",
                                          ram_size);
     memory_region_init_ram(bios, NULL, "mips_mipssim.bios", BIOS_SIZE,
                            &error_fatal);
hw/mips/mips_r4k.c +2 -1
index bc0be26544..59f8cacfb6 100644
@@ -203,7 +203,8 @@ void mips_r4k_init(MachineState *machine)
                      " maximum 256MB", ram_size / MiB);
         exit(1);
     }
-    memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mips_r4k.ram",
+                                         ram_size);
 
     memory_region_add_subregion(address_space_mem, 0, ram);
 

--
2.21.0

#67 lore raw

PATCH 19/21 hw/ppc: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/ppc/e500.c          | 3 ++-
 hw/ppc/mac_newworld.c  | 3 ++-
 hw/ppc/mac_oldworld.c  | 2 +-
 hw/ppc/pnv.c           | 2 +-
 hw/ppc/ppc405_boards.c | 6 +++---
 hw/ppc/prep.c          | 3 ++-
 hw/ppc/spapr.c         | 2 +-
 hw/ppc/virtex_ml507.c  | 2 +-
 8 files changed, 13 insertions(+), 10 deletions(-)
hw/ppc/e500.c +2 -1
index 91cd4c26f9..9c7be26248 100644
@@ -912,7 +912,8 @@ void ppce500_init(MachineState *machine)
     machine->ram_size = ram_size;
 
     /* Register Memory */
-    memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mpc8544ds.ram",
+                                         ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     dev = qdev_create(NULL, "e500-ccsr");
hw/ppc/mac_newworld.c +2 -1
index c5bbcc7433..8409114eed 100644
@@ -152,7 +152,8 @@ static void ppc_core99_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_core99.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "ppc_core99.ram",
+                                         ram_size);
     memory_region_add_subregion(get_system_memory(), 0, ram);
 
     /* allocate and load BIOS */
hw/ppc/mac_oldworld.c +1 -1
index 0fa680b749..9dd645476a 100644
@@ -127,7 +127,7 @@ static void ppc_heathrow_init(MachineState *machine)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram",
+    memory_region_allocate_system_memory(ram, machine, "ppc_heathrow.ram",
                                          ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
hw/ppc/pnv.c +1 -1
index 7cf64b6d25..ac731c4f88 100644
@@ -640,7 +640,7 @@ static void pnv_init(MachineState *machine)
     }
 
     ram = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram, NULL, "pnv.ram",
+    memory_region_allocate_system_memory(ram, machine, "pnv.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), 0, ram);
 
hw/ppc/ppc405_boards.c +3 -3
index 388cae0b43..8a2d2f4511 100644
@@ -162,8 +162,8 @@ static void ref405ep_init(MachineState *machine)
     MemoryRegion *sysmem = get_system_memory();
 
     /* XXX: fix this */
-    memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram",
-                                         0x08000000);
+    memory_region_allocate_system_memory(&ram_memories[0], machine,
+                                         "ef405ep.ram", 128 * MiB);
     ram_bases[0] = 0;
     ram_sizes[0] = 0x08000000;
     memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0);
@@ -427,7 +427,7 @@ static void taihu_405ep_init(MachineState *machine)
 
     /* RAM is soldered to the board so the size cannot be changed */
     ram_size = 0x08000000;
-    memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram",
+    memory_region_allocate_system_memory(ram, machine, "taihu_405ep.ram",
                                          ram_size);
 
     ram_bases[0] = 0;
hw/ppc/prep.c +2 -1
index 4f3c6bf190..54b00805e0 100644
@@ -445,7 +445,8 @@ static void ppc_prep_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_prep.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "ppc_prep.ram",
+                                         ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
     if (linux_boot) {
hw/ppc/spapr.c +1 -1
index 4eb97d3a9b..1f168edd43 100644
@@ -2840,7 +2840,7 @@ static void spapr_machine_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
+    memory_region_allocate_system_memory(ram, machine, "ppc_spapr.ram",
                                          machine->ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
hw/ppc/virtex_ml507.c +1 -1
index 68625522d8..86c9273dc0 100644
@@ -224,7 +224,7 @@ static void virtex_init(MachineState *machine)
 
     qemu_register_reset(main_cpu_reset, cpu);
 
-    memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size);
+    memory_region_allocate_system_memory(phys_ram, machine, "ram", ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
Signature · 1 line
2.21.0
Acked-by on v1 19/21
#68 lore raw

Re: [PATCH 19/21] hw/ppc: Let the machine be the owner of the system memory

Quoted 1 line · Philippe Mathieu-Daudé
Quoted 129 lines
---
 hw/ppc/e500.c          | 3 ++-
 hw/ppc/mac_newworld.c  | 3 ++-
 hw/ppc/mac_oldworld.c  | 2 +-
 hw/ppc/pnv.c           | 2 +-
 hw/ppc/ppc405_boards.c | 6 +++---
 hw/ppc/prep.c          | 3 ++-
 hw/ppc/spapr.c         | 2 +-
 hw/ppc/virtex_ml507.c  | 2 +-
 8 files changed, 13 insertions(+), 10 deletions(-)
hw/ppc/e500.c +2 -1
index 91cd4c26f9..9c7be26248 100644
@@ -912,7 +912,8 @@ void ppce500_init(MachineState *machine)
     machine->ram_size = ram_size;
 
     /* Register Memory */
-    memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "mpc8544ds.ram",
+                                         ram_size);
     memory_region_add_subregion(address_space_mem, 0, ram);
 
     dev = qdev_create(NULL, "e500-ccsr");
hw/ppc/mac_newworld.c +2 -1
index c5bbcc7433..8409114eed 100644
@@ -152,7 +152,8 @@ static void ppc_core99_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_core99.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "ppc_core99.ram",
+                                         ram_size);
     memory_region_add_subregion(get_system_memory(), 0, ram);
 
     /* allocate and load BIOS */
hw/ppc/mac_oldworld.c +1 -1
index 0fa680b749..9dd645476a 100644
@@ -127,7 +127,7 @@ static void ppc_heathrow_init(MachineState *machine)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram",
+    memory_region_allocate_system_memory(ram, machine, "ppc_heathrow.ram",
                                          ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
hw/ppc/pnv.c +1 -1
index 7cf64b6d25..ac731c4f88 100644
@@ -640,7 +640,7 @@ static void pnv_init(MachineState *machine)
     }
 
     ram = g_new(MemoryRegion, 1);
-    memory_region_allocate_system_memory(ram, NULL, "pnv.ram",
+    memory_region_allocate_system_memory(ram, machine, "pnv.ram",
                                          machine->ram_size);
     memory_region_add_subregion(get_system_memory(), 0, ram);
 
hw/ppc/ppc405_boards.c +3 -3
index 388cae0b43..8a2d2f4511 100644
@@ -162,8 +162,8 @@ static void ref405ep_init(MachineState *machine)
     MemoryRegion *sysmem = get_system_memory();
 
     /* XXX: fix this */
-    memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram",
-                                         0x08000000);
+    memory_region_allocate_system_memory(&ram_memories[0], machine,
+                                         "ef405ep.ram", 128 * MiB);
     ram_bases[0] = 0;
     ram_sizes[0] = 0x08000000;
     memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0);
@@ -427,7 +427,7 @@ static void taihu_405ep_init(MachineState *machine)
 
     /* RAM is soldered to the board so the size cannot be changed */
     ram_size = 0x08000000;
-    memory_region_allocate_system_memory(ram, NULL, "taihu_405ep.ram",
+    memory_region_allocate_system_memory(ram, machine, "taihu_405ep.ram",
                                          ram_size);
 
     ram_bases[0] = 0;
hw/ppc/prep.c +2 -1
index 4f3c6bf190..54b00805e0 100644
@@ -445,7 +445,8 @@ static void ppc_prep_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_prep.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "ppc_prep.ram",
+                                         ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
     if (linux_boot) {
hw/ppc/spapr.c +1 -1
index 4eb97d3a9b..1f168edd43 100644
@@ -2840,7 +2840,7 @@ static void spapr_machine_init(MachineState *machine)
     }
 
     /* allocate RAM */
-    memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
+    memory_region_allocate_system_memory(ram, machine, "ppc_spapr.ram",
                                          machine->ram_size);
     memory_region_add_subregion(sysmem, 0, ram);
 
hw/ppc/virtex_ml507.c +1 -1
index 68625522d8..86c9273dc0 100644
@@ -224,7 +224,7 @@ static void virtex_init(MachineState *machine)
 
     qemu_register_reset(main_cpu_reset, cpu);
 
-    memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size);
+    memory_region_allocate_system_memory(phys_ram, machine, "ram", ram_size);
     memory_region_add_subregion(address_space_mem, ram_base, phys_ram);
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on v1 19/21
#69 lore raw

Re: [PATCH 19/21] hw/ppc: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé
---
 hw/ppc/e500.c          | 3 ++-
 hw/ppc/mac_newworld.c  | 3 ++-
 hw/ppc/mac_oldworld.c  | 2 +-
 hw/ppc/pnv.c           | 2 +-
 hw/ppc/ppc405_boards.c | 6 +++---
 hw/ppc/prep.c          | 3 ++-
 hw/ppc/spapr.c         | 2 +-
 hw/ppc/virtex_ml507.c  | 2 +-
 8 files changed, 13 insertions(+), 10 deletions(-)

r~

#70 lore raw

PATCH 20/21 hw/sparc: Let the machine be the owner of the system memory

In reply to Philippe Mathieu-Daudé
---
 hw/sparc/leon3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sparc/leon3.c +1 -1
index c5f1b1ee72..f58f2782c6 100644
@@ -244,7 +244,7 @@ static void leon3_generic_hw_init(MachineState *machine)
         exit(1);
     }
 
-    memory_region_allocate_system_memory(ram, NULL, "leon3.ram", ram_size);
+    memory_region_allocate_system_memory(ram, machine, "leon3.ram", ram_size);
     memory_region_add_subregion(address_space_mem, LEON3_RAM_OFFSET, ram);
 
     /* Allocate BIOS */
Signature · 1 line
2.21.0
#72 lore raw

PATCH 21/21 hw/core: Assert memory_region_allocate_system_memory has machine owner

In reply to Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() pass a MachineState argument. Add an assertion to ensure the new boards/machines added set this argument, so all system memory object have the machine as its QOM owner.

---
 hw/core/numa.c      | 4 +---
 include/hw/boards.h | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)
hw/core/numa.c +1 -3
index 2e29e4bfe0..3e07e94d00 100644
@@ -527,9 +527,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
     uint64_t addr = 0;
     int i;
 
-    if (!ms) {
-        ms = MACHINE(qdev_get_machine());
-    }
+    g_assert(ms);
 
     if (ms->numa_state == NULL ||
         ms->numa_state->num_nodes == 0 || !have_memdevs) {
include/hw/boards.h +1 -1
index 3b6cb82b6c..31ab6e7586 100644
@@ -14,7 +14,7 @@
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
- * @ms: the #MachineState object that own the system memory
+ * @ms: the #MachineState object that own the system memory (must not be NULL)
  * @name: name of the memory region
  * @ram_size: size of the region in bytes
  *
Signature · 1 line
2.21.0
Reviewed-by on v1 21/21
#73 lore raw

Re: [PATCH 21/21] hw/core: Assert memory_region_allocate_system_memory has machine owner

Quoted 10 lines · Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() pass a MachineState argument. Add an assertion to ensure the new boards/machines added set this argument, so all system memory object have the machine as its QOM owner.

---
 hw/core/numa.c      | 4 +---
 include/hw/boards.h | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

It would be a good idea to add __attribute__((nonnull(x,y,z))) as well, but since we don't currently have any markup for that in qemu, that can go in a separate patch set.

r~

Reviewed-by on v1 21/21
#74 lore raw

Re: [PATCH 21/21] hw/core: Assert memory_region_allocate_system_memory has machine owner

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

All the memory_region_allocate_system_memory() pass a MachineState argument. Add an assertion to ensure the new boards/machines added set this argument, so all system memory object have the machine as its QOM owner.

Alistair

Quoted 37 lines
---
 hw/core/numa.c      | 4 +---
 include/hw/boards.h | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)
hw/core/numa.c +1 -3
index 2e29e4bfe0..3e07e94d00 100644
@@ -527,9 +527,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, MachineState *ms,
     uint64_t addr = 0;
     int i;
 
-    if (!ms) {
-        ms = MACHINE(qdev_get_machine());
-    }
+    g_assert(ms);
 
     if (ms->numa_state == NULL ||
         ms->numa_state->num_nodes == 0 || !have_memdevs) {
include/hw/boards.h +1 -2
index 3b6cb82b6c..31ab6e7586 100644
@@ -14,7 +14,7 @@
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
- * @ms: the #MachineState object that own the system memory
+ * @ms: the #MachineState object that own the system memory (must not be NULL)
  * @name: name of the memory region
  * @ram_size: size of the region in bytes
  *
--

2.21.0

#75 lore raw
In reply to Philippe Mathieu-Daudé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH 00/21] hw: Let the machine be the owner of the system memory
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Switched to a new branch 'test'
23b4e9a hw/core: Assert memory_region_allocate_system_memory has machine owner 67caaf0 hw/sparc: Let the machine be the owner of the system memory 9610d69 hw/ppc: Let the machine be the owner of the system memory 3cf0c55 hw/mips: Let the machine be the owner of the system memory c6cd486 hw/m68k: Let the machine be the owner of the system memory dd8e9a6 hw/lm32: Let the machine be the owner of the system memory c7b9ccd hw/i386: Let the machine be the owner of the system memory 655182f hw/hppa: Let the machine be the owner of the system memory 20dc622 hw/cris: Let the machine be the owner of the system memory fc3c6d2 hw/arm: Let the machine be the owner of the system memory e9f1ebc hw/alpha: Let the machine be the owner of the system memory 3ef111b hw/core: Let the machine be the owner of the system memory 31bd838 hw: Let memory_region_allocate_system_memory take MachineState argument dae9d11 hw/alpha/dp264: Create the RAM in the board
c31eba0 hw: Drop QOM ownership on memory_region_allocate_system_memory() calls 728aa65 hw/arm/digic4: Inline digic4_board_setup_ram() function c2a9052 hw/arm/omap1: Create the RAM in the board
4f4977f hw/arm/omap2: Create the RAM in the board
d1959b2 hw/arm/collie: Create the RAM in the board
815f5c1 hw/arm/mps2: Use the IEC binary prefix definitions
103190f hw/arm/xilinx_zynq: Use the IEC binary prefix definitions

=== OUTPUT BEGIN ===
1/21 Checking commit 103190fd9b28 (hw/arm/xilinx_zynq: Use the IEC binary prefix definitions) 2/21 Checking commit 815f5c166924 (hw/arm/mps2: Use the IEC binary prefix definitions) 3/21 Checking commit d1959b2d3e49 (hw/arm/collie: Create the RAM in the board)
4/21 Checking commit 4f4977fa8205 (hw/arm/omap2: Create the RAM in the board)
5/21 Checking commit c2a90524bd33 (hw/arm/omap1: Create the RAM in the board)
6/21 Checking commit 728aa65672f4 (hw/arm/digic4: Inline digic4_board_setup_ram() function) 7/21 Checking commit c31eba0d025b (hw: Drop QOM ownership on memory_region_allocate_system_memory() calls) 8/21 Checking commit dae9d111acb1 (hw/alpha/dp264: Create the RAM in the board)
ERROR: spaces required around that '*' (ctx:WxV)
#24: FILE: hw/alpha/alpha_sys.h:13:
+PCIBus *typhoon_init(ISABus **, qemu_irq *, AlphaCPU *[4],

                                                      ^

total: 1 errors, 0 warnings, 59 lines checked

Patch 8/21 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

9/21 Checking commit 31bd838d2d79 (hw: Let memory_region_allocate_system_memory take MachineState argument) 10/21 Checking commit 3ef111b6a62a (hw/core: Let the machine be the owner of the system memory) 11/21 Checking commit e9f1ebcb1624 (hw/alpha: Let the machine be the owner of the system memory) 12/21 Checking commit fc3c6d23b63f (hw/arm: Let the machine be the owner of the system memory) 13/21 Checking commit 20dc622c1df3 (hw/cris: Let the machine be the owner of the system memory) 14/21 Checking commit 655182f6e74a (hw/hppa: Let the machine be the owner of the system memory) 15/21 Checking commit c7b9ccda7442 (hw/i386: Let the machine be the owner of the system memory) 16/21 Checking commit dd8e9a66c1f0 (hw/lm32: Let the machine be the owner of the system memory) 17/21 Checking commit c6cd4866d6a0 (hw/m68k: Let the machine be the owner of the system memory) 18/21 Checking commit 3cf0c55fcc1b (hw/mips: Let the machine be the owner of the system memory) 19/21 Checking commit 9610d6908cbc (hw/ppc: Let the machine be the owner of the system memory) 20/21 Checking commit 67caaf05019b (hw/sparc: Let the machine be the owner of the system memory) 21/21 Checking commit 23b4e9a52318 (hw/core: Assert memory_region_allocate_system_memory has machine owner) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#76 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 48 lines · Philippe Mathieu-Daudé

Hi,

This series is based on Igor's "eliminate remaining places that abuse memory_region_allocate_system_memory()":
https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg01601.html

It is quite simple, we enforce all machines to be the QOM owner of the system memory.

This changes the memory tree from:

(qemu) info mtree -o
memory-region: pc.ram

     0000000000000000-0000000007ffffff (prio 0, ram): pc.ram parent:{obj path=/machine/unattached}

to:

(qemu) info mtree -o
memory-region: pc.ram

     0000000000000000-0000000007ffffff (prio 0, ram): pc.ram owner:{obj path=/machine}

Few patches are required to clean the codebase first, to unify the creation of the system memory in the board/machine code. Mostly some old ARM machines (pre-QOM) were affected.

Please review (as a generic codebase cleanup).

Regards,

Phil.

Based-on: <[email protected]>

Philippe Mathieu-Daudé (21):
hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board
hw/arm/omap2: Create the RAM in the board
hw/arm/omap1: Create the RAM in the board
hw/arm/digic4: Inline digic4_board_setup_ram() function
hw: Drop QOM ownership on memory_region_allocate_system_memory() calls hw/alpha/dp264: Create the RAM in the board
hw: Let memory_region_allocate_system_memory take MachineState
argument
hw/core: Let the machine be the owner of the system memory hw/alpha: Let the machine be the owner of the system memory hw/arm: Let the machine be the owner of the system memory hw/cris: Let the machine be the owner of the system memory

Quoted 8 lines

hw/hppa: Let the machine be the owner of the system memory hw/i386: Let the machine be the owner of the system memory hw/lm32: Let the machine be the owner of the system memory hw/m68k: Let the machine be the owner of the system memory hw/mips: Let the machine be the owner of the system memory hw/ppc: Let the machine be the owner of the system memory hw/sparc: Let the machine be the owner of the system memory hw/core: Assert memory_region_allocate_system_memory has machine owner

I forgot 4 other calls:

hw/ppc/ppc4xx_devs.c:708: memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_size);
hw/s390x/s390-virtio-ccw.c:164: memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size);
hw/sparc/sun4m.c:791: memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram",
hw/sparc64/niagara.c:114: memory_region_allocate_system_memory(&s->partition_ram, NULL,

#77 lore raw

Hi Peter,

Quoted 58 lines · Philippe Mathieu-Daudé
Quoted 48 lines · Philippe Mathieu-Daudé

Hi,

This series is based on Igor's "eliminate remaining places that abuse memory_region_allocate_system_memory()":
https://lists.gnu.org/archive/html/qemu-devel/2019-10/msg01601.html

It is quite simple, we enforce all machines to be the QOM owner of the system memory.

This changes the memory tree from:

   (qemu) info mtree -o
   memory-region: pc.ram
     0000000000000000-0000000007ffffff (prio 0, ram): pc.ram parent:{obj path=/machine/unattached}

to:

   (qemu) info mtree -o
   memory-region: pc.ram
     0000000000000000-0000000007ffffff (prio 0, ram): pc.ram owner:{obj path=/machine}

Few patches are required to clean the codebase first, to unify the creation of the system memory in the board/machine code. Mostly some old ARM machines (pre-QOM) were affected.

Please review (as a generic codebase cleanup).

Regards,

Phil.

Based-on: <[email protected]>

Philippe Mathieu-Daudé (21):
   hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board
   hw/arm/omap2: Create the RAM in the board
   hw/arm/omap1: Create the RAM in the board
   hw/arm/digic4: Inline digic4_board_setup_ram() function
   hw: Drop QOM ownership on memory_region_allocate_system_memory() calls hw/alpha/dp264: Create the RAM in the board
   hw: Let memory_region_allocate_system_memory take MachineState argument
   hw/core: Let the machine be the owner of the system memory hw/alpha: Let the machine be the owner of the system memory hw/arm: Let the machine be the owner of the system memory hw/cris: Let the machine be the owner of the system memory

Quoted 8 lines

   hw/hppa: Let the machine be the owner of the system memory hw/i386: Let the machine be the owner of the system memory hw/lm32: Let the machine be the owner of the system memory hw/m68k: Let the machine be the owner of the system memory hw/mips: Let the machine be the owner of the system memory hw/ppc: Let the machine be the owner of the system memory hw/sparc: Let the machine be the owner of the system memory hw/core: Assert memory_region_allocate_system_memory has machine owner

Quoted 6 lines

I forgot 4 other calls:

hw/ppc/ppc4xx_devs.c:708:    memory_region_allocate_system_memory(ram, NULL, "ppc4xx.sdram", ram_size); hw/s390x/s390-virtio-ccw.c:164: memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size); hw/sparc/sun4m.c:791:    memory_region_allocate_system_memory(&d->ram, NULL, "sun4m.ram", hw/sparc64/niagara.c:114: memory_region_allocate_system_memory(&s->partition_ram, NULL,

I'll need to respin this series because of this omission, but
- hw/ppc requires more cleanup patches as ARM has,
- hw/sparc is blocked until Igor sent his "convert memory_region_allocate_system_memory() to memdev" series.

I don't plan to rework on the ARM cleanups patches (1-6):

hw/arm/xilinx_zynq: Use the IEC binary prefix definitions hw/arm/mps2: Use the IEC binary prefix definitions hw/arm/collie: Create the RAM in the board hw/arm/omap2: Create the RAM in the board hw/arm/omap1: Create the RAM in the board hw/arm/digic4: Inline digic4_board_setup_ram() function

Maybe you can take them directly in arm-next once they are reviewed, then the rest can go via machine-next.

Thanks,

Phil.