head_32.S 17 KB

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