Linux Audio

Check our new training course

Loading...
v6.2
  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/msr.h>
 13#include <asm/page_types.h>
 14#include <asm/percpu.h>
 15#include <asm/unwind_hints.h>
 16
 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>
 22
 23.pushsection .noinstr.text, "ax"
 24	.balign PAGE_SIZE
 25SYM_CODE_START(hypercall_page)
 26	.rept (PAGE_SIZE / 32)
 27		UNWIND_HINT_FUNC
 28		ANNOTATE_NOENDBR
 29		ANNOTATE_UNRET_SAFE
 30		ret
 31		/*
 32		 * Xen will write the hypercall page, and sort out ENDBR.
 33		 */
 34		.skip 31, 0xcc
 35	.endr
 36
 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>
 41#undef HYPERCALL
 42SYM_CODE_END(hypercall_page)
 43.popsection
 44
 45#ifdef CONFIG_XEN_PV
 46	__INIT
 47SYM_CODE_START(startup_xen)
 48	UNWIND_HINT_EMPTY
 49	ANNOTATE_NOENDBR
 50	cld
 51
 52	mov initial_stack(%rip), %rsp
 53
 54	/* Set up %gs.
 55	 *
 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.
 60	 */
 61	movl	$MSR_GS_BASE,%ecx
 62	movq	$INIT_PER_CPU_VAR(fixed_percpu_data),%rax
 63	cdq
 64	wrmsr
 65
 66	mov	%rsi, %rdi
 67	call xen_start_kernel
 68SYM_CODE_END(startup_xen)
 69	__FINIT
 70
 71#ifdef CONFIG_XEN_PV_SMP
 72.pushsection .text
 73SYM_CODE_START(asm_cpu_bringup_and_idle)
 74	UNWIND_HINT_EMPTY
 75	ENDBR
 76
 77	call cpu_bringup_and_idle
 78SYM_CODE_END(asm_cpu_bringup_and_idle)
 
 
 
 
 
 
 
 79.popsection
 80#endif
 81#endif
 82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 83	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
 84	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
 85	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
 86#ifdef CONFIG_X86_32
 87	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __PAGE_OFFSET)
 88#else
 89	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __START_KERNEL_map)
 90	/* Map the p2m table to a 512GB-aligned user address. */
 91	ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad (PUD_SIZE * PTRS_PER_PUD))
 92#endif
 93#ifdef CONFIG_XEN_PV
 94	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
 95#endif
 96	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
 97	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
 98		.ascii "!writable_page_tables|pae_pgdir_above_4gb")
 99	ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
100		.long (1 << XENFEAT_writable_page_tables) |       \
101		      (1 << XENFEAT_dom0) |                       \
102		      (1 << XENFEAT_linux_rsdp_unrestricted))
103	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
104	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
105	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
106		.quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
107	ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
108	ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
109	ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   _ASM_PTR __HYPERVISOR_VIRT_START)
110	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   _ASM_PTR 0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
112#endif /*CONFIG_XEN */
v6.13.7
  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#include <linux/instrumentation.h>
 10
 11#include <asm/boot.h>
 12#include <asm/asm.h>
 13#include <asm/frame.h>
 14#include <asm/msr.h>
 15#include <asm/page_types.h>
 16#include <asm/percpu.h>
 17#include <asm/unwind_hints.h>
 18
 19#include <xen/interface/elfnote.h>
 20#include <xen/interface/features.h>
 21#include <xen/interface/xen.h>
 22#include <xen/interface/xen-mca.h>
 23#include <asm/xen/interface.h>
 24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 25#ifdef CONFIG_XEN_PV
 26	__INIT
 27SYM_CODE_START(startup_xen)
 28	UNWIND_HINT_END_OF_STACK
 29	ANNOTATE_NOENDBR
 30	cld
 31
 32	leaq	__top_init_kernel_stack(%rip), %rsp
 33
 34	/* Set up %gs.
 35	 *
 36	 * The base of %gs always points to fixed_percpu_data.  If the
 37	 * stack protector canary is enabled, it is located at %gs:40.
 38	 * Note that, on SMP, the boot cpu uses init data section until
 39	 * the per cpu areas are set up.
 40	 */
 41	movl	$MSR_GS_BASE,%ecx
 42	movq	$INIT_PER_CPU_VAR(fixed_percpu_data),%rax
 43	cdq
 44	wrmsr
 45
 46	mov	%rsi, %rdi
 47	call xen_start_kernel
 48SYM_CODE_END(startup_xen)
 49	__FINIT
 50
 51#ifdef CONFIG_XEN_PV_SMP
 52.pushsection .text
 53SYM_CODE_START(asm_cpu_bringup_and_idle)
 54	UNWIND_HINT_END_OF_STACK
 55	ENDBR
 56
 57	call cpu_bringup_and_idle
 58SYM_CODE_END(asm_cpu_bringup_and_idle)
 59
 60SYM_CODE_START(xen_cpu_bringup_again)
 61	UNWIND_HINT_FUNC
 62	mov	%rdi, %rsp
 63	UNWIND_HINT_REGS
 64	call	cpu_bringup_and_idle
 65SYM_CODE_END(xen_cpu_bringup_again)
 66.popsection
 67#endif
 68#endif
 69
 70	.pushsection .noinstr.text, "ax"
 71/*
 72 * Xen hypercall interface to the hypervisor.
 73 *
 74 * Input:
 75 *     %eax: hypercall number
 76 *   32-bit:
 77 *     %ebx, %ecx, %edx, %esi, %edi: args 1..5 for the hypercall
 78 *   64-bit:
 79 *     %rdi, %rsi, %rdx, %r10, %r8: args 1..5 for the hypercall
 80 * Output: %[er]ax
 81 */
 82SYM_FUNC_START(xen_hypercall_hvm)
 83	ENDBR
 84	FRAME_BEGIN
 85	/* Save all relevant registers (caller save and arguments). */
 86#ifdef CONFIG_X86_32
 87	push %eax
 88	push %ebx
 89	push %ecx
 90	push %edx
 91	push %esi
 92	push %edi
 93#else
 94	push %rax
 95	push %rcx
 96	push %rdx
 97	push %rdi
 98	push %rsi
 99	push %r11
