Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
5ead97c8 JF |
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> | |
08b6d290 | 8 | #include <linux/init.h> |
7077c33d | 9 | |
5ead97c8 | 10 | #include <asm/boot.h> |
7077c33d | 11 | #include <asm/asm.h> |
4f277295 | 12 | #include <asm/msr.h> |
0341c14d | 13 | #include <asm/page_types.h> |
4f277295 | 14 | #include <asm/percpu.h> |
abbe1cac | 15 | #include <asm/unwind_hints.h> |
7077c33d | 16 | |
5ead97c8 | 17 | #include <xen/interface/elfnote.h> |
4e903a20 | 18 | #include <xen/interface/features.h> |
526abeae JG |
19 | #include <xen/interface/xen.h> |
20 | #include <xen/interface/xen-mca.h> | |
7e0edc1b | 21 | #include <asm/xen/interface.h> |
5ead97c8 | 22 | |
c504b2f1 | 23 | #ifdef CONFIG_XEN_PV |
08b6d290 | 24 | __INIT |
5ead97c8 | 25 | ENTRY(startup_xen) |
abbe1cac | 26 | UNWIND_HINT_EMPTY |
5ead97c8 | 27 | cld |
04b6b4a5 BO |
28 | |
29 | /* Clear .bss */ | |
30 | xor %eax,%eax | |
31 | mov $__bss_start, %_ASM_DI | |
32 | mov $__bss_stop, %_ASM_CX | |
33 | sub %_ASM_DI, %_ASM_CX | |
34 | shr $__ASM_SEL(2, 3), %_ASM_CX | |
35 | rep __ASM_SIZE(stos) | |
36 | ||
4478c407 BO |
37 | mov %_ASM_SI, xen_start_info |
38 | mov $init_thread_union+THREAD_SIZE, %_ASM_SP | |
39 | ||
4f277295 JG |
40 | #ifdef CONFIG_X86_64 |
41 | /* Set up %gs. | |
42 | * | |
e6401c13 AL |
43 | * The base of %gs always points to fixed_percpu_data. If the |
44 | * stack protector canary is enabled, it is located at %gs:40. | |
45 | * Note that, on SMP, the boot cpu uses init data section until | |
46 | * the per cpu areas are set up. | |
4f277295 JG |
47 | */ |
48 | movl $MSR_GS_BASE,%ecx | |
e6401c13 | 49 | movq $INIT_PER_CPU_VAR(fixed_percpu_data),%rax |
4f277295 JG |
50 | cdq |
51 | wrmsr | |
52 | #endif | |
53 | ||
5ead97c8 | 54 | jmp xen_start_kernel |
2582d3df | 55 | END(startup_xen) |
08b6d290 | 56 | __FINIT |
c504b2f1 | 57 | #endif |
5ead97c8 | 58 | |
a987b16c | 59 | .pushsection .text |
7d0642b9 | 60 | .balign PAGE_SIZE |
5ead97c8 | 61 | ENTRY(hypercall_page) |
abbe1cac JP |
62 | .rept (PAGE_SIZE / 32) |
63 | UNWIND_HINT_EMPTY | |
64 | .skip 32 | |
65 | .endr | |
526abeae JG |
66 | |
67 | #define HYPERCALL(n) \ | |
68 | .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \ | |
69 | .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32 | |
70 | #include <asm/xen-hypercalls.h> | |
71 | #undef HYPERCALL | |
2582d3df | 72 | END(hypercall_page) |
5ead97c8 JF |
73 | .popsection |
74 | ||
75 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") | |
76 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") | |
77 | ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") | |
8c5e5ac3 | 78 | #ifdef CONFIG_X86_32 |
7077c33d | 79 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET) |
8c5e5ac3 JF |
80 | #else |
81 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map) | |
8f5b0c63 | 82 | /* Map the p2m table to a 512GB-aligned user address. */ |
daaa42f0 | 83 | ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD)) |
8c5e5ac3 | 84 | #endif |
c504b2f1 | 85 | #ifdef CONFIG_XEN_PV |
7077c33d | 86 | ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen) |
c504b2f1 | 87 | #endif |
7077c33d | 88 | ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page) |
063334f3 BO |
89 | ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, |
90 | .ascii "!writable_page_tables|pae_pgdir_above_4gb") | |
91 | ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, | |
a5a18ae7 BO |
92 | .long (1 << XENFEAT_writable_page_tables) | \ |
93 | (1 << XENFEAT_dom0) | \ | |
94 | (1 << XENFEAT_linux_rsdp_unrestricted)) | |
5ead97c8 | 95 | ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes") |
5ead97c8 | 96 | ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") |
7e0edc1b JF |
97 | ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, |
98 | .quad _PAGE_PRESENT; .quad _PAGE_PRESENT) | |
99 | ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1) | |
d1e9abd6 | 100 | ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) |
7077c33d | 101 | ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START) |
8c5e5ac3 | 102 | ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0) |
5ead97c8 JF |
103 | |
104 | #endif /*CONFIG_XEN */ |