Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/mm.h>
0003 #include <linux/hugetlb.h>
0004 #include <linux/security.h>
0005 #include <asm/cacheflush.h>
0006 #include <asm/machdep.h>
0007 #include <asm/mman.h>
0008 #include <asm/tlb.h>
0009 
0010 void radix__flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
0011 {
0012     int psize;
0013     struct hstate *hstate = hstate_file(vma->vm_file);
0014 
0015     psize = hstate_get_psize(hstate);
0016     radix__flush_tlb_page_psize(vma->vm_mm, vmaddr, psize);
0017 }
0018 
0019 void radix__local_flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
0020 {
0021     int psize;
0022     struct hstate *hstate = hstate_file(vma->vm_file);
0023 
0024     psize = hstate_get_psize(hstate);
0025     radix__local_flush_tlb_page_psize(vma->vm_mm, vmaddr, psize);
0026 }
0027 
0028 void radix__flush_hugetlb_tlb_range(struct vm_area_struct *vma, unsigned long start,
0029                    unsigned long end)
0030 {
0031     int psize;
0032     struct hstate *hstate = hstate_file(vma->vm_file);
0033 
0034     psize = hstate_get_psize(hstate);
0035     /*
0036      * Flush PWC even if we get PUD_SIZE hugetlb invalidate to keep this simpler.
0037      */
0038     if (end - start >= PUD_SIZE)
0039         radix__flush_tlb_pwc_range_psize(vma->vm_mm, start, end, psize);
0040     else
0041         radix__flush_tlb_range_psize(vma->vm_mm, start, end, psize);
0042 }
0043 
0044 void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
0045                      unsigned long addr, pte_t *ptep,
0046                      pte_t old_pte, pte_t pte)
0047 {
0048     struct mm_struct *mm = vma->vm_mm;
0049 
0050     /*
0051      * POWER9 NMMU must flush the TLB after clearing the PTE before
0052      * installing a PTE with more relaxed access permissions, see
0053      * radix__ptep_set_access_flags.
0054      */
0055     if (!cpu_has_feature(CPU_FTR_ARCH_31) &&
0056         is_pte_rw_upgrade(pte_val(old_pte), pte_val(pte)) &&
0057         atomic_read(&mm->context.copros) > 0)
0058         radix__flush_hugetlb_page(vma, addr);
0059 
0060     set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
0061 }