From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfipS-0002hM-Oe for qemu-devel@nongnu.org; Fri, 02 Sep 2016 03:23:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfipO-00048y-GN for qemu-devel@nongnu.org; Fri, 02 Sep 2016 03:23:57 -0400 Message-ID: <1472800972.9620.8.camel@kernel.crashing.org> From: Benjamin Herrenschmidt Date: Fri, 02 Sep 2016 17:22:52 +1000 In-Reply-To: <1472797976-24210-5-git-send-email-nikunj@linux.vnet.ibm.com> References: <1472797976-24210-1-git-send-email-nikunj@linux.vnet.ibm.com> <1472797976-24210-5-git-send-email-nikunj@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC 4/4] target-ppc: flush tlb from all the cpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikunj A Dadhania , qemu-ppc@nongnu.org, alex.bennee@linaro.org, david@gibson.dropbear.id.au, rth@twiddle.net Cc: qemu-devel@nongnu.org On Fri, 2016-09-02 at 12:02 +0530, Nikunj A Dadhania wrote: > Signed-off-by: Nikunj A Dadhania > --- > =C2=A0cputlb.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| 15 +++++++++++++++ > =C2=A0include/exec/exec-all.h |=C2=A0=C2=A02 ++ > =C2=A0target-ppc/mmu-hash64.c |=C2=A0=C2=A02 +- > =C2=A03 files changed, 18 insertions(+), 1 deletion(-) >=20 > diff --git a/cputlb.c b/cputlb.c > index 64faf47..17ff58e 100644 > --- a/cputlb.c > +++ b/cputlb.c > @@ -123,6 +123,21 @@ void tlb_flush(CPUState *cpu, int flush_global) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} > =C2=A0} > =C2=A0 > +static void tlb_flush_all_async_work(CPUState *cpu, void *opaque) > +{ > +=C2=A0=C2=A0=C2=A0=C2=A0tlb_flush_nocheck(cpu, GPOINTER_TO_INT(opaque)= ); > +} > + > +void tlb_flush_all(CPUState *cpu, int flush_global) > +{ > +=C2=A0=C2=A0=C2=A0=C2=A0CPUState *c; > + > +=C2=A0=C2=A0=C2=A0=C2=A0CPU_FOREACH(c) { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0async_run_on_cpu(c, tl= b_flush_all_async_work, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0GUINT_TO_POINTER(flush_global)); > +=C2=A0=C2=A0=C2=A0=C2=A0} > +} Hrm... this is asynchronous=C2=A0? It probably needs to be synchronous... We must provide a guarantee that no other processor can see the old translation when the tlb invalidation sequence completes. With the current lazy TLB flush, we already delay the invalidation until we hit that synchronization point so we need to be synchronous. Cheers, Ben. > =C2=A0static void tlb_flush_by_mmuidx_async_work(CPUState *cpu, void > *mmu_bitmask) > =C2=A0{ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0CPUArchState *env =3D cpu->env_ptr; > diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h > index e9f3bcf..55c344b 100644 > --- a/include/exec/exec-all.h > +++ b/include/exec/exec-all.h > @@ -116,6 +116,8 @@ void tlb_flush_page(CPUState *cpu, target_ulong > addr); > =C2=A0 * TLB entries, and the argument is ignored. > =C2=A0 */ > =C2=A0void tlb_flush(CPUState *cpu, int flush_global); > +void tlb_flush_all(CPUState *cpu, int flush_global); > + > =C2=A0/** > =C2=A0 * tlb_flush_page_by_mmuidx: > =C2=A0 * @cpu: CPU whose TLB should be flushed > diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c > index 8118143..d852c21 100644 > --- a/target-ppc/mmu-hash64.c > +++ b/target-ppc/mmu-hash64.c > @@ -912,7 +912,7 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* invalidate, and we still don't ha= ve a tlb_flush_mask(env, n, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* mask) in QEMU, we just invalidate= all TLBs > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0*/ > -=C2=A0=C2=A0=C2=A0=C2=A0tlb_flush(CPU(cpu), 1); > +=C2=A0=C2=A0=C2=A0=C2=A0tlb_flush_all(CPU(cpu), 1); > =C2=A0} > =C2=A0 > =C2=A0void ppc_hash64_update_rmls(CPUPPCState *env)