Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 4 | * |
| 5 | * Enhanced CPU detection and feature setting code by Mike Jagdis |
| 6 | * and Martin Mares, November 1997. |
| 7 | */ |
| 8 | |
| 9 | .text |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/threads.h> |
Sam Ravnborg | 8b2f7ff | 2008-01-30 13:33:28 +0100 | [diff] [blame] | 11 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/linkage.h> |
| 13 | #include <asm/segment.h> |
Jeremy Fitzhardinge | 0341c14 | 2009-02-13 11:14:01 -0800 | [diff] [blame] | 14 | #include <asm/page_types.h> |
| 15 | #include <asm/pgtable_types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/desc.h> |
| 17 | #include <asm/cache.h> |
| 18 | #include <asm/thread_info.h> |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 19 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/setup.h> |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 21 | #include <asm/processor-flags.h> |
Tejun Heo | 60a5317 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 22 | #include <asm/percpu.h> |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 23 | |
| 24 | /* Physical address */ |
| 25 | #define pa(X) ((X) - __PAGE_OFFSET) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * References to members of the new_cpu_data structure. |
| 29 | */ |
| 30 | |
| 31 | #define X86 new_cpu_data+CPUINFO_x86 |
| 32 | #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor |
| 33 | #define X86_MODEL new_cpu_data+CPUINFO_x86_model |
| 34 | #define X86_MASK new_cpu_data+CPUINFO_x86_mask |
| 35 | #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math |
| 36 | #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level |
| 37 | #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability |
| 38 | #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id |
| 39 | |
| 40 | /* |
| 41 | * This is how much memory *in addition to the memory covered up to |
Jeremy Fitzhardinge | 9ce8c2e | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 42 | * and including _end* we need mapped initially. |
| 43 | * We need: |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 44 | * (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) |
| 45 | * (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | * |
| 47 | * Modulo rounding, each megabyte assigned here requires a kilobyte of |
| 48 | * memory, which is currently unreclaimed. |
| 49 | * |
| 50 | * This should be a multiple of a page. |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 51 | * |
| 52 | * KERNEL_IMAGE_SIZE should be greater than pa(_end) |
| 53 | * and small than max_low_pfn, otherwise will waste some page table entries |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | */ |
Yinghai Lu | 7543c1d | 2009-03-12 16:04:42 -0700 | [diff] [blame] | 55 | LOW_PAGES = (KERNEL_IMAGE_SIZE + PAGE_SIZE_asm - 1)>>PAGE_SHIFT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Jeremy Fitzhardinge | 9ce8c2e | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 57 | #if PTRS_PER_PMD > 1 |
| 58 | PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PMD) + PTRS_PER_PGD |
| 59 | #else |
| 60 | PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PGD) |
| 61 | #endif |
Jeremy Fitzhardinge | 9ce8c2e | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 62 | ALLOCATOR_SLOP = 4 |
| 63 | |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 64 | INIT_MAP_SIZE = (PAGE_TABLE_SIZE + ALLOCATOR_SLOP) * PAGE_SIZE_asm |
| 65 | RESERVE_BRK(pagetables, INIT_MAP_SIZE) |
Jeremy Fitzhardinge | 796216a | 2009-03-12 16:09:49 -0700 | [diff] [blame] | 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | /* |
| 68 | * 32-bit kernel entrypoint; only used by the boot CPU. On entry, |
| 69 | * %esi points to the real-mode code as a 32-bit pointer. |
| 70 | * CS and DS must be 4 GB flat segments, but we don't depend on |
| 71 | * any particular GDT layout, because we load our own as soon as we |
| 72 | * can. |
| 73 | */ |
Vivek Goyal | f8657e1 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 74 | .section .text.head,"ax",@progbits |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | ENTRY(startup_32) |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 76 | /* test KEEP_SEGMENTS flag to see if the bootloader is asking |
| 77 | us to not reload segments */ |
| 78 | testb $(1<<6), BP_loadflags(%esi) |
| 79 | jnz 2f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * Set segments to known values. |
| 83 | */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 84 | lgdt pa(boot_gdt_descr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | movl $(__BOOT_DS),%eax |
| 86 | movl %eax,%ds |
| 87 | movl %eax,%es |
| 88 | movl %eax,%fs |
| 89 | movl %eax,%gs |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 90 | 2: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | /* |
| 93 | * Clear BSS first so that there are no surprises... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | */ |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 95 | cld |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | xorl %eax,%eax |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 97 | movl $pa(__bss_start),%edi |
| 98 | movl $pa(__bss_stop),%ecx |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | subl %edi,%ecx |
| 100 | shrl $2,%ecx |
| 101 | rep ; stosl |
Vivek Goyal | 484b90c | 2005-09-03 15:56:31 -0700 | [diff] [blame] | 102 | /* |
| 103 | * Copy bootup parameters out of the way. |
| 104 | * Note: %esi still has the pointer to the real-mode data. |
| 105 | * With the kexec as boot loader, parameter segment might be loaded beyond |
| 106 | * kernel image and might not even be addressable by early boot page tables. |
| 107 | * (kexec on panic case). Hence copy out the parameters before initializing |
| 108 | * page tables. |
| 109 | */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 110 | movl $pa(boot_params),%edi |
Vivek Goyal | 484b90c | 2005-09-03 15:56:31 -0700 | [diff] [blame] | 111 | movl $(PARAM_SIZE/4),%ecx |
| 112 | cld |
| 113 | rep |
| 114 | movsl |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 115 | movl pa(boot_params) + NEW_CL_POINTER,%esi |
Vivek Goyal | 484b90c | 2005-09-03 15:56:31 -0700 | [diff] [blame] | 116 | andl %esi,%esi |
H. Peter Anvin | fa76dab | 2007-10-23 22:37:25 +0200 | [diff] [blame] | 117 | jz 1f # No comand line |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 118 | movl $pa(boot_command_line),%edi |
Vivek Goyal | 484b90c | 2005-09-03 15:56:31 -0700 | [diff] [blame] | 119 | movl $(COMMAND_LINE_SIZE/4),%ecx |
| 120 | rep |
| 121 | movsl |
| 122 | 1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 124 | #ifdef CONFIG_PARAVIRT |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 125 | /* This is can only trip for a broken bootloader... */ |
| 126 | cmpw $0x207, pa(boot_params + BP_version) |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 127 | jb default_entry |
| 128 | |
| 129 | /* Paravirt-compatible boot parameters. Look to see what architecture |
| 130 | we're booting under. */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 131 | movl pa(boot_params + BP_hardware_subarch), %eax |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 132 | cmpl $num_subarch_entries, %eax |
| 133 | jae bad_subarch |
| 134 | |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 135 | movl pa(subarch_entries)(,%eax,4), %eax |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 136 | subl $__PAGE_OFFSET, %eax |
| 137 | jmp *%eax |
| 138 | |
| 139 | bad_subarch: |
| 140 | WEAK(lguest_entry) |
| 141 | WEAK(xen_entry) |
| 142 | /* Unknown implementation; there's really |
| 143 | nothing we can do at this point. */ |
| 144 | ud2a |
Sam Ravnborg | 8b2f7ff | 2008-01-30 13:33:28 +0100 | [diff] [blame] | 145 | |
| 146 | __INITDATA |
| 147 | |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 148 | subarch_entries: |
| 149 | .long default_entry /* normal x86/PC */ |
| 150 | .long lguest_entry /* lguest hypervisor */ |
| 151 | .long xen_entry /* Xen hypervisor */ |
| 152 | num_subarch_entries = (. - subarch_entries) / 4 |
| 153 | .previous |
| 154 | #endif /* CONFIG_PARAVIRT */ |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | /* |
| 157 | * Initialize page tables. This creates a PDE and a set of page |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 158 | * tables, which are located immediately beyond __brk_base. The variable |
Jeremy Fitzhardinge | ccf3fe0 | 2009-02-27 13:27:38 -0800 | [diff] [blame] | 159 | * _brk_end is set up to point to the first "safe" location. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | * Mappings are created both at virtual address 0 (identity mapping) |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 161 | * and PAGE_OFFSET for up to _end. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | * |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 163 | * Note that the stack is not yet set up! |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | */ |
Rusty Russell | a24e785 | 2007-10-21 16:41:35 -0700 | [diff] [blame] | 165 | default_entry: |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 166 | #ifdef CONFIG_X86_PAE |
| 167 | |
| 168 | /* |
| 169 | * In PAE mode swapper_pg_dir is statically defined to contain enough |
| 170 | * entries to cover the VMSPLIT option (that is the top 1, 2 or 3 |
| 171 | * entries). The identity mapping is handled by pointing two PGD |
| 172 | * entries to the first kernel PMD. |
| 173 | * |
| 174 | * Note the upper half of each PMD or PTE are always zero at |
| 175 | * this stage. |
| 176 | */ |
| 177 | |
Joe Korty | 86b2b70 | 2008-06-02 17:21:06 -0400 | [diff] [blame] | 178 | #define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 179 | |
| 180 | xorl %ebx,%ebx /* %ebx is kept at zero */ |
| 181 | |
Jeremy Fitzhardinge | ccf3fe0 | 2009-02-27 13:27:38 -0800 | [diff] [blame] | 182 | movl $pa(__brk_base), %edi |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 183 | movl $pa(swapper_pg_pmd), %edx |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 184 | movl $PTE_IDENT_ATTR, %eax |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | 10: |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 186 | leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 187 | movl %ecx,(%edx) /* Store PMD entry */ |
| 188 | /* Upper half already zero */ |
| 189 | addl $8,%edx |
| 190 | movl $512,%ecx |
| 191 | 11: |
| 192 | stosl |
| 193 | xchgl %eax,%ebx |
| 194 | stosl |
| 195 | xchgl %eax,%ebx |
| 196 | addl $0x1000,%eax |
| 197 | loop 11b |
| 198 | |
| 199 | /* |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 200 | * End condition: we must map up to the end. |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 201 | */ |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 202 | movl $pa(_end) + PTE_IDENT_ATTR, %ebp |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 203 | cmpl %ebp,%eax |
| 204 | jb 10b |
| 205 | 1: |
Jeremy Fitzhardinge | ccf3fe0 | 2009-02-27 13:27:38 -0800 | [diff] [blame] | 206 | addl $__PAGE_OFFSET, %edi |
| 207 | movl %edi, pa(_brk_end) |
Yinghai Lu | 6af61a7 | 2008-06-01 23:53:50 -0700 | [diff] [blame] | 208 | shrl $12, %eax |
| 209 | movl %eax, pa(max_pfn_mapped) |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 210 | |
| 211 | /* Do early initialization of the fixmap area */ |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 212 | movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 213 | movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8) |
| 214 | #else /* Not PAE */ |
| 215 | |
| 216 | page_pde_offset = (__PAGE_OFFSET >> 20); |
| 217 | |
Jeremy Fitzhardinge | ccf3fe0 | 2009-02-27 13:27:38 -0800 | [diff] [blame] | 218 | movl $pa(__brk_base), %edi |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 219 | movl $pa(swapper_pg_dir), %edx |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 220 | movl $PTE_IDENT_ATTR, %eax |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 221 | 10: |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 222 | leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | movl %ecx,(%edx) /* Store identity PDE entry */ |
| 224 | movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */ |
| 225 | addl $4,%edx |
| 226 | movl $1024, %ecx |
| 227 | 11: |
| 228 | stosl |
| 229 | addl $0x1000,%eax |
| 230 | loop 11b |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 231 | /* |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 232 | * End condition: we must map up to end |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 233 | */ |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 234 | movl $pa(_end) + PTE_IDENT_ATTR, %ebp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | cmpl %ebp,%eax |
| 236 | jb 10b |
Jeremy Fitzhardinge | ccf3fe0 | 2009-02-27 13:27:38 -0800 | [diff] [blame] | 237 | addl $__PAGE_OFFSET, %edi |
| 238 | movl %edi, pa(_brk_end) |
Yinghai Lu | 6af61a7 | 2008-06-01 23:53:50 -0700 | [diff] [blame] | 239 | shrl $12, %eax |
| 240 | movl %eax, pa(max_pfn_mapped) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 242 | /* Do early initialization of the fixmap area */ |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 243 | movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 244 | movl %eax,pa(swapper_pg_dir+0xffc) |
| 245 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | jmp 3f |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | /* |
| 248 | * Non-boot CPU entry point; entered from trampoline.S |
| 249 | * We can't lgdt here, because lgdt itself uses a data segment, but |
Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 250 | * we know the trampoline has already loaded the boot_gdt for us. |
Vivek Goyal | f8657e1 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 251 | * |
| 252 | * If cpu hotplug is not supported then this code can go in init section |
| 253 | * which will be freed later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | */ |
Vivek Goyal | f8657e1 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 255 | |
Andi Kleen | 5fe4486 | 2007-08-10 22:31:10 +0200 | [diff] [blame] | 256 | #ifndef CONFIG_HOTPLUG_CPU |
Vivek Goyal | f8657e1 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 257 | .section .init.text,"ax",@progbits |
| 258 | #endif |
| 259 | |
| 260 | #ifdef CONFIG_SMP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | ENTRY(startup_32_smp) |
| 262 | cld |
| 263 | movl $(__BOOT_DS),%eax |
| 264 | movl %eax,%ds |
| 265 | movl %eax,%es |
| 266 | movl %eax,%fs |
| 267 | movl %eax,%gs |
Ian Campbell | 5756dd5 | 2008-01-30 13:33:27 +0100 | [diff] [blame] | 268 | #endif /* CONFIG_SMP */ |
| 269 | 3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | /* |
| 272 | * New page tables may be in 4Mbyte page mode and may |
| 273 | * be using the global pages. |
| 274 | * |
| 275 | * NOTE! If we are on a 486 we may have no cr4 at all! |
| 276 | * So we do not try to touch it unless we really have |
| 277 | * some bits in it to set. This won't work if the BSP |
| 278 | * implements cr4 but this AP does not -- very unlikely |
| 279 | * but be warned! The same applies to the pse feature |
| 280 | * if not equally supported. --macro |
| 281 | * |
| 282 | * NOTE! We have to correct for the fact that we're |
| 283 | * not yet offset PAGE_OFFSET.. |
| 284 | */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 285 | #define cr4_bits pa(mmu_cr4_features) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | movl cr4_bits,%edx |
| 287 | andl %edx,%edx |
| 288 | jz 6f |
| 289 | movl %cr4,%eax # Turn on paging options (PSE,PAE,..) |
| 290 | orl %edx,%eax |
| 291 | movl %eax,%cr4 |
| 292 | |
| 293 | btl $5, %eax # check if PAE is enabled |
| 294 | jnc 6f |
| 295 | |
| 296 | /* Check if extended functions are implemented */ |
| 297 | movl $0x80000000, %eax |
| 298 | cpuid |
| 299 | cmpl $0x80000000, %eax |
| 300 | jbe 6f |
| 301 | mov $0x80000001, %eax |
| 302 | cpuid |
| 303 | /* Execute Disable bit supported? */ |
| 304 | btl $20, %edx |
| 305 | jnc 6f |
| 306 | |
| 307 | /* Setup EFER (Extended Feature Enable Register) */ |
| 308 | movl $0xc0000080, %ecx |
| 309 | rdmsr |
| 310 | |
| 311 | btsl $11, %eax |
| 312 | /* Make changes effective */ |
| 313 | wrmsr |
| 314 | |
| 315 | 6: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
| 317 | /* |
| 318 | * Enable paging |
| 319 | */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 320 | movl $pa(swapper_pg_dir),%eax |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | movl %eax,%cr3 /* set the page table pointer.. */ |
| 322 | movl %cr0,%eax |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 323 | orl $X86_CR0_PG,%eax |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | movl %eax,%cr0 /* ..and set paging (PG) bit */ |
| 325 | ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */ |
| 326 | 1: |
| 327 | /* Set up the stack pointer */ |
| 328 | lss stack_start,%esp |
| 329 | |
| 330 | /* |
| 331 | * Initialize eflags. Some BIOS's leave bits like NT set. This would |
| 332 | * confuse the debugger if this code is traced. |
| 333 | * XXX - best to initialize before switching to protected mode. |
| 334 | */ |
| 335 | pushl $0 |
| 336 | popfl |
| 337 | |
| 338 | #ifdef CONFIG_SMP |
Ian Campbell | 5035950 | 2008-01-30 13:33:27 +0100 | [diff] [blame] | 339 | cmpb $0, ready |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | jz 1f /* Initial CPU cleans BSS */ |
| 341 | jmp checkCPUtype |
| 342 | 1: |
| 343 | #endif /* CONFIG_SMP */ |
| 344 | |
| 345 | /* |
| 346 | * start system 32-bit setup. We need to re-do some of the things done |
| 347 | * in 16-bit mode for the "real" operations. |
| 348 | */ |
| 349 | call setup_idt |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | checkCPUtype: |
| 352 | |
| 353 | movl $-1,X86_CPUID # -1 for no CPUID initially |
| 354 | |
| 355 | /* check if it is 486 or 386. */ |
| 356 | /* |
| 357 | * XXX - this does a lot of unnecessary setup. Alignment checks don't |
| 358 | * apply at our cpl of 0 and the stack ought to be aligned already, and |
| 359 | * we don't need to preserve eflags. |
| 360 | */ |
| 361 | |
| 362 | movb $3,X86 # at least 386 |
| 363 | pushfl # push EFLAGS |
| 364 | popl %eax # get EFLAGS |
| 365 | movl %eax,%ecx # save original EFLAGS |
| 366 | xorl $0x240000,%eax # flip AC and ID bits in EFLAGS |
| 367 | pushl %eax # copy to EFLAGS |
| 368 | popfl # set EFLAGS |
| 369 | pushfl # get new EFLAGS |
| 370 | popl %eax # put it in eax |
| 371 | xorl %ecx,%eax # change in flags |
| 372 | pushl %ecx # restore original EFLAGS |
| 373 | popfl |
| 374 | testl $0x40000,%eax # check if AC bit changed |
| 375 | je is386 |
| 376 | |
| 377 | movb $4,X86 # at least 486 |
| 378 | testl $0x200000,%eax # check if ID bit changed |
| 379 | je is486 |
| 380 | |
| 381 | /* get vendor info */ |
| 382 | xorl %eax,%eax # call CPUID with 0 -> return vendor ID |
| 383 | cpuid |
| 384 | movl %eax,X86_CPUID # save CPUID level |
| 385 | movl %ebx,X86_VENDOR_ID # lo 4 chars |
| 386 | movl %edx,X86_VENDOR_ID+4 # next 4 chars |
| 387 | movl %ecx,X86_VENDOR_ID+8 # last 4 chars |
| 388 | |
| 389 | orl %eax,%eax # do we have processor info as well? |
| 390 | je is486 |
| 391 | |
| 392 | movl $1,%eax # Use the CPUID instruction to get CPU type |
| 393 | cpuid |
| 394 | movb %al,%cl # save reg for future use |
| 395 | andb $0x0f,%ah # mask processor family |
| 396 | movb %ah,X86 |
| 397 | andb $0xf0,%al # mask model |
| 398 | shrb $4,%al |
| 399 | movb %al,X86_MODEL |
| 400 | andb $0x0f,%cl # mask mask revision |
| 401 | movb %cl,X86_MASK |
| 402 | movl %edx,X86_CAPABILITY |
| 403 | |
| 404 | is486: movl $0x50022,%ecx # set AM, WP, NE and MP |
| 405 | jmp 2f |
| 406 | |
| 407 | is386: movl $2,%ecx # set MP |
| 408 | 2: movl %cr0,%eax |
| 409 | andl $0x80000011,%eax # Save PG,PE,ET |
| 410 | orl %ecx,%eax |
| 411 | movl %eax,%cr0 |
| 412 | |
| 413 | call check_x87 |
Rusty Russell | 2a57ff1 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 414 | lgdt early_gdt_descr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | lidt idt_descr |
| 416 | ljmp $(__KERNEL_CS),$1f |
| 417 | 1: movl $(__KERNEL_DS),%eax # reload all the segment registers |
| 418 | movl %eax,%ss # after changing gdt. |
| 419 | |
| 420 | movl $(__USER_DS),%eax # DS/ES contains default USER segment |
| 421 | movl %eax,%ds |
| 422 | movl %eax,%es |
| 423 | |
Brian Gerst | 0dd76d7 | 2009-01-21 17:26:05 +0900 | [diff] [blame] | 424 | movl $(__KERNEL_PERCPU), %eax |
| 425 | movl %eax,%fs # set this cpu's percpu |
| 426 | |
Tejun Heo | 60a5317 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 427 | #ifdef CONFIG_CC_STACKPROTECTOR |
| 428 | /* |
| 429 | * The linker can't handle this by relocation. Manually set |
| 430 | * base address in stack canary segment descriptor. |
| 431 | */ |
| 432 | cmpb $0,ready |
| 433 | jne 1f |
| 434 | movl $per_cpu__gdt_page,%eax |
| 435 | movl $per_cpu__stack_canary,%ecx |
Tejun Heo | 5c79d2a | 2009-02-11 16:31:00 +0900 | [diff] [blame] | 436 | subl $20, %ecx |
Tejun Heo | 60a5317 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 437 | movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax) |
| 438 | shrl $16, %ecx |
| 439 | movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax) |
| 440 | movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax) |
| 441 | 1: |
| 442 | #endif |
| 443 | movl $(__KERNEL_STACK_CANARY),%eax |
Jeremy Fitzhardinge | 464d1a7 | 2007-02-13 13:26:20 +0100 | [diff] [blame] | 444 | movl %eax,%gs |
Tejun Heo | 60a5317 | 2009-02-09 22:17:40 +0900 | [diff] [blame] | 445 | |
| 446 | xorl %eax,%eax # Clear LDT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | lldt %ax |
Jeremy Fitzhardinge | f95d47c | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 448 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | cld # gcc2 wants the direction flag cleared at all times |
Jeremy Fitzhardinge | 26fd5e0 | 2006-10-21 18:37:02 +0200 | [diff] [blame] | 450 | pushl $0 # fake return address for unwinder |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | #ifdef CONFIG_SMP |
Shaohua Li | d92de65 | 2005-06-25 14:54:49 -0700 | [diff] [blame] | 452 | movb ready, %cl |
| 453 | movb $1, ready |
Andi Kleen | 29fe5f3 | 2006-08-30 19:37:09 +0200 | [diff] [blame] | 454 | cmpb $0,%cl # the first CPU calls start_kernel |
Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 455 | je 1f |
Glauber Costa | 3e97047 | 2008-05-28 13:01:54 -0300 | [diff] [blame] | 456 | movl (stack_start), %esp |
Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 457 | 1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #endif /* CONFIG_SMP */ |
Glauber Costa | e3f77ed | 2008-05-28 12:57:02 -0300 | [diff] [blame] | 459 | jmp *(initial_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | |
| 461 | /* |
| 462 | * We depend on ET to be correct. This checks for 287/387. |
| 463 | */ |
| 464 | check_x87: |
| 465 | movb $0,X86_HARD_MATH |
| 466 | clts |
| 467 | fninit |
| 468 | fstsw %ax |
| 469 | cmpb $0,%al |
| 470 | je 1f |
| 471 | movl %cr0,%eax /* no coprocessor: have to set bits */ |
| 472 | xorl $4,%eax /* set EM */ |
| 473 | movl %eax,%cr0 |
| 474 | ret |
| 475 | ALIGN |
| 476 | 1: movb $1,X86_HARD_MATH |
| 477 | .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */ |
| 478 | ret |
| 479 | |
| 480 | /* |
| 481 | * setup_idt |
| 482 | * |
| 483 | * sets up a idt with 256 entries pointing to |
| 484 | * ignore_int, interrupt gates. It doesn't actually load |
| 485 | * idt - that can be done only after paging has been enabled |
| 486 | * and the kernel moved to PAGE_OFFSET. Interrupts |
| 487 | * are enabled elsewhere, when we can be relatively |
| 488 | * sure everything is ok. |
| 489 | * |
| 490 | * Warning: %esi is live across this function. |
| 491 | */ |
| 492 | setup_idt: |
| 493 | lea ignore_int,%edx |
| 494 | movl $(__KERNEL_CS << 16),%eax |
| 495 | movw %dx,%ax /* selector = 0x0010 = cs */ |
| 496 | movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ |
| 497 | |
| 498 | lea idt_table,%edi |
| 499 | mov $256,%ecx |
| 500 | rp_sidt: |
| 501 | movl %eax,(%edi) |
| 502 | movl %edx,4(%edi) |
| 503 | addl $8,%edi |
| 504 | dec %ecx |
| 505 | jne rp_sidt |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 506 | |
| 507 | .macro set_early_handler handler,trapno |
| 508 | lea \handler,%edx |
| 509 | movl $(__KERNEL_CS << 16),%eax |
| 510 | movw %dx,%ax |
| 511 | movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ |
| 512 | lea idt_table,%edi |
| 513 | movl %eax,8*\trapno(%edi) |
| 514 | movl %edx,8*\trapno+4(%edi) |
| 515 | .endm |
| 516 | |
| 517 | set_early_handler handler=early_divide_err,trapno=0 |
| 518 | set_early_handler handler=early_illegal_opcode,trapno=6 |
| 519 | set_early_handler handler=early_protection_fault,trapno=13 |
| 520 | set_early_handler handler=early_page_fault,trapno=14 |
| 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | ret |
| 523 | |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 524 | early_divide_err: |
| 525 | xor %edx,%edx |
| 526 | pushl $0 /* fake errcode */ |
| 527 | jmp early_fault |
| 528 | |
| 529 | early_illegal_opcode: |
| 530 | movl $6,%edx |
| 531 | pushl $0 /* fake errcode */ |
| 532 | jmp early_fault |
| 533 | |
| 534 | early_protection_fault: |
| 535 | movl $13,%edx |
| 536 | jmp early_fault |
| 537 | |
| 538 | early_page_fault: |
| 539 | movl $14,%edx |
| 540 | jmp early_fault |
| 541 | |
| 542 | early_fault: |
| 543 | cld |
| 544 | #ifdef CONFIG_PRINTK |
Ingo Molnar | 382f64a | 2007-10-17 18:04:41 +0200 | [diff] [blame] | 545 | pusha |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 546 | movl $(__KERNEL_DS),%eax |
| 547 | movl %eax,%ds |
| 548 | movl %eax,%es |
| 549 | cmpl $2,early_recursion_flag |
| 550 | je hlt_loop |
| 551 | incl early_recursion_flag |
| 552 | movl %cr2,%eax |
| 553 | pushl %eax |
| 554 | pushl %edx /* trapno */ |
| 555 | pushl $fault_msg |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 556 | call printk |
| 557 | #endif |
Ingo Molnar | 94878ef | 2008-01-30 13:33:09 +0100 | [diff] [blame] | 558 | call dump_stack |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 559 | hlt_loop: |
| 560 | hlt |
| 561 | jmp hlt_loop |
| 562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | /* This is the default interrupt "handler" :-) */ |
| 564 | ALIGN |
| 565 | ignore_int: |
| 566 | cld |
Matt Mackall | d59745c | 2005-05-01 08:59:02 -0700 | [diff] [blame] | 567 | #ifdef CONFIG_PRINTK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | pushl %eax |
| 569 | pushl %ecx |
| 570 | pushl %edx |
| 571 | pushl %es |
| 572 | pushl %ds |
| 573 | movl $(__KERNEL_DS),%eax |
| 574 | movl %eax,%ds |
| 575 | movl %eax,%es |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 576 | cmpl $2,early_recursion_flag |
| 577 | je hlt_loop |
| 578 | incl early_recursion_flag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | pushl 16(%esp) |
| 580 | pushl 24(%esp) |
| 581 | pushl 32(%esp) |
| 582 | pushl 40(%esp) |
| 583 | pushl $int_msg |
| 584 | call printk |
Ingo Molnar | d5e397c | 2009-01-26 06:09:00 +0100 | [diff] [blame] | 585 | |
| 586 | call dump_stack |
| 587 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | addl $(5*4),%esp |
| 589 | popl %ds |
| 590 | popl %es |
| 591 | popl %edx |
| 592 | popl %ecx |
| 593 | popl %eax |
Matt Mackall | d59745c | 2005-05-01 08:59:02 -0700 | [diff] [blame] | 594 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | iret |
| 596 | |
Thomas Gleixner | 583323b | 2008-07-27 21:43:11 +0200 | [diff] [blame] | 597 | .section .cpuinit.data,"wa" |
| 598 | .align 4 |
| 599 | ENTRY(initial_code) |
| 600 | .long i386_start_kernel |
| 601 | |
Vivek Goyal | f8657e1 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 602 | .section .text |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | /* |
| 604 | * Real beginning of normal "text" segment |
| 605 | */ |
| 606 | ENTRY(stext) |
| 607 | ENTRY(_stext) |
| 608 | |
| 609 | /* |
| 610 | * BSS section |
| 611 | */ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 612 | .section ".bss.page_aligned","wa" |
| 613 | .align PAGE_SIZE_asm |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 614 | #ifdef CONFIG_X86_PAE |
Adrian Bunk | ed2b7e2 | 2008-02-22 21:58:37 +0200 | [diff] [blame] | 615 | swapper_pg_pmd: |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 616 | .fill 1024*KPMDS,4,0 |
| 617 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | ENTRY(swapper_pg_dir) |
| 619 | .fill 1024,4,0 |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 620 | #endif |
Adrian Bunk | aa65af3 | 2008-02-13 23:29:55 +0200 | [diff] [blame] | 621 | swapper_pg_fixmap: |
Eric W. Biderman | b1c931e | 2007-07-15 23:37:28 -0700 | [diff] [blame] | 622 | .fill 1024,4,0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | ENTRY(empty_zero_page) |
| 624 | .fill 4096,1,0 |
Yinghai Lu | 2bd2753 | 2009-03-09 01:15:57 -0700 | [diff] [blame^] | 625 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | /* |
| 627 | * This starts the data section. |
| 628 | */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 629 | #ifdef CONFIG_X86_PAE |
| 630 | .section ".data.page_aligned","wa" |
| 631 | /* Page-aligned for the benefit of paravirt? */ |
| 632 | .align PAGE_SIZE_asm |
| 633 | ENTRY(swapper_pg_dir) |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 634 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */ |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 635 | # if KPMDS == 3 |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 636 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 |
| 637 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0 |
| 638 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0 |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 639 | # elif KPMDS == 2 |
| 640 | .long 0,0 |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 641 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 |
| 642 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0 |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 643 | # elif KPMDS == 1 |
| 644 | .long 0,0 |
| 645 | .long 0,0 |
Suresh Siddha | b2bc273 | 2008-09-23 14:00:36 -0700 | [diff] [blame] | 646 | .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 |
Ian Campbell | 551889a | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 647 | # else |
| 648 | # error "Kernel PMDs should be 1, 2 or 3" |
| 649 | # endif |
| 650 | .align PAGE_SIZE_asm /* needs to be page-sized too */ |
| 651 | #endif |
| 652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | .data |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | ENTRY(stack_start) |
| 655 | .long init_thread_union+THREAD_SIZE |
| 656 | .long __BOOT_DS |
| 657 | |
| 658 | ready: .byte 0 |
| 659 | |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 660 | early_recursion_flag: |
| 661 | .long 0 |
| 662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | int_msg: |
Ingo Molnar | d5e397c | 2009-01-26 06:09:00 +0100 | [diff] [blame] | 664 | .asciz "Unknown interrupt or fault at: %p %p %p\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 665 | |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 666 | fault_msg: |
Vegard Nossum | 575ca73 | 2008-04-25 21:02:34 +0200 | [diff] [blame] | 667 | /* fault info: */ |
| 668 | .ascii "BUG: Int %d: CR2 %p\n" |
| 669 | /* pusha regs: */ |
| 670 | .ascii " EDI %p ESI %p EBP %p ESP %p\n" |
| 671 | .ascii " EBX %p EDX %p ECX %p EAX %p\n" |
| 672 | /* fault frame: */ |
| 673 | .ascii " err %p EIP %p CS %p flg %p\n" |
| 674 | .ascii "Stack: %p %p %p %p %p %p %p %p\n" |
| 675 | .ascii " %p %p %p %p %p %p %p %p\n" |
| 676 | .asciz " %p %p %p %p %p %p %p %p\n" |
Chuck Ebbert | ec5c092 | 2006-09-26 10:52:39 +0200 | [diff] [blame] | 677 | |
Thomas Gleixner | 9702785 | 2007-10-11 11:16:51 +0200 | [diff] [blame] | 678 | #include "../../x86/xen/xen-head.S" |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | /* |
| 681 | * The IDT and GDT 'descriptors' are a strange 48-bit object |
| 682 | * only used by the lidt and lgdt instructions. They are not |
| 683 | * like usual segment descriptors - they consist of a 16-bit |
| 684 | * segment size, and 32-bit linear address value: |
| 685 | */ |
| 686 | |
| 687 | .globl boot_gdt_descr |
| 688 | .globl idt_descr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
| 690 | ALIGN |
| 691 | # early boot GDT descriptor (must use 1:1 address mapping) |
| 692 | .word 0 # 32 bit align gdt_desc.address |
| 693 | boot_gdt_descr: |
| 694 | .word __BOOT_DS+7 |
Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 695 | .long boot_gdt - __PAGE_OFFSET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | .word 0 # 32-bit align idt_desc.address |
| 698 | idt_descr: |
| 699 | .word IDT_ENTRIES*8-1 # idt contains 256 entries |
| 700 | .long idt_table |
| 701 | |
| 702 | # boot GDT descriptor (later on used by CPU#0): |
| 703 | .word 0 # 32 bit align gdt_desc.address |
Rusty Russell | 2a57ff1 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 704 | ENTRY(early_gdt_descr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | .word GDT_ENTRIES*8-1 |
Jeremy Fitzhardinge | 7a61d35 | 2007-05-02 19:27:15 +0200 | [diff] [blame] | 706 | .long per_cpu__gdt_page /* Overwritten for secondary CPUs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | /* |
Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 709 | * The boot_gdt must mirror the equivalent in setup.S and is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | * used only for booting. |
| 711 | */ |
| 712 | .align L1_CACHE_BYTES |
Sebastien Dugue | 52de74d | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 713 | ENTRY(boot_gdt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 714 | .fill GDT_ENTRY_BOOT_CS,8,0 |
| 715 | .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */ |
| 716 | .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */ |