head_32.S 17 KB

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