From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anbHA-0000jP-0u for qemu-devel@nongnu.org; Tue, 05 Apr 2016 20:24:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anbH6-0004b6-Qu for qemu-devel@nongnu.org; Tue, 05 Apr 2016 20:24:51 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:33992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anbH6-0004ai-Jh for qemu-devel@nongnu.org; Tue, 05 Apr 2016 20:24:48 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Apr 2016 18:24:47 -0600 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1459413561-30745-12-git-send-email-bharata@linux.vnet.ibm.com> References: <1459413561-30745-1-git-send-email-bharata@linux.vnet.ibm.com> <1459413561-30745-12-git-send-email-bharata@linux.vnet.ibm.com> Message-ID: <20160406002439.589.59245@loki> Date: Tue, 05 Apr 2016 19:24:39 -0500 Subject: Re: [Qemu-devel] [RFC PATCH v2.1 11/12] xics, xics_kvm: Handle CPU unplug correctly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao , qemu-devel@nongnu.org Cc: mjrosato@linux.vnet.ibm.com, thuth@redhat.com, pkrempa@redhat.com, ehabkost@redhat.com, aik@ozlabs.ru, armbru@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, qemu-ppc@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com, afaerber@suse.de, david@gibson.dropbear.id.au Quoting Bharata B Rao (2016-03-31 03:39:20) > XICS is setup for each CPU during initialization. Provide a routine > to undo the same when CPU is unplugged. While here, move ss->cs management > into xics from xics_kvm since there is nothing KVM specific in it. > Also ensure xics reset doesn't set irq for CPUs that are already unplugge= d. > = > This allows reboot of a VM that has undergone CPU hotplug and unplug > to work correctly. > = > Signed-off-by: Bharata B Rao > Reviewed-by: David Gibson > --- > hw/intc/xics.c | 14 ++++++++++++++ > hw/intc/xics_kvm.c | 8 ++++---- > include/hw/ppc/xics.h | 1 + > 3 files changed, 19 insertions(+), 4 deletions(-) > = > diff --git a/hw/intc/xics.c b/hw/intc/xics.c > index 213a370..9fdb551 100644 > --- a/hw/intc/xics.c > +++ b/hw/intc/xics.c > @@ -45,6 +45,18 @@ static int get_cpu_index_by_dt_id(int cpu_dt_id) > return -1; > } > = > +void xics_cpu_destroy(XICSState *icp, PowerPCCPU *cpu) > +{ > + CPUState *cs =3D CPU(cpu); > + ICPState *ss =3D &icp->ss[cs->cpu_index]; > + If the following assertion is false, I think you'd get an OOB before you reached it due to the assignment above. > + assert(cs->cpu_index < icp->nr_servers); > + assert(cs =3D=3D ss->cs); > + > + ss->output =3D NULL; > + ss->cs =3D NULL; > +} > +