From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Subject: Re: [PATCH 1/2] KVM: PPC: Book3S HV: Fix handling of secondary HPTEG in HPT resizing code Date: Fri, 9 Feb 2018 10:35:26 +1100 Message-ID: <20180208233526.GE11634@umbus.fritz.box> References: <20180207090445.GC19335@fergus.ozlabs.ibm.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2qXFWqzzG3v1+95a" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org To: Paul Mackerras Return-path: Received: from ozlabs.org ([103.22.144.67]:46027 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbeBHXkt (ORCPT ); Thu, 8 Feb 2018 18:40:49 -0500 Content-Disposition: inline In-Reply-To: <20180207090445.GC19335@fergus.ozlabs.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: --2qXFWqzzG3v1+95a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 07, 2018 at 08:04:45PM +1100, Paul Mackerras wrote: > This fixes the computation of the HPTE index to use when the HPT > resizing code encounters a bolted HPTE which is stored in its > secondary HPTE group. The code inverts the HPTE group number, which > is correct, but doesn't then mask it with new_hash_mask. As a result, > new_pteg will be effectively negative, resulting in new_hptep > pointing before the new HPT, which will corrupt memory. >=20 > In addition, this removes two BUG_ON statements. The condition that > the BUG_ONs were testing -- that we have computed the hash value > incorrectly -- has never been observed in testing, and if it did > occur, would only affect the guest, not the host. Given that > BUG_ON should only be used in conditions where the kernel (i.e. > the host kernel, in this case) can't possibly continue execution, > it is not appropriate here. Fair enough. I think those were there because they were useful during early development, but should have been removed after that. >=20 > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson > --- > arch/powerpc/kvm/book3s_64_mmu_hv.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3= s_64_mmu_hv.c > index 9660972..d196499 100644 > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c > @@ -1329,12 +1329,8 @@ static unsigned long resize_hpt_rehash_hpte(struct= kvm_resize_hpt *resize, > } > =20 > new_pteg =3D hash & new_hash_mask; > - if (vpte & HPTE_V_SECONDARY) { > - BUG_ON(~pteg !=3D (hash & old_hash_mask)); > - new_pteg =3D ~new_pteg; > - } else { > - BUG_ON(pteg !=3D (hash & old_hash_mask)); > - } > + if (vpte & HPTE_V_SECONDARY) > + new_pteg =3D ~hash & new_hash_mask; > =20 > new_idx =3D new_pteg * HPTES_PER_GROUP + (idx % HPTES_PER_GROUP); > new_hptep =3D (__be64 *)(new->virt + (new_idx << 4)); --=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 --2qXFWqzzG3v1+95a Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlp83r4ACgkQbDjKyiDZ s5LV0RAAsrTi7Z1srEIqH+INUxrfFEmkkeqcagLaw+S0aSqxnf7CZrG2TufQ9yaQ Pcq79+nY5yDlnZ0e+tTyWV+lVb/ltyEuem+1pF1PswZwRNlbMn4gZMBqCr5w537P cTYbgZozKeEGHBhhXPhK3004YDd0E3D48pqapcWKnzC7tKtrNA0SdXkhXOTah0IS Xlc3eqO1X20lIzaY0dK9AKu7bLlZvLEhAK2tOoxVPLa/OUr+Cl5A4rtCoZcF0k/c OW76XALz7A2OgupgWRe+9C9Xvh37Yc7bSR37L0SOh8lY76BRYDtPvMa6cbhYQ9KL pn+J5Mphrrnu1Th8fnIBL+5PuYlqRZ1K8dMjPdE2Ez4IGuWSUC9x1onbikegLZe8 Ky81cYUN/BpCdOr2079c9hNuOWKi13limStADm7r2zzNCuAdHukHvHLY8Fj1mMsg c7OtLeAiKwu17wOToW9id+gRTxqC00jvVQfBGiosvCWcCgQCZf+K96lsJbTc26J9 z6ujOgWSRvBtCcDxCgOKRHw+cXS/ee8RbySt7u08kXu5YBaSRB1KN+hyutFDlNBV IpxB0reeZelkOvKGS9WXjMxL2j1FzrV20+Ioajkhze25PvBLUOgMDicuD9TmEjZ2 qBFJmY7IwVZZOnS/uZeBwQAKrNZfFH/K+b9oS8chDyT0a2HYUQ4= =vKXl -----END PGP SIGNATURE----- --2qXFWqzzG3v1+95a--