.. | .. |
---|
18 | 18 | #include <asm/book3s/64/hash-4k.h> |
---|
19 | 19 | #endif |
---|
20 | 20 | |
---|
| 21 | +/* Bits to set in a PMD/PUD/PGD entry valid bit*/ |
---|
| 22 | +#define HASH_PMD_VAL_BITS (0x8000000000000000UL) |
---|
| 23 | +#define HASH_PUD_VAL_BITS (0x8000000000000000UL) |
---|
| 24 | +#define HASH_PGD_VAL_BITS (0x8000000000000000UL) |
---|
| 25 | + |
---|
21 | 26 | /* |
---|
22 | 27 | * Size of EA range mapped by our pagetables. |
---|
23 | 28 | */ |
---|
24 | 29 | #define H_PGTABLE_EADDR_SIZE (H_PTE_INDEX_SIZE + H_PMD_INDEX_SIZE + \ |
---|
25 | 30 | H_PUD_INDEX_SIZE + H_PGD_INDEX_SIZE + PAGE_SHIFT) |
---|
26 | 31 | #define H_PGTABLE_RANGE (ASM_CONST(1) << H_PGTABLE_EADDR_SIZE) |
---|
| 32 | +/* |
---|
| 33 | + * Top 2 bits are ignored in page table walk. |
---|
| 34 | + */ |
---|
| 35 | +#define EA_MASK (~(0xcUL << 60)) |
---|
27 | 36 | |
---|
28 | 37 | /* |
---|
29 | 38 | * We store the slot details in the second half of page table. |
---|
.. | .. |
---|
35 | 44 | #else |
---|
36 | 45 | #define H_PUD_CACHE_INDEX (H_PUD_INDEX_SIZE) |
---|
37 | 46 | #endif |
---|
38 | | -/* |
---|
39 | | - * Define the address range of the kernel non-linear virtual area |
---|
40 | | - */ |
---|
41 | | -#define H_KERN_VIRT_START ASM_CONST(0xD000000000000000) |
---|
42 | | -#define H_KERN_VIRT_SIZE ASM_CONST(0x0000400000000000) /* 64T */ |
---|
43 | 47 | |
---|
44 | 48 | /* |
---|
45 | | - * The vmalloc space starts at the beginning of that region, and |
---|
46 | | - * occupies half of it on hash CPUs and a quarter of it on Book3E |
---|
47 | | - * (we keep a quarter for the virtual memmap) |
---|
| 49 | + * +------------------------------+ |
---|
| 50 | + * | | |
---|
| 51 | + * | | |
---|
| 52 | + * | | |
---|
| 53 | + * +------------------------------+ Kernel virtual map end (0xc00e000000000000) |
---|
| 54 | + * | | |
---|
| 55 | + * | | |
---|
| 56 | + * | 512TB/16TB of vmemmap | |
---|
| 57 | + * | | |
---|
| 58 | + * | | |
---|
| 59 | + * +------------------------------+ Kernel vmemmap start |
---|
| 60 | + * | | |
---|
| 61 | + * | 512TB/16TB of IO map | |
---|
| 62 | + * | | |
---|
| 63 | + * +------------------------------+ Kernel IO map start |
---|
| 64 | + * | | |
---|
| 65 | + * | 512TB/16TB of vmap | |
---|
| 66 | + * | | |
---|
| 67 | + * +------------------------------+ Kernel virt start (0xc008000000000000) |
---|
| 68 | + * | | |
---|
| 69 | + * | | |
---|
| 70 | + * | | |
---|
| 71 | + * +------------------------------+ Kernel linear (0xc.....) |
---|
48 | 72 | */ |
---|
49 | | -#define H_VMALLOC_START H_KERN_VIRT_START |
---|
50 | | -#define H_VMALLOC_SIZE ASM_CONST(0x380000000000) /* 56T */ |
---|
51 | | -#define H_VMALLOC_END (H_VMALLOC_START + H_VMALLOC_SIZE) |
---|
52 | 73 | |
---|
53 | | -#define H_KERN_IO_START H_VMALLOC_END |
---|
| 74 | +#define H_VMALLOC_START H_KERN_VIRT_START |
---|
| 75 | +#define H_VMALLOC_SIZE H_KERN_MAP_SIZE |
---|
| 76 | +#define H_VMALLOC_END (H_VMALLOC_START + H_VMALLOC_SIZE) |
---|
| 77 | + |
---|
| 78 | +#define H_KERN_IO_START H_VMALLOC_END |
---|
| 79 | +#define H_KERN_IO_SIZE H_KERN_MAP_SIZE |
---|
| 80 | +#define H_KERN_IO_END (H_KERN_IO_START + H_KERN_IO_SIZE) |
---|
| 81 | + |
---|
| 82 | +#define H_VMEMMAP_START H_KERN_IO_END |
---|
| 83 | +#define H_VMEMMAP_SIZE H_KERN_MAP_SIZE |
---|
| 84 | +#define H_VMEMMAP_END (H_VMEMMAP_START + H_VMEMMAP_SIZE) |
---|
| 85 | + |
---|
| 86 | +#define NON_LINEAR_REGION_ID(ea) ((((unsigned long)ea - H_KERN_VIRT_START) >> REGION_SHIFT) + 2) |
---|
54 | 87 | |
---|
55 | 88 | /* |
---|
56 | 89 | * Region IDs |
---|
57 | 90 | */ |
---|
58 | | -#define REGION_SHIFT 60UL |
---|
59 | | -#define REGION_MASK (0xfUL << REGION_SHIFT) |
---|
60 | | -#define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT) |
---|
61 | | - |
---|
62 | | -#define VMALLOC_REGION_ID (REGION_ID(H_VMALLOC_START)) |
---|
63 | | -#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET)) |
---|
64 | | -#define VMEMMAP_REGION_ID (0xfUL) /* Server only */ |
---|
65 | | -#define USER_REGION_ID (0UL) |
---|
| 91 | +#define USER_REGION_ID 0 |
---|
| 92 | +#define LINEAR_MAP_REGION_ID 1 |
---|
| 93 | +#define VMALLOC_REGION_ID NON_LINEAR_REGION_ID(H_VMALLOC_START) |
---|
| 94 | +#define IO_REGION_ID NON_LINEAR_REGION_ID(H_KERN_IO_START) |
---|
| 95 | +#define VMEMMAP_REGION_ID NON_LINEAR_REGION_ID(H_VMEMMAP_START) |
---|
| 96 | +#define INVALID_REGION_ID (VMEMMAP_REGION_ID + 1) |
---|
66 | 97 | |
---|
67 | 98 | /* |
---|
68 | 99 | * Defines the address of the vmemap area, in its own region on |
---|
69 | 100 | * hash table CPUs. |
---|
70 | 101 | */ |
---|
71 | | -#define H_VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) |
---|
72 | | - |
---|
73 | 102 | #ifdef CONFIG_PPC_MM_SLICES |
---|
74 | 103 | #define HAVE_ARCH_UNMAPPED_AREA |
---|
75 | 104 | #define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN |
---|
76 | 105 | #endif /* CONFIG_PPC_MM_SLICES */ |
---|
77 | | - |
---|
78 | 106 | |
---|
79 | 107 | /* PTEIDX nibble */ |
---|
80 | 108 | #define _PTEIDX_SECONDARY 0x8 |
---|
.. | .. |
---|
84 | 112 | #define H_PUD_BAD_BITS (PMD_TABLE_SIZE-1) |
---|
85 | 113 | |
---|
86 | 114 | #ifndef __ASSEMBLY__ |
---|
| 115 | +static inline int get_region_id(unsigned long ea) |
---|
| 116 | +{ |
---|
| 117 | + int region_id; |
---|
| 118 | + int id = (ea >> 60UL); |
---|
| 119 | + |
---|
| 120 | + if (id == 0) |
---|
| 121 | + return USER_REGION_ID; |
---|
| 122 | + |
---|
| 123 | + if (id != (PAGE_OFFSET >> 60)) |
---|
| 124 | + return INVALID_REGION_ID; |
---|
| 125 | + |
---|
| 126 | + if (ea < H_KERN_VIRT_START) |
---|
| 127 | + return LINEAR_MAP_REGION_ID; |
---|
| 128 | + |
---|
| 129 | + BUILD_BUG_ON(NON_LINEAR_REGION_ID(H_VMALLOC_START) != 2); |
---|
| 130 | + |
---|
| 131 | + region_id = NON_LINEAR_REGION_ID(ea); |
---|
| 132 | + return region_id; |
---|
| 133 | +} |
---|
| 134 | + |
---|
87 | 135 | #define hash__pmd_bad(pmd) (pmd_val(pmd) & H_PMD_BAD_BITS) |
---|
88 | 136 | #define hash__pud_bad(pud) (pud_val(pud) & H_PUD_BAD_BITS) |
---|
89 | | -static inline int hash__pgd_bad(pgd_t pgd) |
---|
| 137 | +static inline int hash__p4d_bad(p4d_t p4d) |
---|
90 | 138 | { |
---|
91 | | - return (pgd_val(pgd) == 0); |
---|
| 139 | + return (p4d_val(p4d) == 0); |
---|
92 | 140 | } |
---|
93 | 141 | #ifdef CONFIG_STRICT_KERNEL_RWX |
---|
94 | 142 | extern void hash__mark_rodata_ro(void); |
---|
.. | .. |
---|
196 | 244 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
---|
197 | 245 | |
---|
198 | 246 | |
---|
199 | | -extern int hash__map_kernel_page(unsigned long ea, unsigned long pa, |
---|
200 | | - unsigned long flags); |
---|
| 247 | +int hash__map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t prot); |
---|
201 | 248 | extern int __meminit hash__vmemmap_create_mapping(unsigned long start, |
---|
202 | 249 | unsigned long page_size, |
---|
203 | 250 | unsigned long phys); |
---|
204 | 251 | extern void hash__vmemmap_remove_mapping(unsigned long start, |
---|
205 | 252 | unsigned long page_size); |
---|
206 | 253 | |
---|
207 | | -int hash__create_section_mapping(unsigned long start, unsigned long end, int nid); |
---|
| 254 | +int hash__create_section_mapping(unsigned long start, unsigned long end, |
---|
| 255 | + int nid, pgprot_t prot); |
---|
208 | 256 | int hash__remove_section_mapping(unsigned long start, unsigned long end); |
---|
209 | 257 | |
---|
210 | 258 | #endif /* !__ASSEMBLY__ */ |
---|