xref: /linux/arch/um/include/asm/pgalloc.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
4  * Copyright 2003 PathScale, Inc.
5  * Derived from include/asm-i386/pgalloc.h and include/asm-i386/pgtable.h
6  */
7 
8 #ifndef __UM_PGALLOC_H
9 #define __UM_PGALLOC_H
10 
11 #include <linux/mm.h>
12 
13 #include <asm-generic/pgalloc.h>
14 
15 #define pmd_populate_kernel(mm, pmd, pte) \
16 	set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte)))
17 
18 #define pmd_populate(mm, pmd, pte) 				\
19 	set_pmd(pmd, __pmd(_PAGE_TABLE +			\
20 		((unsigned long long)page_to_pfn(pte) <<	\
21 			(unsigned long long) PAGE_SHIFT)))
22 
23 /*
24  * Allocate and free page tables.
25  */
26 extern pgd_t *pgd_alloc(struct mm_struct *);
27 
28 #define __pte_free_tlb(tlb, pte, address)			\
29 do {								\
30 	pagetable_pte_dtor(page_ptdesc(pte));			\
31 	tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte)));	\
32 } while (0)
33 
34 #if CONFIG_PGTABLE_LEVELS > 2
35 
36 #define __pmd_free_tlb(tlb, pmd, address)			\
37 do {								\
38 	pagetable_pmd_dtor(virt_to_ptdesc(pmd));			\
39 	tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pmd));	\
40 } while (0)
41 
42 #if CONFIG_PGTABLE_LEVELS > 3
43 
44 #define __pud_free_tlb(tlb, pud, address)			\
45 do {								\
46 	pagetable_pud_dtor(virt_to_ptdesc(pud));		\
47 	tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pud));	\
48 } while (0)
49 
50 #endif
51 #endif
52 
53 #endif
54 
55