Received: from eggs.gnu.org ([2001:4830:134:3::10]:57191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLmJA-00009O-2s for qemu-devel@nongnu.org; Thu, 12 Feb 2015 00:27:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLmJ8-0002Dd-Oi for qemu-devel@nongnu.org; Thu, 12 Feb 2015 00:27:23 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:41185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLmJ8-0002D7-7R for qemu-devel@nongnu.org; Thu, 12 Feb 2015 00:27:22 -0500 Date: Thu, 12 Feb 2015 16:19:36 +1100 From: David Gibson Message-ID: <20150212051936.GB20593@voom.redhat.com> References: <1420697420-16053-1-git-send-email-bharata@linux.vnet.ibm.com> <1420697420-16053-12-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qcHopEYAB45HaUaB" Content-Disposition: inline In-Reply-To: <1420697420-16053-12-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v1 11/13] spapr: Initialize hotplug memory address space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: imammedo@redhat.com, agraf@suse.de, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com --qcHopEYAB45HaUaB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 08, 2015 at 11:40:18AM +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 | 26 ++++++++++++++++++++++++++ > include/hw/ppc/spapr.h | 3 +++ > 3 files changed, 30 insertions(+) >=20 > diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-so= ftmmu.mak > index bd30d69..03210de 100644 > --- a/default-configs/ppc64-softmmu.mak > +++ b/default-configs/ppc64-softmmu.mak > @@ -60,3 +60,4 @@ CONFIG_I82374=3Dy > CONFIG_I8257=3Dy > CONFIG_MC146818RTC=3Dy > CONFIG_ISA_TESTDEV=3Dy > +CONFIG_MEM_HOTPLUG=3Dy > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 44405b2..9ff08ff 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -120,6 +120,8 @@ struct sPAPRMachineState { > =20 > /*< public >*/ > char *kvm_type; > + ram_addr_t hotplug_memory_base; > + MemoryRegion hotplug_memory; We should really unify sPAPRMachineState with sPAPREnvironment at some point (I realise that doesn't reasonably fit within the scope of this series). > }; > =20 > sPAPREnvironment *spapr; > @@ -1403,6 +1405,7 @@ static void ppc_spapr_init(MachineState *machine) > bool kernel_le =3D false; > char *filename; > int smt =3D kvmppc_smt_threads(); > + sPAPRMachineState *ms =3D SPAPR_MACHINE(machine); > =20 > msi_supported =3D true; > =20 > @@ -1492,6 +1495,29 @@ static void ppc_spapr_init(MachineState *machine) > memory_region_add_subregion(sysmem, 0, rma_region); > } > =20 > + 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, 1ULL << = 30); Is there a particular significance to the 1GiB alignment? Is it just a conveniently large alignment, or is that value specified in PAPR somewhere? Using a named constant would probably help to clarify that. > + 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); > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index ae8b4e1..64681c4 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -482,6 +482,9 @@ struct sPAPRTCETable { > #define TIMEBASE_FREQ 512000000ULL > #define SPAPR_MIN_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ > =20 > +/* Support a min of 1TB hotplug memory assuming 256MB per slot */ > +#define SPAPR_MAX_RAM_SLOTS (1ULL << 12) Is this constraint arbitrary, or does it come from something in PAPR+? > 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 --qcHopEYAB45HaUaB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU3DfoAAoJEGw4ysog2bOS+vMQALZH24X6MfqdmKFF8RozVC+B x7FGwqQgRtevTC/wJa8dYY0vaH1JNjRcZvBFwrPNWhPUzkouJTJFepUKmCS39uMJ Tt7gGqMM9eoedLvNhEnonV4mMYoG1aQxB2dRy0WYCTxtDVVASi74dpNOXLMKNTIi t++LqlGCJw8gTefnwlmgMEnpFe1/TT7SlbcR38adoPoQIgT4o/QRy3BMMPUvGcDv VLlzGXtcp+QPwD6OSqX/lHp/glKI8dnHzQk/JURJzs4fyo9Ukbh1qmCHd8h1Nr6E xAM9xnVZuNULShK2UERUemyPLX+edWEBWCTDOyhMwf2rwMLEeAy44+FshR3RT7XE YYbBrR7VsKD4mzV1VWSQm5QJfp31NbYmEaktD8kBnGv+kzHE0AGIaC/dDll1QHLH MS2Drz40fwlyrmU/B4UvhQ7/tNqhauPhCuTw4GfNrqoja4Ktqlm3+5V3oACz+TlB by2pfQEku4c7upnDMDebCRRWi7Mc8syDthslAe6Zn4lZZlA08K/pJM2afwa9YN/A ivZuAdEcrqHsLs/t+baQOgIyDgofLlv80DtBJsL2JWzAXnMqCtTNh9C/8VeIp2w0 jS8iV3wRuNNrvFr7uLnHdjhHSeJFlI9v2Qj5x83ifIWQrgFJWvDyjndiMRF0YsIG Gr86yRnIENlgTsX7VIOC =DAOu -----END PGP SIGNATURE----- --qcHopEYAB45HaUaB--