1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 .code32
19 .text
20#define _pa(x) ((x) - __START_KERNEL_map)
21
22#include <linux/elfnote.h>
23#include <linux/init.h>
24#include <linux/linkage.h>
25#include <asm/segment.h>
26#include <asm/asm.h>
27#include <asm/boot.h>
28#include <asm/processor-flags.h>
29#include <asm/msr.h>
30#include <xen/interface/elfnote.h>
31
32 __HEAD
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57#define PVH_GDT_ENTRY_CS 1
58#define PVH_GDT_ENTRY_DS 2
59#define PVH_GDT_ENTRY_CANARY 3
60#define PVH_CS_SEL (PVH_GDT_ENTRY_CS * 8)
61#define PVH_DS_SEL (PVH_GDT_ENTRY_DS * 8)
62#define PVH_CANARY_SEL (PVH_GDT_ENTRY_CANARY * 8)
63
64ENTRY(pvh_start_xen)
65 cld
66
67 lgdt (_pa(gdt))
68
69 mov $PVH_DS_SEL,%eax
70 mov %eax,%ds
71 mov %eax,%es
72 mov %eax,%ss
73
74
75 mov $_pa(pvh_start_info), %edi
76 mov %ebx, %esi
77 mov _pa(pvh_start_info_sz), %ecx
78 shr $2,%ecx
79 rep
80 movsl
81
82 mov $_pa(early_stack_end), %esp
83
84
85 mov %cr4, %eax
86 orl $X86_CR4_PAE, %eax
87 mov %eax, %cr4
88
89#ifdef CONFIG_X86_64
90
91 mov $MSR_EFER, %ecx
92 rdmsr
93 btsl $_EFER_LME, %eax
94 wrmsr
95
96
97 mov $_pa(init_top_pgt), %eax
98 mov %eax, %cr3
99 mov $(X86_CR0_PG | X86_CR0_PE), %eax
100 mov %eax, %cr0
101
102
103 ljmp $PVH_CS_SEL, $_pa(1f)
104
105
106 .code64
1071:
108
109 mov $MSR_GS_BASE,%ecx
110 mov $_pa(canary), %eax
111 xor %edx, %edx
112 wrmsr
113
114 call xen_prepare_pvh
115
116
117 mov $_pa(pvh_bootparams), %rsi
118 mov $_pa(startup_64), %rax
119 jmp *%rax
120
121#else
122
123
124 movl $_pa(gdt_start),%eax
125 movl $_pa(canary),%ecx
126 movw %cx, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax)
127 shrl $16, %ecx
128 movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 4(%eax)
129 movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 7(%eax)
130
131 mov $PVH_CANARY_SEL,%eax
132 mov %eax,%gs
133
134 call mk_early_pgtbl_32
135
136 mov $_pa(initial_page_table), %eax
137 mov %eax, %cr3
138
139 mov %cr0, %eax
140 or $(X86_CR0_PG | X86_CR0_PE), %eax
141 mov %eax, %cr0
142
143 ljmp $PVH_CS_SEL, $1f
1441:
145 call xen_prepare_pvh
146 mov $_pa(pvh_bootparams), %esi
147
148
149 ljmp $PVH_CS_SEL, $_pa(2f)
1502:
151 mov %cr0, %eax
152 and $~X86_CR0_PG, %eax
153 mov %eax, %cr0
154 mov %cr4, %eax
155 and $~X86_CR4_PAE, %eax
156 mov %eax, %cr4
157
158 ljmp $PVH_CS_SEL, $_pa(startup_32)
159#endif
160END(pvh_start_xen)
161
162 .section ".init.data","aw"
163 .balign 8
164gdt:
165 .word gdt_end - gdt_start
166 .long _pa(gdt_start)
167 .word 0
168gdt_start:
169 .quad 0x0000000000000000
170#ifdef CONFIG_X86_64
171 .quad GDT_ENTRY(0xa09a, 0, 0xfffff)
172#else
173 .quad GDT_ENTRY(0xc09a, 0, 0xfffff)
174#endif
175 .quad GDT_ENTRY(0xc092, 0, 0xfffff)
176 .quad GDT_ENTRY(0x4090, 0, 0x18)
177gdt_end:
178
179 .balign 16
180canary:
181 .fill 48, 1, 0
182
183early_stack:
184 .fill 256, 1, 0
185early_stack_end:
186
187 ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY,
188 _ASM_PTR (pvh_start_xen - __START_KERNEL_map))
189