head_32.S 17 KB

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