head_32.S 17 KB

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