[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [Qemu-devel] [RFC 2/5] hw/arm/virt: Enable dynamic genera
From: |
Zhu Yijun |
Subject: |
Re: [Qemu-arm] [Qemu-devel] [RFC 2/5] hw/arm/virt: Enable dynamic generation of guest RAM memory regions |
Date: |
Mon, 20 Nov 2017 17:22:44 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 |
Hi Andrew,
Thanks for your review!
On 2017/11/14 22:47, Andrew Jones wrote:
> On Tue, Nov 14, 2017 at 09:15:51AM +0800, address@hidden wrote:
>> From: Zhu Yijun <address@hidden>
>>
>> Register a ram_memory_region_init notify to allocate memory region
>> from system memory and add them as subregions.
>>
>> Signed-off-by: Zhu Yijun <address@hidden>
>> ---
>> hw/arm/virt.c | 21 ++++++++++++++++-----
>> include/hw/arm/virt.h | 1 +
>> 2 files changed, 17 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 9e18b41..ddde5e1 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -1225,6 +1225,19 @@ void virt_machine_done(Notifier *notifier, void *data)
>> virt_build_smbios(vms);
>> }
>>
>> +static void virt_ram_memory_region_init(Notifier *notifier, void *data)
>> +{
>> + MachineState *machine = MACHINE(qdev_get_machine());
> No need to use qdev_get_machine(), you can get it with MACHINE(vms).
OK
>> + MemoryRegion *sysmem = get_system_memory();
>> + MemoryRegion *ram = g_new(MemoryRegion, 1);
>> + VirtMachineState *vms = container_of(notifier, VirtMachineState,
>> + ram_memory_region_init);
>> +
>> + memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
>> + machine->ram_size);
>> + memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
>> +}
>> +
>> static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
>> {
>> uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER;
>> @@ -1258,7 +1271,6 @@ static void machvirt_init(MachineState *machine)
>> MemoryRegion *sysmem = get_system_memory();
>> MemoryRegion *secure_sysmem = NULL;
>> int n, virt_max_cpus;
>> - MemoryRegion *ram = g_new(MemoryRegion, 1);
>> bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
>>
>> /* We can probe only here because during property set
>> @@ -1409,10 +1421,6 @@ static void machvirt_init(MachineState *machine)
>> fdt_add_cpu_nodes(vms);
>> fdt_add_psci_node(vms);
>>
>> - memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram",
>> - machine->ram_size);
>> - memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram);
>> -
>> create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem);
>>
>> create_gic(vms, pic);
>> @@ -1462,6 +1470,9 @@ static void machvirt_init(MachineState *machine)
>> * Notifiers are executed in registration reverse order.
>> */
>> create_platform_bus(vms, pic);
>> +
>> + vms->ram_memory_region_init.notify = virt_ram_memory_region_init;
>> + qemu_add_machine_init_done_notifier(&vms->ram_memory_region_init);
> Does this notifier need to be the first one executed? If so, then a
> comment should be added to state that. Actually the comment above
> create_platform_bus() could be replaced with a comment above the first
> notifier that states all notifier dependencies.
Yes, it should be the first notifier, because reserved memory regions must get
before memory node created in arm_load_kernel_notify.
>> }
>>
>> static bool virt_get_secure(Object *obj, Error **errp)
>> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
>> index 33b0ff3..38906b8 100644
>> --- a/include/hw/arm/virt.h
>> +++ b/include/hw/arm/virt.h
>> @@ -90,6 +90,7 @@ typedef struct {
>> typedef struct {
>> MachineState parent;
>> Notifier machine_done;
>> + Notifier ram_memory_region_init;
>> FWCfgState *fw_cfg;
>> bool secure;
>> bool highmem;
>> --
>> 1.8.3.1
>>
>>
>>
> Thanks,
> drew
>
> .
>
- Re: [Qemu-arm] [Qemu-devel] [RFC 1/5] hw/vfio: Add function for getting reserved_region of device iommu group, (continued)
[Qemu-arm] [RFC 5/5] hw/arm/virt-acpi-build: Build srat table according to mem_list, zhuyijun, 2017/11/13
[Qemu-arm] [RFC 4/5] hw/arm/boot: set fdt size cell of memory node from mem_list, zhuyijun, 2017/11/13
[Qemu-arm] [RFC 2/5] hw/arm/virt: Enable dynamic generation of guest RAM memory regions, zhuyijun, 2017/11/13
Re: [Qemu-arm] [Qemu-devel] [RFC 0/5] arm: Exclude reserved memory regions of iommu to avoid, no-reply, 2017/11/14