From: David Gibson Date: Thu, 27 Sep 2018 04:37:44 +0000 Subject: Re: [RFC PATCH 27/32] KVM: PPC: Book3S HV: Invalidate TLB when nested vcpu moves physical cpu Message-Id: <20180927043744.GN30868@umbus.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="jvP1KVAumivRHpdh" List-Id: References: <1537524123-9578-28-git-send-email-paulus@ozlabs.org> In-Reply-To: <1537524123-9578-28-git-send-email-paulus@ozlabs.org> To: kvm-ppc@vger.kernel.org --jvP1KVAumivRHpdh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 21, 2018 at 08:01:58PM +1000, Paul Mackerras wrote: > From: Suraj Jitindar Singh >=20 > This is only done at level 0, since only level 0 knows which physical > CPU a vcpu is running on. This does for nested guests what L0 already > did for its own guests, which is to flush the TLB on a pCPU when it > goes to run a vCPU there, and there is another vCPU in the same VM > which previously ran on this pCPU and has now started to run on another > pCPU. This is to handle the situation where the other vCPU touched > a mapping, moved to another pCPU and did a tlbiel (local-only tlbie) > on that new pCPU and thus left behind a stale TLB entry on this pCPU. >=20 > Signed-off-by: Suraj Jitindar Singh > Signed-off-by: Paul Mackerras Reviewed-by: David Gibson [snip] > static void radix_flush_cpu(struct kvm *kvm, int cpu, struct kvm_vcpu *v= cpu) > { > + struct kvm_nested_guest *nested =3D vcpu->arch.nested; > + cpumask_t *cpu_in_guest; > int i; > =20 > cpu =3D cpu_first_thread_sibling(cpu); > - cpumask_set_cpu(cpu, &kvm->arch.need_tlb_flush); > + if (nested) { > + cpumask_set_cpu(cpu, &nested->need_tlb_flush); > + cpu_in_guest =3D &nested->cpu_in_guest; > + } else { > + cpumask_set_cpu(cpu, &kvm->arch.need_tlb_flush); > + cpu_in_guest =3D &kvm->arch.cpu_in_guest; > + } I don't think it's important for now, but a possible followup might be to make a "lpid_state" or something structure for the information that's common between a direct guest and a nested guest. That might collapse a bunch of these if (nested) tests. --=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 --jvP1KVAumivRHpdh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAlusXpYACgkQbDjKyiDZ s5KYNQ//d6uEsefL0MKNTcK3OuWFZDGAOjTbm+UBWooMvz04E26T/5tacSTEPGtb z8dnkQiMXHGv3ndEtlcGSYI1NxiP67LzuhyeH99BjBJMac7A3XVpYfy7k3Y0spN2 Ujwrjze2XBFGJtUhVUqQxIjhNbC4f9sWzV2vAj4qBNp6E+WtAPfpBm+JxKIq4JSU 07JQE0dXkDVrpkTJ3uTGHtnvZXDe0uzr5sbYTAeNwB0iSFPX6BGAhg5ByWqiRnF9 2ttJJWGPb9+V7tyHi8f/OvvW95k+PkkP/Z4wwlAhJXM8z8eoBv6zMfkpATvWSe6x zO8Mf8RLH9wHwxq3TIqlqkQ2jm5XlqBKM1D9bY+z8WmfW0ymr+XIHH8MwcgFWBaT 1WFlavnM1l3Lrn38skewZnoxti18TmE1WhcK5pcM3pmVYKkhNazLkTsli0rTIVD+ KwbLaJ9vi5yh/63DbIJ4RuYcPJduXkdgxQWIePiT6oqaoJCwmid0sXD2mijvoVi7 bPYUNrgiVRkYbijV4+5NvWSa90k4QhitdEIqMFj3g2q+Oypa0S1xyvcK53qX7Oj6 OmwiFj5maHjS1Gt1inTp00o5h3Y53sm7GiESOKMsAKR5VOhtN+ukYOAy00u8wLuh tmJ8p8ePuOm3nXgJE1gdraHsqfbpAN47HrQZmtqQpxWVAJDw3lM= =dHQ6 -----END PGP SIGNATURE----- --jvP1KVAumivRHpdh--