From: David Gibson Date: Tue, 25 Sep 2018 06:53:43 +0000 Subject: Re: [RFC PATCH 09/32] KVM: PPC: Book3S HV: Handle hypervisor instruction faults better Message-Id: <20180925065343.GI30868@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Ksq4alxdE/AwthTb" List-Id: References: <1537524123-9578-10-git-send-email-paulus@ozlabs.org> In-Reply-To: <1537524123-9578-10-git-send-email-paulus@ozlabs.org> To: kvm-ppc@vger.kernel.org --Ksq4alxdE/AwthTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 21, 2018 at 08:01:40PM +1000, Paul Mackerras wrote: > Currently the code for handling hypervisor instruction page faults > passes 0 for the flags indicating the type of fault, which is OK in > the usual case that the page is not mapped in the partition-scoped > page tables. However, there are other causes for hypervisor > instruction page faults, such as not being to update a reference > (R) or change (C) bit. The cause is indicated in bits in HSRR1, > including a bit which indicates that the fault is due to not being > able to write to a page (for example to update an R or C bit). > Not handling these other kinds of faults correctly can lead to a > loop of continual faults without forward progress in the guest. >=20 > In order to handle these faults better, this patch constructs a > "DSISR-like" value from the bits which DSISR and SRR1 (for a HISI) > have in common, and passes it to kvmppc_book3s_hv_page_fault() so > that it knows what caused the fault. >=20 > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson > --- > arch/powerpc/include/asm/reg.h | 1 + > arch/powerpc/kvm/book3s_hv.c | 5 ++++- > 2 files changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/re= g.h > index e5b314e..6fda746 100644 > --- a/arch/powerpc/include/asm/reg.h > +++ b/arch/powerpc/include/asm/reg.h > @@ -766,6 +766,7 @@ > #define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */ > #define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */ > #define HSRR1_DENORM 0x00100000 /* Denorm exception */ > +#define HSRR1_HISI_WRITE 0x00010000 /* HISI bcs couldn't update mem */ > =20 > #define SPRN_TBCTL 0x35f /* PA6T Timebase control register */ > #define TBCTL_FREEZE 0x0000000000000000ull /* Freeze all tbs */ > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > index 8576a7b..e0e92f2 100644 > --- a/arch/powerpc/kvm/book3s_hv.c > +++ b/arch/powerpc/kvm/book3s_hv.c > @@ -1188,7 +1188,10 @@ static int kvmppc_handle_exit_hv(struct kvm_run *r= un, struct kvm_vcpu *vcpu, > break; > case BOOK3S_INTERRUPT_H_INST_STORAGE: > vcpu->arch.fault_dar =3D kvmppc_get_pc(vcpu); > - vcpu->arch.fault_dsisr =3D 0; > + vcpu->arch.fault_dsisr =3D vcpu->arch.shregs.msr & > + DSISR_SRR1_MATCH_64S; > + if (vcpu->arch.shregs.msr & HSRR1_HISI_WRITE) > + vcpu->arch.fault_dsisr |=3D DSISR_ISSTORE; > r =3D RESUME_PAGE_FAULT; > break; > /* --=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 --Ksq4alxdE/AwthTb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlup23YACgkQbDjKyiDZ s5IqRQ//W2IFNgA702u6u+42Td4bBECgI89VnTM9HU6LjrQhQi7hOq0lHZ0KPD2l pM0EdPd9xYHzxOvG3jOqCM8aFo8qbqwXl2MdRaJLfbwDQY0XGtlpiWOxwe0IeztW nrJy51UoMZIqmUseBmnsW4Y5Yo1pbZJ1qt6rgD5gIG1BXkW4mybPwsC/sWdzVTTR tfOv2rH0A7v3tRGm2AXzwtpS8WM2IpQNUMr99JN/mXB8xGLsFiF7M2PefXSLbY2W 8oJ19kHUbWCfQS5CmmZxlpELVdaJxA6FrAN6oIYCSGBZBtcgaYucshO6nloqGjXd NGKJPgJLbm/Pca8wULu6oFfCgtHIQHLWC1I++5fdRpW2b756Tl2VooYhq0/wbbjU yNvd8BZWBoJ4vsIZDWmZ/yZK3ufWTFrjdVxbX8SzCHS/VK3/DEKkeGKL0ml2mh7m JgIn6m4yjr9poxtOYGo4bPvDYSy/melZsrEKSgUk9dIN5LeZ7061adqilDXa61xI QcDLUnAqOKToE6NnhZgAjMezVlLKsVqDaW9G2BPytxcu+kgjt/r2JBBmJf8BIW9Z 7NfORfGV9ALGLx01XC4X+N9UPrZu2APcPqQONJxCsXTVTc9ySJctjeapKw3rkkpi ZuopLgkBzIzJQR/p5f/R7WckuFF+R0aEpBEK4a5VHP0wpnPqNhw= =5hPh -----END PGP SIGNATURE----- --Ksq4alxdE/AwthTb--