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