memory_region_allocate_system_memory() was designed to be called for
allocating inital RAM. Using it mutiple times within one board is not
supported and could fail if -mem-path with non hugepage path is used.
Keep using memory_region_allocate_system_memory() only for initial
RAM and use memory_region_init_ram() for the rest fixed size regions.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/sparc64/niagara.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index f8a856f..39a4522 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -37,6 +37,7 @@
#include "sysemu/block-backend.h"
#include "qemu/error-report.h"
#include "sysemu/qtest.h"
+#include "qapi/error.h"
typedef struct NiagaraBoardState {
@@ -108,8 +109,8 @@ static void niagara_init(MachineState *machine)
/* init CPUs */
sparc64_cpu_devinit(machine->cpu_type, NIAGARA_PROM_BASE);
/* set up devices */
- memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram",
- NIAGARA_HV_RAM_SIZE);
+ memory_region_init_ram(&s->hv_ram, NULL, "sun4v-hv.ram",
+ NIAGARA_HV_RAM_SIZE, &error_fatal);
memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram);
memory_region_allocate_system_memory(&s->partition_ram, NULL,
@@ -118,17 +119,17 @@ static void niagara_init(MachineState *machine)
memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE,
&s->partition_ram);
- memory_region_allocate_system_memory(&s->nvram, NULL,
- "sun4v.nvram", NIAGARA_NVRAM_SIZE);
+ memory_region_init_ram(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE,
+ &error_fatal);
memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram);
- memory_region_allocate_system_memory(&s->md_rom, NULL,
- "sun4v-md.rom", NIAGARA_MD_ROM_SIZE);
+ memory_region_init_ram(&s->md_rom, NULL, "sun4v-md.rom",
+ NIAGARA_MD_ROM_SIZE, &error_fatal);
memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom);
- memory_region_allocate_system_memory(&s->hv_rom, NULL,
- "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE);
+ memory_region_init_ram(&s->hv_rom, NULL, "sun4v-hv.rom",
+ NIAGARA_HV_ROM_SIZE, &error_fatal);
memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom);
- memory_region_allocate_system_memory(&s->prom, NULL,
- "sun4v.prom", PROM_SIZE_MAX);
+ memory_region_init_ram(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX,
+ &error_fatal);
memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom);
add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE);
@@ -145,8 +146,8 @@ static void niagara_init(MachineState *machine)
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
int size = blk_getlength(blk);
if (size > 0) {
- memory_region_allocate_system_memory(&s->vdisk_ram, NULL,
- "sun4v_vdisk.ram", size);
+ memory_region_init_ram(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size,
+ &error_fatal);
memory_region_add_subregion(get_system_memory(),
NIAGARA_VDISK_BASE, &s->vdisk_ram);
dinfo->is_default = 1;
--
2.7.4
On 4/15/19 3:27 PM, Igor Mammedov wrote:
> memory_region_allocate_system_memory() was designed to be called for
> allocating inital RAM. Using it mutiple times within one board is not
> supported and could fail if -mem-path with non hugepage path is used.
>
> Keep using memory_region_allocate_system_memory() only for initial
> RAM and use memory_region_init_ram() for the rest fixed size regions.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/sparc64/niagara.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index f8a856f..39a4522 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -37,6 +37,7 @@
> #include "sysemu/block-backend.h"
> #include "qemu/error-report.h"
> #include "sysemu/qtest.h"
> +#include "qapi/error.h"
>
>
> typedef struct NiagaraBoardState {
> @@ -108,8 +109,8 @@ static void niagara_init(MachineState *machine)
> /* init CPUs */
> sparc64_cpu_devinit(machine->cpu_type, NIAGARA_PROM_BASE);
> /* set up devices */
> - memory_region_allocate_system_memory(&s->hv_ram, NULL, "sun4v-hv.ram",
> - NIAGARA_HV_RAM_SIZE);
> + memory_region_init_ram(&s->hv_ram, NULL, "sun4v-hv.ram",
> + NIAGARA_HV_RAM_SIZE, &error_fatal);
> memory_region_add_subregion(sysmem, NIAGARA_HV_RAM_BASE, &s->hv_ram);
>
> memory_region_allocate_system_memory(&s->partition_ram, NULL,
Using the partition RAM as system memory rather than HV one seems the
correct choice.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> @@ -118,17 +119,17 @@ static void niagara_init(MachineState *machine)
> memory_region_add_subregion(sysmem, NIAGARA_PARTITION_RAM_BASE,
> &s->partition_ram);
>
> - memory_region_allocate_system_memory(&s->nvram, NULL,
> - "sun4v.nvram", NIAGARA_NVRAM_SIZE);
> + memory_region_init_ram(&s->nvram, NULL, "sun4v.nvram", NIAGARA_NVRAM_SIZE,
> + &error_fatal);
> memory_region_add_subregion(sysmem, NIAGARA_NVRAM_BASE, &s->nvram);
> - memory_region_allocate_system_memory(&s->md_rom, NULL,
> - "sun4v-md.rom", NIAGARA_MD_ROM_SIZE);
> + memory_region_init_ram(&s->md_rom, NULL, "sun4v-md.rom",
> + NIAGARA_MD_ROM_SIZE, &error_fatal);
> memory_region_add_subregion(sysmem, NIAGARA_MD_ROM_BASE, &s->md_rom);
> - memory_region_allocate_system_memory(&s->hv_rom, NULL,
> - "sun4v-hv.rom", NIAGARA_HV_ROM_SIZE);
> + memory_region_init_ram(&s->hv_rom, NULL, "sun4v-hv.rom",
> + NIAGARA_HV_ROM_SIZE, &error_fatal);
> memory_region_add_subregion(sysmem, NIAGARA_HV_ROM_BASE, &s->hv_rom);
> - memory_region_allocate_system_memory(&s->prom, NULL,
> - "sun4v.prom", PROM_SIZE_MAX);
> + memory_region_init_ram(&s->prom, NULL, "sun4v.prom", PROM_SIZE_MAX,
> + &error_fatal);
> memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom);
>
> add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE);
> @@ -145,8 +146,8 @@ static void niagara_init(MachineState *machine)
> BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
> int size = blk_getlength(blk);
> if (size > 0) {
> - memory_region_allocate_system_memory(&s->vdisk_ram, NULL,
> - "sun4v_vdisk.ram", size);
> + memory_region_init_ram(&s->vdisk_ram, NULL, "sun4v_vdisk.ram", size,
> + &error_fatal);
> memory_region_add_subregion(get_system_memory(),
> NIAGARA_VDISK_BASE, &s->vdisk_ram);
> dinfo->is_default = 1;
>
© 2016 - 2026 Red Hat, Inc.