From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZSc3-0007Bu-5S for qemu-devel@nongnu.org; Tue, 08 Sep 2015 19:47:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZSbz-0001s6-4M for qemu-devel@nongnu.org; Tue, 08 Sep 2015 19:47:43 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:40121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZSbz-0001rf-0w for qemu-devel@nongnu.org; Tue, 08 Sep 2015 19:47:39 -0400 Received: from /spool/local by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Sep 2015 19:47:38 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1441749839-30540-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1441749839-30540-1-git-send-email-mdroth@linux.vnet.ibm.com> Message-ID: <20150908234638.9196.6370@loki> Date: Tue, 08 Sep 2015 18:46:38 -0500 Subject: Re: [Qemu-devel] [PATCH] spapr_drc: don't allow 'empty' DRCs to be unisolated List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Bharata B Rao , qemu-ppc@nongnu.org, David Gibson Quoting Michael Roth (2015-09-08 17:03:59) > Logical resources start with allocation-state:UNUSABLE / > isolation-state:ISOLATED. During hotplug, guests will transition > them to allocate-state:USABLE, and then to isolate-state:UNISOLATED. > The former transition does not seem to have any failure path for > cases where a DRC does not have any resources associated with it to > allocate for guest, but instead relies on the subsequent > isolation-state:UNISOLATED transition to indicate failure in this > situation. > = > Currently DRC code does not implement this logic, but instead > tries to indicate failure by refusing the allocation-state:USABLE > transition. Unfortunately, since that's not a documented failure > path, guests continue undeterred, causing undefined behavior in > QEMU and guest code. > = > Fix this by handling things as PAPR defines (13.7 and 13.7.3.1). > = > Cc: qemu-ppc@nongnu.org > Cc: David Gibson > Cc: Bharata B Rao > Signed-off-by: Michael Roth Argh, please ignore. This patch is missing the full changeset. v2 sent. > --- > hw/ppc/spapr_drc.c | 12 ++++++++++++ > include/hw/ppc/spapr_drc.h | 2 ++ > 2 files changed, 14 insertions(+) > = > diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c > index 9ce844a..c1f664f 100644 > --- a/hw/ppc/spapr_drc.c > +++ b/hw/ppc/spapr_drc.c > @@ -66,6 +66,18 @@ static int set_isolation_state(sPAPRDRConnector *drc, > = > DPRINTFN("drc: %x, set_isolation_state: %x", get_index(drc), state); > = > + if (state =3D=3D SPAPR_DR_ISOLATION_STATE_UNISOLATED) { > + /* cannot unisolate a non-existant resource. this generally > + * happens for logical resources where transitions from > + * allocation-state:UNUSABLE to allocation-state:USABLE are > + * unguarded, but instead rely on a subsequent > + * isolation-state:UNISOLATED transition to indicate failure > + */ > + if (!drc->dev) { > + return -1; > + } > + } > + > drc->isolation_state =3D state; > = > if (drc->isolation_state =3D=3D SPAPR_DR_ISOLATION_STATE_ISOLATED) { > diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h > index 28ffeae..3fbe9ea 100644 > --- a/include/hw/ppc/spapr_drc.h > +++ b/include/hw/ppc/spapr_drc.h > @@ -109,6 +109,7 @@ typedef enum { > * unusable: device not currently available to OS > * exchange: (currently unused) > * recover: (currently unused) > + * no_sensor: for logical DR only, returned when no resource available > */ > typedef enum { > SPAPR_DR_ENTITY_SENSE_EMPTY =3D 0, > @@ -116,6 +117,7 @@ typedef enum { > SPAPR_DR_ENTITY_SENSE_UNUSABLE =3D 2, > SPAPR_DR_ENTITY_SENSE_EXCHANGE =3D 3, > SPAPR_DR_ENTITY_SENSE_RECOVER =3D 4, > + SPAPR_DR_ENTITY_SENSE_NO_SENSOR =3D -3, > } sPAPRDREntitySense; > = > typedef enum { > -- = > 1.9.1 >=20