/* SPDX-License-Identifier: GPL-2.0 */1/* Xen-specific pieces of head.S, intended to be included in the right2place in head.S */34#ifdef CONFIG_XEN56#include <linux/elfnote.h>7#include <linux/init.h>8#include <linux/instrumentation.h>910#include <asm/boot.h>11#include <asm/asm.h>12#include <asm/frame.h>13#include <asm/msr.h>14#include <asm/page_types.h>15#include <asm/percpu.h>16#include <asm/unwind_hints.h>1718#include <xen/interface/elfnote.h>19#include <xen/interface/features.h>20#include <xen/interface/xen.h>21#include <xen/interface/xen-mca.h>22#include <asm/xen/interface.h>2324#ifdef CONFIG_XEN_PV25__INIT26SYM_CODE_START(startup_xen)27UNWIND_HINT_END_OF_STACK28ANNOTATE_NOENDBR29cld3031leaq __top_init_kernel_stack(%rip), %rsp3233/*34* Set up GSBASE.35* Note that, on SMP, the boot cpu uses init data section until36* the per cpu areas are set up.37*/38movl $MSR_GS_BASE,%ecx39xorl %eax, %eax40xorl %edx, %edx41wrmsr4243mov %rsi, %rdi44call xen_start_kernel45SYM_CODE_END(startup_xen)46__FINIT4748#ifdef CONFIG_XEN_PV_SMP49.pushsection .text50SYM_CODE_START(asm_cpu_bringup_and_idle)51UNWIND_HINT_END_OF_STACK52ENDBR5354call cpu_bringup_and_idle55SYM_CODE_END(asm_cpu_bringup_and_idle)5657SYM_CODE_START(xen_cpu_bringup_again)58UNWIND_HINT_FUNC59mov %rdi, %rsp60UNWIND_HINT_REGS61call cpu_bringup_and_idle62SYM_CODE_END(xen_cpu_bringup_again)63.popsection64#endif65#endif6667.pushsection .noinstr.text, "ax"68/*69* Xen hypercall interface to the hypervisor.70*71* Input:72* %eax: hypercall number73* 32-bit:74* %ebx, %ecx, %edx, %esi, %edi: args 1..5 for the hypercall75* 64-bit:76* %rdi, %rsi, %rdx, %r10, %r8: args 1..5 for the hypercall77* Output: %[er]ax78*/79SYM_FUNC_START(xen_hypercall_hvm)80ENDBR81FRAME_BEGIN82/* Save all relevant registers (caller save and arguments). */83#ifdef CONFIG_X86_3284push %eax85push %ebx86push %ecx87push %edx88push %esi89push %edi90#else91push %rax92push %rcx93push %rdx94push %rdi95push %rsi96push %r1197push %r1098push %r999push %r8100#endif101/* Set the vendor specific function. */102call __xen_hypercall_setfunc103/* Set ZF = 1 if AMD, Restore saved registers. */104#ifdef CONFIG_X86_32105lea xen_hypercall_amd, %ebx106cmp %eax, %ebx107pop %edi108pop %esi109pop %edx110pop %ecx111pop %ebx112pop %eax113#else114lea xen_hypercall_amd(%rip), %rcx115cmp %rax, %rcx116pop %r8117pop %r9118pop %r10119pop %r11120pop %rsi121pop %rdi122pop %rdx123pop %rcx124pop %rax125#endif126FRAME_END127/* Use correct hypercall function. */128jz xen_hypercall_amd129jmp xen_hypercall_intel130SYM_FUNC_END(xen_hypercall_hvm)131132SYM_FUNC_START(xen_hypercall_amd)133ANNOTATE_NOENDBR134vmmcall135RET136SYM_FUNC_END(xen_hypercall_amd)137138SYM_FUNC_START(xen_hypercall_intel)139ANNOTATE_NOENDBR140vmcall141RET142SYM_FUNC_END(xen_hypercall_intel)143.popsection144145ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")146ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")147ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")148#ifdef CONFIG_XEN_PV149ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)150/* Map the p2m table to a 512GB-aligned user address. */151ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD))152ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .globl xen_elfnote_entry;153xen_elfnote_entry: _ASM_PTR xen_elfnote_entry_value - .)154ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables")155ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")156ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,157.quad _PAGE_PRESENT; .quad _PAGE_PRESENT)158ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)159ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)160# define FEATURES_PV (1 << XENFEAT_writable_page_tables)161#else162# define FEATURES_PV 0163#endif164#ifdef CONFIG_XEN_PVH165# define FEATURES_PVH (1 << XENFEAT_linux_rsdp_unrestricted)166#else167# define FEATURES_PVH 0168#endif169#ifdef CONFIG_XEN_DOM0170# define FEATURES_DOM0 (1 << XENFEAT_dom0)171#else172# define FEATURES_DOM0 0173#endif174ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,175.long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0)176ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")177ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)178179#endif /*CONFIG_XEN */180181182