head_32.S 17 KB

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