From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7EhV-0005YP-SY for qemu-devel@nongnu.org; Mon, 22 Jun 2015 23:16:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7EhS-0005yL-NA for qemu-devel@nongnu.org; Mon, 22 Jun 2015 23:16:41 -0400 Date: Tue, 23 Jun 2015 11:54:29 +1000 From: David Gibson Message-ID: <20150623015429.GX13352@voom.redhat.com> References: <1434709077-17491-1-git-send-email-bharata@linux.vnet.ibm.com> <1434709077-17491-4-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4YpuVpvaG742Nl2X" Content-Disposition: inline In-Reply-To: <1434709077-17491-4-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v4 3/5] spapr: Support ibm, dynamic-reconfiguration-memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com --4YpuVpvaG742Nl2X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 19, 2015 at 03:47:55PM +0530, Bharata B Rao wrote: > Parse ibm,architecture.vec table obtained from the guest and enable > memory node configuration via ibm,dynamic-reconfiguration-memory if guest > supports it. This is in preparation to support memory hotplug for > sPAPR guests. >=20 > This changes the way memory node configuration is done. Currently all > memory nodes are built upfront. But after this patch, only memory@0 node > for RMA is built upfront. Guest kernel boots with just that and rest of > the memory nodes (via memory@XXX or ibm,dynamic-reconfiguration-memory) > are built when guest does ibm,client-architecture-support call. >=20 > Note: This patch needs a SLOF enhancement which is already part of > SLOF binary in QEMU. >=20 > Signed-off-by: Bharata B Rao [snip] > +int spapr_h_cas_compose_response(sPAPRMachineState *spapr, > + target_ulong addr, target_ulong size, > + bool cpu_update, bool memory_update) > +{ > + void *fdt, *fdt_skel; > + sPAPRDeviceTreeUpdateHeader hdr =3D { .version_id =3D 1 }; > + > + size -=3D sizeof(hdr); > + > + /* Create sceleton */ > + fdt_skel =3D g_malloc0(size); > + _FDT((fdt_create(fdt_skel, size))); > + _FDT((fdt_begin_node(fdt_skel, ""))); > + _FDT((fdt_end_node(fdt_skel))); > + _FDT((fdt_finish(fdt_skel))); > + fdt =3D g_malloc0(size); > + _FDT((fdt_open_into(fdt_skel, fdt, size))); > + g_free(fdt_skel); > + > + /* Fixup cpu nodes */ > + if (cpu_update) { > + _FDT((spapr_fixup_cpu_dt(fdt, spapr))); > + } The cpu_update parameter seems like its not related to memory hotplug at all. I'm guessing it relates to CPU hotplug, in which case please defer it until those patches are ready to go. > + > + /* Generate memory nodes or ibm,dynamic-reconfiguration-memory node = */ > + if (memory_update && spapr->dr_lmb_enabled) { > + _FDT((spapr_populate_drconf_memory(spapr, fdt))); > + } else { > + _FDT((spapr_populate_memory(spapr, fdt))); > + } > + > + /* Pack resulting tree */ > + _FDT((fdt_pack(fdt))); > + > + if (fdt_totalsize(fdt) + sizeof(hdr) > size) { > + trace_spapr_cas_failed(size); > + return -1; > + } > + > + cpu_physical_memory_write(addr, &hdr, sizeof(hdr)); > + cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt= )); > + trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr)); > + g_free(fdt); > + > + return 0; > +} > + > static void spapr_finalize_fdt(sPAPRMachineState *spapr, > hwaddr fdt_addr, > hwaddr rtas_addr, > @@ -756,10 +866,16 @@ static void spapr_finalize_fdt(sPAPRMachineState *s= papr, > /* open out the base tree into a temp buffer for the final tweaks */ > _FDT((fdt_open_into(spapr->fdt_skel, fdt, FDT_MAX_SIZE))); > =20 > - ret =3D spapr_populate_memory(spapr, fdt); > - if (ret < 0) { > - fprintf(stderr, "couldn't setup memory nodes in fdt\n"); > - exit(1); > + /* > + * Add memory@0 node to represent RMA. Rest of the memory is either > + * represented by memory nodes or ibm,dynamic-reconfiguration-memory > + * node later during ibm,client-architecture-support call. > + */ > + for (i =3D 0; i < nb_numa_nodes; ++i) { > + if (numa_info[i].node_mem) { > + spapr_populate_memory_node(fdt, i, 0, spapr->rma_size); > + break; > + } ?? The code doesn't seem to match the comment - you appear to be creating a memory@0 node for every NUMA node, not just for the RMA, which doesn't make much sense. > } > =20 > ret =3D spapr_populate_vdevice(spapr->vio_bus, fdt); > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c > index 652ddf6..2caac82 100644 > --- a/hw/ppc/spapr_hcall.c > +++ b/hw/ppc/spapr_hcall.c > @@ -808,6 +808,32 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAP= RMachineState *spapr, > return ret; > } > =20 > +/* > + * Return the offset to the requested option vector @vector in the > + * option vector table @table. > + */ > +static target_ulong cas_get_option_vector(int vector, target_ulong table) > +{ > + int i; > + char nr_vectors, nr_entries; > + > + if (!table) { > + return 0; > + } > + > + nr_vectors =3D (ldl_phys(&address_space_memory, table) >> 24) + 1; > + if (!vector || vector > nr_vectors) { > + return 0; > + } > + table++; /* skip nr option vectors */ > + > + for (i =3D 0; i < vector - 1; i++) { > + nr_entries =3D ldl_phys(&address_space_memory, table) >> 24; > + table +=3D nr_entries + 2; > + } > + return table; > +} > + > typedef struct { > PowerPCCPU *cpu; > uint32_t cpu_version; > @@ -828,19 +854,22 @@ static void do_set_compat(void *arg) > ((cpuver) =3D=3D CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \ > ((cpuver) =3D=3D CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0) > =20 > +#define OV5_DRCONF_MEMORY 0x20 > + > static target_ulong h_client_architecture_support(PowerPCCPU *cpu_, > sPAPRMachineState *spa= pr, > target_ulong opcode, > target_ulong *args) > { > - target_ulong list =3D args[0]; > + target_ulong list =3D args[0], ov_table; > PowerPCCPUClass *pcc_ =3D POWERPC_CPU_GET_CLASS(cpu_); > CPUState *cs; > - bool cpu_match =3D false; > + bool cpu_match =3D false, cpu_update =3D true, memory_update =3D fal= se; > unsigned old_cpu_version =3D cpu_->cpu_version; > unsigned compat_lvl =3D 0, cpu_version =3D 0; > unsigned max_lvl =3D get_compat_level(cpu_->max_compat); > int counter; > + char ov5_byte2; > =20 > /* Parse PVR list */ > for (counter =3D 0; counter < 512; ++counter) { > @@ -890,8 +919,6 @@ static target_ulong h_client_architecture_support(Pow= erPCCPU *cpu_, > } > } > =20 > - /* For the future use: here @list points to the first capability */ > - > /* Parsing finished */ > trace_spapr_cas_pvr(cpu_->cpu_version, cpu_match, > cpu_version, pcc_->pcr_mask); > @@ -915,14 +942,26 @@ static target_ulong h_client_architecture_support(P= owerPCCPU *cpu_, > } > =20 > if (!cpu_version) { > - return H_SUCCESS; > + cpu_update =3D false; > } > =20 > + /* For the future use: here @ov_table points to the first option vec= tor */ > + ov_table =3D list; > + > + list =3D cas_get_option_vector(5, ov_table); > if (!list) { > return H_SUCCESS; > } > =20 > - if (spapr_h_cas_compose_response(spapr, args[1], args[2])) { > + /* @list now points to OV 5 */ > + list +=3D 2; > + ov5_byte2 =3D rtas_ld(list, 0) >> 24; > + if (ov5_byte2 & OV5_DRCONF_MEMORY) { > + memory_update =3D true; > + } > + > + if (spapr_h_cas_compose_response(spapr, args[1], args[2], > + cpu_update, memory_update)) { > qemu_system_reset_request(); > } > =20 > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index b3fba76..2d6921a 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -581,7 +581,8 @@ struct sPAPREventLogEntry { > void spapr_events_init(sPAPRMachineState *sm); > void spapr_events_fdt_skel(void *fdt, uint32_t epow_irq); > int spapr_h_cas_compose_response(sPAPRMachineState *sm, > - target_ulong addr, target_ulong size); > + target_ulong addr, target_ulong size, > + bool cpu_update, bool memory_update); > sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn, > uint64_t bus_offset, > uint32_t page_shift, > @@ -623,4 +624,16 @@ int spapr_rtc_import_offset(DeviceState *dev, int64_= t legacy_offset); > /* 1GB alignment for hotplug memory region */ > #define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30) > =20 > +/* > + * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory > + * property under ibm,dynamic-reconfiguration-memory node. > + */ > +#define SPAPR_DR_LMB_LIST_ENTRY_SIZE 6 > + > +/* > + * This flag value defines the LMB as assigned in ibm,dynamic-memory > + * property under ibm,dynamic-reconfiguration-memory node. > + */ > +#define SPAPR_LMB_FLAGS_ASSIGNED 0x00000008 > + > #endif /* !defined (__HW_SPAPR_H__) */ --=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 --4YpuVpvaG742Nl2X Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJViLxVAAoJEGw4ysog2bOSEzUP/jpBvr8oAsMZIWI9GxNtN+Az bLwR5mLck/ffsIbihw7/5qsh3WadnHq4O7UixdPyazT8PZwU9ve3815WlhKv49Y8 YeY1jOAi3U0j/+vxJ6RoVcBT2+ph+9FN4eD8GQEnkivR5SUFMxwjEX4en6kXh/FL QGzdu4zxaJOujdEuD/s3Vpoi7HIDJ+TlM0Afo/4hFt+zym2fBGRatWkmNdULXG40 ReWTFUxb4saQv4ShMK3WWXfsyPxNsh15NsBmrJcPKCTjLObpBhSztPpQaq9f8320 2g9daFpFVpcRqp8FQ1x0hvt404w14gVq+ubKrHPp0oulUzKFf80ki3SkSyC8SKWj DE8AYaTsZFJbVjNCLgTjjLJtIeUvNOFtWUVgk1ESkWkjZ17KMURkk6G/KMm53p/H gVyhoye2+2cX1NxC2oKzzAHykNcjepYECZTc7OoTSHK3H93NFhKcTkzMk+sLo9+B bGz5O3JHrEOguftpW9I8Kqc7cjZfxGL6+6+LjKVlfuoprL+wjuKxj1h9Kzoxq5bL jgxyXCwepsyD2n8s9I1JhE/ET19aIPMRuoGHCDZ32mDNpg5PA68Dv0Y4fTGsdlhd +Aj6phr0d8dIrXQZPPAhzeIl2D8sA9b2XhZSUUxzZtNe3kUFsbfGACApoEb8iXKd Y/TDPibzPpnYZnt6lztD =KWyK -----END PGP SIGNATURE----- --4YpuVpvaG742Nl2X--