100	push %r10
101	push %r9
102	push %r8
103#ifdef CONFIG_FRAME_POINTER
104	pushq $0	/* Dummy push for stack alignment. */
105#endif
106#endif
107	/* Set the vendor specific function. */
108	call __xen_hypercall_setfunc
109	/* Set ZF = 1 if AMD, Restore saved registers. */
110#ifdef CONFIG_X86_32
111	lea xen_hypercall_amd, %ebx
112	cmp %eax, %ebx
113	pop %edi
114	pop %esi
115	pop %edx
116	pop %ecx
117	pop %ebx
118	pop %eax
119#else
120	lea xen_hypercall_amd(%rip), %rcx
121	cmp %rax, %rcx
122#ifdef CONFIG_FRAME_POINTER
123	pop %rax	/* Dummy pop. */
124#endif
125	pop %r8
126	pop %r9
127	pop %r10
128	pop %r11
129	pop %rsi
130	pop %rdi
131	pop %rdx
132	pop %rcx
133	pop %rax
134#endif
135	FRAME_END
136	/* Use correct hypercall function. */
137	jz xen_hypercall_amd
138	jmp xen_hypercall_intel
139SYM_FUNC_END(xen_hypercall_hvm)
140
141SYM_FUNC_START(xen_hypercall_amd)
142	vmmcall
143	RET
144SYM_FUNC_END(xen_hypercall_amd)
145
146SYM_FUNC_START(xen_hypercall_intel)
147	vmcall
148	RET
149SYM_FUNC_END(xen_hypercall_intel)
150	.popsection
151
152	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
153	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz "2.6")
154	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz "xen-3.0")
155#ifdef CONFIG_XEN_PV
 
 
156	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      _ASM_PTR __START_KERNEL_map)
157	/* Map the p2m table to a 512GB-aligned user address. */
158	ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad (PUD_SIZE * PTRS_PER_PUD))
159	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .globl xen_elfnote_entry;
160		xen_elfnote_entry: _ASM_PTR xen_elfnote_entry_value - .)
161	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .ascii "!writable_page_tables")
 
 
 
 
 
 
 
 
162	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz "yes")
 
163	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
164		.quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
 
165	ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
 
166	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   _ASM_PTR 0)
167# define FEATURES_PV (1 << XENFEAT_writable_page_tables)
168#else
169# define FEATURES_PV 0
170#endif
171#ifdef CONFIG_XEN_PVH
172# define FEATURES_PVH (1 << XENFEAT_linux_rsdp_unrestricted)
173#else
174# define FEATURES_PVH 0
175#endif
176#ifdef CONFIG_XEN_DOM0
177# define FEATURES_DOM0 (1 << XENFEAT_dom0)
178#else
179# define FEATURES_DOM0 0
180#endif
181	ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
182		.long FEATURES_PV | FEATURES_PVH | FEATURES_DOM0)
183	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
184	ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
185
186#endif /*CONFIG_XEN */