assorted radix fixes and improvemets for page fault and invalidation
Nicholas Piggin
reviewercover assorted radix fixes and improvemets for page fault and invalidation
Here's various patches for radix, a few small bugfixes, tracepoint enablement or partition scope tlbie, and some page fault optimisation.
This was tested with the patch to qemu that enables THP for partition scope page tables and things seem to work as expected.
Thanks,
Nick
Nicholas Piggin (10):
KVM: PPC: Book3S HV: radix use correct tlbie sequence in
kvmppc_radix_tlbie_page
KVM: PPC: Book3S HV: radix clear pte when unmapping
KVM: PPC: Book3S HV: use a helper to unmap ptes in the radix fault
path
KVM: PPC: Book3S HV: recursively unmap all page table entries when
unmapping
KVM: PPC: Book3S HV: move table entry clear unmap into helpers powerpc/mm/radix: implement LPID based TLB flushes to be used by KVM
KVM: PPC: Book3S HV: radix use the Linux translation flush functions
for partition scope
KVM: PPC: Book3S HV: radix handle process scoped LPID flush in C, with
relocation on
KVM: PPC: Book3S HV: radix refine IO region partition scope attributes
KVM: PPC: Book3S HV: radix do not clear partition pte when RC or write
bits do not match
.../include/asm/book3s/64/tlbflush-radix.h | 7 + arch/powerpc/kvm/book3s_64_mmu_radix.c | 333 +++++++++++------- arch/powerpc/kvm/book3s_hv.c | 26 ++ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 13 +- arch/powerpc/mm/tlb-radix.c | 207 +++++++++++ 5 files changed, 452 insertions(+), 134 deletions(-)
Signature · 1 line
2.17.0
Nicholas Piggin
reviewerPATCH 6/10 powerpc/mm/radix: implement LPID based TLB flushes to be used by KVM
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.
--- .../include/asm/book3s/64/tlbflush-radix.h | 7 + arch/powerpc/mm/tlb-radix.c | 207 ++++++++++++++++++ 2 files changed, 214 insertions(+)
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +7 -0
@@ -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
arch/powerpc/mm/tlb-radix.c +207 -0
243 lines not on this page · raw message
Signature · 1 line
2.17.0
Re: [PATCH 06/10] powerpc/mm/radix: implement LPID based TLB flushes to be used by KVM
Quoted 40 lines · Nicholas Piggin
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 <[email protected]>--- .../include/asm/book3s/64/tlbflush-radix.h | 7 + arch/powerpc/mm/tlb-radix.c | 207 ++++++++++++++++++ 2 files changed, 214 insertions(+)arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +7
-0@@ -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 arch/powerpc/mm/tlb-radix.c +4
-0@@ -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;
arch/powerpc/mm/tlb-radix.c static inline void __tlbie_pid(unsigned long pid, unsigned long ric) · line 134
Quoted 10 lines
arch/powerpc/mm/tlb-radix.c +10
-0+ + 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.
Nicholas Piggin
reviewerRe: [PATCH 06/10] powerpc/mm/radix: implement LPID based TLB flushes to be used by KVM
Quoted 49 lines · On Mon, 7 May 2018 15:15:26 +1000 Paul Mackerras <[email protected]> wrote:
Quoted 48 lines · Nicholas Piggin
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 <[email protected]>--- .../include/asm/book3s/64/tlbflush-radix.h | 7 + arch/powerpc/mm/tlb-radix.c | 207 ++++++++++++++++++ 2 files changed, 214 insertions(+)arch/powerpc/include/asm/book3s/64/tlbflush-radix.h +7
-0@@ -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 arch/powerpc/mm/tlb-radix.c +12
-0@@ -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)
Quoted 8 lines
arch/powerpc/mm/tlb-radix.c static inline void __tlbie_pid(unsigned long pid, unsigned long ric) · line 134
Quoted 2 lines
arch/powerpc/mm/tlb-radix.c +2
-0+ : : "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()orradix__local_flush_tlb_lpid_guest()is called? That seems like overkill to me. Could we move thetrace_tlbiecalls here and in__tlbiel_lpid_guest()into the callers instead?
Yeah well that's how the powerpc:tlbie tracepoints are defined. I can see possible benefit to feeding the trace directly to a model or simulator, but it does make other things harder.
I have a patch around that changes all those tracepoints around to match the Linux semantics rather than the instructions... If people would prefer that I can send it (cc'ed Balbir).
But for this patch we should just match the existing tracepoints.
Thanks,
Nick