Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
047ea784 PM |
2 | #ifndef _ASM_POWERPC_PGTABLE_H |
3 | #define _ASM_POWERPC_PGTABLE_H | |
4 | ||
9c709f3b | 5 | #ifndef __ASSEMBLY__ |
c34a51ce | 6 | #include <linux/mmdebug.h> |
1c98025c | 7 | #include <linux/mmzone.h> |
9c709f3b DG |
8 | #include <asm/processor.h> /* For TASK_SIZE */ |
9 | #include <asm/mmu.h> | |
10 | #include <asm/page.h> | |
bd5050e3 | 11 | #include <asm/tlbflush.h> |
8d30c14c | 12 | |
9c709f3b | 13 | struct mm_struct; |
8d30c14c | 14 | |
9c709f3b DG |
15 | #endif /* !__ASSEMBLY__ */ |
16 | ||
3dfcb315 AK |
17 | #ifdef CONFIG_PPC_BOOK3S |
18 | #include <asm/book3s/pgtable.h> | |
19 | #else | |
17ed9e31 | 20 | #include <asm/nohash/pgtable.h> |
3dfcb315 | 21 | #endif /* !CONFIG_PPC_BOOK3S */ |
1da177e4 | 22 | |
f4805785 CL |
23 | /* Note due to the way vm flags are laid out, the bits are XWR */ |
24 | #define __P000 PAGE_NONE | |
25 | #define __P001 PAGE_READONLY | |
26 | #define __P010 PAGE_COPY | |
27 | #define __P011 PAGE_COPY | |
28 | #define __P100 PAGE_READONLY_X | |
29 | #define __P101 PAGE_READONLY_X | |
30 | #define __P110 PAGE_COPY_X | |
31 | #define __P111 PAGE_COPY_X | |
32 | ||
33 | #define __S000 PAGE_NONE | |
34 | #define __S001 PAGE_READONLY | |
35 | #define __S010 PAGE_SHARED | |
36 | #define __S011 PAGE_SHARED | |
37 | #define __S100 PAGE_READONLY_X | |
38 | #define __S101 PAGE_READONLY_X | |
39 | #define __S110 PAGE_SHARED_X | |
40 | #define __S111 PAGE_SHARED_X | |
41 | ||
1da177e4 | 42 | #ifndef __ASSEMBLY__ |
64b3d0e8 | 43 | |
78f1dbde AK |
44 | #include <asm/tlbflush.h> |
45 | ||
71087002 BH |
46 | /* Keep these as a macros to avoid include dependency mess */ |
47 | #define pte_page(x) pfn_to_page(pte_pfn(x)) | |
48 | #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) | |
b9fb4480 AK |
49 | /* |
50 | * Select all bits except the pfn | |
51 | */ | |
52 | static inline pgprot_t pte_pgprot(pte_t pte) | |
53 | { | |
54 | unsigned long pte_flags; | |
55 | ||
56 | pte_flags = pte_val(pte) & ~PTE_RPN_MASK; | |
57 | return __pgprot(pte_flags); | |
58 | } | |
71087002 | 59 | |
9c709f3b DG |
60 | /* |
61 | * ZERO_PAGE is a global shared page that is always zero: used | |
62 | * for zero-mapped memory areas etc.. | |
63 | */ | |
64 | extern unsigned long empty_zero_page[]; | |
65 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) | |
66 | ||
67 | extern pgd_t swapper_pg_dir[]; | |
68 | ||
69 | extern void paging_init(void); | |
70 | ||
7cd9b317 CL |
71 | extern unsigned long ioremap_bot; |
72 | ||
9c709f3b DG |
73 | /* |
74 | * kern_addr_valid is intended to indicate whether an address is a valid | |
75 | * kernel address. Most 32-bit archs define it as always true (like this) | |
76 | * but most 64-bit archs actually perform a test. What should we do here? | |
77 | */ | |
78 | #define kern_addr_valid(addr) (1) | |
79 | ||
1da177e4 | 80 | #include <asm-generic/pgtable.h> |
1e3519f8 | 81 | |
074c2eae AK |
82 | #ifndef CONFIG_TRANSPARENT_HUGEPAGE |
83 | #define pmd_large(pmd) 0 | |
074c2eae | 84 | #endif |
e9ab1a1c | 85 | |
94171b19 | 86 | /* can we use this in kvm */ |
e9ab1a1c AK |
87 | unsigned long vmalloc_to_phys(void *vmalloc_addr); |
88 | ||
1e03c7e2 | 89 | void pgtable_cache_add(unsigned int shift); |
029d9252 | 90 | |
3184cc4b | 91 | #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32) |
029d9252 ME |
92 | void mark_initmem_nx(void); |
93 | #else | |
94 | static inline void mark_initmem_nx(void) { } | |
95 | #endif | |
96 | ||
453d87f6 RC |
97 | #ifdef CONFIG_PPC_DEBUG_WX |
98 | void ptdump_check_wx(void); | |
99 | #else | |
100 | static inline void ptdump_check_wx(void) { } | |
101 | #endif | |
102 | ||
a74791dd CL |
103 | /* |
104 | * When used, PTE_FRAG_NR is defined in subarch pgtable.h | |
105 | * so we are sure it is included when arriving here. | |
106 | */ | |
107 | #ifdef PTE_FRAG_NR | |
108 | static inline void *pte_frag_get(mm_context_t *ctx) | |
109 | { | |
110 | return ctx->pte_frag; | |
111 | } | |
112 | ||
113 | static inline void pte_frag_set(mm_context_t *ctx, void *p) | |
114 | { | |
115 | ctx->pte_frag = p; | |
116 | } | |
117 | #else | |
32ea4c14 CL |
118 | #define PTE_FRAG_NR 1 |
119 | #define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT | |
120 | #define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT) | |
121 | ||
a74791dd CL |
122 | static inline void *pte_frag_get(mm_context_t *ctx) |
123 | { | |
124 | return NULL; | |
125 | } | |
126 | ||
127 | static inline void pte_frag_set(mm_context_t *ctx, void *p) | |
128 | { | |
129 | } | |
130 | #endif | |
131 | ||
d6eacedd AK |
132 | #ifndef pmd_is_leaf |
133 | #define pmd_is_leaf pmd_is_leaf | |
134 | static inline bool pmd_is_leaf(pmd_t pmd) | |
135 | { | |
136 | return false; | |
137 | } | |
138 | #endif | |
139 | ||
140 | #ifndef pud_is_leaf | |
141 | #define pud_is_leaf pud_is_leaf | |
142 | static inline bool pud_is_leaf(pud_t pud) | |
143 | { | |
144 | return false; | |
145 | } | |
146 | #endif | |
147 | ||
148 | #ifndef pgd_is_leaf | |
149 | #define pgd_is_leaf pgd_is_leaf | |
150 | static inline bool pgd_is_leaf(pgd_t pgd) | |
151 | { | |
152 | return false; | |
153 | } | |
154 | #endif | |
155 | ||
9bd3bb67 AK |
156 | #ifdef CONFIG_PPC64 |
157 | #define is_ioremap_addr is_ioremap_addr | |
158 | static inline bool is_ioremap_addr(const void *x) | |
159 | { | |
160 | #ifdef CONFIG_MMU | |
161 | unsigned long addr = (unsigned long)x; | |
162 | ||
163 | return addr >= IOREMAP_BASE && addr < IOREMAP_END; | |
164 | #else | |
165 | return false; | |
166 | #endif | |
167 | } | |
168 | #endif /* CONFIG_PPC64 */ | |
169 | ||
1da177e4 LT |
170 | #endif /* __ASSEMBLY__ */ |
171 | ||
047ea784 | 172 | #endif /* _ASM_POWERPC_PGTABLE_H */ |