From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8ixb-0006OD-K9 for qemu-devel@nongnu.org; Fri, 03 Jun 2016 02:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8ixX-0003ew-DP for qemu-devel@nongnu.org; Fri, 03 Jun 2016 02:51:59 -0400 Date: Fri, 3 Jun 2016 16:17:52 +1000 From: David Gibson Message-ID: <20160603061752.GO1087@voom.fritz.box> References: <1463024905-28401-1-git-send-email-bharata@linux.vnet.ibm.com> <1463024905-28401-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="RHdRtM27np9fZUoh" Content-Disposition: inline In-Reply-To: <1463024905-28401-12-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [for-2.7 PATCH v3 11/15] spapr_drc: Prevent detach racing against attach for CPU DR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, afaerber@suse.de, imammedo@redhat.com, armbru@redhat.com, thuth@redhat.com, aik@ozlabs.ru, agraf@suse.de, pbonzini@redhat.com, ehabkost@redhat.com, pkrempa@redhat.com, mdroth@linux.vnet.ibm.com, eblake@redhat.com, mjrosato@linux.vnet.ibm.com, borntraeger@de.ibm.com --RHdRtM27np9fZUoh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 12, 2016 at 09:18:21AM +0530, Bharata B Rao wrote: > If a CPU is hot removed while hotplug of the same is still in progress, > the guest crashes. Prevent this by ensuring that detach is done only > after attach has completed. >=20 > The existing code already prevents such race for PCI hotplug. However > given that CPU is a logical DR unlike PCI and starts with ISOLATED > state, we need a logic that works for CPU too. >=20 > Signed-off-by: Bharata B Rao > Reviewed-by: Michael Roth > Signed-off-by: Michael Roth > [Don't set awaiting_attach for PCI devices] Applied to ppc-cpu-hotplug branch. > --- > hw/ppc/spapr_drc.c | 12 ++++++++++++ > include/hw/ppc/spapr_drc.h | 1 + > 2 files changed, 13 insertions(+) >=20 > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c > index 1f5f1d7..e146267 100644 > --- a/hw/ppc/spapr_drc.c > +++ b/hw/ppc/spapr_drc.c > @@ -140,6 +140,8 @@ static uint32_t set_allocation_state(sPAPRDRConnector= *drc, > DPRINTFN("finalizing device removal"); > drck->detach(drc, DEVICE(drc->dev), drc->detach_cb, > drc->detach_cb_opaque, NULL); > + } else if (drc->allocation_state =3D=3D SPAPR_DR_ALLOCATION_STAT= E_USABLE) { > + drc->awaiting_allocation =3D false; > } > } > return RTAS_OUT_SUCCESS; > @@ -376,6 +378,10 @@ static void attach(sPAPRDRConnector *drc, DeviceStat= e *d, void *fdt, > drc->signalled =3D (drc->type !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) > ? true : coldplug; > =20 > + if (drc->type !=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { > + drc->awaiting_allocation =3D true; > + } > + > object_property_add_link(OBJECT(drc), "device", > object_get_typename(OBJECT(drc->dev)), > (Object **)(&drc->dev), > @@ -424,6 +430,12 @@ static void detach(sPAPRDRConnector *drc, DeviceStat= e *d, > return; > } > =20 > + if (drc->awaiting_allocation) { > + drc->awaiting_release =3D true; > + DPRINTFN("awaiting allocation to complete before removal"); > + return; > + } > + > drc->indicator_state =3D SPAPR_DR_INDICATOR_STATE_INACTIVE; > =20 > if (drc->detach_cb) { > diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h > index fa21ba0..08e8411 100644 > --- a/include/hw/ppc/spapr_drc.h > +++ b/include/hw/ppc/spapr_drc.h > @@ -152,6 +152,7 @@ typedef struct sPAPRDRConnector { > =20 > bool awaiting_release; > bool signalled; > + bool awaiting_allocation; > =20 > /* device pointer, via link property */ > DeviceState *dev; --=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 --RHdRtM27np9fZUoh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXUSEPAAoJEGw4ysog2bOSljMP/jbspO4eXv3+F+Vo1V7CyGIi kuOcxvExcw2iQPdX7Nm/ZqlQfRwfbeyl9k3uCVG40zq89a5mUjOfIQcVdVg0qAja baH24bHmev9s/Wsl94QL59pLZ4zZIZReeIu8CfrBcDgizQEspRAgEmWQbKjL5brI 8OtdDXuu2xORPAVAej/eLCup0/W3g85QdaGu4TqcIjw2XGTEQAWj8NETQbOih1NM 0vJvf5mp/RbePJugi9EzKAqrO+9m6y7+pA5RnngTgsg5bzlIJcGTHRw1eSpsHLHU ZTl9/xnyR07wpaPkaQGZryEL7G97zPHKr3rF5vMP1DFnTYaoJSakkG+SlZuBJ9ku y4ux5mfmUssodcT+MgFSFfuEVqfD0FKf4EN9sFYWkLfhEdnqeBZYY7rZC+qF1WO3 NpqvDoPSLVrsW5VedptPg2jLDBlYFIc0X/B1uFJjg4gNlB89udq3RSBUi71Y62Bb WirI4FdqaOoh/AzavBYDGXC0eFXd7QrM4Gu4YFbfq1fg6/2WxlUOKs2KxD7zbaL1 cWgom0HhXSOI1AqKglyIs4wyfdp7X9ODGZDqYgE5vIfa+Xw0K5K8OM8Gd2ViWn6c xulnoVgqc994veXOj1lzSt72nMD2jS0U7OMOVTyIuIbrIyDUAtGiVBziPqLuA1Rm ea6wI2I2nMbcGS+4Lzew =77ud -----END PGP SIGNATURE----- --RHdRtM27np9fZUoh--