Lines Matching +full:i +full:- +full:tlb +full:- +full:sets

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * TLB flush routines for radix kernels.
5 * Copyright 2015-2016, Aneesh Kumar K.V, IBM Corporation.
15 #include <asm/ppc-opcode.h>
16 #include <asm/tlb.h>
26 * i.e., r=1 and is=01 or is=10 or is=11
39 : : "r"(rb), "r"(rs), "i"(ric), "i"(prs) in tlbiel_radix_set_isa300()
50 * Flush the first set of the TLB, and the entire Page Walk Cache in tlbiel_all_isa300()
51 * and partition table entries. Then flush the remaining sets of the in tlbiel_all_isa300()
52 * TLB. in tlbiel_all_isa300()
95 WARN(1, "%s called on pre-POWER9 CPU\n", __func__); in radix__tlbiel_all()
112 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbiel_pid()
126 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_pid()
140 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_lpid()
154 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_lpid_guest()
170 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbiel_va()
186 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_va()
202 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_lpid_va()
241 unsigned long va = ((1UL << 52) - 1); in fixup_tlbie_pid()
274 unsigned long va = ((1UL << 52) - 1); in fixup_tlbie_lpid()
309 * Flush the first set of the TLB, and if in _tlbiel_pid()
317 /* For the remaining sets, just flush the TLB */ in _tlbiel_pid()
332 * must be a compile-time constraint to match the "i" constraint in _tlbie_pid()
360 if (t->ric == RIC_FLUSH_TLB) in do_tlbiel_pid()
361 _tlbiel_pid(t->pid, RIC_FLUSH_TLB); in do_tlbiel_pid()
362 else if (t->ric == RIC_FLUSH_PWC) in do_tlbiel_pid()
363 _tlbiel_pid(t->pid, RIC_FLUSH_PWC); in do_tlbiel_pid()
365 _tlbiel_pid(t->pid, RIC_FLUSH_ALL); in do_tlbiel_pid()
380 if (atomic_read(&mm->context.copros) > 0) in _tlbiel_pid_multicast()
390 * must be a compile-time contraint to match the "i" constraint in _tlbie_lpid()
413 * must be a compile-time contraint to match the "i" constraint in _tlbie_lpid_guest()
473 fixup_tlbie_va_range(addr - page_size, pid, ap); in __tlbie_va_range()
498 if (t->ric == RIC_FLUSH_TLB) in do_tlbiel_va()
499 _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_TLB); in do_tlbiel_va()
500 else if (t->ric == RIC_FLUSH_PWC) in do_tlbiel_va()
501 _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_PWC); in do_tlbiel_va()
503 _tlbiel_va(t->va, t->pid, t->psize, RIC_FLUSH_ALL); in do_tlbiel_va()
513 if (atomic_read(&mm->context.copros) > 0) in _tlbiel_va_multicast()
530 _tlbiel_va_range(t->start, t->end, t->pid, t->page_size, in do_tlbiel_va_range()
531 t->psize, t->also_pwc); in do_tlbiel_va_range()
567 if (atomic_read(&mm->context.copros) > 0) in _tlbiel_va_range_multicast()
572 * Base TLB flushing operations:
574 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
575 * - flush_tlb_page(vma, vmaddr) flushes one page
576 * - flush_tlb_range(vma, start, end) flushes a range of pages
577 * - flush_tlb_kernel_range(start, end) flushes kernel pages
579 * - local_* variants of page and mm only apply to the current
584 unsigned long pid = mm->context.id; in radix__local_flush_tlb_mm()
598 unsigned long pid = mm->context.id; in radix__local_flush_all_mm()
618 unsigned long pid = mm->context.id; in radix__local_flush_tlb_page_psize()
635 radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); in radix__local_flush_tlb_page()
647 * this workaround is required - escalate all RIC=0 IS=1/2/3 flushes in mm_needs_flush_escalation()
654 if (atomic_read(&mm->context.copros) > 0) in mm_needs_flush_escalation()
665 unsigned long pid = mm->context.id; in exit_lazy_flush_tlb()
671 * interrupted here. In that case, current->mm will be set to mm, in exit_lazy_flush_tlb()
672 * because kthread_use_mm() setting ->mm and switching to the mm is in exit_lazy_flush_tlb()
675 if (current->mm == mm) in exit_lazy_flush_tlb()
678 if (current->active_mm == mm) { in exit_lazy_flush_tlb()
681 WARN_ON_ONCE(current->mm != NULL); in exit_lazy_flush_tlb()
683 * It is a kernel thread and is using mm as the lazy tlb, so in exit_lazy_flush_tlb()
689 current->active_mm = &init_mm; in exit_lazy_flush_tlb()
700 * not otherwise be a problem, but the TLB must be flushed because in exit_lazy_flush_tlb()
742 * mm_cpumask can be trimmed for the case where it's not a single-threaded
744 * flushes. Don't want this to be so low that it adds noticable cost to TLB
767 int active_cpus = atomic_read(&mm->context.active_cpus); in flush_type_needed()
773 if (current->mm != mm) { in flush_type_needed()
788 if (atomic_read(&mm->context.copros) > 0) in flush_type_needed()
800 * If we are running the only thread of a single-threaded process, in flush_type_needed()
805 if (atomic_read(&mm->mm_users) <= 1 && current->mm == mm) { in flush_type_needed()
811 * and the TLB still gets flushed by the IPI, so this CPU in flush_type_needed()
823 if (current->mm == mm) in flush_type_needed()
839 pid = mm->context.id; in radix__flush_tlb_mm()
857 if (atomic_read(&mm->context.copros) > 0) in radix__flush_tlb_mm()
860 H_RPTI_PAGE_ALL, 0, -1UL); in radix__flush_tlb_mm()
871 mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); in radix__flush_tlb_mm()
880 pid = mm->context.id; in __flush_all_mm()
895 if (atomic_read(&mm->context.copros) > 0) in __flush_all_mm()
898 H_RPTI_PAGE_ALL, 0, -1UL); in __flush_all_mm()
905 mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); in __flush_all_mm()
920 pid = mm->context.id; in radix__flush_tlb_page_psize()
937 if (atomic_read(&mm->context.copros) > 0) in radix__flush_tlb_page_psize()
956 radix__flush_tlb_page_psize(vma->vm_mm, vmaddr, mmu_virtual_psize); in radix__flush_tlb_page()
1004 #define TLB_FLUSH_ALL -1UL
1011 * It also does not iterate over sets like the local tlbiel variant when
1013 * individual page flushes to full-pid flushes.
1024 unsigned long nr_pages = (end - start) >> page_shift; in __radix__flush_tlb_range()
1028 pid = mm->context.id; in __radix__flush_tlb_range()
1049 if (!flush_pid && (end - start) >= PMD_SIZE) in __radix__flush_tlb_range()
1059 if (atomic_read(&mm->context.copros) > 0) in __radix__flush_tlb_range()
1081 hstart = (start + PMD_SIZE - 1) & PMD_MASK; in __radix__flush_tlb_range()
1126 __radix__flush_tlb_range(vma->vm_mm, start, end); in radix__flush_tlb_range()
1141 return -1; in radix_get_mmu_psize()
1184 void radix__tlb_flush(struct mmu_gather *tlb) in radix__tlb_flush() argument
1187 struct mm_struct *mm = tlb->mm; in radix__tlb_flush()
1188 int page_size = tlb->page_size; in radix__tlb_flush()
1189 unsigned long start = tlb->start; in radix__tlb_flush()
1190 unsigned long end = tlb->end; in radix__tlb_flush()
1199 if (tlb->fullmm) { in radix__tlb_flush()
1202 * Shootdown based lazy tlb mm refcounting means we in radix__tlb_flush()
1222 } else if ( (psize = radix_get_mmu_psize(page_size)) == -1) { in radix__tlb_flush()
1223 if (!tlb->freed_tables) in radix__tlb_flush()
1228 if (!tlb->freed_tables) in radix__tlb_flush()
1242 unsigned long nr_pages = (end - start) >> page_shift; in __radix__flush_tlb_range_psize()
1246 pid = mm->context.id; in __radix__flush_tlb_range_psize()
1270 if (atomic_read(&mm->context.copros) > 0) in __radix__flush_tlb_range_psize()
1321 pid = mm->context.id; in radix__flush_tlb_collapsed_pmd()
1348 if (atomic_read(&mm->context.copros) > 0) in radix__flush_tlb_collapsed_pmd()
1366 radix__flush_tlb_range_psize(vma->vm_mm, start, end, MMU_PAGE_2M); in radix__flush_pmd_tlb_range()
1373 radix__flush_tlb_range_psize(vma->vm_mm, start, end, MMU_PAGE_1G); in radix__flush_pud_tlb_range()
1385 rs = 1 & ((1UL << 32) - 1); /* any LPID value to flush guest mappings */ in radix__flush_tlb_all()
1392 : : "r"(rb), "i"(r), "i"(1), "i"(ric), "r"(rs) : "memory"); in radix__flush_tlb_all()
1397 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(0) : "memory"); in radix__flush_tlb_all()
1414 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_pid_lpid()
1431 : : "r"(rb), "i"(r), "i"(prs), "i"(ric), "r"(rs) : "memory"); in __tlbie_va_lpid()
1441 unsigned long va = ((1UL << 52) - 1); in fixup_tlbie_pid_lpid()
1462 * must be a compile-time contraint to match the "i" constraint in _tlbie_pid_lpid()
1508 fixup_tlbie_va_range_lpid(addr - page_size, pid, lpid, ap); in __tlbie_va_range_lpid()
1524 * Performs process-scoped invalidations for a given LPID
1548 if (start == 0 && end == -1) in do_h_rpt_invalidate_prt()
1554 if (!(pg_sizes & def->h_rpt_pgsize)) in do_h_rpt_invalidate_prt()
1557 nr_pages = (end - start) >> def->shift; in do_h_rpt_invalidate_prt()
1571 (1UL << def->shift), psize, false); in do_h_rpt_invalidate_prt()