head_32.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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 = 1<<(32-PAGE_SHIFT_asm)
  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. /*
  70. * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
  71. * %esi points to the real-mode code as a 32-bit pointer.
  72. * CS and DS must be 4 GB flat segments, but we don't depend on
  73. * any particular GDT layout, because we load our own as soon as we
  74. * can.
  75. */
  76. .section .text.head,"ax",@progbits
  77. ENTRY(startup_32)
  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. 2:
  92. /*
  93. * Clear BSS first so that there are no surprises...
  94. */
  95. cld
  96. xorl %eax,%eax
  97. movl $pa(__bss_start),%edi
  98. movl $pa(__bss_stop),%ecx
  99. subl %edi,%ecx
  100. shrl $2,%ecx
  101. rep ; stosl
  102. /*
  103. * Copy bootup parameters out of the way.
  104. * Note: %esi still has the pointer to the real-mode data.
  105. * With the kexec as boot loader, parameter segment might be loaded beyond
  106. * kernel image and might not even be addressable by early boot page tables.
  107. * (kexec on panic case). Hence copy out the parameters before initializing
  108. * page tables.
  109. */
  110. movl $pa(boot_params),%edi
  111. movl $(PARAM_SIZE/4),%ecx
  112. cld
  113. rep
  114. movsl
  115. movl pa(boot_params) + NEW_CL_POINTER,%esi
  116. andl %esi,%esi
  117. jz 1f # No comand line
  118. movl $pa(boot_command_line),%edi
  119. movl $(COMMAND_LINE_SIZE/4),%ecx
  120. rep
  121. movsl
  122. 1:
  123. #ifdef CONFIG_PARAVIRT
  124. /* This is can only trip for a broken bootloader... */
  125. cmpw $0x207, pa(boot_params + BP_version)
  126. jb default_entry
  127. /* Paravirt-compatible boot parameters. Look to see what architecture
  128. we're booting under. */
  129. movl pa(boot_params + BP_hardware_subarch), %eax
  130. cmpl $num_subarch_entries, %eax
  131. jae bad_subarch
  132. movl pa(subarch_entries)(,%eax,4), %eax
  133. subl $__PAGE_OFFSET, %eax
  134. jmp *%eax
  135. bad_subarch:
  136. WEAK(lguest_entry)
  137. WEAK(xen_entry)
  138. /* Unknown implementation; there's really
  139. nothing we can do at this point. */
  140. ud2a
  141. __INITDATA
  142. subarch_entries:
  143. .long default_entry /* normal x86/PC */
  144. .long lguest_entry /* lguest hypervisor */
  145. .long xen_entry /* Xen hypervisor */
  146. num_subarch_entries = (. - subarch_entries) / 4
  147. .previous
  148. #endif /* CONFIG_PARAVIRT */
  149. /*
  150. * Initialize page tables. This creates a PDE and a set of page
  151. * tables, which are located immediately beyond _end. The variable
  152. * init_pg_tables_end is set up to point to the first "safe" location.
  153. * Mappings are created both at virtual address 0 (identity mapping)
  154. * and PAGE_OFFSET for up to _end+sizeof(page tables)+INIT_MAP_BEYOND_END.
  155. *
  156. * Note that the stack is not yet set up!
  157. */
  158. default_entry:
  159. #ifdef CONFIG_X86_PAE
  160. /*
  161. * In PAE mode swapper_pg_dir is statically defined to contain enough
  162. * entries to cover the VMSPLIT option (that is the top 1, 2 or 3
  163. * entries). The identity mapping is handled by pointing two PGD
  164. * entries to the first kernel PMD.
  165. *
  166. * Note the upper half of each PMD or PTE are always zero at
  167. * this stage.
  168. */
  169. #define KPMDS (((-__PAGE_OFFSET) >> 30) & 3) /* Number of kernel PMDs */
  170. xorl %ebx,%ebx /* %ebx is kept at zero */
  171. movl $pa(pg0), %edi
  172. movl %edi, pa(init_pg_tables_start)
  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. movl %edi,pa(init_pg_tables_end)
  197. shrl $12, %eax
  198. movl %eax, pa(max_pfn_mapped)
  199. /* Do early initialization of the fixmap area */
  200. movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
  201. movl %eax,pa(swapper_pg_pmd+0x1000*KPMDS-8)
  202. #else /* Not PAE */
  203. page_pde_offset = (__PAGE_OFFSET >> 20);
  204. movl $pa(pg0), %edi
  205. movl %edi, pa(init_pg_tables_start)
  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. movl %edi,pa(init_pg_tables_end)
  227. shrl $12, %eax
  228. movl %eax, pa(max_pfn_mapped)
  229. /* Do early initialization of the fixmap area */
  230. movl $pa(swapper_pg_fixmap)+PDE_IDENT_ATTR,%eax
  231. movl %eax,pa(swapper_pg_dir+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. #ifndef CONFIG_HOTPLUG_CPU
  243. .section .init.text,"ax",@progbits
  244. #endif
  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. #endif /* CONFIG_SMP */
  254. 3:
  255. /*
  256. * New page tables may be in 4Mbyte page mode and may
  257. * be using the global pages.
  258. *
  259. * NOTE! If we are on a 486 we may have no cr4 at all!
  260. * So we do not try to touch it unless we really have
  261. * some bits in it to set. This won't work if the BSP
  262. * implements cr4 but this AP does not -- very unlikely
  263. * but be warned! The same applies to the pse feature
  264. * if not equally supported. --macro
  265. *
  266. * NOTE! We have to correct for the fact that we're
  267. * not yet offset PAGE_OFFSET..
  268. */
  269. #define cr4_bits pa(mmu_cr4_features)
  270. movl cr4_bits,%edx
  271. andl %edx,%edx
  272. jz 6f
  273. movl %cr4,%eax # Turn on paging options (PSE,PAE,..)
  274. orl %edx,%eax
  275. movl %eax,%cr4
  276. btl $5, %eax # check if PAE is enabled
  277. jnc 6f
  278. /* Check if extended functions are implemented */
  279. movl $0x80000000, %eax
  280. cpuid
  281. cmpl $0x80000000, %eax
  282. jbe 6f
  283. mov $0x80000001, %eax
  284. cpuid
  285. /* Execute Disable bit supported? */
  286. btl $20, %edx
  287. jnc 6f
  288. /* Setup EFER (Extended Feature Enable Register) */
  289. movl $0xc0000080, %ecx
  290. rdmsr
  291. btsl $11, %eax
  292. /* Make changes effective */
  293. wrmsr
  294. 6:
  295. /*
  296. * Enable paging
  297. */
  298. movl $pa(swapper_pg_dir),%eax
  299. movl %eax,%cr3 /* set the page table pointer.. */
  300. movl %cr0,%eax
  301. orl $X86_CR0_PG,%eax
  302. movl %eax,%cr0 /* ..and set paging (PG) bit */
  303. ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */
  304. 1:
  305. /* Set up the stack pointer */
  306. lss stack_start,%esp
  307. /*
  308. * Initialize eflags. Some BIOS's leave bits like NT set. This would
  309. * confuse the debugger if this code is traced.
  310. * XXX - best to initialize before switching to protected mode.
  311. */
  312. pushl $0
  313. popfl
  314. #ifdef CONFIG_SMP
  315. cmpb $0, ready
  316. jz 1f /* Initial CPU cleans BSS */
  317. jmp checkCPUtype
  318. 1:
  319. #endif /* CONFIG_SMP */
  320. /*
  321. * start system 32-bit setup. We need to re-do some of the things done
  322. * in 16-bit mode for the "real" operations.
  323. */
  324. call setup_idt
  325. checkCPUtype:
  326. movl $-1,X86_CPUID # -1 for no CPUID initially
  327. /* check if it is 486 or 386. */
  328. /*
  329. * XXX - this does a lot of unnecessary setup. Alignment checks don't
  330. * apply at our cpl of 0 and the stack ought to be aligned already, and
  331. * we don't need to preserve eflags.
  332. */
  333. movb $3,X86 # at least 386
  334. pushfl # push EFLAGS
  335. popl %eax # get EFLAGS
  336. movl %eax,%ecx # save original EFLAGS
  337. xorl $0x240000,%eax # flip AC and ID bits in EFLAGS
  338. pushl %eax # copy to EFLAGS
  339. popfl # set EFLAGS
  340. pushfl # get new EFLAGS
  341. popl %eax # put it in eax
  342. xorl %ecx,%eax # change in flags
  343. pushl %ecx # restore original EFLAGS
  344. popfl
  345. testl $0x40000,%eax # check if AC bit changed
  346. je is386
  347. movb $4,X86 # at least 486
  348. testl $0x200000,%eax # check if ID bit changed
  349. je is486
  350. /* get vendor info */
  351. xorl %eax,%eax # call CPUID with 0 -> return vendor ID
  352. cpuid
  353. movl %eax,X86_CPUID # save CPUID level
  354. movl %ebx,X86_VENDOR_ID # lo 4 chars
  355. movl %edx,X86_VENDOR_ID+4 # next 4 chars
  356. movl %ecx,X86_VENDOR_ID+8 # last 4 chars
  357. orl %eax,%eax # do we have processor info as well?
  358. je is486
  359. movl $1,%eax # Use the CPUID instruction to get CPU type
  360. cpuid
  361. movb %al,%cl # save reg for future use
  362. andb $0x0f,%ah # mask processor family
  363. movb %ah,X86
  364. andb $0xf0,%al # mask model
  365. shrb $4,%al
  366. movb %al,X86_MODEL
  367. andb $0x0f,%cl # mask mask revision
  368. movb %cl,X86_MASK
  369. movl %edx,X86_CAPABILITY
  370. is486: movl $0x50022,%ecx # set AM, WP, NE and MP
  371. jmp 2f
  372. is386: movl $2,%ecx # set MP
  373. 2: movl %cr0,%eax
  374. andl $0x80000011,%eax # Save PG,PE,ET
  375. orl %ecx,%eax
  376. movl %eax,%cr0
  377. call check_x87
  378. lgdt early_gdt_descr
  379. lidt idt_descr
  380. ljmp $(__KERNEL_CS),$1f
  381. 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
  382. movl %eax,%ss # after changing gdt.
  383. movl $(__USER_DS),%eax # DS/ES contains default USER segment
  384. movl %eax,%ds
  385. movl %eax,%es
  386. movl $(__KERNEL_PERCPU), %eax
  387. movl %eax,%fs # set this cpu's percpu
  388. #ifdef CONFIG_CC_STACKPROTECTOR
  389. /*
  390. * The linker can't handle this by relocation. Manually set
  391. * base address in stack canary segment descriptor.
  392. */
  393. cmpb $0,ready
  394. jne 1f
  395. movl $per_cpu__gdt_page,%eax
  396. movl $per_cpu__stack_canary,%ecx
  397. subl $20, %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. .section .cpuinit.data,"wa"
  542. .align 4
  543. ENTRY(initial_code)
  544. .long i386_start_kernel
  545. .section .text
  546. /*
  547. * Real beginning of normal "text" segment
  548. */
  549. ENTRY(stext)
  550. ENTRY(_stext)
  551. /*
  552. * BSS section
  553. */
  554. .section ".bss.page_aligned","wa"
  555. .align PAGE_SIZE_asm
  556. #ifdef CONFIG_X86_PAE
  557. swapper_pg_pmd:
  558. .fill 1024*KPMDS,4,0
  559. #else
  560. ENTRY(swapper_pg_dir)
  561. .fill 1024,4,0
  562. #endif
  563. swapper_pg_fixmap:
  564. .fill 1024,4,0
  565. ENTRY(empty_zero_page)
  566. .fill 4096,1,0
  567. /*
  568. * This starts the data section.
  569. */
  570. #ifdef CONFIG_X86_PAE
  571. .section ".data.page_aligned","wa"
  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 per_cpu__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 */