hw/riscv: virt: Use machine->ram as the system memory
PATCH v3 1/1 hw/riscv: virt: Use machine->ram as the system memory
From: Mingwang Li <[email protected]>
If default main_mem is used to be registered as the system memory, other memory cannot be initialized. Therefore, the system memory should be initialized to the machine->ram, which consists of the default main_mem and other possible memory required by applications, such as shared hugepage memory in DPDK.
Also, the mc->defaul_ram_id should be set to the default main_mem, such as "riscv_virt_board.ram" for the virt machine.
--- hw/riscv/virt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/riscv/virt.c +2 -4
@@ -771,7 +771,6 @@ static void virt_machine_init(MachineState *machine)const MemMapEntry *memmap = virt_memmap;RISCVVirtState *s =RISCV_VIRT_MACHINE (machine);MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *main_mem =g_new (MemoryRegion,1 );MemoryRegion *mask_rom =g_new (MemoryRegion,1 );char *plic_hart_config, *soc_name;target_ulong start_addr = memmap[VIRT_DRAM ].base;
@@ -890,10 +889,8 @@ static void virt_machine_init(MachineState *machine) }/* register system main memory (actual RAM) */ -memory_region_init_ram (main_mem,NULL ,"riscv_virt_board.ram" , - machine->ram_size, &error_fatal);memory_region_add_subregion (system_memory, memmap[VIRT_DRAM ].base, - main_mem); + machine->ram);/* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline,
@@ -1032,6 +1029,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->default_ram_id ="riscv_virt_board.ram" ;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE );
Signature · 1 line
2.19.1
Alistair Francis
AppliedQuoted 9 lines · MingWang Li
From: Mingwang Li <[email protected]>
If default
main_memis used to be registered as the system memory, other memory cannot be initialized. Therefore, the system memory should be initialized to themachine->ram, which consists of the defaultmain_memand other possible memory required by applications, such as shared hugepage memory in DPDK.
Quoted 6 lines
Also, the
mc->defaul_ram_idshould be set to the defaultmain_mem, such as "riscv_virt_board.ram" for the virt machine.Signed-off-by Mingwang Li <[email protected]>Signed-off-by Yifei Jiang <[email protected]>Reviewed-by Alistair Francis <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 40 lines
--- hw/riscv/virt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)hw/riscv/virt.c +2
-5@@ -771,7 +771,6 @@ static void virt_machine_init(MachineState *machine)const MemMapEntry *memmap = virt_memmap;RISCVVirtState *s =RISCV_VIRT_MACHINE (machine);MemoryRegion *system_memory =get_system_memory (); -MemoryRegion *main_mem =g_new (MemoryRegion,1 );MemoryRegion *mask_rom =g_new (MemoryRegion,1 );char *plic_hart_config, *soc_name;target_ulong start_addr = memmap[VIRT_DRAM ].base;@@ -890,10 +889,8 @@ static void virt_machine_init(MachineState *machine) }/* register system main memory (actual RAM) */ -memory_region_init_ram (main_mem,NULL ,"riscv_virt_board.ram" , - machine->ram_size, &error_fatal);memory_region_add_subregion (system_memory, memmap[VIRT_DRAM ].base, - main_mem); + machine->ram);/* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline,@@ -1032,6 +1029,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->default_ram_id ="riscv_virt_board.ram" ;machine_class_allow_dynamic_sysbus_dev (mc,TYPE_RAMFB_DEVICE ); --2.19.1