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>
13 #include <asm/page_types.h>
14 #include <asm/percpu.h>
15 #include <asm/unwind_hints.h>
17 #include <xen/interface/elfnote.h>
18 #include <xen/interface/features.h>
19 #include <xen/interface/xen.h>
20 #include <xen/interface/xen-mca.h>
21 #include <asm/xen/interface.h>
23 .pushsection .noinstr.text, "ax"
25 SYM_CODE_START(hypercall_page)
26 .rept (PAGE_SIZE / 32)
32 * Xen will write the hypercall page, and sort out ENDBR.
37 #define HYPERCALL(n) \
38 .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
39 .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
40 #include <asm/xen-hypercalls.h>
42 SYM_CODE_END(hypercall_page)
47 SYM_CODE_START(startup_xen)
48 UNWIND_HINT_END_OF_STACK
52 leaq __top_init_kernel_stack(%rip), %rsp
56 * The base of %gs always points to fixed_percpu_data. If the
57 * stack protector canary is enabled, it is located at %gs:40.
58 * Note that, on SMP, the boot cpu uses init data section until
59 * the per cpu areas are set up.
61 movl $MSR_GS_BASE,%ecx
62 movq $INIT_PER_CPU_VAR(fixed_percpu_data),%rax
68 SYM_CODE_END(startup_xen)
71 #ifdef CONFIG_XEN_PV_SMP
73 SYM_CODE_START(asm_cpu_bringup_and_idle)
74 UNWIND_HINT_END_OF_STACK
77 call cpu_bringup_and_idle
78 SYM_CODE_END(asm_cpu_bringup_and_idle)
80 SYM_CODE_START(xen_cpu_bringup_again)
84 call cpu_bringup_and_idle
85 SYM_CODE_END(xen_cpu_bringup_again)
90 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
91 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
92 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
94 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
95 /* Map the p2m table to a 512GB-aligned user address. */
96 ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD))
97 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .globl xen_elfnote_entry;
98 xen_elfnote_entry: _ASM_PTR xen_elfnote_entry_value - .)
99 ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables")
100 ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
101 ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
102 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
103 ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
104 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
105 # define FEATURES_PV (1 << XENFEAT_writable_page_tables)
107 # define FEATURES_PV 0
109 #ifdef CONFIG_XEN_PVH
110 # define FEATURES_PVH (1 << XENFEAT_linux_rsdp_unrestricted)
112 # define FEATURES_PVH 0
114 #ifdef CONFIG_XEN_DOM0
115 # define FEATURES_DOM0 (1 << XENFEAT_dom0)
117 # define FEATURES_DOM0 0
119 ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .globl xen_elfnote_hypercall_page;
120 xen_elfnote_hypercall_page: _ASM_PTR xen_elfnote_hypercall_page_value - .)
121 ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
122 .long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0)
123 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
124 ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
126 #endif /*CONFIG_XEN */