ia64/xen-unstable

view xen/arch/x86/boot/x86_64.S @ 16376:6c544894b8b2

x86: GDT reserved page should be a full page.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir@xensource.com>
date Tue Nov 13 19:21:00 2007 +0000 (2007-11-13)
parents f50f0ec7dd2c
children 7f1a36b834e1
line source
1 .code64
3 /* Install relocated data selectors. */
4 lgdt gdt_descr(%rip)
5 mov $(__HYPERVISOR_DS64),%ecx
6 mov %ecx,%ds
7 mov %ecx,%es
8 mov %ecx,%fs
9 mov %ecx,%gs
10 mov %ecx,%ss
12 /* Enable full CR4 features. */
13 mov mmu_cr4_features(%rip),%rcx
14 mov %rcx,%cr4
16 mov stack_start(%rip),%rsp
17 or $(STACK_SIZE-CPUINFO_sizeof),%rsp
19 /* Reset EFLAGS (subsumes CLI and CLD). */
20 pushq $0
21 popf
23 /* Reload code selector. */
24 pushq $(__HYPERVISOR_CS64)
25 leaq 1f(%rip),%rax
26 pushq %rax
27 lretq
28 1: lidt idt_descr(%rip)
30 test %ebx,%ebx
31 jnz start_secondary
33 /* Initialise IDT with simple error defaults. */
34 leaq ignore_int(%rip),%rcx
35 movl %ecx,%eax
36 andl $0xFFFF0000,%eax
37 orl $0x00008E00,%eax
38 shlq $32,%rax
39 movl %ecx,%edx
40 andl $0x0000FFFF,%edx
41 orl $(__HYPERVISOR_CS64<<16),%edx
42 orq %rdx,%rax
43 shrq $32,%rcx
44 movl %ecx,%edx
45 leaq idt_table(%rip),%rdi
46 movl $256,%ecx
47 1: movq %rax,(%rdi)
48 movq %rdx,8(%rdi)
49 addq $16,%rdi
50 loop 1b
52 /* Pass off the Multiboot info structure to C land. */
53 mov multiboot_ptr(%rip),%edi
54 call __start_xen
55 ud2 /* Force a panic (invalid opcode). */
57 /* This is the default interrupt handler. */
58 int_msg:
59 .asciz "Unknown interrupt (cr2=%016lx)\n"
60 hex_msg:
61 .asciz " %016lx"
62 ignore_int:
63 SAVE_ALL
64 movq %cr2,%rsi
65 leaq int_msg(%rip),%rdi
66 xorl %eax,%eax
67 call printk
68 movq %rsp,%rbp
69 0: movq (%rbp),%rsi
70 addq $8,%rbp
71 leaq hex_msg(%rip),%rdi
72 xorl %eax,%eax
73 call printk
74 testq $0xff8,%rbp
75 jnz 0b
76 1: jmp 1b
79 /*** DESCRIPTOR TABLES ***/
81 .align 8, 0xCC
82 multiboot_ptr:
83 .long 0
85 .word 0
86 gdt_descr:
87 .word LAST_RESERVED_GDT_BYTE
88 .quad gdt_table - FIRST_RESERVED_GDT_BYTE
90 .word 0,0,0
91 idt_descr:
92 .word 256*16-1
93 .quad idt_table
95 ENTRY(stack_start)
96 .quad cpu0_stack
98 .align PAGE_SIZE, 0
99 ENTRY(gdt_table)
100 .quad 0x0000000000000000 /* unused */
101 .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */
102 .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */
103 .quad 0x0000000000000000 /* reserved */
104 .quad 0x00cffa000000ffff /* 0xe023 ring 3 code, compatibility */
105 .quad 0x00cff2000000ffff /* 0xe02b ring 3 data */
106 .quad 0x00affa000000ffff /* 0xe033 ring 3 code, 64-bit mode */
107 .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */
109 .align PAGE_SIZE, 0
110 /* NB. Even rings != 0 get access to the full 4Gb, as only the */
111 /* (compatibility) machine->physical mapping table lives there. */
112 ENTRY(compat_gdt_table)
113 .quad 0x0000000000000000 /* unused */
114 .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */
115 .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */
116 .quad 0x00cfba000000ffff /* 0xe019 ring 1 code, compatibility */
117 .quad 0x00cfb2000000ffff /* 0xe021 ring 1 data */
118 .quad 0x00cffa000000ffff /* 0xe02b ring 3 code, compatibility */
119 .quad 0x00cff2000000ffff /* 0xe033 ring 3 data */
120 .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */
121 .align PAGE_SIZE, 0