diff options
author | Vivek Goyal <vgoyal@in.ibm.com> | 2007-05-02 13:27:06 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:06 -0400 |
commit | 67dcbb6bc6537aea92a2466bfc75f015b00e465e (patch) | |
tree | 605b494bd00f634c60c84a7eccbbbb65f4156347 /arch | |
parent | dafe41ee3a9389c08c91cdfd8670295f20f89e04 (diff) |
[PATCH] x86-64: Clean up the early boot page table
- Merge physmem_pgt and ident_pgt, removing physmem_pgt. The merge
is broken as soon as mm/init.c:init_memory_mapping is run.
- As physmem_pgt is gone don't export it in pgtable.h.
- Use defines from pgtable.h for page permissions.
- Fix the physical memory identity mapping so it is at the correct
address.
- Remove the physical memory mapping from wakeup_level4_pgt it
is at the wrong address so we can't possibly be usinging it.
- Simply NEXT_PAGE the work to calculate the phys_ alias
of the labels was very cool. Unfortuantely it was a brittle
special purpose hack that makes maitenance more difficult.
Instead just use label - __START_KERNEL_map like we do
everywhere else in assembly.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86_64/kernel/head.S | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S index 118c6088198a..23b45e79a27c 100644 --- a/arch/x86_64/kernel/head.S +++ b/arch/x86_64/kernel/head.S | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <asm/desc.h> | 14 | #include <asm/desc.h> |
15 | #include <asm/segment.h> | 15 | #include <asm/segment.h> |
16 | #include <asm/pgtable.h> | ||
16 | #include <asm/page.h> | 17 | #include <asm/page.h> |
17 | #include <asm/msr.h> | 18 | #include <asm/msr.h> |
18 | #include <asm/cache.h> | 19 | #include <asm/cache.h> |
@@ -260,52 +261,48 @@ ljumpvector: | |||
260 | ENTRY(stext) | 261 | ENTRY(stext) |
261 | ENTRY(_stext) | 262 | ENTRY(_stext) |
262 | 263 | ||
263 | $page = 0 | ||
264 | #define NEXT_PAGE(name) \ | 264 | #define NEXT_PAGE(name) \ |
265 | $page = $page + 1; \ | 265 | .balign PAGE_SIZE; \ |
266 | .org $page * 0x1000; \ | ||
267 | phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \ | ||
268 | ENTRY(name) | 266 | ENTRY(name) |
269 | 267 | ||
268 | /* Automate the creation of 1 to 1 mapping pmd entries */ | ||
269 | #define PMDS(START, PERM, COUNT) \ | ||
270 | i = 0 ; \ | ||
271 | .rept (COUNT) ; \ | ||
272 | .quad (START) + (i << 21) + (PERM) ; \ | ||
273 | i = i + 1 ; \ | ||
274 | .endr | ||
275 | |||
270 | NEXT_PAGE(init_level4_pgt) | 276 | NEXT_PAGE(init_level4_pgt) |
271 | /* This gets initialized in x86_64_start_kernel */ | 277 | /* This gets initialized in x86_64_start_kernel */ |
272 | .fill 512,8,0 | 278 | .fill 512,8,0 |
273 | 279 | ||
274 | NEXT_PAGE(level3_ident_pgt) | 280 | NEXT_PAGE(level3_ident_pgt) |
275 | .quad phys_level2_ident_pgt | 0x007 | 281 | .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE |
276 | .fill 511,8,0 | 282 | .fill 511,8,0 |
277 | 283 | ||
278 | NEXT_PAGE(level3_kernel_pgt) | 284 | NEXT_PAGE(level3_kernel_pgt) |
279 | .fill 510,8,0 | 285 | .fill 510,8,0 |
280 | /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ | 286 | /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ |
281 | .quad phys_level2_kernel_pgt | 0x007 | 287 | .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE |
282 | .fill 1,8,0 | 288 | .fill 1,8,0 |
283 | 289 | ||
284 | NEXT_PAGE(level2_ident_pgt) | 290 | NEXT_PAGE(level2_ident_pgt) |
285 | /* 40MB for bootup. */ | 291 | /* Since I easily can, map the first 1G. |
286 | i = 0 | 292 | * Don't set NX because code runs from these pages. |
287 | .rept 20 | 293 | */ |
288 | .quad i << 21 | 0x083 | 294 | PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD) |
289 | i = i + 1 | ||
290 | .endr | ||
291 | .fill 492,8,0 | ||
292 | 295 | ||
293 | NEXT_PAGE(level2_kernel_pgt) | 296 | NEXT_PAGE(level2_kernel_pgt) |
294 | /* 40MB kernel mapping. The kernel code cannot be bigger than that. | 297 | /* 40MB kernel mapping. The kernel code cannot be bigger than that. |
295 | When you change this change KERNEL_TEXT_SIZE in page.h too. */ | 298 | When you change this change KERNEL_TEXT_SIZE in page.h too. */ |
296 | /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ | 299 | /* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ |
297 | i = 0 | 300 | PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL, |
298 | .rept 20 | 301 | KERNEL_TEXT_SIZE/PMD_SIZE) |
299 | .quad i << 21 | 0x183 | ||
300 | i = i + 1 | ||
301 | .endr | ||
302 | /* Module mapping starts here */ | 302 | /* Module mapping starts here */ |
303 | .fill 492,8,0 | 303 | .fill (PTRS_PER_PMD - (KERNEL_TEXT_SIZE/PMD_SIZE)),8,0 |
304 | |||
305 | NEXT_PAGE(level3_physmem_pgt) | ||
306 | .quad phys_level2_kernel_pgt | 0x007 /* so that __va works even before pagetable_init */ | ||
307 | .fill 511,8,0 | ||
308 | 304 | ||
305 | #undef PMDS | ||
309 | #undef NEXT_PAGE | 306 | #undef NEXT_PAGE |
310 | 307 | ||
311 | .data | 308 | .data |
@@ -313,12 +310,10 @@ NEXT_PAGE(level3_physmem_pgt) | |||
313 | #ifdef CONFIG_ACPI_SLEEP | 310 | #ifdef CONFIG_ACPI_SLEEP |
314 | .align PAGE_SIZE | 311 | .align PAGE_SIZE |
315 | ENTRY(wakeup_level4_pgt) | 312 | ENTRY(wakeup_level4_pgt) |
316 | .quad phys_level3_ident_pgt | 0x007 | 313 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE |
317 | .fill 255,8,0 | 314 | .fill 510,8,0 |
318 | .quad phys_level3_physmem_pgt | 0x007 | ||
319 | .fill 254,8,0 | ||
320 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ | 315 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ |
321 | .quad phys_level3_kernel_pgt | 0x007 | 316 | .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE |
322 | #endif | 317 | #endif |
323 | 318 | ||
324 | #ifndef CONFIG_HOTPLUG_CPU | 319 | #ifndef CONFIG_HOTPLUG_CPU |
@@ -332,12 +327,12 @@ ENTRY(wakeup_level4_pgt) | |||
332 | */ | 327 | */ |
333 | .align PAGE_SIZE | 328 | .align PAGE_SIZE |
334 | ENTRY(boot_level4_pgt) | 329 | ENTRY(boot_level4_pgt) |
335 | .quad phys_level3_ident_pgt | 0x007 | 330 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE |
336 | .fill 255,8,0 | 331 | .fill 257,8,0 |
337 | .quad phys_level3_physmem_pgt | 0x007 | 332 | .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE |
338 | .fill 254,8,0 | 333 | .fill 252,8,0 |
339 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ | 334 | /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ |
340 | .quad phys_level3_kernel_pgt | 0x007 | 335 | .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE |
341 | 336 | ||
342 | .data | 337 | .data |
343 | 338 | ||