1250c2277SThomas Gleixner/* 2250c2277SThomas Gleixner * linux/arch/x86_64/kernel/head.S -- start in 32bit and switch to 64bit 3250c2277SThomas Gleixner * 4250c2277SThomas Gleixner * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE 5250c2277SThomas Gleixner * Copyright (C) 2000 Pavel Machek <pavel@suse.cz> 6250c2277SThomas Gleixner * Copyright (C) 2000 Karsten Keil <kkeil@suse.de> 7250c2277SThomas Gleixner * Copyright (C) 2001,2002 Andi Kleen <ak@suse.de> 8250c2277SThomas Gleixner * Copyright (C) 2005 Eric Biederman <ebiederm@xmission.com> 9250c2277SThomas Gleixner */ 10250c2277SThomas Gleixner 11250c2277SThomas Gleixner 12250c2277SThomas Gleixner#include <linux/linkage.h> 13250c2277SThomas Gleixner#include <linux/threads.h> 14250c2277SThomas Gleixner#include <linux/init.h> 15250c2277SThomas Gleixner#include <asm/desc.h> 16250c2277SThomas Gleixner#include <asm/segment.h> 17250c2277SThomas Gleixner#include <asm/pgtable.h> 18250c2277SThomas Gleixner#include <asm/page.h> 19250c2277SThomas Gleixner#include <asm/msr.h> 20250c2277SThomas Gleixner#include <asm/cache.h> 21369101daSCyrill Gorcunov#include <asm/processor-flags.h> 22250c2277SThomas Gleixner 2349a69787SGlauber de Oliveira Costa#ifdef CONFIG_PARAVIRT 2449a69787SGlauber de Oliveira Costa#include <asm/asm-offsets.h> 2549a69787SGlauber de Oliveira Costa#include <asm/paravirt.h> 2649a69787SGlauber de Oliveira Costa#else 2749a69787SGlauber de Oliveira Costa#define GET_CR2_INTO_RCX movq %cr2, %rcx 2849a69787SGlauber de Oliveira Costa#endif 2949a69787SGlauber de Oliveira Costa 30250c2277SThomas Gleixner/* we are not able to switch in one step to the final KERNEL ADRESS SPACE 31250c2277SThomas Gleixner * because we need identity-mapped pages. 32250c2277SThomas Gleixner * 33250c2277SThomas Gleixner */ 34250c2277SThomas Gleixner 35a6523748SEduardo Habkost#define pud_index(x) (((x) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) 36a6523748SEduardo Habkost 37a6523748SEduardo HabkostL4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET) 38a6523748SEduardo HabkostL3_PAGE_OFFSET = pud_index(__PAGE_OFFSET) 39a6523748SEduardo HabkostL4_START_KERNEL = pgd_index(__START_KERNEL_map) 40a6523748SEduardo HabkostL3_START_KERNEL = pud_index(__START_KERNEL_map) 41a6523748SEduardo Habkost 42250c2277SThomas Gleixner .text 43250c2277SThomas Gleixner .section .text.head 44250c2277SThomas Gleixner .code64 45250c2277SThomas Gleixner .globl startup_64 46250c2277SThomas Gleixnerstartup_64: 47250c2277SThomas Gleixner 48250c2277SThomas Gleixner /* 49250c2277SThomas Gleixner * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 1, 50250c2277SThomas Gleixner * and someone has loaded an identity mapped page table 51250c2277SThomas Gleixner * for us. These identity mapped page tables map all of the 52250c2277SThomas Gleixner * kernel pages and possibly all of memory. 53250c2277SThomas Gleixner * 54250c2277SThomas Gleixner * %esi holds a physical pointer to real_mode_data. 55250c2277SThomas Gleixner * 56250c2277SThomas Gleixner * We come here either directly from a 64bit bootloader, or from 57250c2277SThomas Gleixner * arch/x86_64/boot/compressed/head.S. 58250c2277SThomas Gleixner * 59250c2277SThomas Gleixner * We only come here initially at boot nothing else comes here. 60250c2277SThomas Gleixner * 61250c2277SThomas Gleixner * Since we may be loaded at an address different from what we were 62250c2277SThomas Gleixner * compiled to run at we first fixup the physical addresses in our page 63250c2277SThomas Gleixner * tables and then reload them. 64250c2277SThomas Gleixner */ 65250c2277SThomas Gleixner 66250c2277SThomas Gleixner /* Compute the delta between the address I am compiled to run at and the 67250c2277SThomas Gleixner * address I am actually running at. 68250c2277SThomas Gleixner */ 69250c2277SThomas Gleixner leaq _text(%rip), %rbp 70250c2277SThomas Gleixner subq $_text - __START_KERNEL_map, %rbp 71250c2277SThomas Gleixner 72250c2277SThomas Gleixner /* Is the address not 2M aligned? */ 73250c2277SThomas Gleixner movq %rbp, %rax 7431422c51SAndi Kleen andl $~PMD_PAGE_MASK, %eax 75250c2277SThomas Gleixner testl %eax, %eax 76250c2277SThomas Gleixner jnz bad_address 77250c2277SThomas Gleixner 78250c2277SThomas Gleixner /* Is the address too large? */ 79250c2277SThomas Gleixner leaq _text(%rip), %rdx 80250c2277SThomas Gleixner movq $PGDIR_SIZE, %rax 81250c2277SThomas Gleixner cmpq %rax, %rdx 82250c2277SThomas Gleixner jae bad_address 83250c2277SThomas Gleixner 84250c2277SThomas Gleixner /* Fixup the physical addresses in the page table 85250c2277SThomas Gleixner */ 86250c2277SThomas Gleixner addq %rbp, init_level4_pgt + 0(%rip) 87a6523748SEduardo Habkost addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip) 88a6523748SEduardo Habkost addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip) 89250c2277SThomas Gleixner 90250c2277SThomas Gleixner addq %rbp, level3_ident_pgt + 0(%rip) 91250c2277SThomas Gleixner 92250c2277SThomas Gleixner addq %rbp, level3_kernel_pgt + (510*8)(%rip) 93250c2277SThomas Gleixner addq %rbp, level3_kernel_pgt + (511*8)(%rip) 94250c2277SThomas Gleixner 95250c2277SThomas Gleixner addq %rbp, level2_fixmap_pgt + (506*8)(%rip) 96250c2277SThomas Gleixner 97250c2277SThomas Gleixner /* Add an Identity mapping if I am above 1G */ 98250c2277SThomas Gleixner leaq _text(%rip), %rdi 9931422c51SAndi Kleen andq $PMD_PAGE_MASK, %rdi 100250c2277SThomas Gleixner 101250c2277SThomas Gleixner movq %rdi, %rax 102250c2277SThomas Gleixner shrq $PUD_SHIFT, %rax 103250c2277SThomas Gleixner andq $(PTRS_PER_PUD - 1), %rax 104250c2277SThomas Gleixner jz ident_complete 105250c2277SThomas Gleixner 106250c2277SThomas Gleixner leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx 107250c2277SThomas Gleixner leaq level3_ident_pgt(%rip), %rbx 108250c2277SThomas Gleixner movq %rdx, 0(%rbx, %rax, 8) 109250c2277SThomas Gleixner 110250c2277SThomas Gleixner movq %rdi, %rax 111250c2277SThomas Gleixner shrq $PMD_SHIFT, %rax 112250c2277SThomas Gleixner andq $(PTRS_PER_PMD - 1), %rax 113b2bc2731SSuresh Siddha leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx 114250c2277SThomas Gleixner leaq level2_spare_pgt(%rip), %rbx 115250c2277SThomas Gleixner movq %rdx, 0(%rbx, %rax, 8) 116250c2277SThomas Gleixnerident_complete: 117250c2277SThomas Gleixner 11831eedd82SThomas Gleixner /* 11931eedd82SThomas Gleixner * Fixup the kernel text+data virtual addresses. Note that 12031eedd82SThomas Gleixner * we might write invalid pmds, when the kernel is relocated 12131eedd82SThomas Gleixner * cleanup_highmap() fixes this up along with the mappings 12231eedd82SThomas Gleixner * beyond _end. 123250c2277SThomas Gleixner */ 12431eedd82SThomas Gleixner 125250c2277SThomas Gleixner leaq level2_kernel_pgt(%rip), %rdi 126250c2277SThomas Gleixner leaq 4096(%rdi), %r8 127250c2277SThomas Gleixner /* See if it is a valid page table entry */ 128250c2277SThomas Gleixner1: testq $1, 0(%rdi) 129250c2277SThomas Gleixner jz 2f 130250c2277SThomas Gleixner addq %rbp, 0(%rdi) 131250c2277SThomas Gleixner /* Go to the next page */ 132250c2277SThomas Gleixner2: addq $8, %rdi 133250c2277SThomas Gleixner cmp %r8, %rdi 134250c2277SThomas Gleixner jne 1b 135250c2277SThomas Gleixner 136250c2277SThomas Gleixner /* Fixup phys_base */ 137250c2277SThomas Gleixner addq %rbp, phys_base(%rip) 138250c2277SThomas Gleixner 13964e83b5aSRafael J. Wysocki#ifdef CONFIG_X86_TRAMPOLINE 140250c2277SThomas Gleixner addq %rbp, trampoline_level4_pgt + 0(%rip) 141250c2277SThomas Gleixner addq %rbp, trampoline_level4_pgt + (511*8)(%rip) 142250c2277SThomas Gleixner#endif 143250c2277SThomas Gleixner 144250c2277SThomas Gleixner /* Due to ENTRY(), sometimes the empty space gets filled with 145250c2277SThomas Gleixner * zeros. Better take a jmp than relying on empty space being 146250c2277SThomas Gleixner * filled with 0x90 (nop) 147250c2277SThomas Gleixner */ 148250c2277SThomas Gleixner jmp secondary_startup_64 149250c2277SThomas GleixnerENTRY(secondary_startup_64) 150250c2277SThomas Gleixner /* 151250c2277SThomas Gleixner * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 1, 152250c2277SThomas Gleixner * and someone has loaded a mapped page table. 153250c2277SThomas Gleixner * 154250c2277SThomas Gleixner * %esi holds a physical pointer to real_mode_data. 155250c2277SThomas Gleixner * 156250c2277SThomas Gleixner * We come here either from startup_64 (using physical addresses) 157250c2277SThomas Gleixner * or from trampoline.S (using virtual addresses). 158250c2277SThomas Gleixner * 159250c2277SThomas Gleixner * Using virtual addresses from trampoline.S removes the need 160250c2277SThomas Gleixner * to have any identity mapped pages in the kernel page table 161250c2277SThomas Gleixner * after the boot processor executes this code. 162250c2277SThomas Gleixner */ 163250c2277SThomas Gleixner 164250c2277SThomas Gleixner /* Enable PAE mode and PGE */ 16505139d8fSCyrill Gorcunov movl $(X86_CR4_PAE | X86_CR4_PGE), %eax 166250c2277SThomas Gleixner movq %rax, %cr4 167250c2277SThomas Gleixner 168250c2277SThomas Gleixner /* Setup early boot stage 4 level pagetables. */ 169250c2277SThomas Gleixner movq $(init_level4_pgt - __START_KERNEL_map), %rax 170250c2277SThomas Gleixner addq phys_base(%rip), %rax 171250c2277SThomas Gleixner movq %rax, %cr3 172250c2277SThomas Gleixner 173250c2277SThomas Gleixner /* Ensure I am executing from virtual addresses */ 174250c2277SThomas Gleixner movq $1f, %rax 175250c2277SThomas Gleixner jmp *%rax 176250c2277SThomas Gleixner1: 177250c2277SThomas Gleixner 178250c2277SThomas Gleixner /* Check if nx is implemented */ 179250c2277SThomas Gleixner movl $0x80000001, %eax 180250c2277SThomas Gleixner cpuid 181250c2277SThomas Gleixner movl %edx,%edi 182250c2277SThomas Gleixner 183250c2277SThomas Gleixner /* Setup EFER (Extended Feature Enable Register) */ 184250c2277SThomas Gleixner movl $MSR_EFER, %ecx 185250c2277SThomas Gleixner rdmsr 186250c2277SThomas Gleixner btsl $_EFER_SCE, %eax /* Enable System Call */ 187250c2277SThomas Gleixner btl $20,%edi /* No Execute supported? */ 188250c2277SThomas Gleixner jnc 1f 189250c2277SThomas Gleixner btsl $_EFER_NX, %eax 190250c2277SThomas Gleixner1: wrmsr /* Make changes effective */ 191250c2277SThomas Gleixner 192250c2277SThomas Gleixner /* Setup cr0 */ 193369101daSCyrill Gorcunov#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \ 194369101daSCyrill Gorcunov X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \ 195369101daSCyrill Gorcunov X86_CR0_PG) 196369101daSCyrill Gorcunov movl $CR0_STATE, %eax 197250c2277SThomas Gleixner /* Make changes effective */ 198250c2277SThomas Gleixner movq %rax, %cr0 199250c2277SThomas Gleixner 200250c2277SThomas Gleixner /* Setup a boot time stack */ 2019cf4f298SGlauber Costa movq stack_start(%rip),%rsp 202250c2277SThomas Gleixner 203250c2277SThomas Gleixner /* zero EFLAGS after setting rsp */ 204250c2277SThomas Gleixner pushq $0 205250c2277SThomas Gleixner popfq 206250c2277SThomas Gleixner 2073e5d8f97STejun Heo#ifdef CONFIG_SMP 2083e5d8f97STejun Heo /* 2093e5d8f97STejun Heo * early_gdt_base should point to the gdt_page in static percpu init 2103e5d8f97STejun Heo * data area. Computing this requires two symbols - __per_cpu_load 2113e5d8f97STejun Heo * and per_cpu__gdt_page. As linker can't do no such relocation, do 2123e5d8f97STejun Heo * it by hand. As early_gdt_descr is manipulated by C code for 2133e5d8f97STejun Heo * secondary CPUs, this should be done only once for the boot CPU 2143e5d8f97STejun Heo * when early_gdt_descr_base contains zero. 2153e5d8f97STejun Heo */ 2163e5d8f97STejun Heo movq early_gdt_descr_base(%rip), %rax 2173e5d8f97STejun Heo testq %rax, %rax 2183e5d8f97STejun Heo jnz 1f 2193e5d8f97STejun Heo movq $__per_cpu_load, %rax 2203e5d8f97STejun Heo addq $per_cpu__gdt_page, %rax 2213e5d8f97STejun Heo movq %rax, early_gdt_descr_base(%rip) 2223e5d8f97STejun Heo1: 2233e5d8f97STejun Heo#endif 224250c2277SThomas Gleixner /* 225250c2277SThomas Gleixner * We must switch to a new descriptor in kernel space for the GDT 226250c2277SThomas Gleixner * because soon the kernel won't have access anymore to the userspace 227250c2277SThomas Gleixner * addresses where we're currently running on. We have to do that here 228250c2277SThomas Gleixner * because in 32bit we couldn't load a 64bit linear address. 229250c2277SThomas Gleixner */ 230a939098aSGlauber Costa lgdt early_gdt_descr(%rip) 231250c2277SThomas Gleixner 232250c2277SThomas Gleixner /* set up data segments. actually 0 would do too */ 233250c2277SThomas Gleixner movl $__KERNEL_DS,%eax 234250c2277SThomas Gleixner movl %eax,%ds 235250c2277SThomas Gleixner movl %eax,%ss 236250c2277SThomas Gleixner movl %eax,%es 237250c2277SThomas Gleixner 238250c2277SThomas Gleixner /* 239250c2277SThomas Gleixner * We don't really need to load %fs or %gs, but load them anyway 240250c2277SThomas Gleixner * to kill any stale realmode selectors. This allows execution 241250c2277SThomas Gleixner * under VT hardware. 242250c2277SThomas Gleixner */ 243250c2277SThomas Gleixner movl %eax,%fs 244250c2277SThomas Gleixner movl %eax,%gs 245250c2277SThomas Gleixner 246f32ff538STejun Heo /* Set up %gs. 247f32ff538STejun Heo * 248f32ff538STejun Heo * %gs should point to the pda. For initial boot, make %gs point 249f32ff538STejun Heo * to the _boot_cpu_pda in data section. For a secondary CPU, 250f32ff538STejun Heo * initial_gs should be set to its pda address before the CPU runs 251f32ff538STejun Heo * this code. 252250c2277SThomas Gleixner */ 253250c2277SThomas Gleixner movl $MSR_GS_BASE,%ecx 254f32ff538STejun Heo movq initial_gs(%rip),%rax 255250c2277SThomas Gleixner movq %rax,%rdx 256250c2277SThomas Gleixner shrq $32,%rdx 257250c2277SThomas Gleixner wrmsr 258250c2277SThomas Gleixner 259250c2277SThomas Gleixner /* esi is pointer to real mode structure with interesting info. 260250c2277SThomas Gleixner pass it to C */ 261250c2277SThomas Gleixner movl %esi, %edi 262250c2277SThomas Gleixner 263250c2277SThomas Gleixner /* Finally jump to run C code and to be on real kernel address 264250c2277SThomas Gleixner * Since we are running on identity-mapped space we have to jump 265250c2277SThomas Gleixner * to the full 64bit address, this is only possible as indirect 266250c2277SThomas Gleixner * jump. In addition we need to ensure %cs is set so we make this 267250c2277SThomas Gleixner * a far return. 268250c2277SThomas Gleixner */ 269250c2277SThomas Gleixner movq initial_code(%rip),%rax 270250c2277SThomas Gleixner pushq $0 # fake return address to stop unwinder 271250c2277SThomas Gleixner pushq $__KERNEL_CS # set correct cs 272250c2277SThomas Gleixner pushq %rax # target address in negative space 273250c2277SThomas Gleixner lretq 274250c2277SThomas Gleixner 275250c2277SThomas Gleixner /* SMP bootup changes these two */ 276da5968aeSSam Ravnborg __REFDATA 277250c2277SThomas Gleixner .align 8 278f1fbabb3SSam Ravnborg ENTRY(initial_code) 279250c2277SThomas Gleixner .quad x86_64_start_kernel 280f32ff538STejun Heo ENTRY(initial_gs) 281f32ff538STejun Heo .quad _boot_cpu_pda 282f1fbabb3SSam Ravnborg __FINITDATA 283f1fbabb3SSam Ravnborg 2849cf4f298SGlauber Costa ENTRY(stack_start) 285250c2277SThomas Gleixner .quad init_thread_union+THREAD_SIZE-8 2869cf4f298SGlauber Costa .word 0 287250c2277SThomas Gleixner 288250c2277SThomas Gleixnerbad_address: 289250c2277SThomas Gleixner jmp bad_address 290250c2277SThomas Gleixner 29141bd4eacSAndi Kleen .section ".init.text","ax" 292076f9776SIngo Molnar#ifdef CONFIG_EARLY_PRINTK 2938866cd9dSRoland McGrath .globl early_idt_handlers 2948866cd9dSRoland McGrathearly_idt_handlers: 295749c970aSAndi Kleen i = 0 296749c970aSAndi Kleen .rept NUM_EXCEPTION_VECTORS 297749c970aSAndi Kleen movl $i, %esi 298749c970aSAndi Kleen jmp early_idt_handler 299749c970aSAndi Kleen i = i + 1 300749c970aSAndi Kleen .endr 301076f9776SIngo Molnar#endif 3028866cd9dSRoland McGrath 303250c2277SThomas GleixnerENTRY(early_idt_handler) 304076f9776SIngo Molnar#ifdef CONFIG_EARLY_PRINTK 305250c2277SThomas Gleixner cmpl $2,early_recursion_flag(%rip) 306250c2277SThomas Gleixner jz 1f 307250c2277SThomas Gleixner incl early_recursion_flag(%rip) 30849a69787SGlauber de Oliveira Costa GET_CR2_INTO_RCX 3098866cd9dSRoland McGrath movq %rcx,%r9 3108866cd9dSRoland McGrath xorl %r8d,%r8d # zero for error code 3118866cd9dSRoland McGrath movl %esi,%ecx # get vector number 3128866cd9dSRoland McGrath # Test %ecx against mask of vectors that push error code. 3138866cd9dSRoland McGrath cmpl $31,%ecx 3148866cd9dSRoland McGrath ja 0f 3158866cd9dSRoland McGrath movl $1,%eax 3168866cd9dSRoland McGrath salq %cl,%rax 3178866cd9dSRoland McGrath testl $0x27d00,%eax 3188866cd9dSRoland McGrath je 0f 3198866cd9dSRoland McGrath popq %r8 # get error code 3208866cd9dSRoland McGrath0: movq 0(%rsp),%rcx # get ip 3218866cd9dSRoland McGrath movq 8(%rsp),%rdx # get cs 3228866cd9dSRoland McGrath xorl %eax,%eax 323250c2277SThomas Gleixner leaq early_idt_msg(%rip),%rdi 324250c2277SThomas Gleixner call early_printk 325250c2277SThomas Gleixner cmpl $2,early_recursion_flag(%rip) 326250c2277SThomas Gleixner jz 1f 327250c2277SThomas Gleixner call dump_stack 328250c2277SThomas Gleixner#ifdef CONFIG_KALLSYMS 329250c2277SThomas Gleixner leaq early_idt_ripmsg(%rip),%rdi 3307aed55d1SJiri Slaby movq 0(%rsp),%rsi # get rip again 331250c2277SThomas Gleixner call __print_symbol 332250c2277SThomas Gleixner#endif 333076f9776SIngo Molnar#endif /* EARLY_PRINTK */ 334250c2277SThomas Gleixner1: hlt 335250c2277SThomas Gleixner jmp 1b 336076f9776SIngo Molnar 337076f9776SIngo Molnar#ifdef CONFIG_EARLY_PRINTK 338250c2277SThomas Gleixnerearly_recursion_flag: 339250c2277SThomas Gleixner .long 0 340250c2277SThomas Gleixner 341250c2277SThomas Gleixnerearly_idt_msg: 3428866cd9dSRoland McGrath .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n" 343250c2277SThomas Gleixnerearly_idt_ripmsg: 344250c2277SThomas Gleixner .asciz "RIP %s\n" 345076f9776SIngo Molnar#endif /* CONFIG_EARLY_PRINTK */ 34641bd4eacSAndi Kleen .previous 347250c2277SThomas Gleixner 348250c2277SThomas Gleixner.balign PAGE_SIZE 349250c2277SThomas Gleixner 350250c2277SThomas Gleixner#define NEXT_PAGE(name) \ 351250c2277SThomas Gleixner .balign PAGE_SIZE; \ 352250c2277SThomas GleixnerENTRY(name) 353250c2277SThomas Gleixner 354250c2277SThomas Gleixner/* Automate the creation of 1 to 1 mapping pmd entries */ 355250c2277SThomas Gleixner#define PMDS(START, PERM, COUNT) \ 356250c2277SThomas Gleixner i = 0 ; \ 357250c2277SThomas Gleixner .rept (COUNT) ; \ 3580e192b99SCyrill Gorcunov .quad (START) + (i << PMD_SHIFT) + (PERM) ; \ 359250c2277SThomas Gleixner i = i + 1 ; \ 360250c2277SThomas Gleixner .endr 361250c2277SThomas Gleixner 362250c2277SThomas Gleixner /* 363250c2277SThomas Gleixner * This default setting generates an ident mapping at address 0x100000 364250c2277SThomas Gleixner * and a mapping for the kernel that precisely maps virtual address 365250c2277SThomas Gleixner * 0xffffffff80000000 to physical address 0x000000. (always using 366250c2277SThomas Gleixner * 2Mbyte large pages provided by PAE mode) 367250c2277SThomas Gleixner */ 368250c2277SThomas GleixnerNEXT_PAGE(init_level4_pgt) 369250c2277SThomas Gleixner .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE 370a6523748SEduardo Habkost .org init_level4_pgt + L4_PAGE_OFFSET*8, 0 371250c2277SThomas Gleixner .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE 372a6523748SEduardo Habkost .org init_level4_pgt + L4_START_KERNEL*8, 0 373250c2277SThomas Gleixner /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ 374250c2277SThomas Gleixner .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE 375250c2277SThomas Gleixner 376250c2277SThomas GleixnerNEXT_PAGE(level3_ident_pgt) 377250c2277SThomas Gleixner .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE 378250c2277SThomas Gleixner .fill 511,8,0 379250c2277SThomas Gleixner 380250c2277SThomas GleixnerNEXT_PAGE(level3_kernel_pgt) 381a6523748SEduardo Habkost .fill L3_START_KERNEL,8,0 382250c2277SThomas Gleixner /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ 383250c2277SThomas Gleixner .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE 384250c2277SThomas Gleixner .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE 385250c2277SThomas Gleixner 386250c2277SThomas GleixnerNEXT_PAGE(level2_fixmap_pgt) 3876596f242SIngo Molnar .fill 506,8,0 3886596f242SIngo Molnar .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE 3896596f242SIngo Molnar /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */ 3906596f242SIngo Molnar .fill 5,8,0 3916596f242SIngo Molnar 3926596f242SIngo MolnarNEXT_PAGE(level1_fixmap_pgt) 393250c2277SThomas Gleixner .fill 512,8,0 394250c2277SThomas Gleixner 395250c2277SThomas GleixnerNEXT_PAGE(level2_ident_pgt) 396250c2277SThomas Gleixner /* Since I easily can, map the first 1G. 397250c2277SThomas Gleixner * Don't set NX because code runs from these pages. 398250c2277SThomas Gleixner */ 399b2bc2731SSuresh Siddha PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD) 400250c2277SThomas Gleixner 401250c2277SThomas GleixnerNEXT_PAGE(level2_kernel_pgt) 40288f3aec7SIngo Molnar /* 40385eb69a1SIngo Molnar * 512 MB kernel mapping. We spend a full page on this pagetable 40488f3aec7SIngo Molnar * anyway. 40588f3aec7SIngo Molnar * 40688f3aec7SIngo Molnar * The kernel code+data+bss must not be bigger than that. 40788f3aec7SIngo Molnar * 40885eb69a1SIngo Molnar * (NOTE: at +512MB starts the module area, see MODULES_VADDR. 40988f3aec7SIngo Molnar * If you want to increase this then increase MODULES_VADDR 41088f3aec7SIngo Molnar * too.) 41188f3aec7SIngo Molnar */ 4128490638cSJeremy Fitzhardinge PMDS(0, __PAGE_KERNEL_LARGE_EXEC, 413d4afe414SIngo Molnar KERNEL_IMAGE_SIZE/PMD_SIZE) 414250c2277SThomas Gleixner 415250c2277SThomas GleixnerNEXT_PAGE(level2_spare_pgt) 416250c2277SThomas Gleixner .fill 512, 8, 0 417250c2277SThomas Gleixner 418250c2277SThomas Gleixner#undef PMDS 419250c2277SThomas Gleixner#undef NEXT_PAGE 420250c2277SThomas Gleixner 421250c2277SThomas Gleixner .data 422250c2277SThomas Gleixner .align 16 423a939098aSGlauber Costa .globl early_gdt_descr 424a939098aSGlauber Costaearly_gdt_descr: 425a939098aSGlauber Costa .word GDT_ENTRIES*8-1 4263e5d8f97STejun Heo#ifdef CONFIG_SMP 4273e5d8f97STejun Heoearly_gdt_descr_base: 4283e5d8f97STejun Heo .quad 0x0000000000000000 4293e5d8f97STejun Heo#else 430a939098aSGlauber Costa .quad per_cpu__gdt_page 4313e5d8f97STejun Heo#endif 432250c2277SThomas Gleixner 433250c2277SThomas GleixnerENTRY(phys_base) 434250c2277SThomas Gleixner /* This must match the first entry in level2_kernel_pgt */ 435250c2277SThomas Gleixner .quad 0x0000000000000000 436250c2277SThomas Gleixner 4378c5e5ac3SJeremy Fitzhardinge#include "../../x86/xen/xen-head.S" 438250c2277SThomas Gleixner 439250c2277SThomas Gleixner .section .bss, "aw", @nobits 440250c2277SThomas Gleixner .align L1_CACHE_BYTES 441250c2277SThomas GleixnerENTRY(idt_table) 442250c2277SThomas Gleixner .skip 256 * 16 443250c2277SThomas Gleixner 444250c2277SThomas Gleixner .section .bss.page_aligned, "aw", @nobits 445250c2277SThomas Gleixner .align PAGE_SIZE 446250c2277SThomas GleixnerENTRY(empty_zero_page) 447250c2277SThomas Gleixner .skip PAGE_SIZE 448