xref: /linux/arch/x86/xen/xen-head.S (revision e0bf6c5ca2d3281f231c5f0c9bf145e9513644de)
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
37ENTRY(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 */
61ENTRY(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
761:	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
87ENTRY(hypercall_page)
88#define NEXT_HYPERCALL(x) \
89	ENTRY(xen_hypercall_##x) \
90	.skip 32
91
92NEXT_HYPERCALL(set_trap_table)
93NEXT_HYPERCALL(mmu_update)
94NEXT_HYPERCALL(set_gdt)
95NEXT_HYPERCALL(stack_switch)
96NEXT_HYPERCALL(set_callbacks)
97NEXT_HYPERCALL(fpu_taskswitch)
98NEXT_HYPERCALL(sched_op_compat)
99NEXT_HYPERCALL(platform_op)
100NEXT_HYPERCALL(set_debugreg)
101NEXT_HYPERCALL(get_debugreg)
102NEXT_HYPERCALL(update_descriptor)
103NEXT_HYPERCALL(ni)
104NEXT_HYPERCALL(memory_op)
105NEXT_HYPERCALL(multicall)
106NEXT_HYPERCALL(update_va_mapping)
107NEXT_HYPERCALL(set_timer_op)
108NEXT_HYPERCALL(event_channel_op_compat)
109NEXT_HYPERCALL(xen_version)
110NEXT_HYPERCALL(console_io)
111NEXT_HYPERCALL(physdev_op_compat)
112NEXT_HYPERCALL(grant_table_op)
113NEXT_HYPERCALL(vm_assist)
114NEXT_HYPERCALL(update_va_mapping_otherdomain)
115NEXT_HYPERCALL(iret)
116NEXT_HYPERCALL(vcpu_op)
117NEXT_HYPERCALL(set_segment_base)
118NEXT_HYPERCALL(mmuext_op)
119NEXT_HYPERCALL(xsm_op)
120NEXT_HYPERCALL(nmi_op)
121NEXT_HYPERCALL(sched_op)
122NEXT_HYPERCALL(callback_op)
123NEXT_HYPERCALL(xenoprof_op)
124NEXT_HYPERCALL(event_channel_op)
125NEXT_HYPERCALL(physdev_op)
126NEXT_HYPERCALL(hvm_op)
127NEXT_HYPERCALL(sysctl)
128NEXT_HYPERCALL(domctl)
129NEXT_HYPERCALL(kexec_op)
130NEXT_HYPERCALL(tmem_op) /* 38 */
131ENTRY(xen_hypercall_rsvr)
132	.skip 320
133NEXT_HYPERCALL(mca) /* 48 */
134NEXT_HYPERCALL(arch_1)
135NEXT_HYPERCALL(arch_2)
136NEXT_HYPERCALL(arch_3)
137NEXT_HYPERCALL(arch_4)
138NEXT_HYPERCALL(arch_5)
139NEXT_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 */
167