head_32.S 17 KB

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