5c63d2d955bbaf715488da57433b0d8266ba3f32
[deliverable/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 <xen/interface/xen.h>
16 #include <xen/interface/xen-mca.h>
17 #include <asm/xen/interface.h>
18
19 #ifdef CONFIG_XEN_PVH
20 #define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
21 /* Note the lack of 'hvm_callback_vector'. Older hypervisor will
22 * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
23 * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore.
24 */
25 #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
26 (1 << XENFEAT_auto_translated_physmap) | \
27 (1 << XENFEAT_supervisor_mode_kernel) | \
28 (1 << XENFEAT_hvm_callback_vector))
29 /* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
30 * up regardless whether this CONFIG option is enabled or not, but it
31 * clarifies what the right flags need to be.
32 */
33 #else
34 #define PVH_FEATURES_STR ""
35 #define PVH_FEATURES (0)
36 #endif
37
38 __INIT
39 ENTRY(startup_xen)
40 cld
41
42 /* Clear .bss */
43 xor %eax,%eax
44 mov $__bss_start, %_ASM_DI
45 mov $__bss_stop, %_ASM_CX
46 sub %_ASM_DI, %_ASM_CX
47 shr $__ASM_SEL(2, 3), %_ASM_CX
48 rep __ASM_SIZE(stos)
49
50 #ifdef CONFIG_X86_32
51 mov %esi,xen_start_info
52 mov $init_thread_union+THREAD_SIZE,%esp
53 #else
54 mov %rsi,xen_start_info
55 mov $init_thread_union+THREAD_SIZE,%rsp
56 #endif
57 jmp xen_start_kernel
58
59 __FINIT
60
61 #ifdef CONFIG_XEN_PVH
62 /*
63 * xen_pvh_early_cpu_init() - early PVH VCPU initialization
64 * @cpu: this cpu number (%rdi)
65 * @entry: true if this is a secondary vcpu coming up on this entry
66 * point, false if this is the boot CPU being initialized for
67 * the first time (%rsi)
68 *
69 * Note: This is called as a function on the boot CPU, and is the entry point
70 * on the secondary CPU.
71 */
72 ENTRY(xen_pvh_early_cpu_init)
73 mov %rsi, %r11
74
75 /* Gather features to see if NX implemented. */
76 mov $0x80000001, %eax
77 cpuid
78 mov %edx, %esi
79
80 mov $MSR_EFER, %ecx
81 rdmsr
82 bts $_EFER_SCE, %eax
83
84 bt $20, %esi
85 jnc 1f /* No NX, skip setting it */
86 bts $_EFER_NX, %eax
87 1: wrmsr
88 #ifdef CONFIG_SMP
89 cmp $0, %r11b
90 jne cpu_bringup_and_idle
91 #endif
92 ret
93
94 #endif /* CONFIG_XEN_PVH */
95
96 .pushsection .text
97 .balign PAGE_SIZE
98 ENTRY(hypercall_page)
99 .skip PAGE_SIZE
100
101 #define HYPERCALL(n) \
102 .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
103 .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
104 #include <asm/xen-hypercalls.h>
105 #undef HYPERCALL
106
107 .popsection
108
109 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
110 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
111 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
112 #ifdef CONFIG_X86_32
113 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
114 #else
115 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
116 /* Map the p2m table to a 512GB-aligned user address. */
117 ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE)
118 #endif
119 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
120 ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
121 ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
122 ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
123 (1 << XENFEAT_writable_page_tables) |
124 (1 << XENFEAT_dom0))
125 ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
126 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
127 ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
128 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
129 ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
130 ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
131 ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
132 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
133
134 #endif /*CONFIG_XEN */
This page took 0.034873 seconds and 4 git commands to generate.