head_32.S 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /*
  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. .text
  9. #include <linux/threads.h>
  10. #include <linux/init.h>
  11. #include <linux/linkage.h>
  12. #include <asm/segment.h>
  13. #include <asm/page_types.h>
  14. #include <asm/pgtable_types.h>
  15. #include <asm/cache.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/asm-offsets.h>
  18. #include <asm/setup.h>
  19. #include <asm/processor-flags.h>
  20. #include <asm/msr-index.h>
  21. #include <asm/cpufeature.h>
  22. #include <asm/percpu.h>
  23. #include <asm/nops.h>
  24. /* Physical address */
  25. #define pa(X) ((X) - __PAGE_OFFSET)
  26. /*
  27. * References to members of the new_cpu_data structure.
  28. */
  29. #define X86 new_cpu_data+CPUINFO_x86
  30. #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor
  31. #define X86_MODEL new_cpu_data+CPUINFO_x86_model
  32. #define X86_MASK new_cpu_data+CPUINFO_x86_mask
  33. #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math
  34. #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level
  35. #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability
  36. #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id
  37. /*
  38. * This is how much memory in addition to the memory covered up to
  39. * and including _end we need mapped initially.
  40. * We need:
  41. * (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE)
  42. * (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE)
  43. *
  44. * Modulo rounding, each megabyte assigned here requires a kilobyte of
  45. * memory, which is currently unreclaimed.
  46. *
  47. * This should be a multiple of a page.
  48. *
  49. * KERNEL_IMAGE_SIZE should be greater than pa(_end)
  50. * and small than max_low_pfn, otherwise will waste some page table entries
  51. */
  52. #if PTRS_PER_PMD > 1
  53. #define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
  54. #else
  55. #define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
  56. #endif
  57. /*
  58. * Number of possible pages in the lowmem region.
  59. *
  60. * We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a
  61. * gas warning about overflowing shift count when gas has been compiled
  62. * with only a host target support using a 32-bit type for internal
  63. * representation.
  64. */
  65. LOWMEM_PAGES = (((2<<31) - __PAGE_OFFSET) >> PAGE_SHIFT)
  66. /* Enough space to fit pagetables for the low memory linear map */
  67. MAPPING_BEYOND_END = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT
  68. /*
  69. * Worst-case size of the kernel mapping we need to make:
  70. * a relocatable kernel can live anywhere in lowmem, so we need to be able
  71. * to map all of lowmem.
  72. */
  73. KERNEL_PAGES = LOWMEM_PAGES
  74. INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
  75. RESERVE_BRK(pagetables, INIT_MAP_SIZE)
  76. /*
  77. * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
  78. * %esi points to the real-mode code as a 32-bit pointer.
  79. * CS and DS must be 4 GB flat segments, but we don't depend on
  80. * any particular GDT layout, because we load our own as soon as we
  81. * can.
  82. */
  83. __HEAD
  84. ENTRY(startup_32)
  85. movl pa(stack_start),%ecx
  86. /* test KEEP_SEGMENTS flag to see if the bootloader is asking
  87. us to not reload segments */
  88. testb $(1<<6), BP_loadflags(%esi)
  89. jnz 2f
  90. /*
  91. * Set segments to known values.
  92. */
  93. lgdt pa(boot_gdt_descr)
  94. movl $(__BOOT_DS),%eax
  95. movl %eax,%ds
  96. movl %eax,%es
  97. movl %eax,%fs
  98. movl %eax,%gs
  99. movl %eax,%ss
  100. 2:
  101. leal -__PAGE_OFFSET(%ecx),%esp
  102. /*
  103. * Clear BSS first so that there are no surprises...
  104. */
  105. cld
  106. xorl %eax,%eax
  107. movl $pa(__bss_start),%edi
  108. movl $pa(__bss_stop),%ecx
  109. subl %edi,%ecx
  110. shrl $2,%ecx
  111. rep ; stosl
  112. /*
  113. * Copy bootup parameters out of the way.
  114. * Note: %esi still has the pointer to the real-mode data.
  115. * With the kexec as boot loader, parameter segment might be loaded beyond
  116. * kernel image and might not even be addressable by early boot page tables.
  117. * (kexec on panic case). Hence copy out the parameters before initializing
  118. * page tables.
  119. */
  120. movl $pa(boot_params),%edi
  121. movl $(PARAM_SIZE/4),%ecx
  122. cld
  123. rep
  124. movsl
  125. movl pa(boot_params) + NEW_CL_POINTER,%esi
  126. andl %esi,%esi
  127. jz 1f # No command line
  128. movl $pa(boot_command_line),%edi
  129. movl $(COMMAND_LINE_SIZE/4),%ecx
  130. rep
  131. movsl
  132. 1:
  133. #ifdef CONFIG_OLPC
  134. /* save OFW's pgdir table for later use when calling into OFW */
  135. movl %cr3, %eax
  136. movl %eax, pa(olpc_ofw_pgd)
  137. #endif
  138. #ifdef CONFIG_MICROCODE_EARLY
  139. /* Early load ucode on BSP. */
  140. call load_ucode_bsp
  141. #endif
  142. /*
  143. * Initialize page tables. This creates a PDE and a set of page
  144. * tables, which are located immediately beyond __brk_base. The variable
  145. * _brk_end is set up to point to the first "safe" location.
  146. * Mappings are created both at virtual address 0 (identity mapping)
  147. * and PAGE_OFFSET for up to _end.
  148. */
  149. #ifdef CONFIG_X86_PAE
  150. /*
  151. * In PAE mode initial_page_table is statically defined to contain
  152. * enough entries to cover the VMSPLIT option (that is the top 1, 2 or 3
  153. * entries). The identity mapping is handled by pointing two PGD entries
  154. * to the first kernel PMD.
  155. *
  156. * Note the upper half of each PMD or PTE are always zero at this stage.
  157. */
  158. #define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
  159. xorl %ebx,%ebx /* %ebx is kept at zero */
  160. movl $pa(__brk_base), %edi
  161. movl $pa(initial_pg_pmd), %edx
  162. movl $PTE_IDENT_ATTR, %eax
  163. 10:
  164. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
  165. movl %ecx,(%edx) /* Store PMD entry */
  166. /* Upper half already zero */
  167. addl $8,%edx
  168. movl $512,%ecx
  169. 11:
  170. stosl
  171. xchgl %eax,%ebx
  172. stosl
  173. xchgl %eax,%ebx
  174. addl $0x1000,%eax
  175. loop 11b
  176. /*
  177. * End condition: we must map up to the end + MAPPING_BEYOND_END.
  178. */
  179. movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
  180. cmpl %ebp,%eax
  181. jb 10b
  182. 1:
  183. addl $__PAGE_OFFSET, %edi
  184. movl %edi, pa(_brk_end)
  185. shrl $12, %eax
  186. movl %eax, pa(max_pfn_mapped)
  187. /* Do early initialization of the fixmap area */
  188. movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
  189. movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
  190. #else /* Not PAE */
  191. page_pde_offset = (__PAGE_OFFSET >> 20);
  192. movl $pa(__brk_base), %edi
  193. movl $pa(initial_page_table), %edx
  194. movl $PTE_IDENT_ATTR, %eax
  195. 10:
  196. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
  197. movl %ecx,(%edx) /* Store identity PDE entry */
  198. movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */
  199. addl $4,%edx
  200. movl $1024, %ecx
  201. 11:
  202. stosl
  203. addl $0x1000,%eax
  204. loop 11b
  205. /*
  206. * End condition: we must map up to the end + MAPPING_BEYOND_END.
  207. */
  208. movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
  209. cmpl %ebp,%eax
  210. jb 10b
  211. addl $__PAGE_OFFSET, %edi
  212. movl %edi, pa(_brk_end)
  213. shrl $12, %eax
  214. movl %eax, pa(max_pfn_mapped)
  215. /* Do early initialization of the fixmap area */
  216. movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
  217. movl %eax,pa(initial_page_table+0xffc)
  218. #endif
  219. #ifdef CONFIG_PARAVIRT
  220. /* This is can only trip for a broken bootloader... */
  221. cmpw $0x207, pa(boot_params + BP_version)
  222. jb default_entry
  223. /* Paravirt-compatible boot parameters. Look to see what architecture
  224. we're booting under. */
  225. movl pa(boot_params + BP_hardware_subarch), %eax
  226. cmpl $num_subarch_entries, %eax
  227. jae bad_subarch
  228. movl pa(subarch_entries)(,%eax,4), %eax
  229. subl $__PAGE_OFFSET, %eax
  230. jmp *%eax
  231. bad_subarch:
  232. WEAK(lguest_entry)
  233. WEAK(xen_entry)
  234. /* Unknown implementation; there's really
  235. nothing we can do at this point. */
  236. ud2a
  237. __INITDATA
  238. subarch_entries:
  239. .long default_entry /* normal x86/PC */
  240. .long lguest_entry /* lguest hypervisor */
  241. .long xen_entry /* Xen hypervisor */
  242. .long default_entry /* Moorestown MID */
  243. num_subarch_entries = (. - subarch_entries) / 4
  244. .previous
  245. #else
  246. jmp default_entry
  247. #endif /* CONFIG_PARAVIRT */
  248. #ifdef CONFIG_HOTPLUG_CPU
  249. /*
  250. * Boot CPU0 entry point. It's called from play_dead(). Everything has been set
  251. * up already except stack. We just set up stack here. Then call
  252. * start_secondary().
  253. */
  254. ENTRY(start_cpu0)
  255. movl stack_start, %ecx
  256. movl %ecx, %esp
  257. jmp *(initial_code)
  258. ENDPROC(start_cpu0)
  259. #endif
  260. /*
  261. * Non-boot CPU entry point; entered from trampoline.S
  262. * We can't lgdt here, because lgdt itself uses a data segment, but
  263. * we know the trampoline has already loaded the boot_gdt for us.
  264. *
  265. * If cpu hotplug is not supported then this code can go in init section
  266. * which will be freed later
  267. */
  268. ENTRY(startup_32_smp)
  269. cld
  270. movl $(__BOOT_DS),%eax
  271. movl %eax,%ds
  272. movl %eax,%es
  273. movl %eax,%fs
  274. movl %eax,%gs
  275. movl pa(stack_start),%ecx
  276. movl %eax,%ss
  277. leal -__PAGE_OFFSET(%ecx),%esp
  278. #ifdef CONFIG_MICROCODE_EARLY
  279. /* Early load ucode on AP. */
  280. call load_ucode_ap
  281. #endif
  282. default_entry:
  283. #define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
  284. X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
  285. X86_CR0_PG)
  286. movl $(CR0_STATE & ~X86_CR0_PG),%eax
  287. movl %eax,%cr0
  288. /*
  289. * We want to start out with EFLAGS unambiguously cleared. Some BIOSes leave
  290. * bits like NT set. This would confuse the debugger if this code is traced. So
  291. * initialize them properly now before switching to protected mode. That means
  292. * DF in particular (even though we have cleared it earlier after copying the
  293. * command line) because GCC expects it.
  294. */
  295. pushl $0
  296. popfl
  297. /*
  298. * New page tables may be in 4Mbyte page mode and may be using the global pages.
  299. *
  300. * NOTE! If we are on a 486 we may have no cr4 at all! Specifically, cr4 exists
  301. * if and only if CPUID exists and has flags other than the FPU flag set.
  302. */
  303. movl $-1,pa(X86_CPUID) # preset CPUID level
  304. movl $X86_EFLAGS_ID,%ecx
  305. pushl %ecx
  306. popfl # set EFLAGS=ID
  307. pushfl
  308. popl %eax # get EFLAGS
  309. testl $X86_EFLAGS_ID,%eax # did EFLAGS.ID remained set?
  310. jz enable_paging # hw disallowed setting of ID bit
  311. # which means no CPUID and no CR4
  312. xorl %eax,%eax
  313. cpuid
  314. movl %eax,pa(X86_CPUID) # save largest std CPUID function
  315. movl $1,%eax
  316. cpuid
  317. andl $~1,%edx # Ignore CPUID.FPU
  318. jz enable_paging # No flags or only CPUID.FPU = no CR4
  319. movl pa(mmu_cr4_features),%eax
  320. movl %eax,%cr4
  321. testb $X86_CR4_PAE, %al # check if PAE is enabled
  322. jz enable_paging
  323. /* Check if extended functions are implemented */
  324. movl $0x80000000, %eax
  325. cpuid
  326. /* Value must be in the range 0x80000001 to 0x8000ffff */
  327. subl $0x80000001, %eax
  328. cmpl $(0x8000ffff-0x80000001), %eax
  329. ja enable_paging
  330. /* Clear bogus XD_DISABLE bits */
  331. call verify_cpu
  332. mov $0x80000001, %eax
  333. cpuid
  334. /* Execute Disable bit supported? */
  335. btl $(X86_FEATURE_NX & 31), %edx
  336. jnc enable_paging
  337. /* Setup EFER (Extended Feature Enable Register) */
  338. movl $MSR_EFER, %ecx
  339. rdmsr
  340. btsl $_EFER_NX, %eax
  341. /* Make changes effective */
  342. wrmsr
  343. enable_paging:
  344. /*
  345. * Enable paging
  346. */
  347. movl $pa(initial_page_table), %eax
  348. movl %eax,%cr3 /* set the page table pointer.. */
  349. movl $CR0_STATE,%eax
  350. movl %eax,%cr0 /* ..and set paging (PG) bit */
  351. ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */
  352. 1:
  353. /* Shift the stack pointer to a virtual address */
  354. addl $__PAGE_OFFSET, %esp
  355. /*
  356. * start system 32-bit setup. We need to re-do some of the things done
  357. * in 16-bit mode for the "real" operations.
  358. */
  359. movl setup_once_ref,%eax
  360. andl %eax,%eax
  361. jz 1f # Did we do this already?
  362. call *%eax
  363. 1:
  364. /*
  365. * Check if it is 486
  366. */
  367. movb $4,X86 # at least 486
  368. cmpl $-1,X86_CPUID
  369. je is486
  370. /* get vendor info */
  371. xorl %eax,%eax # call CPUID with 0 -> return vendor ID
  372. cpuid
  373. movl %eax,X86_CPUID # save CPUID level
  374. movl %ebx,X86_VENDOR_ID # lo 4 chars
  375. movl %edx,X86_VENDOR_ID+4 # next 4 chars
  376. movl %ecx,X86_VENDOR_ID+8 # last 4 chars
  377. orl %eax,%eax # do we have processor info as well?
  378. je is486
  379. movl $1,%eax # Use the CPUID instruction to get CPU type
  380. cpuid
  381. movb %al,%cl # save reg for future use
  382. andb $0x0f,%ah # mask processor family
  383. movb %ah,X86
  384. andb $0xf0,%al # mask model
  385. shrb $4,%al
  386. movb %al,X86_MODEL
  387. andb $0x0f,%cl # mask mask revision
  388. movb %cl,X86_MASK
  389. movl %edx,X86_CAPABILITY
  390. is486:
  391. movl $0x50022,%ecx # set AM, WP, NE and MP
  392. movl %cr0,%eax
  393. andl $0x80000011,%eax # Save PG,PE,ET
  394. orl %ecx,%eax
  395. movl %eax,%cr0
  396. lgdt early_gdt_descr
  397. lidt idt_descr
  398. ljmp $(__KERNEL_CS),$1f
  399. 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
  400. movl %eax,%ss # after changing gdt.
  401. movl $(__USER_DS),%eax # DS/ES contains default USER segment
  402. movl %eax,%ds
  403. movl %eax,%es
  404. movl $(__KERNEL_PERCPU), %eax
  405. movl %eax,%fs # set this cpu's percpu
  406. movl $(__KERNEL_STACK_CANARY),%eax
  407. movl %eax,%gs
  408. xorl %eax,%eax # Clear LDT
  409. lldt %ax
  410. pushl $0 # fake return address for unwinder
  411. jmp *(initial_code)
  412. #include "verify_cpu.S"
  413. /*
  414. * setup_once
  415. *
  416. * The setup work we only want to run on the BSP.
  417. *
  418. * Warning: %esi is live across this function.
  419. */
  420. __INIT
  421. setup_once:
  422. /*
  423. * Set up a idt with 256 interrupt gates that push zero if there
  424. * is no error code and then jump to early_idt_handler_common.
  425. * It doesn't actually load the idt - that needs to be done on
  426. * each CPU. Interrupts are enabled elsewhere, when we can be
  427. * relatively sure everything is ok.
  428. */
  429. movl $idt_table,%edi
  430. movl $early_idt_handler_array,%eax
  431. movl $NUM_EXCEPTION_VECTORS,%ecx
  432. 1:
  433. movl %eax,(%edi)
  434. movl %eax,4(%edi)
  435. /* interrupt gate, dpl=0, present */
  436. movl $(0x8E000000 + __KERNEL_CS),2(%edi)
  437. addl $EARLY_IDT_HANDLER_SIZE,%eax
  438. addl $8,%edi
  439. loop 1b
  440. movl $256 - NUM_EXCEPTION_VECTORS,%ecx
  441. movl $ignore_int,%edx
  442. movl $(__KERNEL_CS << 16),%eax
  443. movw %dx,%ax /* selector = 0x0010 = cs */
  444. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  445. 2:
  446. movl %eax,(%edi)
  447. movl %edx,4(%edi)
  448. addl $8,%edi
  449. loop 2b
  450. #ifdef CONFIG_CC_STACKPROTECTOR
  451. /*
  452. * Configure the stack canary. The linker can't handle this by
  453. * relocation. Manually set base address in stack canary
  454. * segment descriptor.
  455. */
  456. movl $gdt_page,%eax
  457. movl $stack_canary,%ecx
  458. movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
  459. shrl $16, %ecx
  460. movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
  461. movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax)
  462. #endif
  463. andl $0,setup_once_ref /* Once is enough, thanks */
  464. ret
  465. ENTRY(early_idt_handler_array)
  466. # 36(%esp) %eflags
  467. # 32(%esp) %cs
  468. # 28(%esp) %eip
  469. # 24(%rsp) error code
  470. i = 0
  471. .rept NUM_EXCEPTION_VECTORS
  472. .ifeq (EXCEPTION_ERRCODE_MASK >> i) & 1
  473. pushl $0 # Dummy error code, to make stack frame uniform
  474. .endif
  475. pushl $i # 20(%esp) Vector number
  476. jmp early_idt_handler_common
  477. i = i + 1
  478. .fill early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc
  479. .endr
  480. ENDPROC(early_idt_handler_array)
  481. early_idt_handler_common:
  482. /*
  483. * The stack is the hardware frame, an error code or zero, and the
  484. * vector number.
  485. */
  486. cld
  487. cmpl $2,(%esp) # X86_TRAP_NMI
  488. je is_nmi # Ignore NMI
  489. cmpl $2,%ss:early_recursion_flag
  490. je hlt_loop
  491. incl %ss:early_recursion_flag
  492. push %eax # 16(%esp)
  493. push %ecx # 12(%esp)
  494. push %edx # 8(%esp)
  495. push %ds # 4(%esp)
  496. push %es # 0(%esp)
  497. movl $(__KERNEL_DS),%eax
  498. movl %eax,%ds
  499. movl %eax,%es
  500. cmpl $(__KERNEL_CS),32(%esp)
  501. jne 10f
  502. leal 28(%esp),%eax # Pointer to %eip
  503. call early_fixup_exception
  504. andl %eax,%eax
  505. jnz ex_entry /* found an exception entry */
  506. 10:
  507. #ifdef CONFIG_PRINTK
  508. xorl %eax,%eax
  509. movw %ax,2(%esp) /* clean up the segment values on some cpus */
  510. movw %ax,6(%esp)
  511. movw %ax,34(%esp)
  512. leal 40(%esp),%eax
  513. pushl %eax /* %esp before the exception */
  514. pushl %ebx
  515. pushl %ebp
  516. pushl %esi
  517. pushl %edi
  518. movl %cr2,%eax
  519. pushl %eax
  520. pushl (20+6*4)(%esp) /* trapno */
  521. pushl $fault_msg
  522. call printk
  523. #endif
  524. call dump_stack
  525. hlt_loop:
  526. hlt
  527. jmp hlt_loop
  528. ex_entry:
  529. pop %es
  530. pop %ds
  531. pop %edx
  532. pop %ecx
  533. pop %eax
  534. decl %ss:early_recursion_flag
  535. is_nmi:
  536. addl $8,%esp /* drop vector number and error code */
  537. iret
  538. ENDPROC(early_idt_handler_common)
  539. /* This is the default interrupt "handler" :-) */
  540. ALIGN
  541. ignore_int:
  542. cld
  543. #ifdef CONFIG_PRINTK
  544. pushl %eax
  545. pushl %ecx
  546. pushl %edx
  547. pushl %es
  548. pushl %ds
  549. movl $(__KERNEL_DS),%eax
  550. movl %eax,%ds
  551. movl %eax,%es
  552. cmpl $2,early_recursion_flag
  553. je hlt_loop
  554. incl early_recursion_flag
  555. pushl 16(%esp)
  556. pushl 24(%esp)
  557. pushl 32(%esp)
  558. pushl 40(%esp)
  559. pushl $int_msg
  560. call printk
  561. call dump_stack
  562. addl $(5*4),%esp
  563. popl %ds
  564. popl %es
  565. popl %edx
  566. popl %ecx
  567. popl %eax
  568. #endif
  569. iret
  570. ENDPROC(ignore_int)
  571. __INITDATA
  572. .align 4
  573. early_recursion_flag:
  574. .long 0
  575. __REFDATA
  576. .align 4
  577. ENTRY(initial_code)
  578. .long i386_start_kernel
  579. ENTRY(setup_once_ref)
  580. .long setup_once
  581. /*
  582. * BSS section
  583. */
  584. __PAGE_ALIGNED_BSS
  585. .align PAGE_SIZE
  586. #ifdef CONFIG_X86_PAE
  587. initial_pg_pmd:
  588. .fill 1024*KPMDS,4,0
  589. #else
  590. ENTRY(initial_page_table)
  591. .fill 1024,4,0
  592. #endif
  593. initial_pg_fixmap:
  594. .fill 1024,4,0
  595. ENTRY(empty_zero_page)
  596. .fill 4096,1,0
  597. ENTRY(swapper_pg_dir)
  598. .fill 1024,4,0
  599. /*
  600. * This starts the data section.
  601. */
  602. #ifdef CONFIG_X86_PAE
  603. __PAGE_ALIGNED_DATA
  604. /* Page-aligned for the benefit of paravirt? */
  605. .align PAGE_SIZE
  606. ENTRY(initial_page_table)
  607. .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
  608. # if KPMDS == 3
  609. .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
  610. .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  611. .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x2000),0
  612. # elif KPMDS == 2
  613. .long 0,0
  614. .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
  615. .long pa(initial_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  616. # elif KPMDS == 1
  617. .long 0,0
  618. .long 0,0
  619. .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0
  620. # else
  621. # error "Kernel PMDs should be 1, 2 or 3"
  622. # endif
  623. .align PAGE_SIZE /* needs to be page-sized too */
  624. #endif
  625. .data
  626. .balign 4
  627. ENTRY(stack_start)
  628. .long init_thread_union+THREAD_SIZE
  629. __INITRODATA
  630. int_msg:
  631. .asciz "Unknown interrupt or fault at: %p %p %p\n"
  632. fault_msg:
  633. /* fault info: */
  634. .ascii "BUG: Int %d: CR2 %p\n"
  635. /* regs pushed in early_idt_handler: */
  636. .ascii " EDI %p ESI %p EBP %p EBX %p\n"
  637. .ascii " ESP %p ES %p DS %p\n"
  638. .ascii " EDX %p ECX %p EAX %p\n"
  639. /* fault frame: */
  640. .ascii " vec %p err %p EIP %p CS %p flg %p\n"
  641. .ascii "Stack: %p %p %p %p %p %p %p %p\n"
  642. .ascii " %p %p %p %p %p %p %p %p\n"
  643. .asciz " %p %p %p %p %p %p %p %p\n"
  644. #include "../../x86/xen/xen-head.S"
  645. /*
  646. * The IDT and GDT 'descriptors' are a strange 48-bit object
  647. * only used by the lidt and lgdt instructions. They are not
  648. * like usual segment descriptors - they consist of a 16-bit
  649. * segment size, and 32-bit linear address value:
  650. */
  651. .data
  652. .globl boot_gdt_descr
  653. .globl idt_descr
  654. ALIGN
  655. # early boot GDT descriptor (must use 1:1 address mapping)
  656. .word 0 # 32 bit align gdt_desc.address
  657. boot_gdt_descr:
  658. .word __BOOT_DS+7
  659. .long boot_gdt - __PAGE_OFFSET
  660. .word 0 # 32-bit align idt_desc.address
  661. idt_descr:
  662. .word IDT_ENTRIES*8-1 # idt contains 256 entries
  663. .long idt_table
  664. # boot GDT descriptor (later on used by CPU#0):
  665. .word 0 # 32 bit align gdt_desc.address
  666. ENTRY(early_gdt_descr)
  667. .word GDT_ENTRIES*8-1
  668. .long gdt_page /* Overwritten for secondary CPUs */
  669. /*
  670. * The boot_gdt must mirror the equivalent in setup.S and is
  671. * used only for booting.
  672. */
  673. .align L1_CACHE_BYTES
  674. ENTRY(boot_gdt)
  675. .fill GDT_ENTRY_BOOT_CS,8,0
  676. .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
  677. .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */