From: David Gibson Date: Fri, 28 Sep 2018 01:04:37 +0000 Subject: Re: [RFC PATCH 25/32] KVM: PPC: Book3S HV: Introduce rmap to track nested guest mappings Message-Id: <20180928010437.GV30868@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="R8HE/yN9deeWkwj/" List-Id: References: <1537524123-9578-26-git-send-email-paulus@ozlabs.org> In-Reply-To: <1537524123-9578-26-git-send-email-paulus@ozlabs.org> To: kvm-ppc@vger.kernel.org --R8HE/yN9deeWkwj/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 27, 2018 at 03:54:40PM +1000, Paul Mackerras wrote: > On Thu, Sep 27, 2018 at 02:07:58PM +1000, David Gibson wrote: > > On Fri, Sep 21, 2018 at 08:01:56PM +1000, Paul Mackerras wrote: > > > From: Suraj Jitindar Singh > > >=20 > > > When a host (L0) page which is mapped into a (L1) guest is in turn > > > mapped through to a nested (L2) guest we keep a reverse mapping (rmap) > > > so that these mappings can be retrieved later. > > >=20 > > > Whenever we create an entry in a shadow_pgtable for a nested guest we > > > create a corresponding rmap entry and add it to the list for the > > > L1 guest memslot at the index of the L1 guest page it maps. This means > > > at the L1 guest memslot we end up with lists of rmaps as follows; > > >=20 > > > memslot (L1) > > > ----------------- > > > | gfn =3D 0 | -> rmap -> rmap -> rmap -> NULL > > > ----------------- > > > | gfn =3D 1 | > > > ----------------- > > > | gfn =3D 2 | -> rmap -> NULL > > > ----------------- > > > | gfn =3D 3 | -> rmap -> rmap -> NULL > > > ----------------- > > > | gfn =3D 4 | > > > ----------------- > > > | gfn =3D n | > > > ----------------- > > >=20 > > > When we are notified of a host page being invalidated which has been > > > mapped through to a (L1) guest, we can then walk the rmap list for th= at > > > guest page, and find and invalidate all of the corresponding > > > shadow_pgtable entries. > > >=20 > > > Signed-off-by: Suraj Jitindar Singh > > > Signed-off-by: Paul Mackerras > >=20 > > Reviewed-by: David Gibson > >=20 > > Am I right in thinking that the reason we need this in addition to the > > exiting rmap for the L1 guest is that we need to know the LPID(s) to > > invalidate in the case of a host invalidation? >=20 > The existing rmap is not really used for radix guests because we get a > guest real address and we can just index into the partition-scoped > radix tree and find the one and only PTE that maps that guest real > address. >=20 > With a nested guest, a given L1 guest real page could be mapped in the > shadow partition-scoped trees for multiple nested guests at arbitrary > L2 guest real addresses. The rmap that we implement here gives us a > list of (l1 lpid, l2 guest real address) combinations that (may) map > the target L1 guest real page. Ah, right. --=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 --R8HE/yN9deeWkwj/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlutfiEACgkQbDjKyiDZ s5Is1BAAn9si865XkIa/NBJhzlrz5AC0cKiU3RxN7PRsO22URWARsyLRK6EG7to7 MFZJ83PlkI3tOlm6xQtCJq5Iex92p4s8GSY3/pEvRHMksL2kgUJyfIwtHMk5hDRT XIamR9uQ4ody2WPahOU7sTNrKSAPd5T8Mc437Ggoo3lgFPmXz2HfDNWjMA1Iir/A Eiv23JAoPo9OSbFWNM+MfYNjZt0QNTl9NaiY1wcwa+MCaBwBg2zIlt8BJY4GXPmb Vh4iEOmSlP581uvOqJzxnXvWZaS5CdqNUziRyGhbA2bdilFWR3TId0Qi2A5BdefL VWI3N4ZwTzLLabDstAeuqi7is1Twwk/xT93xJRODkK2VsXhMJaWfnlF8bFfgA+sw +LTqNZnOXqqMHTbjfIMf2LA73Fqsmv2HaB4rDkQr7+fVQ7+I9wGXowwoI+DRNVSR PFZbV7xZAKNr9LqIpnV5H6laBF9rr4wHtpQoLKFxSuQzjzO/2DAfkJ+kAGR9yfb8 0qyMG/kVke4b9MXwMMqXnIf9ayA2mvxZeCNCTmbhL/upLiaauaqcMrL0JuVjaPe5 nRg8anePnwpyQqSIw7N5mC+uMO4J6CHMPmnY9NZ3Ket75RloVX9lD2V0b6INoyQv vJfg+I1VQsEM0BYHn/Rgpa0Z+/KDmLF6amZokJTzGO9b3dHCIjY= =xaId -----END PGP SIGNATURE----- --R8HE/yN9deeWkwj/--