~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/mm/book3s32/tlb.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * This file contains the routines for TLB flushing.
  4  * On machines where the MMU uses a hash table to store virtual to
  5  * physical translations, these routines flush entries from the
  6  * hash table also.
  7  *  -- paulus
  8  *
  9  *  Derived from arch/ppc/mm/init.c:
 10  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
 11  *
 12  *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
 13  *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
 14  *    Copyright (C) 1996 Paul Mackerras
 15  *
 16  *  Derived from "arch/i386/mm/init.c"
 17  *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
 18  */
 19 
 20 #include <linux/kernel.h>
 21 #include <linux/mm.h>
 22 #include <linux/init.h>
 23 #include <linux/highmem.h>
 24 #include <linux/pagemap.h>
 25 #include <linux/export.h>
 26 
 27 #include <asm/tlbflush.h>
 28 #include <asm/tlb.h>
 29 
 30 #include <mm/mmu_decl.h>
 31 
 32 /*
 33  * TLB flushing:
 34  *
 35  *  - flush_tlb_mm(mm) flushes the specified mm context TLB's
 36  *  - flush_tlb_page(vma, vmaddr) flushes one page
 37  *  - flush_tlb_range(vma, start, end) flushes a range of pages
 38  *  - flush_tlb_kernel_range(start, end) flushes kernel pages
 39  *
 40  * since the hardware hash table functions as an extension of the
 41  * tlb as far as the linux tables are concerned, flush it too.
 42  *    -- Cort
 43  */
 44 
 45 /*
 46  * For each address in the range, find the pte for the address
 47  * and check _PAGE_HASHPTE bit; if it is set, find and destroy
 48  * the corresponding HPTE.
 49  */
 50 void hash__flush_range(struct mm_struct *mm, unsigned long start, unsigned long end)
 51 {
 52         pmd_t *pmd;
 53         unsigned long pmd_end;
 54         int count;
 55         unsigned int ctx = mm->context.id;
 56 
 57         start &= PAGE_MASK;
 58         if (start >= end)
 59                 return;
 60         end = (end - 1) | ~PAGE_MASK;
 61         pmd = pmd_off(mm, start);
 62         for (;;) {
 63                 pmd_end = ((start + PGDIR_SIZE) & PGDIR_MASK) - 1;
 64                 if (pmd_end > end)
 65                         pmd_end = end;
 66                 if (!pmd_none(*pmd)) {
 67                         count = ((pmd_end - start) >> PAGE_SHIFT) + 1;
 68                         flush_hash_pages(ctx, start, pmd_val(*pmd), count);
 69                 }
 70                 if (pmd_end == end)
 71                         break;
 72                 start = pmd_end + 1;
 73                 ++pmd;
 74         }
 75 }
 76 EXPORT_SYMBOL(hash__flush_range);
 77 
 78 /*
 79  * Flush all the (user) entries for the address space described by mm.
 80  */
 81 void hash__flush_tlb_mm(struct mm_struct *mm)
 82 {
 83         struct vm_area_struct *mp;
 84         VMA_ITERATOR(vmi, mm, 0);
 85 
 86         /*
 87          * It is safe to iterate the vmas when called from dup_mmap,
 88          * holding mmap_lock.  It would also be safe from unmap_region
 89          * or exit_mmap, but not from vmtruncate on SMP - but it seems
 90          * dup_mmap is the only SMP case which gets here.
 91          */
 92         for_each_vma(vmi, mp)
 93                 hash__flush_range(mp->vm_mm, mp->vm_start, mp->vm_end);
 94 }
 95 EXPORT_SYMBOL(hash__flush_tlb_mm);
 96 
 97 void hash__flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
 98 {
 99         struct mm_struct *mm;
100         pmd_t *pmd;
101 
102         mm = (vmaddr < TASK_SIZE)? vma->vm_mm: &init_mm;
103         pmd = pmd_off(mm, vmaddr);
104         if (!pmd_none(*pmd))
105                 flush_hash_pages(mm->context.id, vmaddr, pmd_val(*pmd), 1);
106 }
107 EXPORT_SYMBOL(hash__flush_tlb_page);
108 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php