aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/kernel/head.S')
-rw-r--r--arch/x86_64/kernel/head.S61
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:
260ENTRY(stext) 261ENTRY(stext)
261ENTRY(_stext) 262ENTRY(_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; \
268ENTRY(name) 266ENTRY(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
270NEXT_PAGE(init_level4_pgt) 276NEXT_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
274NEXT_PAGE(level3_ident_pgt) 280NEXT_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
278NEXT_PAGE(level3_kernel_pgt) 284NEXT_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
284NEXT_PAGE(level2_ident_pgt) 290NEXT_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
293NEXT_PAGE(level2_kernel_pgt) 296NEXT_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
305NEXT_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
315ENTRY(wakeup_level4_pgt) 312ENTRY(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
334ENTRY(boot_level4_pgt) 329ENTRY(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