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

TOMOYO Linux Cross Reference
Linux/arch/arm64/include/asm/pgalloc.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * Based on arch/arm/include/asm/pgalloc.h
  4  *
  5  * Copyright (C) 2000-2001 Russell King
  6  * Copyright (C) 2012 ARM Ltd.
  7  */
  8 #ifndef __ASM_PGALLOC_H
  9 #define __ASM_PGALLOC_H
 10 
 11 #include <asm/pgtable-hwdef.h>
 12 #include <asm/processor.h>
 13 #include <asm/cacheflush.h>
 14 #include <asm/tlbflush.h>
 15 
 16 #define __HAVE_ARCH_PGD_FREE
 17 #define __HAVE_ARCH_PUD_FREE
 18 #include <asm-generic/pgalloc.h>
 19 
 20 #define PGD_SIZE        (PTRS_PER_PGD * sizeof(pgd_t))
 21 
 22 #if CONFIG_PGTABLE_LEVELS > 2
 23 
 24 static inline void __pud_populate(pud_t *pudp, phys_addr_t pmdp, pudval_t prot)
 25 {
 26         set_pud(pudp, __pud(__phys_to_pud_val(pmdp) | prot));
 27 }
 28 
 29 static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmdp)
 30 {
 31         pudval_t pudval = PUD_TYPE_TABLE;
 32 
 33         pudval |= (mm == &init_mm) ? PUD_TABLE_UXN : PUD_TABLE_PXN;
 34         __pud_populate(pudp, __pa(pmdp), pudval);
 35 }
 36 #else
 37 static inline void __pud_populate(pud_t *pudp, phys_addr_t pmdp, pudval_t prot)
 38 {
 39         BUILD_BUG();
 40 }
 41 #endif  /* CONFIG_PGTABLE_LEVELS > 2 */
 42 
 43 #if CONFIG_PGTABLE_LEVELS > 3
 44 
 45 static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)
 46 {
 47         if (pgtable_l4_enabled())
 48                 set_p4d(p4dp, __p4d(__phys_to_p4d_val(pudp) | prot));
 49 }
 50 
 51 static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4dp, pud_t *pudp)
 52 {
 53         p4dval_t p4dval = P4D_TYPE_TABLE;
 54 
 55         p4dval |= (mm == &init_mm) ? P4D_TABLE_UXN : P4D_TABLE_PXN;
 56         __p4d_populate(p4dp, __pa(pudp), p4dval);
 57 }
 58 
 59 static inline void pud_free(struct mm_struct *mm, pud_t *pud)
 60 {
 61         if (!pgtable_l4_enabled())
 62                 return;
 63         __pud_free(mm, pud);
 64 }
 65 #else
 66 static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)
 67 {
 68         BUILD_BUG();
 69 }
 70 #endif  /* CONFIG_PGTABLE_LEVELS > 3 */
 71 
 72 #if CONFIG_PGTABLE_LEVELS > 4
 73 
 74 static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t p4dp, pgdval_t prot)
 75 {
 76         if (pgtable_l5_enabled())
 77                 set_pgd(pgdp, __pgd(__phys_to_pgd_val(p4dp) | prot));
 78 }
 79 
 80 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgdp, p4d_t *p4dp)
 81 {
 82         pgdval_t pgdval = PGD_TYPE_TABLE;
 83 
 84         pgdval |= (mm == &init_mm) ? PGD_TABLE_UXN : PGD_TABLE_PXN;
 85         __pgd_populate(pgdp, __pa(p4dp), pgdval);
 86 }
 87 
 88 static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
 89 {
 90         gfp_t gfp = GFP_PGTABLE_USER;
 91 
 92         if (mm == &init_mm)
 93                 gfp = GFP_PGTABLE_KERNEL;
 94         return (p4d_t *)get_zeroed_page(gfp);
 95 }
 96 
 97 static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d)
 98 {
 99         if (!pgtable_l5_enabled())
100                 return;
101         BUG_ON((unsigned long)p4d & (PAGE_SIZE-1));
102         free_page((unsigned long)p4d);
103 }
104 
105 #define __p4d_free_tlb(tlb, p4d, addr)  p4d_free((tlb)->mm, p4d)
106 #else
107 static inline void __pgd_populate(pgd_t *pgdp, phys_addr_t p4dp, pgdval_t prot)
108 {
109         BUILD_BUG();
110 }
111 #endif  /* CONFIG_PGTABLE_LEVELS > 4 */
112 
113 extern pgd_t *pgd_alloc(struct mm_struct *mm);
114 extern void pgd_free(struct mm_struct *mm, pgd_t *pgdp);
115 
116 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t ptep,
117                                   pmdval_t prot)
118 {
119         set_pmd(pmdp, __pmd(__phys_to_pmd_val(ptep) | prot));
120 }
121 
122 /*
123  * Populate the pmdp entry with a pointer to the pte.  This pmd is part
124  * of the mm address space.
125  */
126 static inline void
127 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
128 {
129         VM_BUG_ON(mm && mm != &init_mm);
130         __pmd_populate(pmdp, __pa(ptep), PMD_TYPE_TABLE | PMD_TABLE_UXN);
131 }
132 
133 static inline void
134 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
135 {
136         VM_BUG_ON(mm == &init_mm);
137         __pmd_populate(pmdp, page_to_phys(ptep), PMD_TYPE_TABLE | PMD_TABLE_PXN);
138 }
139 
140 #endif
141 

~ [ 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