Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
48927bbb JS |
2 | /* |
3 | * | |
4 | * Trampoline.S Derived from Setup.S by Linus Torvalds | |
5 | * | |
6 | * 4 Jan 1997 Michael Chastain: changed to gnu as. | |
7 | * | |
8 | * This is only used for booting secondary CPUs in SMP machine | |
9 | * | |
10 | * Entry: CS:IP point to the start of our code, we are | |
11 | * in real mode with no stack, but the rest of the | |
12 | * trampoline page to make our stack and everything else | |
13 | * is a mystery. | |
14 | * | |
15 | * We jump into arch/x86/kernel/head_32.S. | |
16 | * | |
f37240f1 | 17 | * On entry to trampoline_start, the processor is in real mode |
48927bbb JS |
18 | * with 16-bit addressing and 16-bit data. CS has some value |
19 | * and IP is zero. Thus, we load CS to the physical segment | |
20 | * of the real mode code before doing anything further. | |
48927bbb JS |
21 | */ |
22 | ||
23 | #include <linux/linkage.h> | |
48927bbb JS |
24 | #include <asm/segment.h> |
25 | #include <asm/page_types.h> | |
e5684ec4 | 26 | #include "realmode.h" |
48927bbb JS |
27 | |
28 | .text | |
29 | .code16 | |
48927bbb | 30 | |
8e029fcd | 31 | .balign PAGE_SIZE |
78762b0e | 32 | SYM_CODE_START(trampoline_start) |
48927bbb JS |
33 | wbinvd # Needed for NUMA-Q should be harmless for others |
34 | ||
e5684ec4 | 35 | LJMPW_RM(1f) |
48927bbb JS |
36 | 1: |
37 | mov %cs, %ax # Code and data in the same place | |
38 | mov %ax, %ds | |
39 | ||
40 | cli # We should be safe anyway | |
41 | ||
f37240f1 | 42 | movl tr_start, %eax # where we need to go |
968ff9ee | 43 | |
968ff9ee PA |
44 | /* |
45 | * GDT tables in non default location kernel can be beyond 16MB and | |
48927bbb JS |
46 | * lgdt will not be able to load the address as in real mode default |
47 | * operand size is 16bit. Use lgdtl instead to force operand size | |
48 | * to 32 bit. | |
49 | */ | |
f37240f1 JS |
50 | lidtl tr_idt # load idt with 0, 0 |
51 | lgdtl tr_gdt # load gdt with whatever is appropriate | |
48927bbb | 52 | |
968ff9ee PA |
53 | movw $1, %dx # protected mode (PE) bit |
54 | lmsw %dx # into protected mode | |
48927bbb | 55 | |
968ff9ee | 56 | ljmpl $__BOOT_CS, $pa_startup_32 |
78762b0e | 57 | SYM_CODE_END(trampoline_start) |
968ff9ee PA |
58 | |
59 | .section ".text32","ax" | |
60 | .code32 | |
78762b0e | 61 | SYM_CODE_START(startup_32) # note: also used from wakeup_asm.S |
968ff9ee | 62 | jmp *%eax |
78762b0e | 63 | SYM_CODE_END(startup_32) |
48927bbb | 64 | |
51edbe6a PA |
65 | .bss |
66 | .balign 8 | |
78f44330 JS |
67 | SYM_DATA_START(trampoline_header) |
68 | SYM_DATA_LOCAL(tr_start, .space 4) | |
69 | SYM_DATA_LOCAL(tr_gdt_pad, .space 2) | |
70 | SYM_DATA_LOCAL(tr_gdt, .space 6) | |
71 | SYM_DATA_END(trampoline_header) | |
51edbe6a | 72 | |
f37240f1 | 73 | #include "trampoline_common.S" |