674b222544b78dde6c3b737a767500e5f19627b3
[cascardo/linux.git] / arch / x86 / xen / xen-head.S
1 /* Xen-specific pieces of head.S, intended to be included in the right
2         place in head.S */
3
4 #ifdef CONFIG_XEN
5
6 #include <linux/elfnote.h>
7 #include <linux/init.h>
8
9 #include <asm/boot.h>
10 #include <asm/asm.h>
11 #include <asm/page_types.h>
12
13 #include <xen/interface/elfnote.h>
14 #include <xen/interface/features.h>
15 #include <asm/xen/interface.h>
16
17 #ifdef CONFIG_XEN_PVH
18 #define PVH_FEATURES_STR  "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
19 /* Note the lack of 'hvm_callback_vector'. Older hypervisor will
20  * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
21  * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore.
22  */
23 #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
24                       (1 << XENFEAT_auto_translated_physmap) | \
25                       (1 << XENFEAT_supervisor_mode_kernel) | \
26                       (1 << XENFEAT_hvm_callback_vector))
27 /* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
28  * up regardless whether this CONFIG option is enabled or not, but it
29  * clarifies what the right flags need to be.
30  */
31 #else
32 #define PVH_FEATURES_STR  ""
33 #define PVH_FEATURES (0)
34 #endif
35
36         __INIT
37 ENTRY(startup_xen)
38         cld
39 #ifdef CONFIG_X86_32
40         mov %esi,xen_start_info
41         mov $init_thread_union+THREAD_SIZE,%esp
42 #else
43         mov %rsi,xen_start_info
44         mov $init_thread_union+THREAD_SIZE,%rsp
45 #endif
46         jmp xen_start_kernel
47
48         __FINIT
49
50 #ifdef CONFIG_XEN_PVH
51 /*
52  * xen_pvh_early_cpu_init() - early PVH VCPU initialization
53  * @cpu:   this cpu number (%rdi)
54  * @entry: true if this is a secondary vcpu coming up on this entry
55  *         point, false if this is the boot CPU being initialized for
56  *         the first time (%rsi)
57  *
58  * Note: This is called as a function on the boot CPU, and is the entry point
59  *       on the secondary CPU.
60  */
61 ENTRY(xen_pvh_early_cpu_init)
62         mov     %rsi, %r11
63
64         /* Gather features to see if NX implemented. */
65         mov     $0x80000001, %eax
66         cpuid
67         mov     %edx, %esi
68
69         mov     $MSR_EFER, %ecx
70         rdmsr
71         bts     $_EFER_SCE, %eax
72
73         bt      $20, %esi
74         jnc     1f              /* No NX, skip setting it */
75         bts     $_EFER_NX, %eax
76 1:      wrmsr
77 #ifdef CONFIG_SMP
78         cmp     $0, %r11b
79         jne     cpu_bringup_and_idle
80 #endif
81         ret
82
83 #endif /* CONFIG_XEN_PVH */
84
85 .pushsection .text
86         .balign PAGE_SIZE
87 ENTRY(hypercall_page)
88 #define NEXT_HYPERCALL(x) \
89         ENTRY(xen_hypercall_##x) \
90         .skip 32
91
92 NEXT_HYPERCALL(set_trap_table)
93 NEXT_HYPERCALL(mmu_update)
94 NEXT_HYPERCALL(set_gdt)
95 NEXT_HYPERCALL(stack_switch)
96 NEXT_HYPERCALL(set_callbacks)
97 NEXT_HYPERCALL(fpu_taskswitch)
98 NEXT_HYPERCALL(sched_op_compat)
99 NEXT_HYPERCALL(platform_op)
100 NEXT_HYPERCALL(set_debugreg)
101 NEXT_HYPERCALL(get_debugreg)
102 NEXT_HYPERCALL(update_descriptor)
103 NEXT_HYPERCALL(ni)
104 NEXT_HYPERCALL(memory_op)
105 NEXT_HYPERCALL(multicall)
106 NEXT_HYPERCALL(update_va_mapping)
107 NEXT_HYPERCALL(set_timer_op)
108 NEXT_HYPERCALL(event_channel_op_compat)
109 NEXT_HYPERCALL(xen_version)
110 NEXT_HYPERCALL(console_io)
111 NEXT_HYPERCALL(physdev_op_compat)
112 NEXT_HYPERCALL(grant_table_op)
113 NEXT_HYPERCALL(vm_assist)
114 NEXT_HYPERCALL(update_va_mapping_otherdomain)
115 NEXT_HYPERCALL(iret)
116 NEXT_HYPERCALL(vcpu_op)
117 NEXT_HYPERCALL(set_segment_base)
118 NEXT_HYPERCALL(mmuext_op)
119 NEXT_HYPERCALL(xsm_op)
120 NEXT_HYPERCALL(nmi_op)
121 NEXT_HYPERCALL(sched_op)
122 NEXT_HYPERCALL(callback_op)
123 NEXT_HYPERCALL(xenoprof_op)
124 NEXT_HYPERCALL(event_channel_op)
125 NEXT_HYPERCALL(physdev_op)
126 NEXT_HYPERCALL(hvm_op)
127 NEXT_HYPERCALL(sysctl)
128 NEXT_HYPERCALL(domctl)
129 NEXT_HYPERCALL(kexec_op)
130 NEXT_HYPERCALL(tmem_op) /* 38 */
131 ENTRY(xen_hypercall_rsvr)
132         .skip 320
133 NEXT_HYPERCALL(mca) /* 48 */
134 NEXT_HYPERCALL(arch_1)
135 NEXT_HYPERCALL(arch_2)
136 NEXT_HYPERCALL(arch_3)
137 NEXT_HYPERCALL(arch_4)
138 NEXT_HYPERCALL(arch_5)
139 NEXT_HYPERCALL(arch_6)
140         .balign PAGE_SIZE
141 .popsection
142
143         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
144         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
145         ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
146 #ifdef CONFIG_X86_32
147         ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __PAGE_OFFSET)
148 #else
149         ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __START_KERNEL_map)
150 #endif
151         ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
152         ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
153         ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
154         ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
155                                                 (1 << XENFEAT_writable_page_tables) |
156                                                 (1 << XENFEAT_dom0))
157         ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
158         ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
159         ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
160                 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
161         ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
162         ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
163         ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   _ASM_PTR __HYPERVISOR_VIRT_START)
164         ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   _ASM_PTR 0)
165
166 #endif /*CONFIG_XEN */