diff options
author | Catalin Marinas <catalin.marinas@arm.com> | 2011-08-23 09:07:23 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-08-23 10:30:33 -0400 |
commit | e73fc88e19d74fd4dd664cff45b88caab8cde45c (patch) | |
tree | 2f018afe68b417d43c9f6defc946f94915a4d6a0 /arch/arm | |
parent | 01f461a3a4321a9f98b6b508f32d2396c5704b7c (diff) |
ARM: 7059/1: LPAE: Use PMD_(SHIFT|SIZE|MASK) instead of PGDIR_*
PGDIR_SHIFT and PMD_SHIFT for the classic 2-level page table format have
the same value (21). This patch converts the PGDIR_* uses in the kernel
to the PMD_* equivalent so that LPAE builds can reuse the same code.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/kernel/head.S | 74 | ||||
-rw-r--r-- | arch/arm/kernel/module.c | 2 | ||||
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 6 | ||||
-rw-r--r-- | arch/arm/mm/mmu.c | 14 |
4 files changed, 51 insertions, 45 deletions
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 742b6108a001..4598c9699d30 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/memory.h> | 21 | #include <asm/memory.h> |
22 | #include <asm/thread_info.h> | 22 | #include <asm/thread_info.h> |
23 | #include <asm/system.h> | 23 | #include <asm/system.h> |
24 | #include <asm/pgtable.h> | ||
24 | 25 | ||
25 | #ifdef CONFIG_DEBUG_LL | 26 | #ifdef CONFIG_DEBUG_LL |
26 | #include <mach/debug-macro.S> | 27 | #include <mach/debug-macro.S> |
@@ -38,11 +39,14 @@ | |||
38 | #error KERNEL_RAM_VADDR must start at 0xXXXX8000 | 39 | #error KERNEL_RAM_VADDR must start at 0xXXXX8000 |
39 | #endif | 40 | #endif |
40 | 41 | ||
42 | #define PG_DIR_SIZE 0x4000 | ||
43 | #define PMD_ORDER 2 | ||
44 | |||
41 | .globl swapper_pg_dir | 45 | .globl swapper_pg_dir |
42 | .equ swapper_pg_dir, KERNEL_RAM_VADDR - 0x4000 | 46 | .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE |
43 | 47 | ||
44 | .macro pgtbl, rd, phys | 48 | .macro pgtbl, rd, phys |
45 | add \rd, \phys, #TEXT_OFFSET - 0x4000 | 49 | add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE |
46 | .endm | 50 | .endm |
47 | 51 | ||
48 | #ifdef CONFIG_XIP_KERNEL | 52 | #ifdef CONFIG_XIP_KERNEL |
@@ -148,11 +152,11 @@ __create_page_tables: | |||
148 | pgtbl r4, r8 @ page table address | 152 | pgtbl r4, r8 @ page table address |
149 | 153 | ||
150 | /* | 154 | /* |
151 | * Clear the 16K level 1 swapper page table | 155 | * Clear the swapper page table |
152 | */ | 156 | */ |
153 | mov r0, r4 | 157 | mov r0, r4 |
154 | mov r3, #0 | 158 | mov r3, #0 |
155 | add r6, r0, #0x4000 | 159 | add r6, r0, #PG_DIR_SIZE |
156 | 1: str r3, [r0], #4 | 160 | 1: str r3, [r0], #4 |
157 | str r3, [r0], #4 | 161 | str r3, [r0], #4 |
158 | str r3, [r0], #4 | 162 | str r3, [r0], #4 |
@@ -171,30 +175,30 @@ __create_page_tables: | |||
171 | sub r0, r0, r3 @ virt->phys offset | 175 | sub r0, r0, r3 @ virt->phys offset |
172 | add r5, r5, r0 @ phys __enable_mmu | 176 | add r5, r5, r0 @ phys __enable_mmu |
173 | add r6, r6, r0 @ phys __enable_mmu_end | 177 | add r6, r6, r0 @ phys __enable_mmu_end |
174 | mov r5, r5, lsr #20 | 178 | mov r5, r5, lsr #SECTION_SHIFT |
175 | mov r6, r6, lsr #20 | 179 | mov r6, r6, lsr #SECTION_SHIFT |
176 | 180 | ||
177 | 1: orr r3, r7, r5, lsl #20 @ flags + kernel base | 181 | 1: orr r3, r7, r5, lsl #SECTION_SHIFT @ flags + kernel base |
178 | str r3, [r4, r5, lsl #2] @ identity mapping | 182 | str r3, [r4, r5, lsl #PMD_ORDER] @ identity mapping |
179 | teq r5, r6 | 183 | cmp r5, r6 |
180 | addne r5, r5, #1 @ next section | 184 | addlo r5, r5, #1 @ next section |
181 | bne 1b | 185 | blo 1b |
182 | 186 | ||
183 | /* | 187 | /* |
184 | * Now setup the pagetables for our kernel direct | 188 | * Now setup the pagetables for our kernel direct |
185 | * mapped region. | 189 | * mapped region. |
186 | */ | 190 | */ |
187 | mov r3, pc | 191 | mov r3, pc |
188 | mov r3, r3, lsr #20 | 192 | mov r3, r3, lsr #SECTION_SHIFT |
189 | orr r3, r7, r3, lsl #20 | 193 | orr r3, r7, r3, lsl #SECTION_SHIFT |
190 | add r0, r4, #(KERNEL_START & 0xff000000) >> 18 | 194 | add r0, r4, #(KERNEL_START & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER) |
191 | str r3, [r0, #(KERNEL_START & 0x00f00000) >> 18]! | 195 | str r3, [r0, #((KERNEL_START & 0x00f00000) >> SECTION_SHIFT) << PMD_ORDER]! |
192 | ldr r6, =(KERNEL_END - 1) | 196 | ldr r6, =(KERNEL_END - 1) |
193 | add r0, r0, #4 | 197 | add r0, r0, #1 << PMD_ORDER |
194 | add r6, r4, r6, lsr #18 | 198 | add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) |
195 | 1: cmp r0, r6 | 199 | 1: cmp r0, r6 |
196 | add r3, r3, #1 << 20 | 200 | add r3, r3, #1 << SECTION_SHIFT |
197 | strls r3, [r0], #4 | 201 | strls r3, [r0], #1 << PMD_ORDER |
198 | bls 1b | 202 | bls 1b |
199 | 203 | ||
200 | #ifdef CONFIG_XIP_KERNEL | 204 | #ifdef CONFIG_XIP_KERNEL |
@@ -203,11 +207,11 @@ __create_page_tables: | |||
203 | */ | 207 | */ |
204 | add r3, r8, #TEXT_OFFSET | 208 | add r3, r8, #TEXT_OFFSET |
205 | orr r3, r3, r7 | 209 | orr r3, r3, r7 |
206 | add r0, r4, #(KERNEL_RAM_VADDR & 0xff000000) >> 18 | 210 | add r0, r4, #(KERNEL_RAM_VADDR & 0xff000000) >> (SECTION_SHIFT - PMD_ORDER) |
207 | str r3, [r0, #(KERNEL_RAM_VADDR & 0x00f00000) >> 18]! | 211 | str r3, [r0, #(KERNEL_RAM_VADDR & 0x00f00000) >> (SECTION_SHIFT - PMD_ORDER)]! |
208 | ldr r6, =(_end - 1) | 212 | ldr r6, =(_end - 1) |
209 | add r0, r0, #4 | 213 | add r0, r0, #4 |
210 | add r6, r4, r6, lsr #18 | 214 | add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) |
211 | 1: cmp r0, r6 | 215 | 1: cmp r0, r6 |
212 | add r3, r3, #1 << 20 | 216 | add r3, r3, #1 << 20 |
213 | strls r3, [r0], #4 | 217 | strls r3, [r0], #4 |
@@ -218,12 +222,12 @@ __create_page_tables: | |||
218 | * Then map boot params address in r2 or | 222 | * Then map boot params address in r2 or |
219 | * the first 1MB of ram if boot params address is not specified. | 223 | * the first 1MB of ram if boot params address is not specified. |
220 | */ | 224 | */ |
221 | mov r0, r2, lsr #20 | 225 | mov r0, r2, lsr #SECTION_SHIFT |
222 | movs r0, r0, lsl #20 | 226 | movs r0, r0, lsl #SECTION_SHIFT |
223 | moveq r0, r8 | 227 | moveq r0, r8 |
224 | sub r3, r0, r8 | 228 | sub r3, r0, r8 |
225 | add r3, r3, #PAGE_OFFSET | 229 | add r3, r3, #PAGE_OFFSET |
226 | add r3, r4, r3, lsr #18 | 230 | add r3, r4, r3, lsr #(SECTION_SHIFT - PMD_ORDER) |
227 | orr r6, r7, r0 | 231 | orr r6, r7, r0 |
228 | str r6, [r3] | 232 | str r6, [r3] |
229 | 233 | ||
@@ -236,21 +240,21 @@ __create_page_tables: | |||
236 | */ | 240 | */ |
237 | addruart r7, r3 | 241 | addruart r7, r3 |
238 | 242 | ||
239 | mov r3, r3, lsr #20 | 243 | mov r3, r3, lsr #SECTION_SHIFT |
240 | mov r3, r3, lsl #2 | 244 | mov r3, r3, lsl #PMD_ORDER |
241 | 245 | ||
242 | add r0, r4, r3 | 246 | add r0, r4, r3 |
243 | rsb r3, r3, #0x4000 @ PTRS_PER_PGD*sizeof(long) | 247 | rsb r3, r3, #0x4000 @ PTRS_PER_PGD*sizeof(long) |
244 | cmp r3, #0x0800 @ limit to 512MB | 248 | cmp r3, #0x0800 @ limit to 512MB |
245 | movhi r3, #0x0800 | 249 | movhi r3, #0x0800 |
246 | add r6, r0, r3 | 250 | add r6, r0, r3 |
247 | mov r3, r7, lsr #20 | 251 | mov r3, r7, lsr #SECTION_SHIFT |
248 | ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags | 252 | ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags |
249 | orr r3, r7, r3, lsl #20 | 253 | orr r3, r7, r3, lsl #SECTION_SHIFT |
250 | 1: str r3, [r0], #4 | 254 | 1: str r3, [r0], #4 |
251 | add r3, r3, #1 << 20 | 255 | add r3, r3, #1 << SECTION_SHIFT |
252 | teq r0, r6 | 256 | cmp r0, r6 |
253 | bne 1b | 257 | blo 1b |
254 | 258 | ||
255 | #else /* CONFIG_DEBUG_ICEDCC */ | 259 | #else /* CONFIG_DEBUG_ICEDCC */ |
256 | /* we don't need any serial debugging mappings for ICEDCC */ | 260 | /* we don't need any serial debugging mappings for ICEDCC */ |
@@ -262,7 +266,7 @@ __create_page_tables: | |||
262 | * If we're using the NetWinder or CATS, we also need to map | 266 | * If we're using the NetWinder or CATS, we also need to map |
263 | * in the 16550-type serial port for the debug messages | 267 | * in the 16550-type serial port for the debug messages |
264 | */ | 268 | */ |
265 | add r0, r4, #0xff000000 >> 18 | 269 | add r0, r4, #0xff000000 >> (SECTION_SHIFT - PMD_ORDER) |
266 | orr r3, r7, #0x7c000000 | 270 | orr r3, r7, #0x7c000000 |
267 | str r3, [r0] | 271 | str r3, [r0] |
268 | #endif | 272 | #endif |
@@ -272,10 +276,10 @@ __create_page_tables: | |||
272 | * Similar reasons here - for debug. This is | 276 | * Similar reasons here - for debug. This is |
273 | * only for Acorn RiscPC architectures. | 277 | * only for Acorn RiscPC architectures. |
274 | */ | 278 | */ |
275 | add r0, r4, #0x02000000 >> 18 | 279 | add r0, r4, #0x02000000 >> (SECTION_SHIFT - PMD_ORDER) |
276 | orr r3, r7, #0x02000000 | 280 | orr r3, r7, #0x02000000 |
277 | str r3, [r0] | 281 | str r3, [r0] |
278 | add r0, r4, #0xd8000000 >> 18 | 282 | add r0, r4, #0xd8000000 >> (SECTION_SHIFT - PMD_ORDER) |
279 | str r3, [r0] | 283 | str r3, [r0] |
280 | #endif | 284 | #endif |
281 | #endif | 285 | #endif |
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index cc2020c2c709..1e9be5d25e56 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c | |||
@@ -33,7 +33,7 @@ | |||
33 | * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned on/off. | 33 | * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned on/off. |
34 | */ | 34 | */ |
35 | #undef MODULES_VADDR | 35 | #undef MODULES_VADDR |
36 | #define MODULES_VADDR (((unsigned long)_etext + ~PGDIR_MASK) & PGDIR_MASK) | 36 | #define MODULES_VADDR (((unsigned long)_etext + ~PMD_MASK) & PMD_MASK) |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #ifdef CONFIG_MMU | 39 | #ifdef CONFIG_MMU |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 0a0a1e7c20d2..4f01bfd6899a 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -123,8 +123,8 @@ static void __dma_free_buffer(struct page *page, size_t size) | |||
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | #define CONSISTENT_OFFSET(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) | 125 | #define CONSISTENT_OFFSET(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT) |
126 | #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT) | 126 | #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PMD_SHIFT) |
127 | #define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT) | 127 | #define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PMD_SHIFT) |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * These are the page tables (2MB each) covering uncached, DMA consistent allocations | 130 | * These are the page tables (2MB each) covering uncached, DMA consistent allocations |
@@ -183,7 +183,7 @@ static int __init consistent_init(void) | |||
183 | } | 183 | } |
184 | 184 | ||
185 | consistent_pte[i++] = pte; | 185 | consistent_pte[i++] = pte; |
186 | base += (1 << PGDIR_SHIFT); | 186 | base += PMD_SIZE; |
187 | } while (base < CONSISTENT_END); | 187 | } while (base < CONSISTENT_END); |
188 | 188 | ||
189 | return ret; | 189 | return ret; |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 594d677b92c8..36e983d98315 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
@@ -863,14 +863,14 @@ static inline void prepare_page_table(void) | |||
863 | /* | 863 | /* |
864 | * Clear out all the mappings below the kernel image. | 864 | * Clear out all the mappings below the kernel image. |
865 | */ | 865 | */ |
866 | for (addr = 0; addr < MODULES_VADDR; addr += PGDIR_SIZE) | 866 | for (addr = 0; addr < MODULES_VADDR; addr += PMD_SIZE) |
867 | pmd_clear(pmd_off_k(addr)); | 867 | pmd_clear(pmd_off_k(addr)); |
868 | 868 | ||
869 | #ifdef CONFIG_XIP_KERNEL | 869 | #ifdef CONFIG_XIP_KERNEL |
870 | /* The XIP kernel is mapped in the module area -- skip over it */ | 870 | /* The XIP kernel is mapped in the module area -- skip over it */ |
871 | addr = ((unsigned long)_etext + PGDIR_SIZE - 1) & PGDIR_MASK; | 871 | addr = ((unsigned long)_etext + PMD_SIZE - 1) & PMD_MASK; |
872 | #endif | 872 | #endif |
873 | for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE) | 873 | for ( ; addr < PAGE_OFFSET; addr += PMD_SIZE) |
874 | pmd_clear(pmd_off_k(addr)); | 874 | pmd_clear(pmd_off_k(addr)); |
875 | 875 | ||
876 | /* | 876 | /* |
@@ -885,10 +885,12 @@ static inline void prepare_page_table(void) | |||
885 | * memory bank, up to the end of the vmalloc region. | 885 | * memory bank, up to the end of the vmalloc region. |
886 | */ | 886 | */ |
887 | for (addr = __phys_to_virt(end); | 887 | for (addr = __phys_to_virt(end); |
888 | addr < VMALLOC_END; addr += PGDIR_SIZE) | 888 | addr < VMALLOC_END; addr += PMD_SIZE) |
889 | pmd_clear(pmd_off_k(addr)); | 889 | pmd_clear(pmd_off_k(addr)); |
890 | } | 890 | } |
891 | 891 | ||
892 | #define SWAPPER_PG_DIR_SIZE (PTRS_PER_PGD * sizeof(pgd_t)) | ||
893 | |||
892 | /* | 894 | /* |
893 | * Reserve the special regions of memory | 895 | * Reserve the special regions of memory |
894 | */ | 896 | */ |
@@ -898,7 +900,7 @@ void __init arm_mm_memblock_reserve(void) | |||
898 | * Reserve the page tables. These are already in use, | 900 | * Reserve the page tables. These are already in use, |
899 | * and can only be in node 0. | 901 | * and can only be in node 0. |
900 | */ | 902 | */ |
901 | memblock_reserve(__pa(swapper_pg_dir), PTRS_PER_PGD * sizeof(pgd_t)); | 903 | memblock_reserve(__pa(swapper_pg_dir), SWAPPER_PG_DIR_SIZE); |
902 | 904 | ||
903 | #ifdef CONFIG_SA1111 | 905 | #ifdef CONFIG_SA1111 |
904 | /* | 906 | /* |
@@ -926,7 +928,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc) | |||
926 | */ | 928 | */ |
927 | vectors_page = early_alloc(PAGE_SIZE); | 929 | vectors_page = early_alloc(PAGE_SIZE); |
928 | 930 | ||
929 | for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE) | 931 | for (addr = VMALLOC_END; addr; addr += PMD_SIZE) |
930 | pmd_clear(pmd_off_k(addr)); | 932 | pmd_clear(pmd_off_k(addr)); |
931 | 933 | ||
932 | /* | 934 | /* |