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

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

Version: ~ [ linux-5.13-rc1 ] ~ [ linux-5.12.2 ] ~ [ linux-5.11.19 ] ~ [ linux-5.10.35 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.117 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.190 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.232 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.268 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.268 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Based on arch/arm/include/asm/pgalloc.h
  3  *
  4  * Copyright (C) 2000-2001 Russell King
  5  * Copyright (C) 2012 ARM Ltd.
  6  *
  7  * This program is free software; you can redistribute it and/or modify
  8  * it under the terms of the GNU General Public License version 2 as
  9  * published by the Free Software Foundation.
 10  *
 11  * This program is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  * GNU General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU General Public License
 17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 18  */
 19 #ifndef __ASM_PGALLOC_H
 20 #define __ASM_PGALLOC_H
 21 
 22 #include <asm/pgtable-hwdef.h>
 23 #include <asm/processor.h>
 24 #include <asm/cacheflush.h>
 25 #include <asm/tlbflush.h>
 26 
 27 #define check_pgt_cache()               do { } while (0)
 28 
 29 #define PGALLOC_GFP     (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)
 30 
 31 #if CONFIG_ARM64_PGTABLE_LEVELS > 2
 32 
 33 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
 34 {
 35         return (pmd_t *)__get_free_page(PGALLOC_GFP);
 36 }
 37 
 38 static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
 39 {
 40         BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
 41         free_page((unsigned long)pmd);
 42 }
 43 
 44 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 45 {
 46         set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
 47 }
 48 
 49 #endif  /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */
 50 
 51 #if CONFIG_ARM64_PGTABLE_LEVELS > 3
 52 
 53 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
 54 {
 55         return (pud_t *)__get_free_page(PGALLOC_GFP);
 56 }
 57 
 58 static inline void pud_free(struct mm_struct *mm, pud_t *pud)
 59 {
 60         BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
 61         free_page((unsigned long)pud);
 62 }
 63 
 64 static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
 65 {
 66         set_pgd(pgd, __pgd(__pa(pud) | PUD_TYPE_TABLE));
 67 }
 68 
 69 #endif  /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */
 70 
 71 extern pgd_t *pgd_alloc(struct mm_struct *mm);
 72 extern void pgd_free(struct mm_struct *mm, pgd_t *pgd);
 73 
 74 static inline pte_t *
 75 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 76 {
 77         return (pte_t *)__get_free_page(PGALLOC_GFP);
 78 }
 79 
 80 static inline pgtable_t
 81 pte_alloc_one(struct mm_struct *mm, unsigned long addr)
 82 {
 83         struct page *pte;
 84 
 85         pte = alloc_pages(PGALLOC_GFP, 0);
 86         if (!pte)
 87                 return NULL;
 88         if (!pgtable_page_ctor(pte)) {
 89                 __free_page(pte);
 90                 return NULL;
 91         }
 92         return pte;
 93 }
 94 
 95 /*
 96  * Free a PTE table.
 97  */
 98 static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 99 {
100         if (pte)
101                 free_page((unsigned long)pte);
102 }
103 
104 static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
105 {
106         pgtable_page_dtor(pte);
107         __free_page(pte);
108 }
109 
110 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
111                                   pmdval_t prot)
112 {
113         set_pmd(pmdp, __pmd(pte | prot));
114 }
115 
116 /*
117  * Populate the pmdp entry with a pointer to the pte.  This pmd is part
118  * of the mm address space.
119  */
120 static inline void
121 pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
122 {
123         /*
124          * The pmd must be loaded with the physical address of the PTE table
125          */
126         __pmd_populate(pmdp, __pa(ptep), PMD_TYPE_TABLE);
127 }
128 
129 static inline void
130 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
131 {
132         __pmd_populate(pmdp, page_to_phys(ptep), PMD_TYPE_TABLE);
133 }
134 #define pmd_pgtable(pmd) pmd_page(pmd)
135 
136 #endif
137 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp