From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKIoF-0000bA-L4 for qemu-devel@nongnu.org; Tue, 05 Jul 2016 01:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKIoE-0003fQ-7v for qemu-devel@nongnu.org; Tue, 05 Jul 2016 01:22:11 -0400 Date: Tue, 5 Jul 2016 15:16:06 +1000 From: David Gibson Message-ID: <20160705051606.GI2251@voom.fritz.box> References: <1467695448-7780-1-git-send-email-david@gibson.dropbear.id.au> <1467695448-7780-15-git-send-email-david@gibson.dropbear.id.au> <1467695535.13965.33.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dMdWWqg3F2Dv/qfw" Content-Disposition: inline In-Reply-To: <1467695535.13965.33.camel@kernel.crashing.org> Subject: Re: [Qemu-devel] [PULL 14/14] ppc/hash64: Fix support for LPCR:ISL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Benjamin Herrenschmidt Cc: peter.maydell@linaro.org, agraf@suse.de, alex.williamson@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, aik@ozlabs.ru --dMdWWqg3F2Dv/qfw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 05, 2016 at 03:12:15PM +1000, Benjamin Herrenschmidt wrote: > On Tue, 2016-07-05 at 15:10 +1000, David Gibson wrote: > > From: Benjamin Herrenschmidt > >=20 > > We need to ignore the segment page size and essentially treat > > all pages as coming from a 4K segment. >=20 > NAK >=20 > The arguments are still wrong to=A0ppc_hash64_pteg_search Crud, sorry, forgot that fix. >=20 > > Signed-off-by: Benjamin Herrenschmidt > > [dwg: Adjusted for differencesin my version of the prereq patches] > > Signed-off-by: David Gibson > > --- > > =A0target-ppc/mmu-hash64.c | 27 +++++++++++++++++++-------- > > =A01 file changed, 19 insertions(+), 8 deletions(-) > >=20 > > diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c > > index 7f31444..bcd1c9d 100644 > > --- a/target-ppc/mmu-hash64.c > > +++ b/target-ppc/mmu-hash64.c > > @@ -488,7 +488,8 @@ static unsigned hpte_page_shift(const struct > > ppc_one_seg_page_size *sps, > > =A0} > > =A0 > > =A0static hwaddr ppc_hash64_pteg_search(PowerPCCPU *cpu, hwaddr hash, > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ppc_slb_t *slb, target_ulong > > ptem, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0const struct > > ppc_one_seg_page_size *sps, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0target_ulong ptem, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ppc_hash_pte64_t *pte, unsigned > > *pshift) > > =A0{ > > =A0=A0=A0=A0=A0CPUPPCState *env =3D &cpu->env; > > @@ -508,7 +509,7 @@ static hwaddr ppc_hash64_pteg_search(PowerPCCPU > > *cpu, hwaddr hash, > > =A0 > > =A0=A0=A0=A0=A0=A0=A0=A0=A0/* This compares V, B, H (secondary) and the= AVPN */ > > =A0=A0=A0=A0=A0=A0=A0=A0=A0if (HPTE64_V_COMPARE(pte0, ptem)) { > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0*pshift =3D hpte_page_shift(slb->s= ps, pte0, pte1); > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0*pshift =3D hpte_page_shift(sps, p= te0, pte1); > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0* If there is no match, ignor= e the PTE, it could simply > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0* be for a different segment = size encoding and the > > @@ -543,23 +544,31 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU > > *cpu, > > =A0=A0=A0=A0=A0hwaddr pte_offset; > > =A0=A0=A0=A0=A0hwaddr hash; > > =A0=A0=A0=A0=A0uint64_t vsid, epnmask, epn, ptem; > > +=A0=A0=A0=A0const struct ppc_one_seg_page_size *sps =3D slb->sps; > > =A0 > > =A0=A0=A0=A0=A0/* The SLB store path should prevent any bad page size e= ncodings > > =A0=A0=A0=A0=A0=A0* getting in there, so: */ > > -=A0=A0=A0=A0assert(slb->sps); > > +=A0=A0=A0=A0assert(sps); > > =A0 > > -=A0=A0=A0=A0epnmask =3D ~((1ULL << slb->sps->page_shift) - 1); > > +=A0=A0=A0=A0/* If ISL is set in LPCR we need to clamp the page size to= 4K */ > > +=A0=A0=A0=A0if (env->spr[SPR_LPCR] & LPCR_ISL) { > > +=A0=A0=A0=A0=A0=A0=A0=A0/* We assume that when using TCG, 4k is first = entry of SPS > > */ > > +=A0=A0=A0=A0=A0=A0=A0=A0sps =3D &env->sps.sps[0]; > > +=A0=A0=A0=A0=A0=A0=A0=A0assert(sps->page_shift =3D=3D 12); > > +=A0=A0=A0=A0} > > + > > +=A0=A0=A0=A0epnmask =3D ~((1ULL << sps->page_shift) - 1); > > =A0 > > =A0=A0=A0=A0=A0if (slb->vsid & SLB_VSID_B) { > > =A0=A0=A0=A0=A0=A0=A0=A0=A0/* 1TB segment */ > > =A0=A0=A0=A0=A0=A0=A0=A0=A0vsid =3D (slb->vsid & SLB_VSID_VSID) >> SLB_= VSID_SHIFT_1T; > > =A0=A0=A0=A0=A0=A0=A0=A0=A0epn =3D (eaddr & ~SEGMENT_MASK_1T) & epnmask; > > -=A0=A0=A0=A0=A0=A0=A0=A0hash =3D vsid ^ (vsid << 25) ^ (epn >> slb->sp= s->page_shift); > > +=A0=A0=A0=A0=A0=A0=A0=A0hash =3D vsid ^ (vsid << 25) ^ (epn >> sps->pa= ge_shift); > > =A0=A0=A0=A0=A0} else { > > =A0=A0=A0=A0=A0=A0=A0=A0=A0/* 256M segment */ > > =A0=A0=A0=A0=A0=A0=A0=A0=A0vsid =3D (slb->vsid & SLB_VSID_VSID) >> SLB_= VSID_SHIFT; > > =A0=A0=A0=A0=A0=A0=A0=A0=A0epn =3D (eaddr & ~SEGMENT_MASK_256M) & epnma= sk; > > -=A0=A0=A0=A0=A0=A0=A0=A0hash =3D vsid ^ (epn >> slb->sps->page_shift); > > +=A0=A0=A0=A0=A0=A0=A0=A0hash =3D vsid ^ (epn >> sps->page_shift); > > =A0=A0=A0=A0=A0} > > =A0=A0=A0=A0=A0ptem =3D (slb->vsid & SLB_VSID_PTEM) | ((epn >> 16) & > > HPTE64_V_AVPN); > > =A0=A0=A0=A0=A0ptem |=3D HPTE64_V_VALID; > > @@ -576,7 +585,8 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU > > *cpu, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0" vsid=3D" TARGET_FMT_lx " ptem= =3D" TARGET_FMT_lx > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0" hash=3D" TARGET_FMT_plx "\n", > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0env->htab_base, env->htab_mask, = vsid, ptem,=A0=A0hash); > > -=A0=A0=A0=A0pte_offset =3D ppc_hash64_pteg_search(cpu, hash, slb, ptem= , pte, > > pshift); > > +=A0=A0=A0=A0pte_offset =3D ppc_hash64_pteg_search(cpu, hash, slb->sps, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ptem, pte, pshift); > > =A0 > > =A0=A0=A0=A0=A0if (pte_offset =3D=3D -1) { > > =A0=A0=A0=A0=A0=A0=A0=A0=A0/* Secondary PTEG lookup */ > > @@ -587,7 +597,8 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU > > *cpu, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0" hash=3D" TARGET_FM= T_plx "\n", env->htab_base, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0env->htab_mask, vsid= , ptem, ~hash); > > =A0 > > -=A0=A0=A0=A0=A0=A0=A0=A0pte_offset =3D ppc_hash64_pteg_search(cpu, ~ha= sh, slb, ptem, > > pte, pshift); > > +=A0=A0=A0=A0=A0=A0=A0=A0pte_offset =3D ppc_hash64_pteg_search(cpu, ~ha= sh, slb->sps, > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ptem, pte, p= shift); > > =A0=A0=A0=A0=A0} > > =A0 > > =A0=A0=A0=A0=A0return pte_offset; >=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 --dMdWWqg3F2Dv/qfw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXe0KWAAoJEGw4ysog2bOSECsQAMR2lIsQGoHnDaR21jDRA0Dm Mlsbb+KzJSb9AWhMaIeWIMz3fH2vvgxDFv0V/x0lU1137aVlbxqfW9LuaZE7MGul khpH6q/aLIMNOhdwp1IDyds+dEVaYFWVSzK8XZdcv2iGMQMCdbkISC9on5dng2W+ n/qfKri0Sjq3lrgZo8Kou5WxEHunJOHr7KA9Yz+HCzTc/dwI/7YBAi+9GU+p3wlE c6/w1cbcVagP7+k+PrcKv0iL1lashT/y375JQiw4Idx51gnaubHqTeIyNyZvNY6k kwlSlk/kSechiFRylGkhM0we4FrksW8U12/9SWlKmAVVcH7WLA6gHh+GMtrodS2D t4Xaa1tXsm44Ymmu8XJUsTf9oZu4GnVthCxUctGKsphHjLbBXKSIG2xIwSbFsV6E KYYyr+pS/ProUrberBYZqfrMLLMavS47ZqLX1fj4t77ADXG0hrX0rbrxhkFiuKqh anz5naByIHtmk+G+lZ3KZVc8xoGIMg++2kq2vrENbaNou/78gdBfZqmG1M+uo0Sh Xccd++IBpC7OGmycSc3FPyLv3UspDZ+nwsRVfEtiop1e6l4PqDja6Su8iCguE4Zo fY836CYa4xvGKwg8oJCuZ7r94CGwaphjujwAoEFlWncM+n5eekH0y+68oumvcZCn VoMM7FIa3NRyXAEIb0r+ =rRE3 -----END PGP SIGNATURE----- --dMdWWqg3F2Dv/qfw--