All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: zhuyijun@huawei.com
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
	eric.auger@redhat.com, peter.maydell@linaro.org,
	shameerali.kolothum.thodi@huawei.com, zhaoshenglong@huawei.com
Subject: Re: [Qemu-devel] [RFC 2/5] hw/arm/virt: Enable dynamic generation of guest RAM memory regions
Date: Tue, 14 Nov 2017 15:47:08 +0100	[thread overview]
Message-ID: <20171114144708.uzh6mkmjygojfpbu@kamzik.brq.redhat.com> (raw)
In-Reply-To: <1510622154-17224-3-git-send-email-zhuyijun@huawei.com>

On Tue, Nov 14, 2017 at 09:15:51AM +0800, zhuyijun@huawei.com wrote:
> From: Zhu Yijun <zhuyijun@huawei.com>
> 
> Register a ram_memory_region_init notify to allocate memory region
> from system memory and add them as subregions.
> 
> Signed-off-by: Zhu Yijun <zhuyijun@huawei.com>
> ---
>  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).

> +    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.

>  }
>  
>  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 

  reply	other threads:[~2017-11-14 14:47 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14  1:15 [Qemu-devel] [RFC 0/5] arm: Exclude reserved memory regions of iommu to avoid zhuyijun
2017-11-14  1:15 ` [Qemu-devel] [RFC 1/5] hw/vfio: Add function for getting reserved_region of device iommu group zhuyijun
2017-11-14 15:47   ` Alex Williamson
2017-11-15  9:49     ` Shameerali Kolothum Thodi
2017-11-15 18:25       ` Alex Williamson
2017-11-20 11:58         ` Shameerali Kolothum Thodi
2017-11-20 15:57           ` Alex Williamson
2017-11-20 16:31             ` Shameerali Kolothum Thodi
2017-12-06 10:30             ` Shameerali Kolothum Thodi
2017-12-06 14:01               ` Auger Eric
2017-12-06 14:38                 ` Shameerali Kolothum Thodi
2017-12-06 14:59                   ` Auger Eric
2017-12-06 15:19                     ` Shameerali Kolothum Thodi
2017-11-14  1:15 ` [Qemu-devel] [RFC 2/5] hw/arm/virt: Enable dynamic generation of guest RAM memory regions zhuyijun
2017-11-14 14:47   ` Andrew Jones [this message]
2017-11-20  9:22     ` Zhu Yijun
2017-11-14  1:15 ` [Qemu-devel] [RFC 3/5] hw/arm: add scattered RAM memory region support zhuyijun
2017-11-14 14:50   ` Andrew Jones
2017-11-20  9:54     ` Zhu Yijun
2018-04-19  9:06     ` Shameerali Kolothum Thodi
2018-04-24 15:29       ` Andrew Jones
2018-04-25 13:24         ` Shameerali Kolothum Thodi
2017-11-14  1:15 ` [Qemu-devel] [RFC 4/5] hw/arm/boot: set fdt size cell of memory node from mem_list zhuyijun
2017-11-14 14:51   ` Andrew Jones
2017-11-20  9:38     ` Zhu Yijun
2017-11-14  1:15 ` [Qemu-devel] [RFC 5/5] hw/arm/virt-acpi-build: Build srat table according to mem_list zhuyijun
2017-11-14 14:51   ` Andrew Jones
2017-11-20  9:39     ` Zhu Yijun
2017-11-14  1:42 ` [Qemu-devel] [RFC 0/5] arm: Exclude reserved memory regions of iommu to avoid no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171114144708.uzh6mkmjygojfpbu@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=zhaoshenglong@huawei.com \
    --cc=zhuyijun@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.