From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aafE8-0002zI-Th for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:00:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aafE3-0005lp-44 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:00:16 -0500 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:35476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aafE2-0005lQ-Jk for qemu-devel@nongnu.org; Tue, 01 Mar 2016 03:00:11 -0500 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 Mar 2016 18:00:06 +1000 Date: Tue, 1 Mar 2016 13:28:56 +0530 From: Bharata B Rao Message-ID: <20160301075856.GH5756@in.ibm.com> References: <1456417362-20652-1-git-send-email-bharata@linux.vnet.ibm.com> <1456417362-20652-5-git-send-email-bharata@linux.vnet.ibm.com> <20160226035141.GG20657@voom.fritz.box> <20160229044210.GA5756@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160229044210.GA5756@in.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v0 4/6] spapr: CPU hotplug support Reply-To: bharata@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: mjrosato@linux.vnet.ibm.com, agraf@suse.de, thuth@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, armbru@redhat.com, borntraeger@de.ibm.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com, afaerber@suse.de, mdroth@linux.vnet.ibm.com On Mon, Feb 29, 2016 at 10:12:10AM +0530, Bharata B Rao wrote: > > > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > > > index b7c5ebd..cc0369e 100644 > > > --- a/hw/ppc/spapr_rtas.c > > > +++ b/hw/ppc/spapr_rtas.c > > > @@ -34,6 +34,7 @@ > > > > > > #include "hw/ppc/spapr.h" > > > #include "hw/ppc/spapr_vio.h" > > > +#include "hw/ppc/ppc.h" > > > #include "qapi-event.h" > > > #include "hw/boards.h" > > > > > > @@ -161,6 +162,27 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_, > > > rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); > > > } > > > > > > +/* > > > + * Set the timebase offset of the CPU to that of first CPU. > > > + * This helps hotplugged CPU to have the correct timebase offset. > > > + */ > > > +static void spapr_cpu_update_tb_offset(PowerPCCPU *cpu) > > > +{ > > > + PowerPCCPU *fcpu = POWERPC_CPU(first_cpu); > > > + > > > + cpu->env.tb_env->tb_offset = fcpu->env.tb_env->tb_offset; > > > +} > > > + > > > +static void spapr_cpu_set_endianness(PowerPCCPU *cpu) > > > +{ > > > + PowerPCCPU *fcpu = POWERPC_CPU(first_cpu); > > > + PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(fcpu); > > > + > > > + if (!pcc->interrupts_big_endian(fcpu)) { > > > + cpu->env.spr[SPR_LPCR] |= LPCR_ILE; > > > + } > > > +} > > > + > > > > Any particular reason for doing these things at rtas_start_cpu() time, > > but other initialization at plug time? Could you consolidate it to > > one place or the other? > > Those board specific things that are needed to be done have been consolidated > into spapr_cpu_init() which will be called from the plug handler. We have > discussed this earlier at: > > https://lists.nongnu.org/archive/html/qemu-devel/2015-02/msg04399.html > > It has been a while but there was a good reason why setting endianness > here rather than in plug handler is necessary. W/o this LE hotplug on guests > wouldn't work, I will dig up and come back on what exactly necessiated > this change. If we set LPCR_ILE in cpu->env.spr[SPR_LPCR] at plug time (from spapr_cpu_init()), there are at least two places later where it gets over-written. One is spapr_cpu_reset() and the other one when kvm_cpu_synchronize_state() is called from rtas_start_cpu(). We could probably issue a kvm_arch_put_registers(), but I found rtas_start_cpu() as a place where this change is guaranteed to get reflected. Regards, Bharata.