From: David Gibson Date: Wed, 02 Jan 2019 02:47:04 +0000 Subject: Re: [PATCH 1/5] KVM: PPC: Book3S HV: Hold kvm->mmu_lock across updating nested pte rc bits Message-Id: <20190102024704.GE27457@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="HeFlAV5LIbMFYYuh" List-Id: To: kvm-ppc@vger.kernel.org --HeFlAV5LIbMFYYuh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 21, 2018 at 02:28:39PM +1100, Suraj Jitindar Singh wrote: > We already hold the kvm->mmu_lock spin lock across updating the rc bits > in the pte for the L1 guest. Continue to hold the lock across updating > the rc bits in the pte for the nested guest as well to prevent > invalidations from occurring. >=20 > Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson > --- > arch/powerpc/kvm/book3s_hv_nested.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) >=20 > diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3= s_hv_nested.c > index 401d2ecbebc5..0dfbf093bde5 100644 > --- a/arch/powerpc/kvm/book3s_hv_nested.c > +++ b/arch/powerpc/kvm/book3s_hv_nested.c > @@ -1049,7 +1049,7 @@ static long kvmhv_handle_nested_set_rc(struct kvm_v= cpu *vcpu, > struct kvm *kvm =3D vcpu->kvm; > bool writing =3D !!(dsisr & DSISR_ISSTORE); > u64 pgflags; > - bool ret; > + long ret; > =20 > /* Are the rc bits set in the L1 partition scoped pte? */ > pgflags =3D _PAGE_ACCESSED; > @@ -1062,16 +1062,22 @@ static long kvmhv_handle_nested_set_rc(struct kvm= _vcpu *vcpu, > /* Set the rc bit in the pte of our (L0) pgtable for the L1 guest */ > ret =3D kvmppc_hv_handle_set_rc(kvm, kvm->arch.pgtable, writing, > gpte.raddr, kvm->arch.lpid); > - spin_unlock(&kvm->mmu_lock); > - if (!ret) > - return -EINVAL; > + if (!ret) { > + ret =3D -EINVAL; > + goto out_unlock; > + } > =20 > /* Set the rc bit in the pte of the shadow_pgtable for the nest guest */ > ret =3D kvmppc_hv_handle_set_rc(kvm, gp->shadow_pgtable, writing, n_gpa, > gp->shadow_lpid); > if (!ret) > - return -EINVAL; > - return 0; > + ret =3D -EINVAL; > + else > + ret =3D 0; > + > +out_unlock: > + spin_unlock(&kvm->mmu_lock); > + return ret; > } > =20 > static inline int kvmppc_radix_level_to_shift(int level) --=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 --HeFlAV5LIbMFYYuh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlwsJigACgkQbDjKyiDZ s5KVhxAAw8IcA9COvnrlELmgLPbIPoxdx573Y3OMtgC3QLZ72tFVSJhdM+l2hjpS HxqKnCd0T1mVFzrw98XPy+O1kcwNFLdU51O0s/qPtIIqtGXMxqTth+d8kzD66fSa ZZJZokCHLcFfwq89F+AY9LqFP3EW7Ebzhl/iBB6PK0vwIAUBCXT5X+sP7yhoGwky iGZHZHCF/CCwoGn8nnyC9PxpQMdhCmO+LuDyO3A2pZMWcWiAbnGXkjGpGF1doyIn ug565VYCcGuptZKFbMuo9rsA+axPVNx5c9QsAfSE7owxA3FNUYZwJLz4CYHZO0Ck ZbOlDzmdUtQDAWZZhckP6JU6NfqDUFJNknQ7WCn1bThyghreKb0mghbNfyHUApOn feFC0C1+hZpRqFDAvVMBivVVfGAnxezIlc7mifNC3Y2DrqxVDzRs6hITz/IJjp9P 3BwqsmnVNTiKBos2QrFVSetufZA9DoBvcDL12O+BIHwvuUiYJnU+FA0/ABwUYOnK UTafyBQRlvGTjvoJLdRPdI7viGFNwLop/EafV6Qkb3niY8JXGl5zVwhgRHmPwsPE DGE29tBeao+fZRtznXphxb7a3RLe0KbCu35zHgT/nWMJSQ0JnHN9enNNowZnlP2a M2EfG29c09EvDUn8ScPp4q5U3+IYPQF6n+axLIgpXKSUsFEAUNU= =RvqI -----END PGP SIGNATURE----- --HeFlAV5LIbMFYYuh--