1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2084ee1c6SJarkko Sakkinen #ifndef _ARCH_X86_REALMODE_H 3084ee1c6SJarkko Sakkinen #define _ARCH_X86_REALMODE_H 4084ee1c6SJarkko Sakkinen 546d010e0STom Lendacky /* 646d010e0STom Lendacky * Flag bit definitions for use with the flags field of the trampoline header 746d010e0STom Lendacky * in the CONFIG_X86_64 variant. 846d010e0STom Lendacky */ 946d010e0STom Lendacky #define TH_FLAGS_SME_ACTIVE_BIT 0 1046d010e0STom Lendacky #define TH_FLAGS_SME_ACTIVE BIT(TH_FLAGS_SME_ACTIVE_BIT) 1146d010e0STom Lendacky 1246d010e0STom Lendacky #ifndef __ASSEMBLY__ 1346d010e0STom Lendacky 14084ee1c6SJarkko Sakkinen #include <linux/types.h> 15084ee1c6SJarkko Sakkinen #include <asm/io.h> 16084ee1c6SJarkko Sakkinen 17957a227dSSean Christopherson /* This must match data at realmode/rm/header.S */ 18084ee1c6SJarkko Sakkinen struct real_mode_header { 19084ee1c6SJarkko Sakkinen u32 text_start; 20084ee1c6SJarkko Sakkinen u32 ro_end; 2148927bbbSJarkko Sakkinen /* SMP trampoline */ 22f37240f1SJarkko Sakkinen u32 trampoline_start; 23f37240f1SJarkko Sakkinen u32 trampoline_header; 24bf5ff276SJoerg Roedel #ifdef CONFIG_AMD_MEM_ENCRYPT 25bf5ff276SJoerg Roedel u32 sev_es_trampoline_start; 26bf5ff276SJoerg Roedel #endif 27f37240f1SJarkko Sakkinen #ifdef CONFIG_X86_64 28ff2e6468SSean Christopherson u32 trampoline_start64; 29f37240f1SJarkko Sakkinen u32 trampoline_pgd; 3048927bbbSJarkko Sakkinen #endif 31f37240f1SJarkko Sakkinen /* ACPI S3 wakeup */ 32c9b77ccbSJarkko Sakkinen #ifdef CONFIG_ACPI_SLEEP 33c9b77ccbSJarkko Sakkinen u32 wakeup_start; 34c9b77ccbSJarkko Sakkinen u32 wakeup_header; 35c9b77ccbSJarkko Sakkinen #endif 36f37240f1SJarkko Sakkinen /* APM/BIOS reboot */ 37f37240f1SJarkko Sakkinen u32 machine_real_restart_asm; 3865051397SH. Peter Anvin #ifdef CONFIG_X86_64 3965051397SH. Peter Anvin u32 machine_real_restart_seg; 40f37240f1SJarkko Sakkinen #endif 41cda846f1SJarkko Sakkinen }; 42f37240f1SJarkko Sakkinen 43957a227dSSean Christopherson /* This must match data at realmode/rm/trampoline_{32,64}.S */ 44f37240f1SJarkko Sakkinen struct trampoline_header { 45f37240f1SJarkko Sakkinen #ifdef CONFIG_X86_32 46f37240f1SJarkko Sakkinen u32 start; 47cda846f1SJarkko Sakkinen u16 gdt_pad; 48f37240f1SJarkko Sakkinen u16 gdt_limit; 49f37240f1SJarkko Sakkinen u32 gdt_base; 50f37240f1SJarkko Sakkinen #else 51f37240f1SJarkko Sakkinen u64 start; 52638d957bSH. Peter Anvin u64 efer; 53cda846f1SJarkko Sakkinen u32 cr4; 5446d010e0STom Lendacky u32 flags; 55f37240f1SJarkko Sakkinen u32 lock; 56cda846f1SJarkko Sakkinen #endif 57084ee1c6SJarkko Sakkinen }; 58b429dbf6SJarkko Sakkinen 59b429dbf6SJarkko Sakkinen extern struct real_mode_header *real_mode_header; 60084ee1c6SJarkko Sakkinen extern unsigned char real_mode_blob_end[]; 61084ee1c6SJarkko Sakkinen 62b32f96c7SJosh Poimboeuf extern unsigned long initial_code; 631aa9aa8eSJoerg Roedel extern unsigned long initial_stack; 641aa9aa8eSJoerg Roedel #ifdef CONFIG_AMD_MEM_ENCRYPT 651aa9aa8eSJoerg Roedel extern unsigned long initial_vc_handler; 66084ee1c6SJarkko Sakkinen #endif 67084ee1c6SJarkko Sakkinen 68084ee1c6SJarkko Sakkinen extern u32 *trampoline_lock; 69084ee1c6SJarkko Sakkinen 7048927bbbSJarkko Sakkinen extern unsigned char real_mode_blob[]; 7148927bbbSJarkko Sakkinen extern unsigned char real_mode_relocs[]; 7248927bbbSJarkko Sakkinen 7348927bbbSJarkko Sakkinen #ifdef CONFIG_X86_32 7448927bbbSJarkko Sakkinen extern unsigned char startup_32_smp[]; 753ecacdbdSJoerg Roedel extern unsigned char boot_gdt[]; 7648927bbbSJarkko Sakkinen #else 7748927bbbSJarkko Sakkinen extern unsigned char secondary_startup_64[]; 785ff3e2c3SAndy Lutomirski extern unsigned char secondary_startup_64_no_verify[]; 795ff3e2c3SAndy Lutomirski #endif 805ff3e2c3SAndy Lutomirski real_mode_size_needed(void)815ff3e2c3SAndy Lutomirskistatic inline size_t real_mode_size_needed(void) 825ff3e2c3SAndy Lutomirski { 835ff3e2c3SAndy Lutomirski if (real_mode_header) 845ff3e2c3SAndy Lutomirski return 0; /* already allocated. */ 855ff3e2c3SAndy Lutomirski 86f560bd19SMatteo Croce return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); 87f560bd19SMatteo Croce } 88f560bd19SMatteo Croce set_real_mode_mem(phys_addr_t mem)89f560bd19SMatteo Crocestatic inline void set_real_mode_mem(phys_addr_t mem) 90f560bd19SMatteo Croce { 914f7b9226SYinghai Lu real_mode_header = (struct real_mode_header *) __va(mem); 9271d5049bSJoerg Roedel } 93*f1e52500SJuergen Gross 94084ee1c6SJarkko Sakkinen void reserve_real_mode(void); 9546d010e0STom Lendacky void load_trampoline_pgtable(void); 9646d010e0STom Lendacky void init_real_mode(void); 97084ee1c6SJarkko Sakkinen 98 #endif /* __ASSEMBLY__ */ 99 100 #endif /* _ARCH_X86_REALMODE_H */ 101