[PATCH 06/10] powerpc/mm/radix: implement LPID based TLB flushes to be used by KVM
Paul Mackerras
paulus at ozlabs.org
Mon May 7 15:15:26 AEST 2018
On Sun, May 06, 2018 at 05:37:27PM +1000, Nicholas Piggin wrote:
> Implement a local TLB flush for invalidating an LPID with variants for
> process or partition scope. And a global TLB flush for invalidating
> a partition scoped page of an LPID.
>
> These will be used by KVM in subsequent patches.
>
> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
> ---
> .../include/asm/book3s/64/tlbflush-radix.h | 7 +
> arch/powerpc/mm/tlb-radix.c | 207 ++++++++++++++++++
> 2 files changed, 214 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> index 19b45ba6caf9..ef5c3f2994c9 100644
> --- a/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
> @@ -51,4 +51,11 @@ extern void radix__flush_tlb_all(void);
> extern void radix__flush_tlb_pte_p9_dd1(unsigned long old_pte, struct mm_struct *mm,
> unsigned long address);
>
> +extern void radix__flush_tlb_lpid_page(unsigned int lpid,
> + unsigned long addr,
> + unsigned long page_size);
> +extern void radix__flush_pwc_lpid(unsigned int lpid);
> +extern void radix__local_flush_tlb_lpid(unsigned int lpid);
> +extern void radix__local_flush_tlb_lpid_guest(unsigned int lpid);
> +
> #endif
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index a5d7309c2d05..5ac3206c51cc 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -118,6 +118,53 @@ static inline void __tlbie_pid(unsigned long pid, unsigned long ric)
> trace_tlbie(0, 0, rb, rs, ric, prs, r);
> }
>
> +static inline void __tlbiel_lpid(unsigned long lpid, int set,
> + unsigned long ric)
> +{
> + unsigned long rb,rs,prs,r;
> +
> + rb = PPC_BIT(52); /* IS = 2 */
> + rb |= set << PPC_BITLSHIFT(51);
> + rs = 0; /* LPID comes from LPIDR */
> + prs = 0; /* partition scoped */
> + r = 1; /* radix format */
> +
> + asm volatile(PPC_TLBIEL(%0, %4, %3, %2, %1)
> + : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory");
> + trace_tlbie(lpid, 1, rb, rs, ric, prs, r);
Do we really want 128 trace entries every time
radix__local_flush_tlb_lpid() or radix__local_flush_tlb_lpid_guest()
is called? That seems like overkill to me. Could we move the
trace_tlbie calls here and in __tlbiel_lpid_guest() into the callers
instead?
Paul.
More information about the Linuxppc-dev
mailing list