xref: /openbmc/linux/arch/x86/kernel/head_64.S (revision f6f1ae91)
1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
2250c2277SThomas Gleixner/*
35b171e82SAlexander Kuleshov *  linux/arch/x86/kernel/head_64.S -- start in 32bit and switch to 64bit
4250c2277SThomas Gleixner *
5250c2277SThomas Gleixner *  Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
6250c2277SThomas Gleixner *  Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
7250c2277SThomas Gleixner *  Copyright (C) 2000 Karsten Keil <kkeil@suse.de>
8250c2277SThomas Gleixner *  Copyright (C) 2001,2002 Andi Kleen <ak@suse.de>
9250c2277SThomas Gleixner *  Copyright (C) 2005 Eric Biederman <ebiederm@xmission.com>
10250c2277SThomas Gleixner */
11250c2277SThomas Gleixner
12250c2277SThomas Gleixner
13250c2277SThomas Gleixner#include <linux/linkage.h>
14250c2277SThomas Gleixner#include <linux/threads.h>
15250c2277SThomas Gleixner#include <linux/init.h>
16ca5999fdSMike Rapoport#include <linux/pgtable.h>
1765fddcfcSMike Rapoport#include <asm/segment.h>
18250c2277SThomas Gleixner#include <asm/page.h>
19250c2277SThomas Gleixner#include <asm/msr.h>
20250c2277SThomas Gleixner#include <asm/cache.h>
21369101daSCyrill Gorcunov#include <asm/processor-flags.h>
22b12d8db8STejun Heo#include <asm/percpu.h>
239900aa2fSH. Peter Anvin#include <asm/nops.h>
247bbcdb1cSAndy Lutomirski#include "../entry/calling.h"
25784d5699SAl Viro#include <asm/export.h>
26bd89004fSPeter Zijlstra#include <asm/nospec-branch.h>
2705ab1d8aSFeng Tang#include <asm/fixmap.h>
28250c2277SThomas Gleixner
2975da04f7SThomas Gleixner/*
3075da04f7SThomas Gleixner * We are not able to switch in one step to the final KERNEL ADDRESS SPACE
31250c2277SThomas Gleixner * because we need identity-mapped pages.
32250c2277SThomas Gleixner */
33b9952ec7SKirill A. Shutemov#define l4_index(x)	(((x) >> 39) & 511)
34a6523748SEduardo Habkost#define pud_index(x)	(((x) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
35a6523748SEduardo Habkost
36b9952ec7SKirill A. ShutemovL4_PAGE_OFFSET = l4_index(__PAGE_OFFSET_BASE_L4)
37b9952ec7SKirill A. ShutemovL4_START_KERNEL = l4_index(__START_KERNEL_map)
38b9952ec7SKirill A. Shutemov
39a6523748SEduardo HabkostL3_START_KERNEL = pud_index(__START_KERNEL_map)
40a6523748SEduardo Habkost
41250c2277SThomas Gleixner	.text
424ae59b91STim Abbott	__HEAD
43250c2277SThomas Gleixner	.code64
4437818afdSJiri SlabySYM_CODE_START_NOALIGN(startup_64)
45fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
46250c2277SThomas Gleixner	/*
471256276cSKonrad Rzeszutek Wilk	 * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0,
48250c2277SThomas Gleixner	 * and someone has loaded an identity mapped page table
49250c2277SThomas Gleixner	 * for us.  These identity mapped page tables map all of the
50250c2277SThomas Gleixner	 * kernel pages and possibly all of memory.
51250c2277SThomas Gleixner	 *
528170e6beSH. Peter Anvin	 * %rsi holds a physical pointer to real_mode_data.
53250c2277SThomas Gleixner	 *
54250c2277SThomas Gleixner	 * We come here either directly from a 64bit bootloader, or from
555b171e82SAlexander Kuleshov	 * arch/x86/boot/compressed/head_64.S.
56250c2277SThomas Gleixner	 *
57250c2277SThomas Gleixner	 * We only come here initially at boot nothing else comes here.
58250c2277SThomas Gleixner	 *
59250c2277SThomas Gleixner	 * Since we may be loaded at an address different from what we were
60250c2277SThomas Gleixner	 * compiled to run at we first fixup the physical addresses in our page
61250c2277SThomas Gleixner	 * tables and then reload them.
62250c2277SThomas Gleixner	 */
63250c2277SThomas Gleixner
643adee777SBrian Gerst	/* Set up the stack for verify_cpu() */
653adee777SBrian Gerst	leaq	(__end_init_task - PTREGS_SIZE)(%rip), %rsp
6691ed140dSBorislav Petkov
67866b556eSJoerg Roedel	leaq	_text(%rip), %rdi
68469693d8SMichael Roth
698f6be6d8SBrian Gerst	/* Setup GSBASE to allow stack canary access for C code */
70469693d8SMichael Roth	movl	$MSR_GS_BASE, %ecx
718f6be6d8SBrian Gerst	leaq	INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
728f6be6d8SBrian Gerst	movl	%edx, %eax
73469693d8SMichael Roth	shrq	$32,  %rdx
74469693d8SMichael Roth	wrmsr
75469693d8SMichael Roth
76866b556eSJoerg Roedel	pushq	%rsi
77866b556eSJoerg Roedel	call	startup_64_setup_env
78866b556eSJoerg Roedel	popq	%rsi
79866b556eSJoerg Roedel
80bcce8290SMichael Roth#ifdef CONFIG_AMD_MEM_ENCRYPT
81bcce8290SMichael Roth	/*
82bcce8290SMichael Roth	 * Activate SEV/SME memory encryption if supported/enabled. This needs to
83bcce8290SMichael Roth	 * be done now, since this also includes setup of the SEV-SNP CPUID table,
84bcce8290SMichael Roth	 * which needs to be done before any CPUID instructions are executed in
85bcce8290SMichael Roth	 * subsequent code.
86bcce8290SMichael Roth	 */
87bcce8290SMichael Roth	movq	%rsi, %rdi
88bcce8290SMichael Roth	pushq	%rsi
89bcce8290SMichael Roth	call	sme_enable
90bcce8290SMichael Roth	popq	%rsi
91bcce8290SMichael Roth#endif
92bcce8290SMichael Roth
93866b556eSJoerg Roedel	/* Now switch to __KERNEL_CS so IRET works reliably */
94866b556eSJoerg Roedel	pushq	$__KERNEL_CS
95866b556eSJoerg Roedel	leaq	.Lon_kernel_cs(%rip), %rax
96866b556eSJoerg Roedel	pushq	%rax
97866b556eSJoerg Roedel	lretq
98866b556eSJoerg Roedel
99866b556eSJoerg Roedel.Lon_kernel_cs:
100fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
101866b556eSJoerg Roedel
10204633df0SBorislav Petkov	/* Sanitize CPU configuration */
10304633df0SBorislav Petkov	call verify_cpu
10404633df0SBorislav Petkov
1055868f365STom Lendacky	/*
1065868f365STom Lendacky	 * Perform pagetable fixups. Additionally, if SME is active, encrypt
1075868f365STom Lendacky	 * the kernel and retrieve the modifier (SME encryption mask if SME
1085868f365STom Lendacky	 * is active) to be added to the initial pgdir entry that will be
1095868f365STom Lendacky	 * programmed into CR3.
1105868f365STom Lendacky	 */
111250c2277SThomas Gleixner	leaq	_text(%rip), %rdi
112c88d7150SKirill A. Shutemov	pushq	%rsi
113c88d7150SKirill A. Shutemov	call	__startup_64
114c88d7150SKirill A. Shutemov	popq	%rsi
115250c2277SThomas Gleixner
1165868f365STom Lendacky	/* Form the CR3 value being sure to include the CR3 modifier */
1175868f365STom Lendacky	addq	$(early_top_pgt - __START_KERNEL_map), %rax
1188170e6beSH. Peter Anvin	jmp 1f
11937818afdSJiri SlabySYM_CODE_END(startup_64)
12037818afdSJiri Slaby
121bc7b11c0SJiri SlabySYM_CODE_START(secondary_startup_64)
122fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
1233e3f0695SPeter Zijlstra	ANNOTATE_NOENDBR
124250c2277SThomas Gleixner	/*
1251256276cSKonrad Rzeszutek Wilk	 * At this point the CPU runs in 64bit mode CS.L = 1 CS.D = 0,
126250c2277SThomas Gleixner	 * and someone has loaded a mapped page table.
127250c2277SThomas Gleixner	 *
1288170e6beSH. Peter Anvin	 * %rsi holds a physical pointer to real_mode_data.
129250c2277SThomas Gleixner	 *
130250c2277SThomas Gleixner	 * We come here either from startup_64 (using physical addresses)
131250c2277SThomas Gleixner	 * or from trampoline.S (using virtual addresses).
132250c2277SThomas Gleixner	 *
133250c2277SThomas Gleixner	 * Using virtual addresses from trampoline.S removes the need
134250c2277SThomas Gleixner	 * to have any identity mapped pages in the kernel page table
135250c2277SThomas Gleixner	 * after the boot processor executes this code.
136250c2277SThomas Gleixner	 */
137250c2277SThomas Gleixner
13804633df0SBorislav Petkov	/* Sanitize CPU configuration */
13904633df0SBorislav Petkov	call verify_cpu
14004633df0SBorislav Petkov
1415868f365STom Lendacky	/*
1423ecacdbdSJoerg Roedel	 * The secondary_startup_64_no_verify entry point is only used by
1433ecacdbdSJoerg Roedel	 * SEV-ES guests. In those guests the call to verify_cpu() would cause
1443ecacdbdSJoerg Roedel	 * #VC exceptions which can not be handled at this stage of secondary
1453ecacdbdSJoerg Roedel	 * CPU bringup.
1463ecacdbdSJoerg Roedel	 *
1473ecacdbdSJoerg Roedel	 * All non SEV-ES systems, especially Intel systems, need to execute
1483ecacdbdSJoerg Roedel	 * verify_cpu() above to make sure NX is enabled.
1493ecacdbdSJoerg Roedel	 */
1503ecacdbdSJoerg RoedelSYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
151fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
1523e3f0695SPeter Zijlstra	ANNOTATE_NOENDBR
1533ecacdbdSJoerg Roedel
1543ecacdbdSJoerg Roedel	/*
1555868f365STom Lendacky	 * Retrieve the modifier (SME encryption mask if SME is active) to be
1565868f365STom Lendacky	 * added to the initial pgdir entry that will be programmed into CR3.
1575868f365STom Lendacky	 */
158469693d8SMichael Roth#ifdef CONFIG_AMD_MEM_ENCRYPT
159469693d8SMichael Roth	movq	sme_me_mask, %rax
160469693d8SMichael Roth#else
161469693d8SMichael Roth	xorq	%rax, %rax
162469693d8SMichael Roth#endif
1635868f365STom Lendacky
1645868f365STom Lendacky	/* Form the CR3 value being sure to include the CR3 modifier */
1655868f365STom Lendacky	addq	$(init_top_pgt - __START_KERNEL_map), %rax
1668170e6beSH. Peter Anvin1:
1678170e6beSH. Peter Anvin
16877a512e3SSean Christopherson#ifdef CONFIG_X86_MCE
16977a512e3SSean Christopherson	/*
17077a512e3SSean Christopherson	 * Preserve CR4.MCE if the kernel will enable #MC support.
17177a512e3SSean Christopherson	 * Clearing MCE may fault in some environments (that also force #MC
17277a512e3SSean Christopherson	 * support). Any machine check that occurs before #MC support is fully
17377a512e3SSean Christopherson	 * configured will crash the system regardless of the CR4.MCE value set
17477a512e3SSean Christopherson	 * here.
17577a512e3SSean Christopherson	 */
17677a512e3SSean Christopherson	movq	%cr4, %rcx
17777a512e3SSean Christopherson	andl	$X86_CR4_MCE, %ecx
17877a512e3SSean Christopherson#else
17977a512e3SSean Christopherson	movl	$0, %ecx
18077a512e3SSean Christopherson#endif
18177a512e3SSean Christopherson
182032370b9SKirill A. Shutemov	/* Enable PAE mode, PGE and LA57 */
18377a512e3SSean Christopherson	orl	$(X86_CR4_PAE | X86_CR4_PGE), %ecx
184032370b9SKirill A. Shutemov#ifdef CONFIG_X86_5LEVEL
18539b95522SKirill A. Shutemov	testl	$1, __pgtable_l5_enabled(%rip)
1866f9dd329SKirill A. Shutemov	jz	1f
187032370b9SKirill A. Shutemov	orl	$X86_CR4_LA57, %ecx
1886f9dd329SKirill A. Shutemov1:
189032370b9SKirill A. Shutemov#endif
1908170e6beSH. Peter Anvin	movq	%rcx, %cr4
191250c2277SThomas Gleixner
192032370b9SKirill A. Shutemov	/* Setup early boot stage 4-/5-level pagetables. */
193250c2277SThomas Gleixner	addq	phys_base(%rip), %rax
194c9f09539SJoerg Roedel
195c9f09539SJoerg Roedel	/*
196c9f09539SJoerg Roedel	 * For SEV guests: Verify that the C-bit is correct. A malicious
197c9f09539SJoerg Roedel	 * hypervisor could lie about the C-bit position to perform a ROP
198c9f09539SJoerg Roedel	 * attack on the guest by writing to the unencrypted stack and wait for
199c9f09539SJoerg Roedel	 * the next RET instruction.
200c9f09539SJoerg Roedel	 * %rsi carries pointer to realmode data and is callee-clobbered. Save
201c9f09539SJoerg Roedel	 * and restore it.
202c9f09539SJoerg Roedel	 */
203c9f09539SJoerg Roedel	pushq	%rsi
204c9f09539SJoerg Roedel	movq	%rax, %rdi
205c9f09539SJoerg Roedel	call	sev_verify_cbit
206c9f09539SJoerg Roedel	popq	%rsi
207c9f09539SJoerg Roedel
208f154f290SJoerg Roedel	/*
209f154f290SJoerg Roedel	 * Switch to new page-table
210f154f290SJoerg Roedel	 *
211f154f290SJoerg Roedel	 * For the boot CPU this switches to early_top_pgt which still has the
212f154f290SJoerg Roedel	 * indentity mappings present. The secondary CPUs will switch to the
213f154f290SJoerg Roedel	 * init_top_pgt here, away from the trampoline_pgd and unmap the
214f154f290SJoerg Roedel	 * indentity mapped ranges.
215f154f290SJoerg Roedel	 */
216250c2277SThomas Gleixner	movq	%rax, %cr3
217250c2277SThomas Gleixner
218f154f290SJoerg Roedel	/*
219f154f290SJoerg Roedel	 * Do a global TLB flush after the CR3 switch to make sure the TLB
220f154f290SJoerg Roedel	 * entries from the identity mapping are flushed.
221f154f290SJoerg Roedel	 */
222f154f290SJoerg Roedel	movq	%cr4, %rcx
223f154f290SJoerg Roedel	movq	%rcx, %rax
224f154f290SJoerg Roedel	xorq	$X86_CR4_PGE, %rcx
225f154f290SJoerg Roedel	movq	%rcx, %cr4
226f154f290SJoerg Roedel	movq	%rax, %cr4
227f154f290SJoerg Roedel
228250c2277SThomas Gleixner	/* Ensure I am executing from virtual addresses */
229250c2277SThomas Gleixner	movq	$1f, %rax
230bd89004fSPeter Zijlstra	ANNOTATE_RETPOLINE_SAFE
231250c2277SThomas Gleixner	jmp	*%rax
232250c2277SThomas Gleixner1:
233fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
2343e3f0695SPeter Zijlstra	ANNOTATE_NOENDBR // above
235250c2277SThomas Gleixner
2363adee777SBrian Gerst#ifdef CONFIG_SMP
2373adee777SBrian Gerst	movl	smpboot_control(%rip), %ecx
2383adee777SBrian Gerst
2393adee777SBrian Gerst	/* Get the per cpu offset for the given CPU# which is in ECX */
2403adee777SBrian Gerst	movq	__per_cpu_offset(,%rcx,8), %rdx
2413adee777SBrian Gerst#else
2423adee777SBrian Gerst	xorl	%edx, %edx /* zero-extended to clear all of RDX */
2433adee777SBrian Gerst#endif /* CONFIG_SMP */
2443adee777SBrian Gerst
2453adee777SBrian Gerst	/*
2463adee777SBrian Gerst	 * Setup a boot time stack - Any secondary CPU will have lost its stack
2473adee777SBrian Gerst	 * by now because the cr3-switch above unmaps the real-mode stack.
2483adee777SBrian Gerst	 *
2493adee777SBrian Gerst	 * RDX contains the per-cpu offset
2503adee777SBrian Gerst	 */
2513adee777SBrian Gerst	movq	pcpu_hot + X86_current_task(%rdx), %rax
2523adee777SBrian Gerst	movq	TASK_threadsp(%rax), %rsp
2533adee777SBrian Gerst
254e04b8833SJoerg Roedel	/*
255*f6f1ae91SThomas Gleixner	 * Now that this CPU is running on its own stack, drop the realmode
256*f6f1ae91SThomas Gleixner	 * protection. For the boot CPU the pointer is NULL!
257*f6f1ae91SThomas Gleixner	 */
258*f6f1ae91SThomas Gleixner	movq	trampoline_lock(%rip), %rax
259*f6f1ae91SThomas Gleixner	testq	%rax, %rax
260*f6f1ae91SThomas Gleixner	jz	.Lsetup_gdt
261*f6f1ae91SThomas Gleixner	movl	$0, (%rax)
262*f6f1ae91SThomas Gleixner
263*f6f1ae91SThomas Gleixner.Lsetup_gdt:
264*f6f1ae91SThomas Gleixner	/*
265e04b8833SJoerg Roedel	 * We must switch to a new descriptor in kernel space for the GDT
266e04b8833SJoerg Roedel	 * because soon the kernel won't have access anymore to the userspace
267e04b8833SJoerg Roedel	 * addresses where we're currently running on. We have to do that here
268e04b8833SJoerg Roedel	 * because in 32bit we couldn't load a 64bit linear address.
269e04b8833SJoerg Roedel	 */
270c253b640SBrian Gerst	subq	$16, %rsp
271c253b640SBrian Gerst	movw	$(GDT_SIZE-1), (%rsp)
272c253b640SBrian Gerst	leaq	gdt_page(%rdx), %rax
273c253b640SBrian Gerst	movq	%rax, 2(%rsp)
274c253b640SBrian Gerst	lgdt	(%rsp)
275c253b640SBrian Gerst	addq	$16, %rsp
276e04b8833SJoerg Roedel
2777b99819dSJoerg Roedel	/* set up data segments */
2787b99819dSJoerg Roedel	xorl %eax,%eax
2797b99819dSJoerg Roedel	movl %eax,%ds
2807b99819dSJoerg Roedel	movl %eax,%ss
2817b99819dSJoerg Roedel	movl %eax,%es
2827b99819dSJoerg Roedel
2837b99819dSJoerg Roedel	/*
2847b99819dSJoerg Roedel	 * We don't really need to load %fs or %gs, but load them anyway
2857b99819dSJoerg Roedel	 * to kill any stale realmode selectors.  This allows execution
2867b99819dSJoerg Roedel	 * under VT hardware.
2877b99819dSJoerg Roedel	 */
2887b99819dSJoerg Roedel	movl %eax,%fs
2897b99819dSJoerg Roedel	movl %eax,%gs
2907b99819dSJoerg Roedel
2917b99819dSJoerg Roedel	/* Set up %gs.
2927b99819dSJoerg Roedel	 *
2937b99819dSJoerg Roedel	 * The base of %gs always points to fixed_percpu_data. If the
2947b99819dSJoerg Roedel	 * stack protector canary is enabled, it is located at %gs:40.
2957b99819dSJoerg Roedel	 * Note that, on SMP, the boot cpu uses init data section until
2967b99819dSJoerg Roedel	 * the per cpu areas are set up.
2977b99819dSJoerg Roedel	 */
2987b99819dSJoerg Roedel	movl	$MSR_GS_BASE,%ecx
2998f6be6d8SBrian Gerst#ifndef CONFIG_SMP
3008f6be6d8SBrian Gerst	leaq	INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
3018f6be6d8SBrian Gerst#endif
3028f6be6d8SBrian Gerst	movl	%edx, %eax
3038f6be6d8SBrian Gerst	shrq	$32, %rdx
3047b99819dSJoerg Roedel	wrmsr
3057b99819dSJoerg Roedel
306f5963ba7SJoerg Roedel	/* Setup and Load IDT */
307f5963ba7SJoerg Roedel	pushq	%rsi
308f5963ba7SJoerg Roedel	call	early_setup_idt
309f5963ba7SJoerg Roedel	popq	%rsi
310f5963ba7SJoerg Roedel
311250c2277SThomas Gleixner	/* Check if nx is implemented */
312250c2277SThomas Gleixner	movl	$0x80000001, %eax
313250c2277SThomas Gleixner	cpuid
314250c2277SThomas Gleixner	movl	%edx,%edi
315250c2277SThomas Gleixner
316250c2277SThomas Gleixner	/* Setup EFER (Extended Feature Enable Register) */
317250c2277SThomas Gleixner	movl	$MSR_EFER, %ecx
318250c2277SThomas Gleixner	rdmsr
31977a512e3SSean Christopherson	/*
32077a512e3SSean Christopherson	 * Preserve current value of EFER for comparison and to skip
32177a512e3SSean Christopherson	 * EFER writes if no change was made (for TDX guest)
32277a512e3SSean Christopherson	 */
32377a512e3SSean Christopherson	movl    %eax, %edx
324250c2277SThomas Gleixner	btsl	$_EFER_SCE, %eax	/* Enable System Call */
325250c2277SThomas Gleixner	btl	$20,%edi		/* No Execute supported? */
326250c2277SThomas Gleixner	jnc     1f
327250c2277SThomas Gleixner	btsl	$_EFER_NX, %eax
32878d77df7SH. Peter Anvin	btsq	$_PAGE_BIT_NX,early_pmd_flags(%rip)
329250c2277SThomas Gleixner
33077a512e3SSean Christopherson	/* Avoid writing EFER if no change was made (for TDX guest) */
33177a512e3SSean Christopherson1:	cmpl	%edx, %eax
33277a512e3SSean Christopherson	je	1f
33377a512e3SSean Christopherson	xor	%edx, %edx
33477a512e3SSean Christopherson	wrmsr				/* Make changes effective */
33577a512e3SSean Christopherson1:
336250c2277SThomas Gleixner	/* Setup cr0 */
337369101daSCyrill Gorcunov	movl	$CR0_STATE, %eax
338250c2277SThomas Gleixner	/* Make changes effective */
339250c2277SThomas Gleixner	movq	%rax, %cr0
340250c2277SThomas Gleixner
341250c2277SThomas Gleixner	/* zero EFLAGS after setting rsp */
342250c2277SThomas Gleixner	pushq $0
343250c2277SThomas Gleixner	popfq
344250c2277SThomas Gleixner
3458170e6beSH. Peter Anvin	/* rsi is pointer to real mode structure with interesting info.
346250c2277SThomas Gleixner	   pass it to C */
3478170e6beSH. Peter Anvin	movq	%rsi, %rdi
348250c2277SThomas Gleixner
34979d243a0SBorislav Petkov.Ljump_to_C_code:
350a9468df5SJosh Poimboeuf	/*
351a9468df5SJosh Poimboeuf	 * Jump to run C code and to be on a real kernel address.
352250c2277SThomas Gleixner	 * Since we are running on identity-mapped space we have to jump
353250c2277SThomas Gleixner	 * to the full 64bit address, this is only possible as indirect
354250c2277SThomas Gleixner	 * jump.  In addition we need to ensure %cs is set so we make this
355250c2277SThomas Gleixner	 * a far return.
3568170e6beSH. Peter Anvin	 *
3578170e6beSH. Peter Anvin	 * Note: do not change to far jump indirect with 64bit offset.
3588170e6beSH. Peter Anvin	 *
3598170e6beSH. Peter Anvin	 * AMD does not support far jump indirect with 64bit offset.
3608170e6beSH. Peter Anvin	 * AMD64 Architecture Programmer's Manual, Volume 3: states only
3618170e6beSH. Peter Anvin	 *	JMP FAR mem16:16 FF /5 Far jump indirect,
3628170e6beSH. Peter Anvin	 *		with the target specified by a far pointer in memory.
3638170e6beSH. Peter Anvin	 *	JMP FAR mem16:32 FF /5 Far jump indirect,
3648170e6beSH. Peter Anvin	 *		with the target specified by a far pointer in memory.
3658170e6beSH. Peter Anvin	 *
3668170e6beSH. Peter Anvin	 * Intel64 does support 64bit offset.
3678170e6beSH. Peter Anvin	 * Software Developer Manual Vol 2: states:
3688170e6beSH. Peter Anvin	 *	FF /5 JMP m16:16 Jump far, absolute indirect,
3698170e6beSH. Peter Anvin	 *		address given in m16:16
3708170e6beSH. Peter Anvin	 *	FF /5 JMP m16:32 Jump far, absolute indirect,
3718170e6beSH. Peter Anvin	 *		address given in m16:32.
3728170e6beSH. Peter Anvin	 *	REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
3738170e6beSH. Peter Anvin	 *		address given in m16:64.
374250c2277SThomas Gleixner	 */
37531dcfec1SJosh Poimboeuf	pushq	$.Lafter_lret	# put return address on stack for unwinder
376a7bea830SJan Beulich	xorl	%ebp, %ebp	# clear frame pointer
377250c2277SThomas Gleixner	movq	initial_code(%rip), %rax
378250c2277SThomas Gleixner	pushq	$__KERNEL_CS	# set correct cs
379250c2277SThomas Gleixner	pushq	%rax		# target address in negative space
380250c2277SThomas Gleixner	lretq
38131dcfec1SJosh Poimboeuf.Lafter_lret:
3823e3f0695SPeter Zijlstra	ANNOTATE_NOENDBR
383bc7b11c0SJiri SlabySYM_CODE_END(secondary_startup_64)
384250c2277SThomas Gleixner
38504633df0SBorislav Petkov#include "verify_cpu.S"
386c9f09539SJoerg Roedel#include "sev_verify_cbit.S"
38704633df0SBorislav Petkov
388cded3679SThomas Gleixner#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_AMD_MEM_ENCRYPT)
38942e78e97SFenghua Yu/*
390666e1156SThomas Gleixner * Entry point for soft restart of a CPU. Invoked from xxx_play_dead() for
391666e1156SThomas Gleixner * restarting the boot CPU or for restarting SEV guest CPUs after CPU hot
392666e1156SThomas Gleixner * unplug. Everything is set up already except the stack.
39342e78e97SFenghua Yu */
394666e1156SThomas GleixnerSYM_CODE_START(soft_restart_cpu)
395e81dc127SThomas Gleixner	ANNOTATE_NOENDBR
396fb799447SJosh Poimboeuf	UNWIND_HINT_END_OF_STACK
3973adee777SBrian Gerst
3983adee777SBrian Gerst	/* Find the idle task stack */
3993adee777SBrian Gerst	movq	PER_CPU_VAR(pcpu_hot) + X86_current_task, %rcx
4003adee777SBrian Gerst	movq	TASK_threadsp(%rcx), %rsp
4013adee777SBrian Gerst
40279d243a0SBorislav Petkov	jmp	.Ljump_to_C_code
403666e1156SThomas GleixnerSYM_CODE_END(soft_restart_cpu)
40442e78e97SFenghua Yu#endif
40542e78e97SFenghua Yu
4061aa9aa8eSJoerg Roedel#ifdef CONFIG_AMD_MEM_ENCRYPT
4071aa9aa8eSJoerg Roedel/*
4081aa9aa8eSJoerg Roedel * VC Exception handler used during early boot when running on kernel
4091aa9aa8eSJoerg Roedel * addresses, but before the switch to the idt_table can be made.
4101aa9aa8eSJoerg Roedel * The early_idt_handler_array can't be used here because it calls into a lot
4111aa9aa8eSJoerg Roedel * of __init code and this handler is also used during CPU offlining/onlining.
4121aa9aa8eSJoerg Roedel * Therefore this handler ends up in the .text section so that it stays around
4131aa9aa8eSJoerg Roedel * when .init.text is freed.
4141aa9aa8eSJoerg Roedel */
4151aa9aa8eSJoerg RoedelSYM_CODE_START_NOALIGN(vc_boot_ghcb)
4161aa9aa8eSJoerg Roedel	UNWIND_HINT_IRET_REGS offset=8
417e8d61bdfSPeter Zijlstra	ENDBR
4181aa9aa8eSJoerg Roedel
4191aa9aa8eSJoerg Roedel	/* Build pt_regs */
4201aa9aa8eSJoerg Roedel	PUSH_AND_CLEAR_REGS
4211aa9aa8eSJoerg Roedel
4221aa9aa8eSJoerg Roedel	/* Call C handler */
4231aa9aa8eSJoerg Roedel	movq    %rsp, %rdi
4241aa9aa8eSJoerg Roedel	movq	ORIG_RAX(%rsp), %rsi
4251aa9aa8eSJoerg Roedel	movq	initial_vc_handler(%rip), %rax
4261aa9aa8eSJoerg Roedel	ANNOTATE_RETPOLINE_SAFE
4271aa9aa8eSJoerg Roedel	call	*%rax
4281aa9aa8eSJoerg Roedel
4291aa9aa8eSJoerg Roedel	/* Unwind pt_regs */
4301aa9aa8eSJoerg Roedel	POP_REGS
4311aa9aa8eSJoerg Roedel
4321aa9aa8eSJoerg Roedel	/* Remove Error Code */
4331aa9aa8eSJoerg Roedel	addq    $8, %rsp
4341aa9aa8eSJoerg Roedel
4351aa9aa8eSJoerg Roedel	iretq
4361aa9aa8eSJoerg RoedelSYM_CODE_END(vc_boot_ghcb)
4371aa9aa8eSJoerg Roedel#endif
4381aa9aa8eSJoerg Roedel
439b32f96c7SJosh Poimboeuf	/* Both SMP bootup and ACPI suspend change these variables */
440da5968aeSSam Ravnborg	__REFDATA
4418170e6beSH. Peter Anvin	.balign	8
442b1bd27b9SJiri SlabySYM_DATA(initial_code,	.quad x86_64_start_kernel)
4431aa9aa8eSJoerg Roedel#ifdef CONFIG_AMD_MEM_ENCRYPT
4441aa9aa8eSJoerg RoedelSYM_DATA(initial_vc_handler,	.quad handle_vc_boot_ghcb)
4451aa9aa8eSJoerg Roedel#endif
446*f6f1ae91SThomas Gleixner
447*f6f1ae91SThomas GleixnerSYM_DATA(trampoline_lock, .quad 0);
448b9af7c0dSSuresh Siddha	__FINITDATA
449250c2277SThomas Gleixner
4508170e6beSH. Peter Anvin	__INIT
451bc7b11c0SJiri SlabySYM_CODE_START(early_idt_handler_array)
452749c970aSAndi Kleen	i = 0
453749c970aSAndi Kleen	.rept NUM_EXCEPTION_VECTORS
45482c62fa0SJosh Poimboeuf	.if ((EXCEPTION_ERRCODE_MASK >> i) & 1) == 0
4552704fbb6SJosh Poimboeuf		UNWIND_HINT_IRET_REGS
4568f93402bSPeter Zijlstra		ENDBR
4579900aa2fSH. Peter Anvin		pushq $0	# Dummy error code, to make stack frame uniform
4582704fbb6SJosh Poimboeuf	.else
4592704fbb6SJosh Poimboeuf		UNWIND_HINT_IRET_REGS offset=8
4608f93402bSPeter Zijlstra		ENDBR
4619900aa2fSH. Peter Anvin	.endif
4629900aa2fSH. Peter Anvin	pushq $i		# 72(%rsp) Vector number
463cdeb6048SAndy Lutomirski	jmp early_idt_handler_common
4642704fbb6SJosh Poimboeuf	UNWIND_HINT_IRET_REGS
465749c970aSAndi Kleen	i = i + 1
466cdeb6048SAndy Lutomirski	.fill early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc
467749c970aSAndi Kleen	.endr
468bc7b11c0SJiri SlabySYM_CODE_END(early_idt_handler_array)
4695b2fc515SPeter Zijlstra	ANNOTATE_NOENDBR // early_idt_handler_array[NUM_EXCEPTION_VECTORS]
4708866cd9dSRoland McGrath
471ef77e688SJiri SlabySYM_CODE_START_LOCAL(early_idt_handler_common)
4728f93402bSPeter Zijlstra	UNWIND_HINT_IRET_REGS offset=16
473cdeb6048SAndy Lutomirski	/*
474cdeb6048SAndy Lutomirski	 * The stack is the hardware frame, an error code or zero, and the
475cdeb6048SAndy Lutomirski	 * vector number.
476cdeb6048SAndy Lutomirski	 */
4779900aa2fSH. Peter Anvin	cld
4789900aa2fSH. Peter Anvin
479250c2277SThomas Gleixner	incl early_recursion_flag(%rip)
4809900aa2fSH. Peter Anvin
4817bbcdb1cSAndy Lutomirski	/* The vector number is currently in the pt_regs->di slot. */
4827bbcdb1cSAndy Lutomirski	pushq %rsi				/* pt_regs->si */
4837bbcdb1cSAndy Lutomirski	movq 8(%rsp), %rsi			/* RSI = vector number */
4847bbcdb1cSAndy Lutomirski	movq %rdi, 8(%rsp)			/* pt_regs->di = RDI */
4857bbcdb1cSAndy Lutomirski	pushq %rdx				/* pt_regs->dx */
4867bbcdb1cSAndy Lutomirski	pushq %rcx				/* pt_regs->cx */
4877bbcdb1cSAndy Lutomirski	pushq %rax				/* pt_regs->ax */
4887bbcdb1cSAndy Lutomirski	pushq %r8				/* pt_regs->r8 */
4897bbcdb1cSAndy Lutomirski	pushq %r9				/* pt_regs->r9 */
4907bbcdb1cSAndy Lutomirski	pushq %r10				/* pt_regs->r10 */
4917bbcdb1cSAndy Lutomirski	pushq %r11				/* pt_regs->r11 */
4927bbcdb1cSAndy Lutomirski	pushq %rbx				/* pt_regs->bx */
4937bbcdb1cSAndy Lutomirski	pushq %rbp				/* pt_regs->bp */
4947bbcdb1cSAndy Lutomirski	pushq %r12				/* pt_regs->r12 */
4957bbcdb1cSAndy Lutomirski	pushq %r13				/* pt_regs->r13 */
4967bbcdb1cSAndy Lutomirski	pushq %r14				/* pt_regs->r14 */
4977bbcdb1cSAndy Lutomirski	pushq %r15				/* pt_regs->r15 */
4982704fbb6SJosh Poimboeuf	UNWIND_HINT_REGS
4999900aa2fSH. Peter Anvin
5007bbcdb1cSAndy Lutomirski	movq %rsp,%rdi		/* RDI = pt_regs; RSI is already trapnr */
5014b47cdbdSJoerg Roedel	call do_early_exception
5029900aa2fSH. Peter Anvin
5039900aa2fSH. Peter Anvin	decl early_recursion_flag(%rip)
50426c4ef9cSAndy Lutomirski	jmp restore_regs_and_return_to_kernel
505ef77e688SJiri SlabySYM_CODE_END(early_idt_handler_common)
5069900aa2fSH. Peter Anvin
50774d8d9d5SJoerg Roedel#ifdef CONFIG_AMD_MEM_ENCRYPT
50874d8d9d5SJoerg Roedel/*
50974d8d9d5SJoerg Roedel * VC Exception handler used during very early boot. The
51074d8d9d5SJoerg Roedel * early_idt_handler_array can't be used because it returns via the
51174d8d9d5SJoerg Roedel * paravirtualized INTERRUPT_RETURN and pv-ops don't work that early.
51274d8d9d5SJoerg Roedel *
5138b87d8ceSPeter Zijlstra * XXX it does, fix this.
5148b87d8ceSPeter Zijlstra *
51574d8d9d5SJoerg Roedel * This handler will end up in the .init.text section and not be
51674d8d9d5SJoerg Roedel * available to boot secondary CPUs.
51774d8d9d5SJoerg Roedel */
51874d8d9d5SJoerg RoedelSYM_CODE_START_NOALIGN(vc_no_ghcb)
51974d8d9d5SJoerg Roedel	UNWIND_HINT_IRET_REGS offset=8
520e8d61bdfSPeter Zijlstra	ENDBR
52174d8d9d5SJoerg Roedel
52274d8d9d5SJoerg Roedel	/* Build pt_regs */
52374d8d9d5SJoerg Roedel	PUSH_AND_CLEAR_REGS
52474d8d9d5SJoerg Roedel
52574d8d9d5SJoerg Roedel	/* Call C handler */
52674d8d9d5SJoerg Roedel	movq    %rsp, %rdi
52774d8d9d5SJoerg Roedel	movq	ORIG_RAX(%rsp), %rsi
52874d8d9d5SJoerg Roedel	call    do_vc_no_ghcb
52974d8d9d5SJoerg Roedel
53074d8d9d5SJoerg Roedel	/* Unwind pt_regs */
53174d8d9d5SJoerg Roedel	POP_REGS
53274d8d9d5SJoerg Roedel
53374d8d9d5SJoerg Roedel	/* Remove Error Code */
53474d8d9d5SJoerg Roedel	addq    $8, %rsp
53574d8d9d5SJoerg Roedel
53674d8d9d5SJoerg Roedel	/* Pure iret required here - don't use INTERRUPT_RETURN */
53774d8d9d5SJoerg Roedel	iretq
53874d8d9d5SJoerg RoedelSYM_CODE_END(vc_no_ghcb)
53974d8d9d5SJoerg Roedel#endif
540b1bd27b9SJiri Slaby
541b1bd27b9SJiri Slaby#define SYM_DATA_START_PAGE_ALIGNED(name)			\
542b1bd27b9SJiri Slaby	SYM_START(name, SYM_L_GLOBAL, .balign PAGE_SIZE)
543250c2277SThomas Gleixner
544d9e9a641SDave Hansen#ifdef CONFIG_PAGE_TABLE_ISOLATION
545d9e9a641SDave Hansen/*
546d9e9a641SDave Hansen * Each PGD needs to be 8k long and 8k aligned.  We do not
547d9e9a641SDave Hansen * ever go out to userspace with these, so we do not
548d9e9a641SDave Hansen * strictly *need* the second page, but this allows us to
549d9e9a641SDave Hansen * have a single set_pgd() implementation that does not
550d9e9a641SDave Hansen * need to worry about whether it has 4k or 8k to work
551d9e9a641SDave Hansen * with.
552d9e9a641SDave Hansen *
553d9e9a641SDave Hansen * This ensures PGDs are 8k long:
554d9e9a641SDave Hansen */
555d9e9a641SDave Hansen#define PTI_USER_PGD_FILL	512
556d9e9a641SDave Hansen/* This ensures they are 8k-aligned: */
557b1bd27b9SJiri Slaby#define SYM_DATA_START_PTI_ALIGNED(name) \
558b1bd27b9SJiri Slaby	SYM_START(name, SYM_L_GLOBAL, .balign 2 * PAGE_SIZE)
559d9e9a641SDave Hansen#else
560b1bd27b9SJiri Slaby#define SYM_DATA_START_PTI_ALIGNED(name) \
561b1bd27b9SJiri Slaby	SYM_DATA_START_PAGE_ALIGNED(name)
562d9e9a641SDave Hansen#define PTI_USER_PGD_FILL	0
563d9e9a641SDave Hansen#endif
564d9e9a641SDave Hansen
565250c2277SThomas Gleixner/* Automate the creation of 1 to 1 mapping pmd entries */
566250c2277SThomas Gleixner#define PMDS(START, PERM, COUNT)			\
567250c2277SThomas Gleixner	i = 0 ;						\
568250c2277SThomas Gleixner	.rept (COUNT) ;					\
5690e192b99SCyrill Gorcunov	.quad	(START) + (i << PMD_SHIFT) + (PERM) ;	\
570250c2277SThomas Gleixner	i = i + 1 ;					\
571250c2277SThomas Gleixner	.endr
572250c2277SThomas Gleixner
5738170e6beSH. Peter Anvin	__INITDATA
5741a8770b7SJiri Slaby	.balign 4
5751a8770b7SJiri Slaby
576b1bd27b9SJiri SlabySYM_DATA_START_PTI_ALIGNED(early_top_pgt)
5776f9dd329SKirill A. Shutemov	.fill	512,8,0
578d9e9a641SDave Hansen	.fill	PTI_USER_PGD_FILL,8,0
579b1bd27b9SJiri SlabySYM_DATA_END(early_top_pgt)
5808170e6beSH. Peter Anvin
581b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(early_dynamic_pgts)
5828170e6beSH. Peter Anvin	.fill	512*EARLY_DYNAMIC_PAGE_TABLES,8,0
583b1bd27b9SJiri SlabySYM_DATA_END(early_dynamic_pgts)
5848170e6beSH. Peter Anvin
585b1bd27b9SJiri SlabySYM_DATA(early_recursion_flag, .long 0)
5861a8770b7SJiri Slaby
587b9af7c0dSSuresh Siddha	.data
5888170e6beSH. Peter Anvin
5897733607fSMaran Wilson#if defined(CONFIG_XEN_PV) || defined(CONFIG_PVH)
590b1bd27b9SJiri SlabySYM_DATA_START_PTI_ALIGNED(init_top_pgt)
59121729f81STom Lendacky	.quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
592b9952ec7SKirill A. Shutemov	.org    init_top_pgt + L4_PAGE_OFFSET*8, 0
59321729f81STom Lendacky	.quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
594b9952ec7SKirill A. Shutemov	.org    init_top_pgt + L4_START_KERNEL*8, 0
595250c2277SThomas Gleixner	/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
59621729f81STom Lendacky	.quad   level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
597d9e9a641SDave Hansen	.fill	PTI_USER_PGD_FILL,8,0
598b1bd27b9SJiri SlabySYM_DATA_END(init_top_pgt)
599250c2277SThomas Gleixner
600b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level3_ident_pgt)
60121729f81STom Lendacky	.quad	level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
602250c2277SThomas Gleixner	.fill	511, 8, 0
603b1bd27b9SJiri SlabySYM_DATA_END(level3_ident_pgt)
604b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level2_ident_pgt)
605430d4005SDave Hansen	/*
606430d4005SDave Hansen	 * Since I easily can, map the first 1G.
6078170e6beSH. Peter Anvin	 * Don't set NX because code runs from these pages.
608430d4005SDave Hansen	 *
609430d4005SDave Hansen	 * Note: This sets _PAGE_GLOBAL despite whether
610430d4005SDave Hansen	 * the CPU supports it or it is enabled.  But,
611430d4005SDave Hansen	 * the CPU should ignore the bit.
6128170e6beSH. Peter Anvin	 */
6138170e6beSH. Peter Anvin	PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
614b1bd27b9SJiri SlabySYM_DATA_END(level2_ident_pgt)
6154375c299SKirill A. Shutemov#else
616b1bd27b9SJiri SlabySYM_DATA_START_PTI_ALIGNED(init_top_pgt)
6174375c299SKirill A. Shutemov	.fill	512,8,0
618d9e9a641SDave Hansen	.fill	PTI_USER_PGD_FILL,8,0
619b1bd27b9SJiri SlabySYM_DATA_END(init_top_pgt)
6208170e6beSH. Peter Anvin#endif
621250c2277SThomas Gleixner
622032370b9SKirill A. Shutemov#ifdef CONFIG_X86_5LEVEL
623b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level4_kernel_pgt)
624032370b9SKirill A. Shutemov	.fill	511,8,0
62521729f81STom Lendacky	.quad	level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
626b1bd27b9SJiri SlabySYM_DATA_END(level4_kernel_pgt)
627032370b9SKirill A. Shutemov#endif
628032370b9SKirill A. Shutemov
629b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level3_kernel_pgt)
630a6523748SEduardo Habkost	.fill	L3_START_KERNEL,8,0
631250c2277SThomas Gleixner	/* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
63221729f81STom Lendacky	.quad	level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
63321729f81STom Lendacky	.quad	level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
634b1bd27b9SJiri SlabySYM_DATA_END(level3_kernel_pgt)
635250c2277SThomas Gleixner
636b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level2_kernel_pgt)
63788f3aec7SIngo Molnar	/*
638ea3186b9SArvind Sankar	 * Kernel high mapping.
63988f3aec7SIngo Molnar	 *
640ea3186b9SArvind Sankar	 * The kernel code+data+bss must be located below KERNEL_IMAGE_SIZE in
641ea3186b9SArvind Sankar	 * virtual address space, which is 1 GiB if RANDOMIZE_BASE is enabled,
642ea3186b9SArvind Sankar	 * 512 MiB otherwise.
64388f3aec7SIngo Molnar	 *
644ea3186b9SArvind Sankar	 * (NOTE: after that starts the module area, see MODULES_VADDR.)
645430d4005SDave Hansen	 *
646ea3186b9SArvind Sankar	 * This table is eventually used by the kernel during normal runtime.
647ea3186b9SArvind Sankar	 * Care must be taken to clear out undesired bits later, like _PAGE_RW
648ea3186b9SArvind Sankar	 * or _PAGE_GLOBAL in some cases.
64988f3aec7SIngo Molnar	 */
650ea3186b9SArvind Sankar	PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
651b1bd27b9SJiri SlabySYM_DATA_END(level2_kernel_pgt)
652250c2277SThomas Gleixner
653b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level2_fixmap_pgt)
65405ab1d8aSFeng Tang	.fill	(512 - 4 - FIXMAP_PMD_NUM),8,0
65505ab1d8aSFeng Tang	pgtno = 0
65605ab1d8aSFeng Tang	.rept (FIXMAP_PMD_NUM)
65705ab1d8aSFeng Tang	.quad level1_fixmap_pgt + (pgtno << PAGE_SHIFT) - __START_KERNEL_map \
65805ab1d8aSFeng Tang		+ _PAGE_TABLE_NOENC;
65905ab1d8aSFeng Tang	pgtno = pgtno + 1
66005ab1d8aSFeng Tang	.endr
66105ab1d8aSFeng Tang	/* 6 MB reserved space + a 2MB hole */
66205ab1d8aSFeng Tang	.fill	4,8,0
663b1bd27b9SJiri SlabySYM_DATA_END(level2_fixmap_pgt)
6648170e6beSH. Peter Anvin
665b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(level1_fixmap_pgt)
66605ab1d8aSFeng Tang	.rept (FIXMAP_PMD_NUM)
667250c2277SThomas Gleixner	.fill	512,8,0
66805ab1d8aSFeng Tang	.endr
669b1bd27b9SJiri SlabySYM_DATA_END(level1_fixmap_pgt)
670250c2277SThomas Gleixner
671250c2277SThomas Gleixner#undef PMDS
672250c2277SThomas Gleixner
673250c2277SThomas Gleixner	.data
674250c2277SThomas Gleixner	.align 16
675250c2277SThomas Gleixner
6763adee777SBrian GerstSYM_DATA(smpboot_control,		.long 0)
6773adee777SBrian Gerst
6783adee777SBrian Gerst	.align 16
679250c2277SThomas Gleixner/* This must match the first entry in level2_kernel_pgt */
680b1bd27b9SJiri SlabySYM_DATA(phys_base, .quad 0x0)
681784d5699SAl ViroEXPORT_SYMBOL(phys_base)
682250c2277SThomas Gleixner
6838c5e5ac3SJeremy Fitzhardinge#include "../../x86/xen/xen-head.S"
684250c2277SThomas Gleixner
68502b7da37STim Abbott	__PAGE_ALIGNED_BSS
686b1bd27b9SJiri SlabySYM_DATA_START_PAGE_ALIGNED(empty_zero_page)
687250c2277SThomas Gleixner	.skip PAGE_SIZE
688b1bd27b9SJiri SlabySYM_DATA_END(empty_zero_page)
689784d5699SAl ViroEXPORT_SYMBOL(empty_zero_page)
690ef7f0d6aSAndrey Ryabinin
691