blob: 674b222544b78dde6c3b737a767500e5f19627b3 [file] [log] [blame]
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -07001/* 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>
Sam Ravnborg08b6d292008-01-30 13:33:25 +01007#include <linux/init.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -07008
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -07009#include <asm/boot.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -070010#include <asm/asm.h>
Jeremy Fitzhardinge0341c142009-02-13 11:14:01 -080011#include <asm/page_types.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -070012
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070013#include <xen/interface/elfnote.h>
Mukesh Rathor4e903a22013-12-31 11:16:25 -050014#include <xen/interface/features.h>
Jeremy Fitzhardinge7e0edc12008-05-31 01:33:04 +010015#include <asm/xen/interface.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070016
Mukesh Rathor4e903a22013-12-31 11:16:25 -050017#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
Sam Ravnborg08b6d292008-01-30 13:33:25 +010036 __INIT
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070037ENTRY(startup_xen)
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070038 cld
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -070039#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
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070046 jmp xen_start_kernel
Sam Ravnborg08b6d292008-01-30 13:33:25 +010047
48 __FINIT
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070049
Mukesh Rathora2ef5dc2014-09-10 16:36:06 -070050#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
Jeremy Fitzhardingea987b162008-06-16 15:01:56 -070085.pushsection .text
Konrad Rzeszutek Wilk7d0642b2012-07-11 15:03:18 -040086 .balign PAGE_SIZE
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070087ENTRY(hypercall_page)
Konrad Rzeszutek Wilk7d0642b2012-07-11 15:03:18 -040088#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
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700141.popsection
142
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700143 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")
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700146#ifdef CONFIG_X86_32
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700147 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700148#else
149 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
150#endif
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700151 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
152 ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
Mukesh Rathor4e903a22013-12-31 11:16:25 -0500153 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))
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700157 ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700158 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
Jeremy Fitzhardinge7e0edc12008-05-31 01:33:04 +0100159 ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
160 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
161 ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
Juergen Grossd1e9abd2014-09-17 06:12:36 +0200162 ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700163 ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700164 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700165
166#endif /*CONFIG_XEN */