All of lore.kernel.org
 help / color / mirror / Atom feed
From: "kwangwoo.lee@sk.com" <kwangwoo.lee@sk.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Shannon Zhao <zhaoshenglong@huawei.com>,
	Shannon Zhao <shannon.zhao@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	"woosuk.chung@sk.com" <woosuk.chung@sk.com>,
	"hyunchul3.kim@sk.com" <hyunchul3.kim@sk.com>
Subject: Re: [Qemu-devel] [RFC PATCH 1/3] hw/arm/virt: add hotplug memory support
Date: Mon, 1 Aug 2016 00:35:35 +0000	[thread overview]
Message-ID: <79b91f02b26441be993e372cef44002d@nmail01.hynixad.com> (raw)
In-Reply-To: <CAFEAcA_5jngVxajJxdJ0krz0inrkdjTNYYZ+5SNGOipoQo35ZA@mail.gmail.com>

Hi Peter,

Thanks a lot for your comments! I answered in line below.

> -----Original Message-----
> From: Peter Maydell [mailto:peter.maydell@linaro.org]
> Sent: Saturday, July 30, 2016 3:10 AM
> To: 이광우(LEE KWANGWOO) MS SW
> Cc: Xiao Guangrong; Michael S. Tsirkin; Igor Mammedov; Paolo Bonzini; Richard Henderson; Eduardo
> Habkost; Shannon Zhao; Shannon Zhao; QEMU Developers; qemu-arm; 정우석(CHUNG WOO SUK) MS SW; 김현철(KIM
> HYUNCHUL) MS SW
> Subject: Re: [RFC PATCH 1/3] hw/arm/virt: add hotplug memory support
> 
> On 20 July 2016 at 01:49, Kwangwoo Lee <kwangwoo.lee@sk.com> wrote:
> > Add hotplug memory feature on aarch64 virt platfom. This patch is
> > required to emulate a DIMM type memory like NVDIMM.
> >
> > Signed-off-by: Kwangwoo Lee <kwangwoo.lee@sk.com>
> > ---
> >  default-configs/aarch64-softmmu.mak |   1 +
> >  hw/arm/virt.c                       | 110 ++++++++++++++++++++++++++++++++++++
> >  include/hw/arm/virt.h               |   3 +
> >  3 files changed, 114 insertions(+)
> >
> > diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak
> > index 2449483..5790cd2 100644
> > --- a/default-configs/aarch64-softmmu.mak
> > +++ b/default-configs/aarch64-softmmu.mak
> > @@ -7,3 +7,4 @@ CONFIG_AUX=y
> >  CONFIG_DDC=y
> >  CONFIG_DPCD=y
> >  CONFIG_XLNX_ZYNQMP=y
> > +CONFIG_MEM_HOTPLUG=y
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> > index a193b5a..f7ff411 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -58,6 +58,8 @@
> >  #include "hw/smbios/smbios.h"
> >  #include "qapi/visitor.h"
> >  #include "standard-headers/linux/input.h"
> > +#include "hw/mem/pc-dimm.h"
> > +#include "hw/acpi/acpi.h"
> >
> >  /* Number of external interrupt lines to configure the GIC with */
> >  #define NUM_IRQS 256
> > @@ -91,6 +93,7 @@ typedef struct {
> >      bool secure;
> >      bool highmem;
> >      int32_t gic_version;
> > +    MemoryHotplugState hotplug_memory;
> >  } VirtMachineState;
> >
> >  #define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
> > @@ -1376,6 +1379,40 @@ static void machvirt_init(MachineState *machine)
> >      guest_info_state->machine_done.notify = virt_guest_info_machine_done;
> >      qemu_add_machine_init_done_notifier(&guest_info_state->machine_done);
> >
> > +    /* initialize hotplug memory address space */
> > +    if (machine->ram_size < machine->maxram_size) {
> > +        ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
> > +
> > +        if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) {
> > +            error_report("unsupported amount of memory slots: %"PRIu64,
> 
> "number of"

OK. I'll fix this.

> > +                     machine->ram_slots);
> > +            exit(EXIT_FAILURE);
> > +        }
> > +
> > +        if (QEMU_ALIGN_UP(machine->maxram_size,
> > +                     TARGET_PAGE_SIZE) != machine->maxram_size) {
> > +            error_report("maximum memory size must by aligned to multiple of "
> 
> "must be"

OK. I'll fix this

> > +                     "%d bytes", TARGET_PAGE_SIZE);
> > +            exit(EXIT_FAILURE);
> > +        }
> > +
> > +        vms->hotplug_memory.base =
> > +                     ROUND_UP(vbi->memmap[VIRT_MEM].base + machine->ram_size,
> > +                                              ARCH_VIRT_HOTPLUG_MEM_ALIGN);
> > +
> > +        if ((vms->hotplug_memory.base + hotplug_mem_size) <
> > +            hotplug_mem_size) {
> 
> This expression is confusing. Is it trying to test for overflow?
> When can that happen?

Ah.. you are right. No need to check this. I'll remove this. Thanks!

> > +            error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
> > +                     machine->maxram_size);
> > +            exit(EXIT_FAILURE);
> > +        }
> > +
> > +        memory_region_init(&vms->hotplug_memory.mr, OBJECT(vms),
> > +                           "hotplug-memory", hotplug_mem_size);
> > +        memory_region_add_subregion(sysmem, vms->hotplug_memory.base,
> > +                                    &vms->hotplug_memory.mr);
> > +    }
> > +
> >      vbi->bootinfo.ram_size = machine->ram_size;
> >      vbi->bootinfo.kernel_filename = machine->kernel_filename;
> >      vbi->bootinfo.kernel_cmdline = machine->kernel_cmdline;
> > @@ -1448,9 +1485,75 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)
> >      }
> >  }
> >
> > +static void virt_dimm_plug(HotplugHandler *hotplug_dev,
> > +                         DeviceState *dev, Error **errp)
> > +{
> > +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> > +    PCDIMMDevice *dimm = PC_DIMM(dev);
> > +    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
> > +    MemoryRegion *mr = ddc->get_memory_region(dimm);
> > +    Error *local_err = NULL;
> > +    uint64_t align = memory_region_get_alignment(mr);
> > +
> > +    pc_dimm_memory_plug(dev, &vms->hotplug_memory, mr, align, &local_err);
> > +    if (local_err) {
> > +        goto out;
> > +    }
> > +
> > +out:
> > +    error_propagate(errp, local_err);
> > +}
> > +
> > +static void virt_dimm_unplug(HotplugHandler *hotplug_dev,
> > +                           DeviceState *dev, Error **errp)
> > +{
> > +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> > +    PCDIMMDevice *dimm = PC_DIMM(dev);
> > +    PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
> > +    MemoryRegion *mr = ddc->get_memory_region(dimm);
> > +    Error *local_err = NULL;
> > +
> > +    pc_dimm_memory_unplug(dev, &vms->hotplug_memory, mr);
> > +    object_unparent(OBJECT(dev));
> > +
> > +    error_propagate(errp, local_err);
> > +}
> > +
> > +static void virt_machinedevice_plug_cb(HotplugHandler *hotplug_dev,
> > +                                      DeviceState *dev, Error **errp)
> > +{
> > +    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +        virt_dimm_plug(hotplug_dev, dev, errp);
> > +    } else {
> > +        error_setg(errp, "acpi: device plug request for not supported device"
> 
> "unsupported"

OK. Will fix.

> > +                   " type: %s", object_get_typename(OBJECT(dev)));
> > +    }
> > +}
> > +
> > +static void virt_machinedevice_unplug_cb(HotplugHandler *hotplug_dev,
> > +                                        DeviceState *dev, Error **errp)
> > +{
> > +    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +        virt_dimm_unplug(hotplug_dev, dev, errp);
> > +    } else {
> > +        error_setg(errp, "acpi: device unplug for not supported device"
> 
> "unsupported"

OK. Will fix.

> > +                   " type: %s", object_get_typename(OBJECT(dev)));
> > +    }
> > +}
> > +
> > +static HotplugHandler *virt_get_hotplug_handler(MachineState *machine,
> > +                                             DeviceState *dev)
> > +{
> > +    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > +        return HOTPLUG_HANDLER(machine);
> > +    }
> > +    return NULL;
> > +}
> > +
> >  static void virt_machine_class_init(ObjectClass *oc, void *data)
> >  {
> >      MachineClass *mc = MACHINE_CLASS(oc);
> > +    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
> >
> >      mc->init = machvirt_init;
> >      /* Start max_cpus at the maximum QEMU supports. We'll further restrict
> > @@ -1462,6 +1565,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
> >      mc->block_default_type = IF_VIRTIO;
> >      mc->no_cdrom = 1;
> >      mc->pci_allow_0_address = true;
> > +    mc->get_hotplug_handler = virt_get_hotplug_handler;
> > +    hc->plug = virt_machinedevice_plug_cb;
> > +    hc->unplug = virt_machinedevice_unplug_cb;
> >  }
> >
> >  static const TypeInfo virt_machine_info = {
> > @@ -1471,6 +1577,10 @@ static const TypeInfo virt_machine_info = {
> >      .instance_size = sizeof(VirtMachineState),
> >      .class_size    = sizeof(VirtMachineClass),
> >      .class_init    = virt_machine_class_init,
> > +    .interfaces = (InterfaceInfo[]) {
> > +         { TYPE_HOTPLUG_HANDLER },
> > +         { }
> > +    },
> >  };
> >
> >  static void machvirt_machine_init(void)
> > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> > index 9650193..35aa3cc 100644
> > --- a/include/hw/arm/virt.h
> > +++ b/include/hw/arm/virt.h
> > @@ -45,6 +45,9 @@
> >
> >  #define PPI(irq) ((irq) + 16)
> >
> > +/* 1GB alignment for hotplug memory region */
> > +#define ARCH_VIRT_HOTPLUG_MEM_ALIGN (1ULL << 30)
> 
> Where does the 1GB alignment come from? Why do we need 1GB
> alignment for the base but only 1KB alignment for the size?

The alignment value of hotplug_memory.base referred from i386 pc.c and ppc spapr.c.
Could you suggest a proper range for this?

> > +
> >  enum {
> >      VIRT_FLASH,
> >      VIRT_MEM,
> > --
> > 2.5.0
> 
> thanks
> -- PMM

Best Regards,
Kwangwoo Lee

  reply	other threads:[~2016-08-01  0:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20  0:49 [Qemu-devel] [RFC PATCH 0/3] add nvdimm support on AArch64 virt platform Kwangwoo Lee
2016-07-20  0:49 ` [Qemu-devel] [RFC PATCH 1/3] hw/arm/virt: add hotplug memory support Kwangwoo Lee
2016-07-29 18:10   ` Peter Maydell
2016-08-01  0:35     ` kwangwoo.lee [this message]
2016-08-01  7:46       ` Igor Mammedov
2016-08-01  8:13         ` Peter Maydell
2016-08-01  9:14           ` Igor Mammedov
2016-08-02  5:54             ` kwangwoo.lee
2016-08-02  7:59             ` Peter Maydell
2016-08-02 12:18               ` Igor Mammedov
2016-08-04 23:30                 ` kwangwoo.lee
2016-07-20  0:49 ` [Qemu-devel] [RFC PATCH 2/3] nvdimm: use configurable ACPI IO base and size Kwangwoo Lee
2016-07-25 16:12   ` Peter Maydell
2016-07-26  6:55     ` kwangwoo.lee
2016-07-20  0:49 ` [Qemu-devel] [RFC PATCH 3/3] hw/arm/virt: add nvdimm emulation support Kwangwoo Lee
2016-07-25 16:05   ` Peter Maydell
2016-07-26  7:03     ` kwangwoo.lee
2016-07-26  8:23       ` Peter Maydell
2016-07-27  2:23         ` kwangwoo.lee
2016-07-25 16:06 ` [Qemu-devel] [RFC PATCH 0/3] add nvdimm support on AArch64 virt platform Peter Maydell
2016-07-26  6:32   ` kwangwoo.lee
2016-07-29 18:11     ` Peter Maydell

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=79b91f02b26441be993e372cef44002d@nmail01.hynixad.com \
    --to=kwangwoo.lee@sk.com \
    --cc=ehabkost@redhat.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=hyunchul3.kim@sk.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=shannon.zhao@linaro.org \
    --cc=woosuk.chung@sk.com \
    --cc=zhaoshenglong@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.