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