head_32.S 17 KB

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