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/desc.h>
  16. #include <asm/cache.h>
  17. #include <asm/thread_info.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/setup.h>
  20. #include <asm/processor-flags.h>
  21. #include <asm/percpu.h>
  22. /* Physical address */
  23. #define pa(X) ((X) - __PAGE_OFFSET)
  24. /*
  25. * References to members of the new_cpu_data structure.
  26. */
  27. #define X86 new_cpu_data+CPUINFO_x86
  28. #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor
  29. #define X86_MODEL new_cpu_data+CPUINFO_x86_model
  30. #define X86_MASK new_cpu_data+CPUINFO_x86_mask
  31. #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math
  32. #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level
  33. #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability
  34. #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id
  35. /*
  36. * This is how much memory *in addition to the memory covered up to
  37. * and including _end* we need mapped initially.
  38. * We need:
  39. * - one bit for each possible page, but only in low memory, which means
  40. * 2^32/4096/8 = 128K worst case (4G/4G split.)
  41. * - enough space to map all low memory, which means
  42. * (2^32/4096) / 1024 pages (worst case, non PAE)
  43. * (2^32/4096) / 512 + 4 pages (worst case for PAE)
  44. * - a few pages for allocator use before the kernel pagetable has
  45. * been set up
  46. *
  47. * Modulo rounding, each megabyte assigned here requires a kilobyte of
  48. * memory, which is currently unreclaimed.
  49. *
  50. * This should be a multiple of a page.
  51. */
  52. LOW_PAGES = (KERNEL_IMAGE_SIZE + PAGE_SIZE_asm - 1)>>PAGE_SHIFT
  53. /*
  54. * To preserve the DMA pool in PAGEALLOC kernels, we'll allocate
  55. * pagetables from above the 16MB DMA limit, so we'll have to set
  56. * up pagetables 16MB more (worst-case):
  57. */
  58. #ifdef CONFIG_DEBUG_PAGEALLOC
  59. LOW_PAGES = LOW_PAGES + 0x1000000
  60. #endif
  61. #if PTRS_PER_PMD > 1
  62. PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PMD) + PTRS_PER_PGD
  63. #else
  64. PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PGD)
  65. #endif
  66. BOOTBITMAP_SIZE = LOW_PAGES / 8
  67. ALLOCATOR_SLOP = 4
  68. INIT_MAP_BEYOND_END = BOOTBITMAP_SIZE + (PAGE_TABLE_SIZE + ALLOCATOR_SLOP)*PAGE_SIZE_asm
  69. RESERVE_BRK(pagetables, PAGE_TABLE_SIZE * PAGE_SIZE)
  70. /*
  71. * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
  72. * %esi points to the real-mode code as a 32-bit pointer.
  73. * CS and DS must be 4 GB flat segments, but we don't depend on
  74. * any particular GDT layout, because we load our own as soon as we
  75. * can.
  76. */
  77. .section .text.head,"ax",@progbits
  78. ENTRY(startup_32)
  79. /* test KEEP_SEGMENTS flag to see if the bootloader is asking
  80. us to not reload segments */
  81. testb $(1<<6), BP_loadflags(%esi)
  82. jnz 2f
  83. /*
  84. * Set segments to known values.
  85. */
  86. lgdt pa(boot_gdt_descr)
  87. movl $(__BOOT_DS),%eax
  88. movl %eax,%ds
  89. movl %eax,%es
  90. movl %eax,%fs
  91. movl %eax,%gs
  92. 2:
  93. /*
  94. * Clear BSS first so that there are no surprises...
  95. */
  96. cld
  97. xorl %eax,%eax
  98. movl $pa(__bss_start),%edi
  99. movl $pa(__bss_stop),%ecx
  100. subl %edi,%ecx
  101. shrl $2,%ecx
  102. rep ; stosl
  103. /*
  104. * Copy bootup parameters out of the way.
  105. * Note: %esi still has the pointer to the real-mode data.
  106. * With the kexec as boot loader, parameter segment might be loaded beyond
  107. * kernel image and might not even be addressable by early boot page tables.
  108. * (kexec on panic case). Hence copy out the parameters before initializing
  109. * page tables.
  110. */
  111. movl $pa(boot_params),%edi
  112. movl $(PARAM_SIZE/4),%ecx
  113. cld
  114. rep
  115. movsl
  116. movl pa(boot_params) + NEW_CL_POINTER,%esi
  117. andl %esi,%esi
  118. jz 1f # No comand line
  119. movl $pa(boot_command_line),%edi
  120. movl $(COMMAND_LINE_SIZE/4),%ecx
  121. rep
  122. movsl
  123. 1:
  124. #ifdef CONFIG_PARAVIRT
  125. /* This is can only trip for a broken bootloader... */
  126. cmpw $0x207, pa(boot_params + BP_version)
  127. jb default_entry
  128. /* Paravirt-compatible boot parameters. Look to see what architecture
  129. we're booting under. */
  130. movl pa(boot_params + BP_hardware_subarch), %eax
  131. cmpl $num_subarch_entries, %eax
  132. jae bad_subarch
  133. movl pa(subarch_entries)(,%eax,4), %eax
  134. subl $__PAGE_OFFSET, %eax
  135. jmp *%eax
  136. bad_subarch:
  137. WEAK(lguest_entry)
  138. WEAK(xen_entry)
  139. /* Unknown implementation; there's really
  140. nothing we can do at this point. */
  141. ud2a
  142. __INITDATA
  143. subarch_entries:
  144. .long default_entry /* normal x86/PC */
  145. .long lguest_entry /* lguest hypervisor */
  146. .long xen_entry /* Xen hypervisor */
  147. num_subarch_entries = (. - subarch_entries) / 4
  148. .previous
  149. #endif /* CONFIG_PARAVIRT */
  150. /*
  151. * Initialize page tables. This creates a PDE and a set of page
  152. * tables, which are located immediately beyond _end. The variable
  153. * _brk_end is set up to point to the first "safe" location.
  154. * Mappings are created both at virtual address 0 (identity mapping)
  155. * and PAGE_OFFSET for up to _end+sizeof(page tables)+INIT_MAP_BEYOND_END.
  156. *
  157. * Note that the stack is not yet set up!
  158. */
  159. default_entry:
  160. #ifdef CONFIG_X86_PAE
  161. /*
  162. * In PAE mode swapper_pg_dir is statically defined to contain enough
  163. * entries to cover the VMSPLIT option (that is the top 1, 2 or 3
  164. * entries). The identity mapping is handled by pointing two PGD
  165. * entries to the first kernel PMD.
  166. *
  167. * Note the upper half of each PMD or PTE are always zero at
  168. * this stage.
  169. */
  170. #define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
  171. xorl %ebx,%ebx /* %ebx is kept at zero */
  172. movl $pa(__brk_base), %edi
  173. movl $pa(swapper_pg_pmd), %edx
  174. movl $PTE_IDENT_ATTR, %eax
  175. 10:
  176. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PMD entry */
  177. movl %ecx,(%edx) /* Store PMD entry */
  178. /* Upper half already zero */
  179. addl $8,%edx
  180. movl $512,%ecx
  181. 11:
  182. stosl
  183. xchgl %eax,%ebx
  184. stosl
  185. xchgl %eax,%ebx
  186. addl $0x1000,%eax
  187. loop 11b
  188. /*
  189. * End condition: we must map up to and including INIT_MAP_BEYOND_END
  190. * bytes beyond the end of our own page tables.
  191. */
  192. leal (INIT_MAP_BEYOND_END+PTE_IDENT_ATTR)(%edi),%ebp
  193. cmpl %ebp,%eax
  194. jb 10b
  195. 1:
  196. addl $__PAGE_OFFSET, %edi
  197. movl %edi, pa(_brk_end)
  198. shrl $12, %eax
  199. movl %eax, pa(max_pfn_mapped)
  200. /* Do early initialization of the fixmap area */
  201. movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
  202. movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8)
  203. #else /* Not PAE */
  204. page_pde_offset = (__PAGE_OFFSET >> 20);
  205. movl $pa(__brk_base), %edi
  206. movl $pa(swapper_pg_dir), %edx
  207. movl $PTE_IDENT_ATTR, %eax
  208. 10:
  209. leal PDE_IDENT_ATTR(%edi),%ecx /* Create PDE entry */
  210. movl %ecx,(%edx) /* Store identity PDE entry */
  211. movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */
  212. addl $4,%edx
  213. movl $1024, %ecx
  214. 11:
  215. stosl
  216. addl $0x1000,%eax
  217. loop 11b
  218. /*
  219. * End condition: we must map up to and including INIT_MAP_BEYOND_END
  220. * bytes beyond the end of our own page tables; the +0x007 is
  221. * the attribute bits
  222. */
  223. leal (INIT_MAP_BEYOND_END+PTE_IDENT_ATTR)(%edi),%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. #ifndef CONFIG_HOTPLUG_CPU
  244. .section .init.text,"ax",@progbits
  245. #endif
  246. #ifdef CONFIG_SMP
  247. ENTRY(startup_32_smp)
  248. cld
  249. movl $(__BOOT_DS),%eax
  250. movl %eax,%ds
  251. movl %eax,%es
  252. movl %eax,%fs
  253. movl %eax,%gs
  254. #endif /* CONFIG_SMP */
  255. 3:
  256. /*
  257. * New page tables may be in 4Mbyte page mode and may
  258. * be using the global pages.
  259. *
  260. * NOTE! If we are on a 486 we may have no cr4 at all!
  261. * So we do not try to touch it unless we really have
  262. * some bits in it to set. This won't work if the BSP
  263. * implements cr4 but this AP does not -- very unlikely
  264. * but be warned! The same applies to the pse feature
  265. * if not equally supported. --macro
  266. *
  267. * NOTE! We have to correct for the fact that we're
  268. * not yet offset PAGE_OFFSET..
  269. */
  270. #define cr4_bits pa(mmu_cr4_features)
  271. movl cr4_bits,%edx
  272. andl %edx,%edx
  273. jz 6f
  274. movl %cr4,%eax # Turn on paging options (PSE,PAE,..)
  275. orl %edx,%eax
  276. movl %eax,%cr4
  277. btl $5, %eax # check if PAE is enabled
  278. jnc 6f
  279. /* Check if extended functions are implemented */
  280. movl $0x80000000, %eax
  281. cpuid
  282. cmpl $0x80000000, %eax
  283. jbe 6f
  284. mov $0x80000001, %eax
  285. cpuid
  286. /* Execute Disable bit supported? */
  287. btl $20, %edx
  288. jnc 6f
  289. /* Setup EFER (Extended Feature Enable Register) */
  290. movl $0xc0000080, %ecx
  291. rdmsr
  292. btsl $11, %eax
  293. /* Make changes effective */
  294. wrmsr
  295. 6:
  296. /*
  297. * Enable paging
  298. */
  299. movl $pa(swapper_pg_dir),%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 $per_cpu__gdt_page,%eax
  397. movl $per_cpu__stack_canary,%ecx
  398. subl $20, %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. .section .cpuinit.data,"wa"
  543. .align 4
  544. ENTRY(initial_code)
  545. .long i386_start_kernel
  546. .section .text
  547. /*
  548. * Real beginning of normal "text" segment
  549. */
  550. ENTRY(stext)
  551. ENTRY(_stext)
  552. /*
  553. * BSS section
  554. */
  555. .section ".bss.page_aligned","wa"
  556. .align PAGE_SIZE_asm
  557. #ifdef CONFIG_X86_PAE
  558. swapper_pg_pmd:
  559. .fill 1024*KPMDS,4,0
  560. #else
  561. ENTRY(swapper_pg_dir)
  562. .fill 1024,4,0
  563. #endif
  564. swapper_pg_fixmap:
  565. .fill 1024,4,0
  566. ENTRY(empty_zero_page)
  567. .fill 4096,1,0
  568. /*
  569. * This starts the data section.
  570. */
  571. #ifdef CONFIG_X86_PAE
  572. .section ".data.page_aligned","wa"
  573. /* Page-aligned for the benefit of paravirt? */
  574. .align PAGE_SIZE_asm
  575. ENTRY(swapper_pg_dir)
  576. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
  577. # if KPMDS == 3
  578. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  579. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  580. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0
  581. # elif KPMDS == 2
  582. .long 0,0
  583. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  584. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  585. # elif KPMDS == 1
  586. .long 0,0
  587. .long 0,0
  588. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  589. # else
  590. # error "Kernel PMDs should be 1, 2 or 3"
  591. # endif
  592. .align PAGE_SIZE_asm /* needs to be page-sized too */
  593. #endif
  594. .data
  595. ENTRY(stack_start)
  596. .long init_thread_union+THREAD_SIZE
  597. .long __BOOT_DS
  598. ready: .byte 0
  599. early_recursion_flag:
  600. .long 0
  601. int_msg:
  602. .asciz "Unknown interrupt or fault at: %p %p %p\n"
  603. fault_msg:
  604. /* fault info: */
  605. .ascii "BUG: Int %d: CR2 %p\n"
  606. /* pusha regs: */
  607. .ascii " EDI %p ESI %p EBP %p ESP %p\n"
  608. .ascii " EBX %p EDX %p ECX %p EAX %p\n"
  609. /* fault frame: */
  610. .ascii " err %p EIP %p CS %p flg %p\n"
  611. .ascii "Stack: %p %p %p %p %p %p %p %p\n"
  612. .ascii " %p %p %p %p %p %p %p %p\n"
  613. .asciz " %p %p %p %p %p %p %p %p\n"
  614. #include "../../x86/xen/xen-head.S"
  615. /*
  616. * The IDT and GDT 'descriptors' are a strange 48-bit object
  617. * only used by the lidt and lgdt instructions. They are not
  618. * like usual segment descriptors - they consist of a 16-bit
  619. * segment size, and 32-bit linear address value:
  620. */
  621. .globl boot_gdt_descr
  622. .globl idt_descr
  623. ALIGN
  624. # early boot GDT descriptor (must use 1:1 address mapping)
  625. .word 0 # 32 bit align gdt_desc.address
  626. boot_gdt_descr:
  627. .word __BOOT_DS+7
  628. .long boot_gdt - __PAGE_OFFSET
  629. .word 0 # 32-bit align idt_desc.address
  630. idt_descr:
  631. .word IDT_ENTRIES*8-1 # idt contains 256 entries
  632. .long idt_table
  633. # boot GDT descriptor (later on used by CPU#0):
  634. .word 0 # 32 bit align gdt_desc.address
  635. ENTRY(early_gdt_descr)
  636. .word GDT_ENTRIES*8-1
  637. .long per_cpu__gdt_page /* Overwritten for secondary CPUs */
  638. /*
  639. * The boot_gdt must mirror the equivalent in setup.S and is
  640. * used only for booting.
  641. */
  642. .align L1_CACHE_BYTES
  643. ENTRY(boot_gdt)
  644. .fill GDT_ENTRY_BOOT_CS,8,0
  645. .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
  646. .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */