From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvea7-0003wD-Qp for qemu-devel@nongnu.org; Mon, 09 Nov 2015 00:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvea4-0008HK-JV for qemu-devel@nongnu.org; Mon, 09 Nov 2015 00:01:27 -0500 Date: Mon, 9 Nov 2015 15:24:15 +1100 From: David Gibson Message-ID: <20151109042415.GD18558@voom.redhat.com> References: <1446545299-19446-1-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="T7mxYSe680VjQnyC" Content-Disposition: inline In-Reply-To: <1446545299-19446-1-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH for-2.5 1/1] spapr: Handle failure of KVM_PPC_ALLOCATE_HTAB ioctl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com --T7mxYSe680VjQnyC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 03, 2015 at 03:38:19PM +0530, Bharata B Rao wrote: > KVM_PPC_ALLOCATE_HTAB ioctl can return -ENOMEM for KVM guests and QEMU > never handled this correctly. But this didn't cause any problems till > now as KVM_PPC_ALLOCATE_HTAB ioctl returned with smaller than requested > HTAB when enough contiguous memory wasn't available in the host. > After the proposed kernel change: https://patchwork.ozlabs.org/patch/5305= 01/, > KVM_PPC_ALLOCATE_HTAB ioctl will not fallback to lower sized HTAB > allocation and will fail if requested HTAB size can't be met. >=20 > Check for such failures in QEMU and abort appropriately. This will > prevent guest kernel from hanging/freezing during early boot by doing > graceful exit when host is unable to allocate requested HTAB. >=20 > Signed-off-by: Bharata B Rao I'm going to apply this, since it fixes a real problem. I'm not entirely happy with the way it's done though - I'd prefer to see a separate case for (shift < 0) giving an unconditional error. Handling both the HV success case and the failure case in that first branch is unnecessarily subtle and confusing, IMO. > --- > hw/ppc/spapr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index e1202ce..ec6e141 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1022,7 +1022,7 @@ static void spapr_alloc_htab(sPAPRMachineState *spa= pr) > =20 > shift =3D kvmppc_reset_htab(spapr->htab_shift); > =20 > - if (shift > 0) { > + if (shift !=3D 0) { > /* Kernel handles htab, we don't need to allocate one */ > if (shift !=3D spapr->htab_shift) { > error_setg(&error_abort, "Failed to allocate HTAB of request= ed size, try with smaller maxmem"); > @@ -1055,7 +1055,7 @@ static void spapr_reset_htab(sPAPRMachineState *spa= pr) > int index; > =20 > shift =3D kvmppc_reset_htab(spapr->htab_shift); > - if (shift > 0) { > + if (shift !=3D 0) { > if (shift !=3D spapr->htab_shift) { > error_setg(&error_abort, "Requested HTAB allocation failed d= uring reset"); > } --=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 --T7mxYSe680VjQnyC Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWQB/vAAoJEGw4ysog2bOSNUoP/jSfUuTv6rGFLVjm+PCuemE7 JJfvr930SACn/Bd5MNOdY7s1x2+qQoyBYf4xhp0ns6wC+IPnkJudI0/cIKhIb/7a 5OHwUDORYYgGfq9yZs5D6gHswIjQGRkQK98vIeQOj7pGR4bH48vEtbMjOVZEs2P3 pDV3+bDsicnv6TBW+0fmny+VCX5pWcrNGG1LkMImilh3gzI6cM+/BYyuzPznUMyh tgkzW/wgAx4Y8c0pOZvsPVa6KTTA6O+9k4U9TeWCAqY+sTS9pTpA28nPe6+vFWzS XMVID91wkGotYLsU/IEmk1X9Au31/vA1a4nd5bBVz/Ko+JW+1wCovIhK/367ItoM +CC7wV9q3Eaj6/qJOrquSLcVa86yDbog9f5hoWqX0969GL5lvLhIDHASO4H7sFV3 xzLhpjv2pgXhgtvswQfZyEUn8PM6kgkgLqjAjUbeC1ijbgcwOucGz10cpWsPtR05 h1/EHDaVLwN4rZmmeinBo8Blh4LjEsWr874VdlnHkkFFd9Sm3Pc415xvmJZEeagA 6g3sGsprh+I/N0ZgEonaBcVBNb1k5WJtAh5mzW7xbvdyl8g7o75j00O1wngHnSuQ POqKlqmGsf4xVCr5nfNjo7zNHD2zCd4Xoczk/C6KLo6NEBn/7YiNRJuXg+gH3bvw v8yU8kh2xyukMJ+BX44Q =ry1b -----END PGP SIGNATURE----- --T7mxYSe680VjQnyC--