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