head_32.S 17 KB

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