From: David Gibson Date: Mon, 20 Aug 2018 06:31:46 +0000 Subject: Re: [PATCH] KVM: PPC: Book3S HV: Don't truncate HPTE index in xlate function Message-Id: <20180820063146.GB3348@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="tsOsTdHNUZQcU9Ye" List-Id: References: <20180820060659.GA19336@fergus> In-Reply-To: <20180820060659.GA19336@fergus> To: kvm-ppc@vger.kernel.org --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 20, 2018 at 04:06:59PM +1000, Paul Mackerras wrote: > This fixes a bug which causes guest virtual addresses to get translated > to guest real addresses incorrectly when the guest is using the HPT MMU > and has more than 256GB of RAM, or more specifically has a HPT larger > than 2GB. This has showed up in testing as a failure of the host to > emulate doorbell instructions correctly on POWER9 for HPT guests with > more than 256GB of RAM. >=20 > The bug is that the HPTE index in kvmppc_mmu_book3s_64_hv_xlate() > is stored as an int, and in forming the HPTE address, the index gets > shifted left 4 bits as an int before being signed-extended to 64 bits. > The simple fix is to make the variable a long int, matching the > return type of kvmppc_hv_find_lock_hpte(), which is what calculates > the index. >=20 > Fixes: 697d3899dcb4 ("KVM: PPC: Implement MMIO emulation support for Book= 3S HV guests") > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson Unfortunately I haven't been able to get a hold of POWER9 time to test it yet, still working on it. > --- > arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3= s_64_mmu_hv.c > index 7f3a8cf..4c08f42 100644 > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c > @@ -359,7 +359,7 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_v= cpu *vcpu, gva_t eaddr, > unsigned long pp, key; > unsigned long v, orig_v, gr; > __be64 *hptep; > - int index; > + long int index; > int virtmode =3D vcpu->arch.shregs.msr & (data ? MSR_DR : MSR_IR); > =20 > if (kvm_is_radix(vcpu->kvm)) --=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 --tsOsTdHNUZQcU9Ye Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlt6YFIACgkQbDjKyiDZ s5Ld7A//XL3BJ8h4UIQiEQfqiUuNP5QvwSVZ09Yx0l1CH7S8QgjCRS8A6qWSuKnA f4Zi9s4gGOuoeQwv7OTlN66q39Sb5/U3PIN9Kq2PkVt2pf603XjgHR5NyJZEb+lS z7mvBjXndhAavddp9PO0rhHg6ATQVV126ageAkwHKEVnuU1DqxbBVx4m9joiJvCh xEg9A9CTjfhVIhcjl94ITQGQrKMRR89IO/AsHEAV+n7Nt7EN8/Uo/bxfW31tTHaq em/ZJDc+4pOxH8ZjB72h4mtPh6k214WBiJ2ecana9ksZZ49FYlhkcvQUuRJN1+/i TP2Ru7mw9Uk3zGCjWVJe4YHV+4fDiwMylaWWyysz7VFUbPxuNmQIxT+eS7QtvRzS Na9zQWKa/EO+Ccn5oYZ8Myad8NHDhMeB47SUl09MXCG+DACjCQfZD2bg1J+1tOjn zauBaouelyBqUNZ+DRvFFLIFsxw2CSjs2snwqwa8s1ZAerKINXYBTyRxZOl5NZuO c4Sbh3TfpeEgzot/BZmO1/DPxYkzjU8S0RBySYuQmkrbg6+RQQpxEUrnpmBmoPNe CIoUDvOv45FwtKXltlyXJT345gwx78raqLbMZ6f6UQ9I+aWHwv0zHaBBxCjBZtu4 FUQITqIYxYdM50Exql94N2Y0AeM/fkdjb+DXWDRVMLVGqYQunCU= =ay8K -----END PGP SIGNATURE----- --tsOsTdHNUZQcU9Ye--