1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Xen-specific pieces of head.S, intended to be included in the right
7 #include <linux/elfnote.h>
8 #include <linux/init.h>
9 #include <linux/instrumentation.h>
13 #include <asm/frame.h>
15 #include <asm/page_types.h>
16 #include <asm/percpu.h>
17 #include <asm/unwind_hints.h>
19 #include <xen/interface/elfnote.h>
20 #include <xen/interface/features.h>
21 #include <xen/interface/xen.h>
22 #include <xen/interface/xen-mca.h>
23 #include <asm/xen/interface.h>
27 SYM_CODE_START(startup_xen)
28 UNWIND_HINT_END_OF_STACK
32 leaq __top_init_kernel_stack(%rip), %rsp
36 * The base of %gs always points to fixed_percpu_data. If the
37 * stack protector canary is enabled, it is located at %gs:40.
38 * Note that, on SMP, the boot cpu uses init data section until
39 * the per cpu areas are set up.
41 movl $MSR_GS_BASE,%ecx
42 movq $INIT_PER_CPU_VAR(fixed_percpu_data),%rax
48 SYM_CODE_END(startup_xen)
51 #ifdef CONFIG_XEN_PV_SMP
53 SYM_CODE_START(asm_cpu_bringup_and_idle)
54 UNWIND_HINT_END_OF_STACK
57 call cpu_bringup_and_idle
58 SYM_CODE_END(asm_cpu_bringup_and_idle)
60 SYM_CODE_START(xen_cpu_bringup_again)
64 call cpu_bringup_and_idle
65 SYM_CODE_END(xen_cpu_bringup_again)
70 .pushsection .noinstr.text, "ax"
72 * Xen hypercall interface to the hypervisor.
75 * %eax: hypercall number
77 * %ebx, %ecx, %edx, %esi, %edi: args 1..5 for the hypercall
79 * %rdi, %rsi, %rdx, %r10, %r8: args 1..5 for the hypercall
82 SYM_FUNC_START(xen_hypercall_hvm)
85 /* Save all relevant registers (caller save and arguments). */
103 #ifdef CONFIG_FRAME_POINTER
104 pushq $0 /* Dummy push for stack alignment. */
107 /* Set the vendor specific function. */
108 call __xen_hypercall_setfunc
109 /* Set ZF = 1 if AMD, Restore saved registers. */
111 lea xen_hypercall_amd, %ebx
120 lea xen_hypercall_amd(%rip), %rbx
122 #ifdef CONFIG_FRAME_POINTER
123 pop %rax /* Dummy pop. */
135 /* Use correct hypercall function. */
137 jmp xen_hypercall_intel
138 SYM_FUNC_END(xen_hypercall_hvm)
140 SYM_FUNC_START(xen_hypercall_amd)
143 SYM_FUNC_END(xen_hypercall_amd)
145 SYM_FUNC_START(xen_hypercall_intel)
148 SYM_FUNC_END(xen_hypercall_intel)
151 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
152 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
153 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
155 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
156 /* Map the p2m table to a 512GB-aligned user address. */
157 ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD))
158 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .globl xen_elfnote_entry;
159 xen_elfnote_entry: _ASM_PTR xen_elfnote_entry_value - .)
160 ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables")
161 ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
162 ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
163 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
164 ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
165 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
166 # define FEATURES_PV (1 << XENFEAT_writable_page_tables)
168 # define FEATURES_PV 0
170 #ifdef CONFIG_XEN_PVH
171 # define FEATURES_PVH (1 << XENFEAT_linux_rsdp_unrestricted)
173 # define FEATURES_PVH 0
175 #ifdef CONFIG_XEN_DOM0
176 # define FEATURES_DOM0 (1 << XENFEAT_dom0)
178 # define FEATURES_DOM0 0
180 ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
181 .long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0)
182 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
183 ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
185 #endif /*CONFIG_XEN */