From: David Gibson Date: Wed, 02 Jan 2019 02:48:15 +0000 Subject: Re: [PATCH 2/5] KVM: PPC: Book3S HV: Align gfn to L1 page size when inserting nest-rmap entry Message-Id: <20190102024815.GF27457@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="rWhLK7VZz0iBluhq" List-Id: To: kvm-ppc@vger.kernel.org --rWhLK7VZz0iBluhq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 21, 2018 at 02:28:40PM +1100, Suraj Jitindar Singh wrote: > Nested rmap entries are used to store the translation from L1 gpa to L2 > gpa when entries are inserted into the shadow (nested) page tables. This > rmap list is located by indexing the rmap array in the memslot by L1 > gfn. When we come to search for these entries we only know the L1 page si= ze > (which could be PAGE_SIZE, 2M or a 1G page) and so can only select a gfn > aligned to that size. This means that when we insert the entry, so we can > find it later, we need to align the gfn we use to select the rmap list > in which to insert the entry to L1 page size as well. >=20 > By not doing this we were missing nested rmap entries when modifying L1 > ptes which were for a page also passed through to an L2 guest. >=20 > Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson > --- > arch/powerpc/kvm/book3s_hv_nested.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3= s_hv_nested.c > index 0dfbf093bde5..9dfb927ea14f 100644 > --- a/arch/powerpc/kvm/book3s_hv_nested.c > +++ b/arch/powerpc/kvm/book3s_hv_nested.c > @@ -1226,6 +1226,8 @@ static long int __kvmhv_nested_page_fault(struct kv= m_vcpu *vcpu, > return ret; > shift =3D kvmppc_radix_level_to_shift(level); > } > + /* Align gfn to the start of the page */ > + gfn =3D (gpa & ~((1UL << shift) - 1)) >> PAGE_SHIFT; > =20 > /* 3. Compute the pte we need to insert for nest_gpa -> host r_addr */ > =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 --rWhLK7VZz0iBluhq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlwsJm8ACgkQbDjKyiDZ s5IxRRAApZQfQ/k8WGa/qbSKxuBW/RF2id8tn+QNqzzK5vSimFxwvHDTNBKxgDaa gxxJPDRiCbv+Gc0ni/g6F4lodEHFcXmUBLaSKcAfMDtGgGtBcahZ7iFkoGVqXRhR 1sv2l6RgIhtoijZcpXO1eYTAfPTJCnk3hIdJs2iVh2n9z2+XsGfy0cleTJckrL61 V8RM//tu7YKOqNbltyUqlHC/qZBWm1B3b+bHdXgu6eDzYhysOO3tgviUewWFrFZv ahH87W17fYeojUiT6vrsRojbw6XNs11LehTizN2ocC0oUxuCUak54061RXoo+ZDE 32P1gvshEAPY02qErIfXU9ZZeMwanm48uI24vDTAxEEkBlyUllTezhO472iQNs04 aU+qZZu8MtmvRpHpBEzeC2wPlKb78sSqaFcPD+NbSafpNnlcKso69i+ZJ1/zcJCW CxjsxXhnQjHmQPl7yRW0Qnbz4xdCKs8fO9jSDzdSI1vi4k461FOeg37P0DJmiWOn HevKsnxnxsf0v8RudhXROLKPAM5Eb9U35WIf7v6l203xZNTf1mWwxUQrvjfJ/74P yu9qDdy4uAnqJWdvmHqJyh1Op/+9BLeV8LIW55LvYdMHTWfBoLRhqmVl3P2LU+Sf fueszGscLkClfmduk5YZCEOV8WYIErUq3xWrBCRinFFFExqyJqM= =6DmS -----END PGP SIGNATURE----- --rWhLK7VZz0iBluhq--