Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Xen-specific pieces of head.S, intended to be included in the right
0003     place in head.S */
0004 
0005 #ifdef CONFIG_XEN
0006 
0007 #include <linux/elfnote.h>
0008 #include <linux/init.h>
0009 
0010 #include <asm/boot.h>
0011 #include <asm/asm.h>
0012 #include <asm/msr.h>
0013 #include <asm/page_types.h>
0014 #include <asm/percpu.h>
0015 #include <asm/unwind_hints.h>
0016 
0017 #include <xen/interface/elfnote.h>
0018 #include <xen/interface/features.h>
0019 #include <xen/interface/xen.h>
0020 #include <xen/interface/xen-mca.h>
0021 #include <asm/xen/interface.h>
0022 
0023 .pushsection .noinstr.text, "ax"
0024     .balign PAGE_SIZE
0025 SYM_CODE_START(hypercall_page)
0026     .rept (PAGE_SIZE / 32)
0027         UNWIND_HINT_FUNC
0028         ANNOTATE_NOENDBR
0029         ANNOTATE_UNRET_SAFE
0030         ret
0031         /*
0032          * Xen will write the hypercall page, and sort out ENDBR.
0033          */
0034         .skip 31, 0xcc
0035     .endr
0036 
0037 #define HYPERCALL(n) \
0038     .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
0039     .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
0040 #include <asm/xen-hypercalls.h>
0041 #undef HYPERCALL
0042 SYM_CODE_END(hypercall_page)
0043 .popsection
0044 
0045 #ifdef CONFIG_XEN_PV
0046     __INIT
0047 SYM_CODE_START(startup_xen)
0048     UNWIND_HINT_EMPTY
0049     ANNOTATE_NOENDBR
0050     cld
0051 
0052     mov initial_stack(%rip), %rsp
0053 
0054     /* Set up %gs.
0055      *
0056      * The base of %gs always points to fixed_percpu_data.  If the
0057      * stack protector canary is enabled, it is located at %gs:40.
0058      * Note that, on SMP, the boot cpu uses init data section until
0059      * the per cpu areas are set up.
0060      */
0061     movl    $MSR_GS_BASE,%ecx
0062     movq    $INIT_PER_CPU_VAR(fixed_percpu_data),%rax
0063     cdq
0064     wrmsr
0065 
0066     mov %rsi, %rdi
0067     call xen_start_kernel
0068 SYM_CODE_END(startup_xen)
0069     __FINIT
0070 
0071 #ifdef CONFIG_XEN_PV_SMP
0072 .pushsection .text
0073 SYM_CODE_START(asm_cpu_bringup_and_idle)
0074     UNWIND_HINT_EMPTY
0075     ENDBR
0076 
0077     call cpu_bringup_and_idle
0078 SYM_CODE_END(asm_cpu_bringup_and_idle)
0079 .popsection
0080 #endif
0081 #endif
0082 
0083     ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
0084     ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
0085     ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
0086 #ifdef CONFIG_X86_32
0087     ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __PAGE_OFFSET)
0088 #else
0089     ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __START_KERNEL_map)
0090     /* Map the p2m table to a 512GB-aligned user address. */
0091     ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad (PUD_SIZE * PTRS_PER_PUD))
0092 #endif
0093 #ifdef CONFIG_XEN_PV
0094     ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
0095 #endif
0096     ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
0097     ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
0098         .ascii "!writable_page_tables|pae_pgdir_above_4gb")
0099     ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
0100         .long (1 << XENFEAT_writable_page_tables) |       \
0101               (1 << XENFEAT_dom0) |                       \
0102               (1 << XENFEAT_linux_rsdp_unrestricted))
0103     ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
0104     ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
0105     ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
0106         .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
0107     ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
0108     ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
0109     ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   _ASM_PTR __HYPERVISOR_VIRT_START)
0110     ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   _ASM_PTR 0)
0111 
0112 #endif /*CONFIG_XEN */