Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  IBM System z Huge TLB Page Support for Kernel.
0004  *
0005  *    Copyright IBM Corp. 2008
0006  *    Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
0007  */
0008 
0009 #ifndef _ASM_S390_HUGETLB_H
0010 #define _ASM_S390_HUGETLB_H
0011 
0012 #include <linux/pgtable.h>
0013 #include <asm/page.h>
0014 
0015 #define hugetlb_free_pgd_range          free_pgd_range
0016 #define hugepages_supported()           (MACHINE_HAS_EDAT1)
0017 
0018 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
0019              pte_t *ptep, pte_t pte);
0020 pte_t huge_ptep_get(pte_t *ptep);
0021 pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
0022                   unsigned long addr, pte_t *ptep);
0023 
0024 /*
0025  * If the arch doesn't supply something else, assume that hugepage
0026  * size aligned regions are ok without further preparation.
0027  */
0028 static inline int prepare_hugepage_range(struct file *file,
0029             unsigned long addr, unsigned long len)
0030 {
0031     struct hstate *h = hstate_file(file);
0032 
0033     if (len & ~huge_page_mask(h))
0034         return -EINVAL;
0035     if (addr & ~huge_page_mask(h))
0036         return -EINVAL;
0037     return 0;
0038 }
0039 
0040 static inline void arch_clear_hugepage_flags(struct page *page)
0041 {
0042     clear_bit(PG_arch_1, &page->flags);
0043 }
0044 #define arch_clear_hugepage_flags arch_clear_hugepage_flags
0045 
0046 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
0047                   pte_t *ptep, unsigned long sz)
0048 {
0049     if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
0050         set_pte(ptep, __pte(_REGION3_ENTRY_EMPTY));
0051     else
0052         set_pte(ptep, __pte(_SEGMENT_ENTRY_EMPTY));
0053 }
0054 
0055 static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma,
0056                       unsigned long address, pte_t *ptep)
0057 {
0058     return huge_ptep_get_and_clear(vma->vm_mm, address, ptep);
0059 }
0060 
0061 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
0062                          unsigned long addr, pte_t *ptep,
0063                          pte_t pte, int dirty)
0064 {
0065     int changed = !pte_same(huge_ptep_get(ptep), pte);
0066     if (changed) {
0067         huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
0068         set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
0069     }
0070     return changed;
0071 }
0072 
0073 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
0074                        unsigned long addr, pte_t *ptep)
0075 {
0076     pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep);
0077     set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte));
0078 }
0079 
0080 static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot)
0081 {
0082     return mk_pte(page, pgprot);
0083 }
0084 
0085 static inline int huge_pte_none(pte_t pte)
0086 {
0087     return pte_none(pte);
0088 }
0089 
0090 static inline int huge_pte_none_mostly(pte_t pte)
0091 {
0092     return huge_pte_none(pte);
0093 }
0094 
0095 static inline int huge_pte_write(pte_t pte)
0096 {
0097     return pte_write(pte);
0098 }
0099 
0100 static inline int huge_pte_dirty(pte_t pte)
0101 {
0102     return pte_dirty(pte);
0103 }
0104 
0105 static inline pte_t huge_pte_mkwrite(pte_t pte)
0106 {
0107     return pte_mkwrite(pte);
0108 }
0109 
0110 static inline pte_t huge_pte_mkdirty(pte_t pte)
0111 {
0112     return pte_mkdirty(pte);
0113 }
0114 
0115 static inline pte_t huge_pte_wrprotect(pte_t pte)
0116 {
0117     return pte_wrprotect(pte);
0118 }
0119 
0120 static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot)
0121 {
0122     return pte_modify(pte, newprot);
0123 }
0124 
0125 static inline pte_t huge_pte_mkuffd_wp(pte_t pte)
0126 {
0127     return pte;
0128 }
0129 
0130 static inline pte_t huge_pte_clear_uffd_wp(pte_t pte)
0131 {
0132     return pte;
0133 }
0134 
0135 static inline int huge_pte_uffd_wp(pte_t pte)
0136 {
0137     return 0;
0138 }
0139 
0140 static inline bool gigantic_page_runtime_supported(void)
0141 {
0142     return true;
0143 }
0144 
0145 #endif /* _ASM_S390_HUGETLB_H */