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 %eax,%fs # gets reset once there's real percpu
  383. movl $(__USER_DS),%eax # DS/ES contains default USER segment
  384. movl %eax,%ds
  385. movl %eax,%es
  386. xorl %eax,%eax # Clear GS and LDT
  387. movl %eax,%gs
  388. lldt %ax
  389. cld # gcc2 wants the direction flag cleared at all times
  390. pushl $0 # fake return address for unwinder
  391. #ifdef CONFIG_SMP
  392. movb ready, %cl
  393. movb $1, ready
  394. cmpb $0,%cl # the first CPU calls start_kernel
  395. je 1f
  396. movl $(__KERNEL_PERCPU), %eax
  397. movl %eax,%fs # set this cpu's percpu
  398. movl (stack_start), %esp
  399. 1:
  400. #endif /* CONFIG_SMP */
  401. jmp *(initial_code)
  402. /*
  403. * We depend on ET to be correct. This checks for 287/387.
  404. */
  405. check_x87:
  406. movb $0,X86_HARD_MATH
  407. clts
  408. fninit
  409. fstsw %ax
  410. cmpb $0,%al
  411. je 1f
  412. movl %cr0,%eax /* no coprocessor: have to set bits */
  413. xorl $4,%eax /* set EM */
  414. movl %eax,%cr0
  415. ret
  416. ALIGN
  417. 1: movb $1,X86_HARD_MATH
  418. .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */
  419. ret
  420. /*
  421. * setup_idt
  422. *
  423. * sets up a idt with 256 entries pointing to
  424. * ignore_int, interrupt gates. It doesn't actually load
  425. * idt - that can be done only after paging has been enabled
  426. * and the kernel moved to PAGE_OFFSET. Interrupts
  427. * are enabled elsewhere, when we can be relatively
  428. * sure everything is ok.
  429. *
  430. * Warning: %esi is live across this function.
  431. */
  432. setup_idt:
  433. lea ignore_int,%edx
  434. movl $(__KERNEL_CS << 16),%eax
  435. movw %dx,%ax /* selector = 0x0010 = cs */
  436. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  437. lea idt_table,%edi
  438. mov $256,%ecx
  439. rp_sidt:
  440. movl %eax,(%edi)
  441. movl %edx,4(%edi)
  442. addl $8,%edi
  443. dec %ecx
  444. jne rp_sidt
  445. .macro set_early_handler handler,trapno
  446. lea \handler,%edx
  447. movl $(__KERNEL_CS << 16),%eax
  448. movw %dx,%ax
  449. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  450. lea idt_table,%edi
  451. movl %eax,8*\trapno(%edi)
  452. movl %edx,8*\trapno+4(%edi)
  453. .endm
  454. set_early_handler handler=early_divide_err,trapno=0
  455. set_early_handler handler=early_illegal_opcode,trapno=6
  456. set_early_handler handler=early_protection_fault,trapno=13
  457. set_early_handler handler=early_page_fault,trapno=14
  458. ret
  459. early_divide_err:
  460. xor %edx,%edx
  461. pushl $0 /* fake errcode */
  462. jmp early_fault
  463. early_illegal_opcode:
  464. movl $6,%edx
  465. pushl $0 /* fake errcode */
  466. jmp early_fault
  467. early_protection_fault:
  468. movl $13,%edx
  469. jmp early_fault
  470. early_page_fault:
  471. movl $14,%edx
  472. jmp early_fault
  473. early_fault:
  474. cld
  475. #ifdef CONFIG_PRINTK
  476. pusha
  477. movl $(__KERNEL_DS),%eax
  478. movl %eax,%ds
  479. movl %eax,%es
  480. cmpl $2,early_recursion_flag
  481. je hlt_loop
  482. incl early_recursion_flag
  483. movl %cr2,%eax
  484. pushl %eax
  485. pushl %edx /* trapno */
  486. pushl $fault_msg
  487. #ifdef CONFIG_EARLY_PRINTK
  488. call early_printk
  489. #else
  490. call printk
  491. #endif
  492. #endif
  493. call dump_stack
  494. hlt_loop:
  495. hlt
  496. jmp hlt_loop
  497. /* This is the default interrupt "handler" :-) */
  498. ALIGN
  499. ignore_int:
  500. cld
  501. #ifdef CONFIG_PRINTK
  502. pushl %eax
  503. pushl %ecx
  504. pushl %edx
  505. pushl %es
  506. pushl %ds
  507. movl $(__KERNEL_DS),%eax
  508. movl %eax,%ds
  509. movl %eax,%es
  510. cmpl $2,early_recursion_flag
  511. je hlt_loop
  512. incl early_recursion_flag
  513. pushl 16(%esp)
  514. pushl 24(%esp)
  515. pushl 32(%esp)
  516. pushl 40(%esp)
  517. pushl $int_msg
  518. #ifdef CONFIG_EARLY_PRINTK
  519. call early_printk
  520. #else
  521. call printk
  522. #endif
  523. addl $(5*4),%esp
  524. popl %ds
  525. popl %es
  526. popl %edx
  527. popl %ecx
  528. popl %eax
  529. #endif
  530. iret
  531. .section .cpuinit.data,"wa"
  532. .align 4
  533. ENTRY(initial_code)
  534. .long i386_start_kernel
  535. .section .text
  536. /*
  537. * Real beginning of normal "text" segment
  538. */
  539. ENTRY(stext)
  540. ENTRY(_stext)
  541. /*
  542. * BSS section
  543. */
  544. .section ".bss.page_aligned","wa"
  545. .align PAGE_SIZE_asm
  546. #ifdef CONFIG_X86_PAE
  547. swapper_pg_pmd:
  548. .fill 1024*KPMDS,4,0
  549. #else
  550. ENTRY(swapper_pg_dir)
  551. .fill 1024,4,0
  552. #endif
  553. swapper_pg_fixmap:
  554. .fill 1024,4,0
  555. ENTRY(empty_zero_page)
  556. .fill 4096,1,0
  557. /*
  558. * This starts the data section.
  559. */
  560. #ifdef CONFIG_X86_PAE
  561. .section ".data.page_aligned","wa"
  562. /* Page-aligned for the benefit of paravirt? */
  563. .align PAGE_SIZE_asm
  564. ENTRY(swapper_pg_dir)
  565. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
  566. # if KPMDS == 3
  567. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  568. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  569. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0
  570. # elif KPMDS == 2
  571. .long 0,0
  572. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  573. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  574. # elif KPMDS == 1
  575. .long 0,0
  576. .long 0,0
  577. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  578. # else
  579. # error "Kernel PMDs should be 1, 2 or 3"
  580. # endif
  581. .align PAGE_SIZE_asm /* needs to be page-sized too */
  582. #endif
  583. .data
  584. ENTRY(stack_start)
  585. .long init_thread_union+THREAD_SIZE
  586. .long __BOOT_DS
  587. ready: .byte 0
  588. early_recursion_flag:
  589. .long 0
  590. int_msg:
  591. .asciz "Unknown interrupt or fault at EIP %p %p %p\n"
  592. fault_msg:
  593. /* fault info: */
  594. .ascii "BUG: Int %d: CR2 %p\n"
  595. /* pusha regs: */
  596. .ascii " EDI %p ESI %p EBP %p ESP %p\n"
  597. .ascii " EBX %p EDX %p ECX %p EAX %p\n"
  598. /* fault frame: */
  599. .ascii " err %p EIP %p CS %p flg %p\n"
  600. .ascii "Stack: %p %p %p %p %p %p %p %p\n"
  601. .ascii " %p %p %p %p %p %p %p %p\n"
  602. .asciz " %p %p %p %p %p %p %p %p\n"
  603. #include "../../x86/xen/xen-head.S"
  604. /*
  605. * The IDT and GDT 'descriptors' are a strange 48-bit object
  606. * only used by the lidt and lgdt instructions. They are not
  607. * like usual segment descriptors - they consist of a 16-bit
  608. * segment size, and 32-bit linear address value:
  609. */
  610. .globl boot_gdt_descr
  611. .globl idt_descr
  612. ALIGN
  613. # early boot GDT descriptor (must use 1:1 address mapping)
  614. .word 0 # 32 bit align gdt_desc.address
  615. boot_gdt_descr:
  616. .word __BOOT_DS+7
  617. .long boot_gdt - __PAGE_OFFSET
  618. .word 0 # 32-bit align idt_desc.address
  619. idt_descr:
  620. .word IDT_ENTRIES*8-1 # idt contains 256 entries
  621. .long idt_table
  622. # boot GDT descriptor (later on used by CPU#0):
  623. .word 0 # 32 bit align gdt_desc.address
  624. ENTRY(early_gdt_descr)
  625. .word GDT_ENTRIES*8-1
  626. .long per_cpu__gdt_page /* Overwritten for secondary CPUs */
  627. /*
  628. * The boot_gdt must mirror the equivalent in setup.S and is
  629. * used only for booting.
  630. */
  631. .align L1_CACHE_BYTES
  632. ENTRY(boot_gdt)
  633. .fill GDT_ENTRY_BOOT_CS,8,0
  634. .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
  635. .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */