head_32.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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 swapper_pg_dir is statically defined to contain enough
  166. * 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
  168. * entries to the first kernel PMD.
  169. *
  170. * Note the upper half of each PMD or PTE are always zero at
  171. * this stage.
  172. */
  173. #define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
  174. xorl %ebx,%ebx /* %ebx is kept at zero */
  175. movl $pa(__brk_base), %edi
  176. movl $pa(swapper_pg_pmd), %edx
  177. movl $PTE_IDENT_ATTR, %eax
  178. 10:
  179. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
  180. movl %ecx,(%edx) /* Store PMD entry */
  181. /* Upper half already zero */
  182. addl $8,%edx
  183. movl $512,%ecx
  184. 11:
  185. stosl
  186. xchgl %eax,%ebx
  187. stosl
  188. xchgl %eax,%ebx
  189. addl $0x1000,%eax
  190. loop 11b
  191. /*
  192. * End condition: we must map up to the end + MAPPING_BEYOND_END.
  193. */
  194. movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
  195. cmpl %ebp,%eax
  196. jb 10b
  197. 1:
  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(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
  204. movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8)
  205. #else /* Not PAE */
  206. page_pde_offset = (__PAGE_OFFSET >> 20);
  207. movl $pa(__brk_base), %edi
  208. movl $pa(swapper_pg_dir), %edx
  209. movl $PTE_IDENT_ATTR, %eax
  210. 10:
  211. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
  212. movl %ecx,(%edx) /* Store identity PDE entry */
  213. movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */
  214. addl $4,%edx
  215. movl $1024, %ecx
  216. 11:
  217. stosl
  218. addl $0x1000,%eax
  219. loop 11b
  220. /*
  221. * End condition: we must map up to the end + MAPPING_BEYOND_END.
  222. */
  223. movl $pa(_end) + MAPPING_BEYOND_END + PTE_IDENT_ATTR, %ebp
  224. cmpl %ebp,%eax
  225. jb 10b
  226. addl $__PAGE_OFFSET, %edi
  227. movl %edi, pa(_brk_end)
  228. shrl $12, %eax
  229. movl %eax, pa(max_pfn_mapped)
  230. /* Do early initialization of the fixmap area */
  231. movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
  232. movl %eax,pa(swapper_pg_dir+0xffc)
  233. #endif
  234. jmp 3f
  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. 3:
  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. mov $0x80000001, %eax
  285. cpuid
  286. /* Execute Disable bit supported? */
  287. btl $(X86_FEATURE_NX & 31), %edx
  288. jnc 6f
  289. /* Setup EFER (Extended Feature Enable Register) */
  290. movl $MSR_EFER, %ecx
  291. rdmsr
  292. btsl $_EFER_NX, %eax
  293. /* Make changes effective */
  294. wrmsr
  295. 6:
  296. /*
  297. * Enable paging
  298. */
  299. movl pa(initial_page_table), %eax
  300. movl %eax,%cr3 /* set the page table pointer.. */
  301. movl %cr0,%eax
  302. orl $X86_CR0_PG,%eax
  303. movl %eax,%cr0 /* ..and set paging (PG) bit */
  304. ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */
  305. 1:
  306. /* Set up the stack pointer */
  307. lss stack_start,%esp
  308. /*
  309. * Initialize eflags. Some BIOS's leave bits like NT set. This would
  310. * confuse the debugger if this code is traced.
  311. * XXX - best to initialize before switching to protected mode.
  312. */
  313. pushl $0
  314. popfl
  315. #ifdef CONFIG_SMP
  316. cmpb $0, ready
  317. jz 1f /* Initial CPU cleans BSS */
  318. jmp checkCPUtype
  319. 1:
  320. #endif /* CONFIG_SMP */
  321. /*
  322. * start system 32-bit setup. We need to re-do some of the things done
  323. * in 16-bit mode for the "real" operations.
  324. */
  325. call setup_idt
  326. checkCPUtype:
  327. movl $-1,X86_CPUID # -1 for no CPUID initially
  328. /* check if it is 486 or 386. */
  329. /*
  330. * XXX - this does a lot of unnecessary setup. Alignment checks don't
  331. * apply at our cpl of 0 and the stack ought to be aligned already, and
  332. * we don't need to preserve eflags.
  333. */
  334. movb $3,X86 # at least 386
  335. pushfl # push EFLAGS
  336. popl %eax # get EFLAGS
  337. movl %eax,%ecx # save original EFLAGS
  338. xorl $0x240000,%eax # flip AC and ID bits in EFLAGS
  339. pushl %eax # copy to EFLAGS
  340. popfl # set EFLAGS
  341. pushfl # get new EFLAGS
  342. popl %eax # put it in eax
  343. xorl %ecx,%eax # change in flags
  344. pushl %ecx # restore original EFLAGS
  345. popfl
  346. testl $0x40000,%eax # check if AC bit changed
  347. je is386
  348. movb $4,X86 # at least 486
  349. testl $0x200000,%eax # check if ID bit changed
  350. je is486
  351. /* get vendor info */
  352. xorl %eax,%eax # call CPUID with 0 -> return vendor ID
  353. cpuid
  354. movl %eax,X86_CPUID # save CPUID level
  355. movl %ebx,X86_VENDOR_ID # lo 4 chars
  356. movl %edx,X86_VENDOR_ID+4 # next 4 chars
  357. movl %ecx,X86_VENDOR_ID+8 # last 4 chars
  358. orl %eax,%eax # do we have processor info as well?
  359. je is486
  360. movl $1,%eax # Use the CPUID instruction to get CPU type
  361. cpuid
  362. movb %al,%cl # save reg for future use
  363. andb $0x0f,%ah # mask processor family
  364. movb %ah,X86
  365. andb $0xf0,%al # mask model
  366. shrb $4,%al
  367. movb %al,X86_MODEL
  368. andb $0x0f,%cl # mask mask revision
  369. movb %cl,X86_MASK
  370. movl %edx,X86_CAPABILITY
  371. is486: movl $0x50022,%ecx # set AM, WP, NE and MP
  372. jmp 2f
  373. is386: movl $2,%ecx # set MP
  374. 2: movl %cr0,%eax
  375. andl $0x80000011,%eax # Save PG,PE,ET
  376. orl %ecx,%eax
  377. movl %eax,%cr0
  378. call check_x87
  379. lgdt early_gdt_descr
  380. lidt idt_descr
  381. ljmp $(__KERNEL_CS),$1f
  382. 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
  383. movl %eax,%ss # after changing gdt.
  384. movl $(__USER_DS),%eax # DS/ES contains default USER segment
  385. movl %eax,%ds
  386. movl %eax,%es
  387. movl $(__KERNEL_PERCPU), %eax
  388. movl %eax,%fs # set this cpu's percpu
  389. #ifdef CONFIG_CC_STACKPROTECTOR
  390. /*
  391. * The linker can't handle this by relocation. Manually set
  392. * base address in stack canary segment descriptor.
  393. */
  394. cmpb $0,ready
  395. jne 1f
  396. movl $gdt_page,%eax
  397. movl $stack_canary,%ecx
  398. movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
  399. shrl $16, %ecx
  400. movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
  401. movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax)
  402. 1:
  403. #endif
  404. movl $(__KERNEL_STACK_CANARY),%eax
  405. movl %eax,%gs
  406. xorl %eax,%eax # Clear LDT
  407. lldt %ax
  408. cld # gcc2 wants the direction flag cleared at all times
  409. pushl $0 # fake return address for unwinder
  410. #ifdef CONFIG_SMP
  411. movb ready, %cl
  412. movb $1, ready
  413. cmpb $0,%cl # the first CPU calls start_kernel
  414. je 1f
  415. movl (stack_start), %esp
  416. 1:
  417. #endif /* CONFIG_SMP */
  418. jmp *(initial_code)
  419. /*
  420. * We depend on ET to be correct. This checks for 287/387.
  421. */
  422. check_x87:
  423. movb $0,X86_HARD_MATH
  424. clts
  425. fninit
  426. fstsw %ax
  427. cmpb $0,%al
  428. je 1f
  429. movl %cr0,%eax /* no coprocessor: have to set bits */
  430. xorl $4,%eax /* set EM */
  431. movl %eax,%cr0
  432. ret
  433. ALIGN
  434. 1: movb $1,X86_HARD_MATH
  435. .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */
  436. ret
  437. /*
  438. * setup_idt
  439. *
  440. * sets up a idt with 256 entries pointing to
  441. * ignore_int, interrupt gates. It doesn't actually load
  442. * idt - that can be done only after paging has been enabled
  443. * and the kernel moved to PAGE_OFFSET. Interrupts
  444. * are enabled elsewhere, when we can be relatively
  445. * sure everything is ok.
  446. *
  447. * Warning: %esi is live across this function.
  448. */
  449. setup_idt:
  450. lea ignore_int,%edx
  451. movl $(__KERNEL_CS << 16),%eax
  452. movw %dx,%ax /* selector = 0x0010 = cs */
  453. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  454. lea idt_table,%edi
  455. mov $256,%ecx
  456. rp_sidt:
  457. movl %eax,(%edi)
  458. movl %edx,4(%edi)
  459. addl $8,%edi
  460. dec %ecx
  461. jne rp_sidt
  462. .macro set_early_handler handler,trapno
  463. lea \handler,%edx
  464. movl $(__KERNEL_CS << 16),%eax
  465. movw %dx,%ax
  466. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  467. lea idt_table,%edi
  468. movl %eax,8*\trapno(%edi)
  469. movl %edx,8*\trapno+4(%edi)
  470. .endm
  471. set_early_handler handler=early_divide_err,trapno=0
  472. set_early_handler handler=early_illegal_opcode,trapno=6
  473. set_early_handler handler=early_protection_fault,trapno=13
  474. set_early_handler handler=early_page_fault,trapno=14
  475. ret
  476. early_divide_err:
  477. xor %edx,%edx
  478. pushl $0 /* fake errcode */
  479. jmp early_fault
  480. early_illegal_opcode:
  481. movl $6,%edx
  482. pushl $0 /* fake errcode */
  483. jmp early_fault
  484. early_protection_fault:
  485. movl $13,%edx
  486. jmp early_fault
  487. early_page_fault:
  488. movl $14,%edx
  489. jmp early_fault
  490. early_fault:
  491. cld
  492. #ifdef CONFIG_PRINTK
  493. pusha
  494. movl $(__KERNEL_DS),%eax
  495. movl %eax,%ds
  496. movl %eax,%es
  497. cmpl $2,early_recursion_flag
  498. je hlt_loop
  499. incl early_recursion_flag
  500. movl %cr2,%eax
  501. pushl %eax
  502. pushl %edx /* trapno */
  503. pushl $fault_msg
  504. call printk
  505. #endif
  506. call dump_stack
  507. hlt_loop:
  508. hlt
  509. jmp hlt_loop
  510. /* This is the default interrupt "handler" :-) */
  511. ALIGN
  512. ignore_int:
  513. cld
  514. #ifdef CONFIG_PRINTK
  515. pushl %eax
  516. pushl %ecx
  517. pushl %edx
  518. pushl %es
  519. pushl %ds
  520. movl $(__KERNEL_DS),%eax
  521. movl %eax,%ds
  522. movl %eax,%es
  523. cmpl $2,early_recursion_flag
  524. je hlt_loop
  525. incl early_recursion_flag
  526. pushl 16(%esp)
  527. pushl 24(%esp)
  528. pushl 32(%esp)
  529. pushl 40(%esp)
  530. pushl $int_msg
  531. call printk
  532. call dump_stack
  533. addl $(5*4),%esp
  534. popl %ds
  535. popl %es
  536. popl %edx
  537. popl %ecx
  538. popl %eax
  539. #endif
  540. iret
  541. __REFDATA
  542. .align 4
  543. ENTRY(initial_code)
  544. .long i386_start_kernel
  545. ENTRY(initial_page_table)
  546. .long pa(swapper_pg_dir)
  547. /*
  548. * BSS section
  549. */
  550. __PAGE_ALIGNED_BSS
  551. .align PAGE_SIZE_asm
  552. #ifdef CONFIG_X86_PAE
  553. swapper_pg_pmd:
  554. .fill 1024*KPMDS,4,0
  555. #else
  556. ENTRY(swapper_pg_dir)
  557. .fill 1024,4,0
  558. #endif
  559. swapper_pg_fixmap:
  560. .fill 1024,4,0
  561. #ifdef CONFIG_X86_TRAMPOLINE
  562. ENTRY(trampoline_pg_dir)
  563. .fill 1024,4,0
  564. #endif
  565. ENTRY(empty_zero_page)
  566. .fill 4096,1,0
  567. /*
  568. * This starts the data section.
  569. */
  570. #ifdef CONFIG_X86_PAE
  571. __PAGE_ALIGNED_DATA
  572. /* Page-aligned for the benefit of paravirt? */
  573. .align PAGE_SIZE_asm
  574. ENTRY(swapper_pg_dir)
  575. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
  576. # if KPMDS == 3
  577. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  578. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  579. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0
  580. # elif KPMDS == 2
  581. .long 0,0
  582. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  583. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  584. # elif KPMDS == 1
  585. .long 0,0
  586. .long 0,0
  587. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  588. # else
  589. # error "Kernel PMDs should be 1, 2 or 3"
  590. # endif
  591. .align PAGE_SIZE_asm /* needs to be page-sized too */
  592. #endif
  593. .data
  594. ENTRY(stack_start)
  595. .long init_thread_union+THREAD_SIZE
  596. .long __BOOT_DS
  597. ready: .byte 0
  598. early_recursion_flag:
  599. .long 0
  600. int_msg:
  601. .asciz "Unknown interrupt or fault at: %p %p %p\n"
  602. fault_msg:
  603. /* fault info: */
  604. .ascii "BUG: Int %d: CR2 %p\n"
  605. /* pusha regs: */
  606. .ascii " EDI %p ESI %p EBP %p ESP %p\n"
  607. .ascii " EBX %p EDX %p ECX %p EAX %p\n"
  608. /* fault frame: */
  609. .ascii " err %p EIP %p CS %p flg %p\n"
  610. .ascii "Stack: %p %p %p %p %p %p %p %p\n"
  611. .ascii " %p %p %p %p %p %p %p %p\n"
  612. .asciz " %p %p %p %p %p %p %p %p\n"
  613. #include "../../x86/xen/xen-head.S"
  614. /*
  615. * The IDT and GDT 'descriptors' are a strange 48-bit object
  616. * only used by the lidt and lgdt instructions. They are not
  617. * like usual segment descriptors - they consist of a 16-bit
  618. * segment size, and 32-bit linear address value:
  619. */
  620. .globl boot_gdt_descr
  621. .globl idt_descr
  622. ALIGN
  623. # early boot GDT descriptor (must use 1:1 address mapping)
  624. .word 0 # 32 bit align gdt_desc.address
  625. boot_gdt_descr:
  626. .word __BOOT_DS+7
  627. .long boot_gdt - __PAGE_OFFSET
  628. .word 0 # 32-bit align idt_desc.address
  629. idt_descr:
  630. .word IDT_ENTRIES*8-1 # idt contains 256 entries
  631. .long idt_table
  632. # boot GDT descriptor (later on used by CPU#0):
  633. .word 0 # 32 bit align gdt_desc.address
  634. ENTRY(early_gdt_descr)
  635. .word GDT_ENTRIES*8-1
  636. .long gdt_page /* Overwritten for secondary CPUs */
  637. /*
  638. * The boot_gdt must mirror the equivalent in setup.S and is
  639. * used only for booting.
  640. */
  641. .align L1_CACHE_BYTES
  642. ENTRY(boot_gdt)
  643. .fill GDT_ENTRY_BOOT_CS,8,0
  644. .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
  645. .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */