ia64/xen-unstable

view linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S @ 13978:477a3bde3b61

linux: miscellaneous changes after upgrade through 2.6.17.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Thu Feb 15 14:12:32 2007 +0000 (2007-02-15)
parents 4fad820a2233
children 0a348e9ecedb
line source
1 /*
2 * linux/arch/x86_64/kernel/head.S -- start in 32bit and switch to 64bit
3 *
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 * Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
6 * Copyright (C) 2000 Karsten Keil <kkeil@suse.de>
7 * Copyright (C) 2001,2002 Andi Kleen <ak@suse.de>
8 *
9 * $Id: head.S,v 1.49 2002/03/19 17:39:25 ak Exp $
10 *
11 * Jun Nakajima <jun.nakajima@intel.com>
12 * Modified for Xen
13 */
16 #include <linux/linkage.h>
17 #include <linux/threads.h>
18 #include <linux/init.h>
19 #include <linux/elfnote.h>
20 #include <asm/desc.h>
21 #include <asm/segment.h>
22 #include <asm/page.h>
23 #include <asm/msr.h>
24 #include <asm/cache.h>
26 #include <xen/interface/elfnote.h>
28 .section .bootstrap.text, "ax", @progbits
29 .code64
30 #define VIRT_ENTRY_OFFSET 0x0
31 .org VIRT_ENTRY_OFFSET
32 .globl startup_64
33 startup_64:
34 ENTRY(_start)
35 movq $(init_thread_union+THREAD_SIZE-8),%rsp
36 /* zero EFLAGS after setting rsp */
37 pushq $0
38 popfq
40 /* rsi is pointer to startup info structure.
41 pass it to C */
42 movq %rsi,%rdi
43 jmp x86_64_start_kernel
45 ENTRY(stext)
46 ENTRY(_stext)
48 $page = 0
49 #define NEXT_PAGE(name) \
50 $page = $page + 1; \
51 .org $page * 0x1000; \
52 phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \
53 ENTRY(name)
55 NEXT_PAGE(init_level4_pgt)
56 /* This gets initialized in x86_64_start_kernel */
57 .fill 512,8,0
59 /*
60 * We update two pgd entries to make kernel and user pgd consistent
61 * at pgd_populate(). It can be used for kernel modules. So we place
62 * this page here for those cases to avoid memory corruption.
63 * We also use this page to establish the initiali mapping for
64 * vsyscall area.
65 */
66 NEXT_PAGE(init_level4_user_pgt)
67 .fill 512,8,0
69 NEXT_PAGE(level3_kernel_pgt)
70 .fill 512,8,0
72 /*
73 * This is used for vsyscall area mapping as we have a different
74 * level4 page table for user.
75 */
76 NEXT_PAGE(level3_user_pgt)
77 .fill 512,8,0
79 NEXT_PAGE(level2_kernel_pgt)
80 .fill 512,8,0
82 NEXT_PAGE(hypercall_page)
83 .fill 512,8,0
85 #undef NEXT_PAGE
87 .data
89 .align 16
90 .globl cpu_gdt_descr
91 cpu_gdt_descr:
92 .word gdt_end-cpu_gdt_table-1
93 gdt:
94 .quad cpu_gdt_table
95 #ifdef CONFIG_SMP
96 .rept NR_CPUS-1
97 .word 0
98 .quad 0
99 .endr
100 #endif
102 /* We need valid kernel segments for data and code in long mode too
103 * IRET will check the segment types kkeil 2000/10/28
104 * Also sysret mandates a special GDT layout
105 */
107 .section .data.page_aligned, "aw"
108 .align PAGE_SIZE
110 /* The TLS descriptors are currently at a different place compared to i386.
111 Hopefully nobody expects them at a fixed place (Wine?) */
113 ENTRY(cpu_gdt_table)
114 .quad 0x0000000000000000 /* NULL descriptor */
115 .quad 0x0 /* unused */
116 .quad 0x00af9a000000ffff /* __KERNEL_CS */
117 .quad 0x00cf92000000ffff /* __KERNEL_DS */
118 .quad 0x00cffa000000ffff /* __USER32_CS */
119 .quad 0x00cff2000000ffff /* __USER_DS, __USER32_DS */
120 .quad 0x00affa000000ffff /* __USER_CS */
121 .quad 0x00cf9a000000ffff /* __KERNEL32_CS */
122 .quad 0,0 /* TSS */
123 .quad 0,0 /* LDT */
124 .quad 0,0,0 /* three TLS descriptors */
125 .quad 0 /* unused */
126 gdt_end:
127 /* asm/segment.h:GDT_ENTRIES must match this */
128 /* This should be a multiple of the cache line size */
129 /* GDTs of other CPUs are now dynamically allocated */
131 /* zero the remaining page */
132 .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
134 .section .bss.page_aligned, "aw", @nobits
135 .align PAGE_SIZE
136 ENTRY(empty_zero_page)
137 .skip PAGE_SIZE
139 #ifdef CONFIG_XEN_COMPAT_030002
140 /*
141 * __xen_guest information
142 */
143 .macro utoh value
144 .if (\value) < 0 || (\value) >= 0x10
145 utoh (((\value)>>4)&0x0fffffffffffffff)
146 .endif
147 .if ((\value) & 0xf) < 10
148 .byte '0' + ((\value) & 0xf)
149 .else
150 .byte 'A' + ((\value) & 0xf) - 10
151 .endif
152 .endm
154 .section __xen_guest
155 .ascii "GUEST_OS=linux,GUEST_VER=2.6"
156 .ascii ",XEN_VER=xen-3.0"
157 .ascii ",VIRT_BASE=0x"
158 utoh __START_KERNEL_map
159 .ascii ",ELF_PADDR_OFFSET=0x"
160 utoh __START_KERNEL_map
161 .ascii ",VIRT_ENTRY=0x"
162 utoh (__START_KERNEL_map + __PHYSICAL_START + VIRT_ENTRY_OFFSET)
163 .ascii ",HYPERCALL_PAGE=0x"
164 utoh (phys_hypercall_page >> PAGE_SHIFT)
165 .ascii ",FEATURES=writable_page_tables"
166 .ascii "|writable_descriptor_tables"
167 .ascii "|auto_translated_physmap"
168 .ascii "|supervisor_mode_kernel"
169 .ascii ",LOADER=generic"
170 .byte 0
171 #endif /* CONFIG_XEN_COMPAT_030002 */
173 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "linux")
174 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "2.6")
175 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
176 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .quad, __START_KERNEL_map)
177 #ifdef CONFIG_XEN_COMPAT_030002
178 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, __START_KERNEL_map)
179 #else
180 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0)
181 #endif /* !CONFIG_XEN_COMPAT_030002 */
182 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64)
183 ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page)
184 ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
185 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")