From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNhZk-0003EJ-Tr for qemu-devel@nongnu.org; Mon, 25 Jan 2016 08:53:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNhZj-0003tq-Km for qemu-devel@nongnu.org; Mon, 25 Jan 2016 08:53:00 -0500 Date: Tue, 26 Jan 2016 00:26:35 +1100 From: David Gibson Message-ID: <20160125132635.GJ32205@voom.redhat.com> References: <1453698952-32092-1-git-send-email-david@gibson.dropbear.id.au> <1453698952-32092-6-git-send-email-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Tu8ztk+XgTAiG9Id" Content-Disposition: inline In-Reply-To: <1453698952-32092-6-git-send-email-david@gibson.dropbear.id.au> Subject: Re: [Qemu-devel] [PATCH 05/10] target-ppc: Use actual page size encodings from HPTE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: benh@kernel.crashing.org Cc: lvivier@redhat.com, thuth@redhat.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org --Tu8ztk+XgTAiG9Id Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 25, 2016 at 04:15:47PM +1100, David Gibson wrote: > At present the 64-bit hash MMU code uses information from the SLB to > determine the page size of a translation. We do need that information to > correctly look up the hash table. However the MMU also allows a > possibly larger page size to be encoded into the HPTE itself, which is us= ed > to populate the TLB. At present qemu doesn't check that, and so doesn't > support the MPSS "Multiple Page Size per Segment" feature. >=20 > This makes a start on allowing this, by adding an hpte_page_shift() > function which looks up the page size of an HPTE. We use this to validate > page sizes encodings on faults, and populate the qemu TLB with larger > page sizes when appropriate. >=20 > Signed-off-by: David Gibson > --- > target-ppc/mmu-hash64.c | 74 +++++++++++++++++++++++++++++++++++++++++++= +++--- > 1 file changed, 70 insertions(+), 4 deletions(-) >=20 > diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c > index 28ad361..bcad826 100644 > --- a/target-ppc/mmu-hash64.c > +++ b/target-ppc/mmu-hash64.c > @@ -21,6 +21,7 @@ > #include "exec/helper-proto.h" > #include "qemu/error-report.h" > #include "sysemu/kvm.h" > +#include "qemu/error-report.h" > #include "kvm_ppc.h" > #include "mmu-hash64.h" > =20 > @@ -474,6 +475,43 @@ static hwaddr ppc_hash64_htab_lookup(PowerPCCPU *cpu, > return pte_offset; > } > =20 > +static unsigned hpte_page_shift(const struct ppc_one_seg_page_size *sps, > + uint64_t pte0, uint64_t pte1) > +{ > + int i; > + > + if (!(pte0 & HPTE64_V_LARGE)) { > + if (sps->page_shift !=3D 12) { > + /* 4kiB page in a non 4kiB segment */ > + return 0; > + } > + /* Normal 4kiB page */ > + return 12; > + } > + > + for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { > + const struct ppc_one_page_size *ps =3D &sps->enc[i]; > + uint64_t mask; > + > + if (!ps->page_shift) { > + break; > + } > + > + if (ps->page_shift =3D=3D 12) { > + /* L bit is set so this can't be a 4kiB page */ > + continue; > + } > + > + mask =3D ((1ULL << ps->page_shift) - 1) & HPTE64_R_RPN; > + > + if ((pte1 & mask) =3D=3D ps->pte_enc) { Gah. This needs to be (ps->pte_enc << HPTE64_R_RPN_SHIFT) or everything breaks. I remember fixing this earlier, but somehow I managed to lose the fix in both this posting and the previous one. --=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 --Tu8ztk+XgTAiG9Id Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWpiKLAAoJEGw4ysog2bOSsMIQAKo4glsFsB5QS/cmp4X2eyWV 28LoC30FDOTGvrgcQzWJ/HTv9kieALQsWyLqs5p+Ow1JXW2pOmjseYX0POtSuUcp 5xTzEK3PR3jeFpxanBoyGovPI4CVguM2g+YpiNgTGHLLZbJolKfXf6F+/Qiat0QQ 6CPTmvnX35PRJ2RpS25GPlQhq4ZvfSRkXB+zF9CRQ6gC+22l2INZ9fv7cXvuE686 3r4LkyaToe3E0Bh7jY1Rno7Sy0yhvs4UJIBkPIBzHZM+7nigEdnP1ZeG9QyDfO3C Xf3JBxGi0YqO/U8d/Y3+tI5ZZTpRwyUtPu70TpiRz6GIGVn3GYHe3w67y5zVLLHU /vXwYm216QVNQlkoFBwsXTjKPI+xv2J92pn7iCtum7jRb2cbxwjT/zSw4E9Fc4eF zcvkvnwXB7kuT70KgWIKMwvgoQ14t2n9+Ug82WAraYA2rtHNnQzfJrE6IvGtfg7/ Kqtc00UE9LP+x9WcnViUESFqqRRKzKL0OG0v+2HtDZDuRjl82cj2+w2JOeeh5GUO fgNCGcsjQdRA0upv7nNHnglNCAE+8Hg4clg56S3DUwqft+/0lxUWYBBlREYsY8QN BGjPknhIL8Q7jrMzVxjWXus91e5GMtr6yWGkFto95lPJvXab4uOA5H9NdXirFyeY xqoXqHPlKWyZZ0cTib1X =H1Zt -----END PGP SIGNATURE----- --Tu8ztk+XgTAiG9Id--