From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvi5t-0008Fu-3P for qemu-devel@nongnu.org; Mon, 09 Nov 2015 03:46:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvi5o-0003Qm-Rb for qemu-devel@nongnu.org; Mon, 09 Nov 2015 03:46:29 -0500 Date: Mon, 9 Nov 2015 19:46:55 +1100 From: David Gibson Message-ID: <20151109084655.GG18558@voom.redhat.com> References: <1446545299-19446-1-git-send-email-bharata@linux.vnet.ibm.com> <20151109042415.GD18558@voom.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Fnm8lRGFTVS/3GuM" Content-Disposition: inline In-Reply-To: <20151109042415.GD18558@voom.redhat.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 --Fnm8lRGFTVS/3GuM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 09, 2015 at 03:24:15PM +1100, David Gibson wrote: > 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/53= 0501/, > > 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 >=20 > I'm going to apply this, since it fixes a real problem. >=20 > 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. Ugh.. actually.. this patch seems to cause make check failures when configured for powerpc guest on an x86 host. I haven't debugged yet, but I'm guessing the shift !=3D 0 is now catching the TCG (or PR) case where we need to allocate the htab ourselves. >=20 >=20 > > --- > > 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 *s= papr) > > =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 reque= sted size, try with smaller maxmem"); > > @@ -1055,7 +1055,7 @@ static void spapr_reset_htab(sPAPRMachineState *s= papr) > > 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= during reset"); > > } >=20 --=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 --Fnm8lRGFTVS/3GuM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWQF1+AAoJEGw4ysog2bOSFO4P/0wUM5ikrgLUb+ADj8gA6X+g O5e3E13ZQL1h2IdFifxEipY3RfrrpkyDL47Dl2Kp4RTPLiS1+X/JwK7ovFwkE4t8 FGy4QmKjwa8x6pjtJlT1rsRxVAIawh62g9JHFvNNqFJCRk+an8W4fq96auO9jZhR RgCgOw0JiJJS75/WJYiBhWa8vxpN8dNGu31IpnB3vZZGDH2Thydo4sPLSWYTNCGT DdxOiS2xkebg2e+62pkIQqRkytfBdpWxycAlEOoBw05ewZmBj2BnAErLGyM4SYgs T0TlmR2fTxYeRaLpHl3UEqcdlA+MGMYlu6v2yqiFPwjuE0lLj9yD8b6TaXI5n2tx mFszLegHwW3h2Kmxv5ec3qSLXQBvkt58pqm76gP/rhhJSnr6cEzMBGAKE0T/ayvA rCQYCrhweP1s+lXXOIdmV7NNhSMPT440Ds4220d4vaB6BRZwcjZfsEiDE8TLUjMB vxIzRQiSzkhy+iGhZJIH1NRaJVXvgxquNNvBFrREoaqJMEAdUMfvgP0Xp4AbMR3h nb0rdSdAw4meot8+ump5/KEx5fPmGtGc/75GyVRG0+KSIJgeCv5tgFS9WEMErkYa kXdF/74kiBpcxosM7qKTfWVA8foStPhwgJv2yL7FzTTlL0bGdprK+VWcWwEx/3Vs kXYNzZ7ZNGUSuS0gQ8eh =Gr/V -----END PGP SIGNATURE----- --Fnm8lRGFTVS/3GuM--