head_32.S 18 KB

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