Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[muen/linux.git] / arch / x86 / xen / xen-head.S
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Xen-specific pieces of head.S, intended to be included in the right
3         place in head.S */
4
5 #ifdef CONFIG_XEN
6
7 #include <linux/elfnote.h>
8 #include <linux/init.h>
9
10 #include <asm/boot.h>
11 #include <asm/asm.h>
12 #include <asm/page_types.h>
13 #include <asm/unwind_hints.h>
14
15 #include <xen/interface/elfnote.h>
16 #include <xen/interface/features.h>
17 #include <xen/interface/xen.h>
18 #include <xen/interface/xen-mca.h>
19 #include <asm/xen/interface.h>
20
21 #ifdef CONFIG_XEN_PV
22         __INIT
23 ENTRY(startup_xen)
24         UNWIND_HINT_EMPTY
25         cld
26
27         /* Clear .bss */
28         xor %eax,%eax
29         mov $__bss_start, %_ASM_DI
30         mov $__bss_stop, %_ASM_CX
31         sub %_ASM_DI, %_ASM_CX
32         shr $__ASM_SEL(2, 3), %_ASM_CX
33         rep __ASM_SIZE(stos)
34
35         mov %_ASM_SI, xen_start_info
36         mov $init_thread_union+THREAD_SIZE, %_ASM_SP
37
38         jmp xen_start_kernel
39 END(startup_xen)
40         __FINIT
41 #endif
42
43 .pushsection .text
44         .balign PAGE_SIZE
45 ENTRY(hypercall_page)
46         .rept (PAGE_SIZE / 32)
47                 UNWIND_HINT_EMPTY
48                 .skip 32
49         .endr
50
51 #define HYPERCALL(n) \
52         .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
53         .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
54 #include <asm/xen-hypercalls.h>
55 #undef HYPERCALL
56 END(hypercall_page)
57 .popsection
58
59         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
60         ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
61         ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
62 #ifdef CONFIG_X86_32
63         ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __PAGE_OFFSET)
64 #else
65         ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __START_KERNEL_map)
66         /* Map the p2m table to a 512GB-aligned user address. */
67         ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad (PUD_SIZE * PTRS_PER_PUD))
68 #endif
69 #ifdef CONFIG_XEN_PV
70         ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
71 #endif
72         ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
73         ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
74                 .ascii "!writable_page_tables|pae_pgdir_above_4gb")
75         ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
76                 .long (1 << XENFEAT_writable_page_tables) | (1 << XENFEAT_dom0))
77         ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
78         ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
79         ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
80                 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
81         ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
82         ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
83         ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   _ASM_PTR __HYPERVISOR_VIRT_START)
84         ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   _ASM_PTR 0)
85
86 #endif /*CONFIG_XEN */