head_32.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  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. .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. subl $20, %ecx
  390. movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
  391. shrl $16, %ecx
  392. movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
  393. movb %ch, 8 * GDT_ENTRY_STACK_CANARY + 7(%eax)
  394. 1:
  395. #endif
  396. movl $(__KERNEL_STACK_CANARY),%eax
  397. movl %eax,%gs
  398. xorl %eax,%eax # Clear LDT
  399. lldt %ax
  400. cld # gcc2 wants the direction flag cleared at all times
  401. pushl $0 # fake return address for unwinder
  402. #ifdef CONFIG_SMP
  403. movb ready, %cl
  404. movb $1, ready
  405. cmpb $0,%cl # the first CPU calls start_kernel
  406. je 1f
  407. movl (stack_start), %esp
  408. 1:
  409. #endif /* CONFIG_SMP */
  410. jmp *(initial_code)
  411. /*
  412. * We depend on ET to be correct. This checks for 287/387.
  413. */
  414. check_x87:
  415. movb $0,X86_HARD_MATH
  416. clts
  417. fninit
  418. fstsw %ax
  419. cmpb $0,%al
  420. je 1f
  421. movl %cr0,%eax /* no coprocessor: have to set bits */
  422. xorl $4,%eax /* set EM */
  423. movl %eax,%cr0
  424. ret
  425. ALIGN
  426. 1: movb $1,X86_HARD_MATH
  427. .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */
  428. ret
  429. /*
  430. * setup_idt
  431. *
  432. * sets up a idt with 256 entries pointing to
  433. * ignore_int, interrupt gates. It doesn't actually load
  434. * idt - that can be done only after paging has been enabled
  435. * and the kernel moved to PAGE_OFFSET. Interrupts
  436. * are enabled elsewhere, when we can be relatively
  437. * sure everything is ok.
  438. *
  439. * Warning: %esi is live across this function.
  440. */
  441. setup_idt:
  442. lea ignore_int,%edx
  443. movl $(__KERNEL_CS << 16),%eax
  444. movw %dx,%ax /* selector = 0x0010 = cs */
  445. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  446. lea idt_table,%edi
  447. mov $256,%ecx
  448. rp_sidt:
  449. movl %eax,(%edi)
  450. movl %edx,4(%edi)
  451. addl $8,%edi
  452. dec %ecx
  453. jne rp_sidt
  454. .macro set_early_handler handler,trapno
  455. lea \handler,%edx
  456. movl $(__KERNEL_CS << 16),%eax
  457. movw %dx,%ax
  458. movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
  459. lea idt_table,%edi
  460. movl %eax,8*\trapno(%edi)
  461. movl %edx,8*\trapno+4(%edi)
  462. .endm
  463. set_early_handler handler=early_divide_err,trapno=0
  464. set_early_handler handler=early_illegal_opcode,trapno=6
  465. set_early_handler handler=early_protection_fault,trapno=13
  466. set_early_handler handler=early_page_fault,trapno=14
  467. ret
  468. early_divide_err:
  469. xor %edx,%edx
  470. pushl $0 /* fake errcode */
  471. jmp early_fault
  472. early_illegal_opcode:
  473. movl $6,%edx
  474. pushl $0 /* fake errcode */
  475. jmp early_fault
  476. early_protection_fault:
  477. movl $13,%edx
  478. jmp early_fault
  479. early_page_fault:
  480. movl $14,%edx
  481. jmp early_fault
  482. early_fault:
  483. cld
  484. #ifdef CONFIG_PRINTK
  485. pusha
  486. movl $(__KERNEL_DS),%eax
  487. movl %eax,%ds
  488. movl %eax,%es
  489. cmpl $2,early_recursion_flag
  490. je hlt_loop
  491. incl early_recursion_flag
  492. movl %cr2,%eax
  493. pushl %eax
  494. pushl %edx /* trapno */
  495. pushl $fault_msg
  496. call printk
  497. #endif
  498. call dump_stack
  499. hlt_loop:
  500. hlt
  501. jmp hlt_loop
  502. /* This is the default interrupt "handler" :-) */
  503. ALIGN
  504. ignore_int:
  505. cld
  506. #ifdef CONFIG_PRINTK
  507. pushl %eax
  508. pushl %ecx
  509. pushl %edx
  510. pushl %es
  511. pushl %ds
  512. movl $(__KERNEL_DS),%eax
  513. movl %eax,%ds
  514. movl %eax,%es
  515. cmpl $2,early_recursion_flag
  516. je hlt_loop
  517. incl early_recursion_flag
  518. pushl 16(%esp)
  519. pushl 24(%esp)
  520. pushl 32(%esp)
  521. pushl 40(%esp)
  522. pushl $int_msg
  523. call printk
  524. call dump_stack
  525. addl $(5*4),%esp
  526. popl %ds
  527. popl %es
  528. popl %edx
  529. popl %ecx
  530. popl %eax
  531. #endif
  532. iret
  533. __REFDATA
  534. .align 4
  535. ENTRY(initial_code)
  536. .long i386_start_kernel
  537. /*
  538. * BSS section
  539. */
  540. .section ".bss.page_aligned","wa"
  541. .align PAGE_SIZE_asm
  542. #ifdef CONFIG_X86_PAE
  543. swapper_pg_pmd:
  544. .fill 1024*KPMDS,4,0
  545. #else
  546. ENTRY(swapper_pg_dir)
  547. .fill 1024,4,0
  548. #endif
  549. swapper_pg_fixmap:
  550. .fill 1024,4,0
  551. ENTRY(empty_zero_page)
  552. .fill 4096,1,0
  553. /*
  554. * This starts the data section.
  555. */
  556. #ifdef CONFIG_X86_PAE
  557. .section ".data.page_aligned","wa"
  558. /* Page-aligned for the benefit of paravirt? */
  559. .align PAGE_SIZE_asm
  560. ENTRY(swapper_pg_dir)
  561. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
  562. # if KPMDS == 3
  563. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  564. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  565. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x2000),0
  566. # elif KPMDS == 2
  567. .long 0,0
  568. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  569. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR+0x1000),0
  570. # elif KPMDS == 1
  571. .long 0,0
  572. .long 0,0
  573. .long pa(swapper_pg_pmd+PGD_IDENT_ATTR),0
  574. # else
  575. # error "Kernel PMDs should be 1, 2 or 3"
  576. # endif
  577. .align PAGE_SIZE_asm /* needs to be page-sized too */
  578. #endif
  579. .data
  580. ENTRY(stack_start)
  581. .long init_thread_union+THREAD_SIZE
  582. .long __BOOT_DS
  583. ready: .byte 0
  584. early_recursion_flag:
  585. .long 0
  586. int_msg:
  587. .asciz "Unknown interrupt or fault at: %p %p %p\n"
  588. fault_msg:
  589. /* fault info: */
  590. .ascii "BUG: Int %d: CR2 %p\n"
  591. /* pusha regs: */
  592. .ascii " EDI %p ESI %p EBP %p ESP %p\n"
  593. .ascii " EBX %p EDX %p ECX %p EAX %p\n"
  594. /* fault frame: */
  595. .ascii " err %p EIP %p CS %p flg %p\n"
  596. .ascii "Stack: %p %p %p %p %p %p %p %p\n"
  597. .ascii " %p %p %p %p %p %p %p %p\n"
  598. .asciz " %p %p %p %p %p %p %p %p\n"
  599. #include "../../x86/xen/xen-head.S"
  600. /*
  601. * The IDT and GDT 'descriptors' are a strange 48-bit object
  602. * only used by the lidt and lgdt instructions. They are not
  603. * like usual segment descriptors - they consist of a 16-bit
  604. * segment size, and 32-bit linear address value:
  605. */
  606. .globl boot_gdt_descr
  607. .globl idt_descr
  608. ALIGN
  609. # early boot GDT descriptor (must use 1:1 address mapping)
  610. .word 0 # 32 bit align gdt_desc.address
  611. boot_gdt_descr:
  612. .word __BOOT_DS+7
  613. .long boot_gdt - __PAGE_OFFSET
  614. .word 0 # 32-bit align idt_desc.address
  615. idt_descr:
  616. .word IDT_ENTRIES*8-1 # idt contains 256 entries
  617. .long idt_table
  618. # boot GDT descriptor (later on used by CPU#0):
  619. .word 0 # 32 bit align gdt_desc.address
  620. ENTRY(early_gdt_descr)
  621. .word GDT_ENTRIES*8-1
  622. .long per_cpu__gdt_page /* Overwritten for secondary CPUs */
  623. /*
  624. * The boot_gdt must mirror the equivalent in setup.S and is
  625. * used only for booting.
  626. */
  627. .align L1_CACHE_BYTES
  628. ENTRY(boot_gdt)
  629. .fill GDT_ENTRY_BOOT_CS,8,0
  630. .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
  631. .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */