2 * (C) Copyright 2014 Google, Inc
3 * Copyright (C) 1991, 1992, 1993 Linus Torvalds
5 * Parts of this copied from Linux arch/x86/boot/compressed/head_64.S
7 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/global_data.h>
11 #include <asm/msr-index.h>
12 #include <asm/processor-flags.h>
18 * cpu_call64(ulong pgtable, ulong setup_base, ulong target)
25 push %ecx /* arg2 = target */
26 push %edx /* arg1 = setup_base */
29 /* Load new GDT with the 64bit segments using 32bit descriptor */
35 movl $(X86_CR4_PAE), %eax
38 /* Enable the boot page tables */
42 /* Enable Long mode in EFER (Extended Feature Enable Register) */
48 /* After gdt is loaded */
55 * Setup for the jump to 64bit mode
57 * When the jump is performed we will be in long mode but
58 * in 32bit compatibility mode with EFER.LME = 1, CS.L = 0, CS.D = 1
59 * (and in turn EFER.LMA = 1). To jump into 64bit mode we use
60 * the new gdt/idt that has __KERNEL_CS with CS.L = 1.
61 * We place all of the values on our mini stack so lret can
62 * used to perform that far jump. See the gdt below.
64 pop %esi /* setup_base */
67 leal lret_target, %eax
70 /* Enter paged protected Mode, activating Long Mode */
71 movl $(X86_CR0_PG | X86_CR0_PE), %eax
74 /* Jump from 32bit compatibility mode into 64bit mode. */
80 mov %eax, %eax /* Clear bits 63:32 */
81 jmp *%eax /* Jump to the 64-bit target */
85 .word gdt_end - gdt - 1
86 .long gdt /* Fixed up by code above */
88 .quad 0x0000000000000000 /* NULL descriptor */
89 .quad 0x00af9a000000ffff /* __KERNEL_CS */
90 .quad 0x00cf92000000ffff /* __KERNEL_DS */
91 .quad 0x0080890000000000 /* TS descriptor */
92 .quad 0x0000000000000000 /* TS continued */