From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YafRT-0000nO-VX for qemu-devel@nongnu.org; Wed, 25 Mar 2015 03:09:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YafRR-0008RL-Up for qemu-devel@nongnu.org; Wed, 25 Mar 2015 03:09:31 -0400 Date: Wed, 25 Mar 2015 16:58:18 +1100 From: David Gibson Message-ID: <20150325055818.GF25043@voom.fritz.box> References: <1427117764-23008-1-git-send-email-bharata@linux.vnet.ibm.com> <1427117764-23008-22-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7Magvp2j5U6epoiy" Content-Disposition: inline In-Reply-To: <1427117764-23008-22-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v2 21/23] spapr: Initialize hotplug memory address space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com, afaerber@suse.de --7Magvp2j5U6epoiy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 23, 2015 at 07:06:02PM +0530, Bharata B Rao wrote: > Initialize a hotplug memory region under which all the hotplugged > memory is accommodated. Also enable memory hotplug by setting > CONFIG_MEM_HOTPLUG. >=20 > Modelled on i386 memory hotplug. >=20 > Signed-off-by: Bharata B Rao > --- > default-configs/ppc64-softmmu.mak | 1 + > hw/ppc/spapr.c | 50 +++++++++++++++++++++++++++++++++= ++++++ > include/hw/ppc/spapr.h | 12 ++++++++++ > 3 files changed, 63 insertions(+) >=20 > diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-so= ftmmu.mak > index 22ef132..16b3011 100644 > --- a/default-configs/ppc64-softmmu.mak > +++ b/default-configs/ppc64-softmmu.mak > @@ -51,3 +51,4 @@ CONFIG_XICS_KVM=3D$(and $(CONFIG_PSERIES),$(CONFIG_KVM)) > # For PReP > CONFIG_MC146818RTC=3Dy > CONFIG_ISA_TESTDEV=3Dy > +CONFIG_MEM_HOTPLUG=3Dy > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 3e56d9e..e43bb49 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -125,8 +125,13 @@ struct sPAPRMachineState { > =20 > /*< public >*/ > char *kvm_type; > + ram_addr_t hotplug_memory_base; > + MemoryRegion hotplug_memory; > + bool enforce_aligned_dimm; > }; > =20 > +#define SPAPR_MACHINE_ENFORCE_ALIGNED_DIMM "enforce-aligned-dimm" What's the rationale for including this option? > + > sPAPREnvironment *spapr; > =20 > static XICSState *try_create_xics(const char *type, int nr_servers, > @@ -1499,6 +1504,7 @@ static void ppc_spapr_init(MachineState *machine) > int smt =3D kvmppc_smt_threads(); > Object *socket; > int sockets; > + sPAPRMachineState *ms =3D SPAPR_MACHINE(machine); > =20 > msi_supported =3D true; > =20 > @@ -1585,6 +1591,36 @@ static void ppc_spapr_init(MachineState *machine) > memory_region_add_subregion(sysmem, 0, rma_region); > } > =20 > + /* initialize hotplug memory address space */ > + if (machine->ram_size < machine->maxram_size) { > + ram_addr_t hotplug_mem_size =3D > + machine->maxram_size - machine->ram_size; > + > + if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) { > + error_report("unsupported amount of memory slots: %"PRIu64, > + machine->ram_slots); > + exit(EXIT_FAILURE); > + } > + > + ms->hotplug_memory_base =3D ROUND_UP(machine->ram_size, > + SPAPR_HOTPLUG_MEM_ALIGN); > + > + if (ms->enforce_aligned_dimm) { > + hotplug_mem_size +=3D SPAPR_HOTPLUG_MEM_ALIGN * machine->ram= _slots; > + } > + > + if ((ms->hotplug_memory_base + hotplug_mem_size) < hotplug_mem_s= ize) { > + error_report("unsupported amount of maximum memory: " RAM_AD= DR_FMT, > + machine->maxram_size); > + exit(EXIT_FAILURE); > + } > + > + memory_region_init(&ms->hotplug_memory, OBJECT(ms), > + "hotplug-memory", hotplug_mem_size); > + memory_region_add_subregion(sysmem, ms->hotplug_memory_base, > + &ms->hotplug_memory); > + } > + > filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); > spapr->rtas_size =3D get_image_size(filename); > spapr->rtas_blob =3D g_malloc(spapr->rtas_size); > @@ -1827,13 +1863,27 @@ static void spapr_set_kvm_type(Object *obj, const= char *value, Error **errp) > sm->kvm_type =3D g_strdup(value); > } > =20 > +static bool spapr_machine_get_aligned_dimm(Object *obj, Error **errp) > +{ > + sPAPRMachineState *ms =3D SPAPR_MACHINE(obj); > + > + return ms->enforce_aligned_dimm; > +} > + > static void spapr_machine_initfn(Object *obj) > { > + sPAPRMachineState *ms =3D SPAPR_MACHINE(obj); > + > object_property_add_str(obj, "kvm-type", > spapr_get_kvm_type, spapr_set_kvm_type, NULL= ); > object_property_set_description(obj, "kvm-type", > "Specifies the KVM virtualization mo= de (HV, PR)", > NULL); > + > + ms->enforce_aligned_dimm =3D true; > + object_property_add_bool(obj, SPAPR_MACHINE_ENFORCE_ALIGNED_DIMM, > + spapr_machine_get_aligned_dimm, > + NULL, NULL); > } > =20 > static void ppc_cpu_do_nmi_on_cpu(void *arg) > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index ecac6e3..53560e9 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -542,6 +542,18 @@ struct sPAPREventLogEntry { > =20 > #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ > =20 > +/* > + * This defines the maximum number of DIMM slots we can have for sPAPR > + * guest. This is not defined by sPAPR but we are defining it to 4096 sl= ots > + * here. With the worst case addition of SPAPR_MEMORY_BLOCK_SIZE > + * (256MB) memory per slot, we should be able to support 1TB of guest > + * hotpluggable memory. > + */ > +#define SPAPR_MAX_RAM_SLOTS (1ULL << 12) > + > +/* 1GB alignment for hotplug memory region */ > +#define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30) > + > void spapr_events_init(sPAPREnvironment *spapr); > void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq); > int spapr_h_cas_compose_response(target_ulong addr, target_ulong size); --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --7Magvp2j5U6epoiy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVEk55AAoJEGw4ysog2bOS74IQAMSQAfeFr0GXIBoR/ejT0BcF sMoF+NrCLnnLd6mswVZild4mLzcYM2r3v13VjWF/EYOjDcnI03KUdQi1ro96RDvH PA/I/RKYpo9ZuapS2fl4M1SuijMZcnI4hs7zn0wuKy6eoSNOsEgZxxH13K0u6DlS MdvqjUzWvXyoXeI9fmhjqVypdTQLowO9Ygoti3/cG35ZsE3WAinr3WutIhA5DLjx XmmgMzA1w4lnVd/+f0ACtewPwBV7W6SfXbowMGl7z3d+kQxvuWmPbym2ViqfduYe oDTc6LTlUqkypTYfq5tfm+l7IShBuvzVMZLCFmGLofJ7PF4noRlo133Aa+BrVm2w kOVuiHD3bxN8ToguZP/u2DUBz5bhlAy4fFbzBVzI5dJlA0WxHRuqtYCJEZ6NU0Kn ppfGuR6gey5Jd7LbRbe919lxV2MApM3xnV16zmMDhxo9QkcIevMcbXRUJzrMnw2A tEUCxJ/PuG0XmOPH6fkQMItAekvwbAu4w3R7Yymkx52Oh36eqo9oU5WSBlsIGU20 6qmSONXLELtNU1RAS0r6ao8Kj2NkDMm11W8U9+ERVqk6CmgdEGUTZKqCCl+qouYE vCfkKYuBPn647YaGxodHvnnZEpacj2Y2TVKjcaRIlJjLMR4CXgz7Nd7wumbExAWb KTzrLQ2Xs72QWeCrklJ+ =Vr4N -----END PGP SIGNATURE----- --7Magvp2j5U6epoiy--