head_32.S 17 KB

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