| .. | .. |
|---|
| 29 | 29 | */ |
|---|
| 30 | 30 | |
|---|
| 31 | 31 | /* |
|---|
| 32 | + * Support for KUEP feature. |
|---|
| 33 | + */ |
|---|
| 34 | +#define MMU_FTR_KUEP ASM_CONST(0x00000400) |
|---|
| 35 | + |
|---|
| 36 | +/* |
|---|
| 37 | + * Support for memory protection keys. |
|---|
| 38 | + */ |
|---|
| 39 | +#define MMU_FTR_PKEY ASM_CONST(0x00000800) |
|---|
| 40 | + |
|---|
| 41 | +/* Guest Translation Shootdown Enable */ |
|---|
| 42 | +#define MMU_FTR_GTSE ASM_CONST(0x00001000) |
|---|
| 43 | + |
|---|
| 44 | +/* |
|---|
| 32 | 45 | * Support for 68 bit VA space. We added that from ISA 2.05 |
|---|
| 33 | 46 | */ |
|---|
| 34 | 47 | #define MMU_FTR_68_BIT_VA ASM_CONST(0x00002000) |
|---|
| .. | .. |
|---|
| 48 | 61 | #define MMU_FTR_USE_HIGH_BATS ASM_CONST(0x00010000) |
|---|
| 49 | 62 | |
|---|
| 50 | 63 | /* Enable >32-bit physical addresses on 32-bit processor, only used |
|---|
| 51 | | - * by CONFIG_6xx currently as BookE supports that from day 1 |
|---|
| 64 | + * by CONFIG_PPC_BOOK3S_32 currently as BookE supports that from day 1 |
|---|
| 52 | 65 | */ |
|---|
| 53 | 66 | #define MMU_FTR_BIG_PHYS ASM_CONST(0x00020000) |
|---|
| 54 | 67 | |
|---|
| .. | .. |
|---|
| 107 | 120 | */ |
|---|
| 108 | 121 | #define MMU_FTR_1T_SEGMENT ASM_CONST(0x40000000) |
|---|
| 109 | 122 | |
|---|
| 123 | +/* |
|---|
| 124 | + * Supports KUAP (key 0 controlling userspace addresses) on radix |
|---|
| 125 | + */ |
|---|
| 126 | +#define MMU_FTR_RADIX_KUAP ASM_CONST(0x80000000) |
|---|
| 127 | + |
|---|
| 110 | 128 | /* MMU feature bit sets for various CPUs */ |
|---|
| 111 | 129 | #define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \ |
|---|
| 112 | 130 | MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2 |
|---|
| .. | .. |
|---|
| 117 | 135 | #define MMU_FTRS_POWER7 MMU_FTRS_POWER6 |
|---|
| 118 | 136 | #define MMU_FTRS_POWER8 MMU_FTRS_POWER6 |
|---|
| 119 | 137 | #define MMU_FTRS_POWER9 MMU_FTRS_POWER6 |
|---|
| 138 | +#define MMU_FTRS_POWER10 MMU_FTRS_POWER6 |
|---|
| 120 | 139 | #define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ |
|---|
| 121 | 140 | MMU_FTR_CI_LARGE_PAGE |
|---|
| 122 | 141 | #define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ |
|---|
| .. | .. |
|---|
| 124 | 143 | #ifndef __ASSEMBLY__ |
|---|
| 125 | 144 | #include <linux/bug.h> |
|---|
| 126 | 145 | #include <asm/cputable.h> |
|---|
| 146 | +#include <asm/page.h> |
|---|
| 147 | + |
|---|
| 148 | +typedef pte_t *pgtable_t; |
|---|
| 127 | 149 | |
|---|
| 128 | 150 | #ifdef CONFIG_PPC_FSL_BOOK3E |
|---|
| 129 | 151 | #include <asm/percpu.h> |
|---|
| .. | .. |
|---|
| 131 | 153 | #endif |
|---|
| 132 | 154 | |
|---|
| 133 | 155 | enum { |
|---|
| 134 | | - MMU_FTRS_POSSIBLE = MMU_FTR_HPTE_TABLE | MMU_FTR_TYPE_8xx | |
|---|
| 135 | | - MMU_FTR_TYPE_40x | MMU_FTR_TYPE_44x | MMU_FTR_TYPE_FSL_E | |
|---|
| 136 | | - MMU_FTR_TYPE_47x | MMU_FTR_USE_HIGH_BATS | MMU_FTR_BIG_PHYS | |
|---|
| 137 | | - MMU_FTR_USE_TLBIVAX_BCAST | MMU_FTR_USE_TLBILX | |
|---|
| 138 | | - MMU_FTR_LOCK_BCAST_INVAL | MMU_FTR_NEED_DTLB_SW_LRU | |
|---|
| 156 | + MMU_FTRS_POSSIBLE = |
|---|
| 157 | +#ifdef CONFIG_PPC_BOOK3S |
|---|
| 158 | + MMU_FTR_HPTE_TABLE | |
|---|
| 159 | +#endif |
|---|
| 160 | +#ifdef CONFIG_PPC_8xx |
|---|
| 161 | + MMU_FTR_TYPE_8xx | |
|---|
| 162 | +#endif |
|---|
| 163 | +#ifdef CONFIG_40x |
|---|
| 164 | + MMU_FTR_TYPE_40x | |
|---|
| 165 | +#endif |
|---|
| 166 | +#ifdef CONFIG_44x |
|---|
| 167 | + MMU_FTR_TYPE_44x | |
|---|
| 168 | +#endif |
|---|
| 169 | +#if defined(CONFIG_E200) || defined(CONFIG_E500) |
|---|
| 170 | + MMU_FTR_TYPE_FSL_E | MMU_FTR_BIG_PHYS | MMU_FTR_USE_TLBILX | |
|---|
| 171 | +#endif |
|---|
| 172 | +#ifdef CONFIG_PPC_47x |
|---|
| 173 | + MMU_FTR_TYPE_47x | MMU_FTR_USE_TLBIVAX_BCAST | MMU_FTR_LOCK_BCAST_INVAL | |
|---|
| 174 | +#endif |
|---|
| 175 | +#ifdef CONFIG_PPC_BOOK3S_32 |
|---|
| 176 | + MMU_FTR_USE_HIGH_BATS | MMU_FTR_NEED_DTLB_SW_LRU | |
|---|
| 177 | +#endif |
|---|
| 178 | +#ifdef CONFIG_PPC_BOOK3E_64 |
|---|
| 139 | 179 | MMU_FTR_USE_TLBRSRV | MMU_FTR_USE_PAIRED_MAS | |
|---|
| 180 | +#endif |
|---|
| 181 | +#ifdef CONFIG_PPC_BOOK3S_64 |
|---|
| 140 | 182 | MMU_FTR_NO_SLBIE_B | MMU_FTR_16M_PAGE | MMU_FTR_TLBIEL | |
|---|
| 141 | 183 | MMU_FTR_LOCKLESS_TLBIE | MMU_FTR_CI_LARGE_PAGE | |
|---|
| 142 | 184 | MMU_FTR_1T_SEGMENT | MMU_FTR_TLBIE_CROP_VA | |
|---|
| 143 | 185 | MMU_FTR_KERNEL_RO | MMU_FTR_68_BIT_VA | |
|---|
| 186 | +#endif |
|---|
| 144 | 187 | #ifdef CONFIG_PPC_RADIX_MMU |
|---|
| 145 | 188 | MMU_FTR_TYPE_RADIX | |
|---|
| 189 | + MMU_FTR_GTSE | |
|---|
| 190 | +#ifdef CONFIG_PPC_KUAP |
|---|
| 191 | + MMU_FTR_RADIX_KUAP | |
|---|
| 192 | +#endif /* CONFIG_PPC_KUAP */ |
|---|
| 193 | +#endif /* CONFIG_PPC_RADIX_MMU */ |
|---|
| 194 | +#ifdef CONFIG_PPC_MEM_KEYS |
|---|
| 195 | + MMU_FTR_PKEY | |
|---|
| 146 | 196 | #endif |
|---|
| 197 | +#ifdef CONFIG_PPC_KUEP |
|---|
| 198 | + MMU_FTR_KUEP | |
|---|
| 199 | +#endif /* CONFIG_PPC_KUAP */ |
|---|
| 200 | + |
|---|
| 147 | 201 | 0, |
|---|
| 148 | 202 | }; |
|---|
| 149 | 203 | |
|---|
| .. | .. |
|---|
| 225 | 279 | /* Functions for creating and updating partition table on POWER9 */ |
|---|
| 226 | 280 | extern void mmu_partition_table_init(void); |
|---|
| 227 | 281 | extern void mmu_partition_table_set_entry(unsigned int lpid, unsigned long dw0, |
|---|
| 228 | | - unsigned long dw1); |
|---|
| 282 | + unsigned long dw1, bool flush); |
|---|
| 229 | 283 | #endif /* CONFIG_PPC64 */ |
|---|
| 230 | 284 | |
|---|
| 231 | 285 | struct mm_struct; |
|---|
| .. | .. |
|---|
| 259 | 313 | } |
|---|
| 260 | 314 | #endif |
|---|
| 261 | 315 | |
|---|
| 262 | | -#ifdef CONFIG_PPC_MEM_KEYS |
|---|
| 263 | | -extern u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address); |
|---|
| 264 | | -#else |
|---|
| 265 | | -static inline u16 get_mm_addr_key(struct mm_struct *mm, unsigned long address) |
|---|
| 316 | +#ifdef CONFIG_STRICT_KERNEL_RWX |
|---|
| 317 | +static inline bool strict_kernel_rwx_enabled(void) |
|---|
| 266 | 318 | { |
|---|
| 267 | | - return 0; |
|---|
| 319 | + return rodata_enabled; |
|---|
| 268 | 320 | } |
|---|
| 269 | | -#endif /* CONFIG_PPC_MEM_KEYS */ |
|---|
| 270 | | - |
|---|
| 321 | +#else |
|---|
| 322 | +static inline bool strict_kernel_rwx_enabled(void) |
|---|
| 323 | +{ |
|---|
| 324 | + return false; |
|---|
| 325 | +} |
|---|
| 326 | +#endif |
|---|
| 271 | 327 | #endif /* !__ASSEMBLY__ */ |
|---|
| 272 | 328 | |
|---|
| 273 | 329 | /* The kernel use the constants below to index in the page sizes array. |
|---|
| .. | .. |
|---|
| 320 | 376 | extern void setup_initial_memory_limit(phys_addr_t first_memblock_base, |
|---|
| 321 | 377 | phys_addr_t first_memblock_size); |
|---|
| 322 | 378 | static inline void mmu_early_init_devtree(void) { } |
|---|
| 379 | + |
|---|
| 380 | +static inline void pkey_early_init_devtree(void) {} |
|---|
| 381 | + |
|---|
| 382 | +extern void *abatron_pteptrs[2]; |
|---|
| 323 | 383 | #endif /* __ASSEMBLY__ */ |
|---|
| 324 | 384 | #endif |
|---|
| 325 | 385 | |
|---|
| 326 | | -#if defined(CONFIG_PPC_STD_MMU_32) |
|---|
| 386 | +#if defined(CONFIG_PPC_BOOK3S_32) |
|---|
| 327 | 387 | /* 32-bit classic hash table MMU */ |
|---|
| 328 | 388 | #include <asm/book3s/32/mmu-hash.h> |
|---|
| 329 | | -#elif defined(CONFIG_40x) |
|---|
| 330 | | -/* 40x-style software loaded TLB */ |
|---|
| 331 | | -# include <asm/mmu-40x.h> |
|---|
| 332 | | -#elif defined(CONFIG_44x) |
|---|
| 333 | | -/* 44x-style software loaded TLB */ |
|---|
| 334 | | -# include <asm/mmu-44x.h> |
|---|
| 335 | | -#elif defined(CONFIG_PPC_BOOK3E_MMU) |
|---|
| 336 | | -/* Freescale Book-E software loaded TLB or Book-3e (ISA 2.06+) MMU */ |
|---|
| 337 | | -# include <asm/mmu-book3e.h> |
|---|
| 338 | | -#elif defined (CONFIG_PPC_8xx) |
|---|
| 339 | | -/* Motorola/Freescale 8xx software loaded TLB */ |
|---|
| 340 | | -# include <asm/mmu-8xx.h> |
|---|
| 389 | +#elif defined(CONFIG_PPC_MMU_NOHASH) |
|---|
| 390 | +#include <asm/nohash/mmu.h> |
|---|
| 341 | 391 | #endif |
|---|
| 342 | 392 | |
|---|
| 343 | 393 | #endif /* __KERNEL__ */ |
|---|