head_32.S 17 KB

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