ia64/xen-unstable

view xen/arch/x86/boot/trampoline.S @ 15277:0feaf2fc75d3

xen: Boot on PAE systems with no EFER MSR.
Bug tracked down by Stefan Berger.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jun 05 10:28:59 2007 +0100 (2007-06-05)
parents 23c4790512db
children a5ae31a91b10
line source
1 .code16
3 .globl trampoline_realmode_entry
4 trampoline_realmode_entry:
5 nop # We use this byte as a progress flag
6 movb $0xA5,trampoline_cpu_started - trampoline_start
7 cld
8 cli
9 lidt %cs:idt_48 - trampoline_start
10 lgdt %cs:gdt_48 - trampoline_start
11 xor %ax, %ax
12 inc %ax
13 lmsw %ax # CR0.PE = 1 (enter protected mode)
14 mov $1,%bl # EBX != 0 indicates we are an AP
15 jmp 1f
16 1: ljmpl $TRAMP_CS32,$SYM_TRAMP_PHYS(trampoline_protmode_entry)
18 idt_48: .word 0, 0, 0 # base = limit = 0
19 gdt_48: .word 4*8-1
20 .long SYM_TRAMP_PHYS(trampoline_gdt)
21 trampoline_gdt:
22 .quad 0x0000000000000000 /* 0x0000: unused */
23 .quad 0x00cf9a000000ffff /* 0x0008: ring 0 code, 32-bit mode */
24 .quad 0x00af9a000000ffff /* 0x0010: ring 0 code, 64-bit mode */
25 .quad 0x00cf92000000ffff /* 0x0018: ring 0 data */
27 cpuid_ext_features:
28 .long 0
30 .globl trampoline_xen_phys_start
31 trampoline_xen_phys_start:
32 .long 0
34 .globl trampoline_cpu_started
35 trampoline_cpu_started:
36 .byte 0
38 .code32
39 trampoline_protmode_entry:
40 /* Set up a few descriptors: on entry only CS is guaranteed good. */
41 mov $TRAMP_DS,%eax
42 mov %eax,%ds
43 mov %eax,%es
45 /* Set up FPU. */
46 fninit
48 /* Initialise CR4. */
49 #if CONFIG_PAGING_LEVELS == 2
50 mov $X86_CR4_PSE,%ecx
51 #else
52 mov $X86_CR4_PAE,%ecx
53 #endif
54 mov %ecx,%cr4
56 /* Load pagetable base register. */
57 mov $SYM_PHYS(idle_pg_table),%eax
58 add SYM_TRAMP_PHYS(trampoline_xen_phys_start),%eax
59 mov %eax,%cr3
61 #if CONFIG_PAGING_LEVELS != 2
62 /* Set up EFER (Extended Feature Enable Register). */
63 mov SYM_TRAMP_PHYS(cpuid_ext_features),%edi
64 test $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */
65 jz .Lskip_efer
66 movl $MSR_EFER,%ecx
67 rdmsr
68 #if CONFIG_PAGING_LEVELS == 4
69 btsl $_EFER_LME,%eax /* Long Mode */
70 btsl $_EFER_SCE,%eax /* SYSCALL/SYSRET */
71 #endif
72 btl $20,%edi /* No Execute? */
73 jnc 1f
74 btsl $_EFER_NX,%eax /* No Execute */
75 1: wrmsr
76 .Lskip_efer:
77 #endif
79 mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */
80 mov %eax,%cr0
81 jmp 1f
82 1:
84 #if defined(__x86_64__)
86 /* Now in compatibility mode. Long-jump into 64-bit mode. */
87 ljmp $TRAMP_CS64,$SYM_TRAMP_PHYS(start64)
89 .code64
90 start64:
91 /* Jump to high mappings. */
92 mov high_start(%rip),%rax
93 jmpq *%rax
95 high_start:
96 .quad __high_start
98 #else /* !defined(__x86_64__) */
100 /* Install relocated selectors. */
101 lgdt gdt_descr
102 mov $(__HYPERVISOR_DS),%eax
103 mov %eax,%ds
104 mov %eax,%es
105 mov %eax,%fs
106 mov %eax,%gs
107 mov %eax,%ss
108 ljmp $(__HYPERVISOR_CS),$__high_start
110 #endif