Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 2 | #ifndef _ARCH_X86_REALMODE_H |
| 3 | #define _ARCH_X86_REALMODE_H |
| 4 | |
Tom Lendacky | 46d010e | 2017-07-17 16:10:25 -0500 | [diff] [blame] | 5 | /* |
| 6 | * Flag bit definitions for use with the flags field of the trampoline header |
| 7 | * in the CONFIG_X86_64 variant. |
| 8 | */ |
| 9 | #define TH_FLAGS_SME_ACTIVE_BIT 0 |
| 10 | #define TH_FLAGS_SME_ACTIVE BIT(TH_FLAGS_SME_ACTIVE_BIT) |
| 11 | |
| 12 | #ifndef __ASSEMBLY__ |
| 13 | |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 14 | #include <linux/types.h> |
| 15 | #include <asm/io.h> |
| 16 | |
| 17 | /* This must match data at realmode.S */ |
| 18 | struct real_mode_header { |
| 19 | u32 text_start; |
| 20 | u32 ro_end; |
Jarkko Sakkinen | 48927bb | 2012-05-08 21:22:28 +0300 | [diff] [blame] | 21 | /* SMP trampoline */ |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 22 | u32 trampoline_start; |
Jarkko Sakkinen | 48927bb | 2012-05-08 21:22:28 +0300 | [diff] [blame] | 23 | u32 trampoline_status; |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 24 | u32 trampoline_header; |
| 25 | #ifdef CONFIG_X86_64 |
| 26 | u32 trampoline_pgd; |
Jarkko Sakkinen | 48927bb | 2012-05-08 21:22:28 +0300 | [diff] [blame] | 27 | #endif |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 28 | /* ACPI S3 wakeup */ |
Jarkko Sakkinen | c9b77cc | 2012-05-08 21:22:29 +0300 | [diff] [blame] | 29 | #ifdef CONFIG_ACPI_SLEEP |
| 30 | u32 wakeup_start; |
| 31 | u32 wakeup_header; |
| 32 | #endif |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 33 | /* APM/BIOS reboot */ |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 34 | u32 machine_real_restart_asm; |
H. Peter Anvin | 6505139 | 2012-06-16 21:47:37 -0700 | [diff] [blame] | 35 | #ifdef CONFIG_X86_64 |
| 36 | u32 machine_real_restart_seg; |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 37 | #endif |
Jarkko Sakkinen | cda846f | 2012-05-08 21:22:46 +0300 | [diff] [blame] | 38 | }; |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 39 | |
| 40 | /* This must match data at trampoline_32/64.S */ |
| 41 | struct trampoline_header { |
| 42 | #ifdef CONFIG_X86_32 |
| 43 | u32 start; |
Jarkko Sakkinen | cda846f | 2012-05-08 21:22:46 +0300 | [diff] [blame] | 44 | u16 gdt_pad; |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 45 | u16 gdt_limit; |
| 46 | u32 gdt_base; |
| 47 | #else |
| 48 | u64 start; |
H. Peter Anvin | 638d957 | 2012-05-16 14:02:05 -0700 | [diff] [blame] | 49 | u64 efer; |
Jarkko Sakkinen | cda846f | 2012-05-08 21:22:46 +0300 | [diff] [blame] | 50 | u32 cr4; |
Tom Lendacky | 46d010e | 2017-07-17 16:10:25 -0500 | [diff] [blame] | 51 | u32 flags; |
Jarkko Sakkinen | f37240f | 2012-05-08 21:22:43 +0300 | [diff] [blame] | 52 | #endif |
Jarkko Sakkinen | cda846f | 2012-05-08 21:22:46 +0300 | [diff] [blame] | 53 | }; |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 54 | |
Jarkko Sakkinen | b429dbf | 2012-05-08 21:22:41 +0300 | [diff] [blame] | 55 | extern struct real_mode_header *real_mode_header; |
| 56 | extern unsigned char real_mode_blob_end[]; |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 57 | |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 58 | extern unsigned long initial_code; |
| 59 | extern unsigned long initial_gs; |
Josh Poimboeuf | b32f96c | 2016-08-18 10:59:03 -0500 | [diff] [blame] | 60 | extern unsigned long initial_stack; |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 61 | |
| 62 | extern unsigned char real_mode_blob[]; |
| 63 | extern unsigned char real_mode_relocs[]; |
| 64 | |
Jarkko Sakkinen | 48927bb | 2012-05-08 21:22:28 +0300 | [diff] [blame] | 65 | #ifdef CONFIG_X86_32 |
| 66 | extern unsigned char startup_32_smp[]; |
| 67 | extern unsigned char boot_gdt[]; |
| 68 | #else |
| 69 | extern unsigned char secondary_startup_64[]; |
| 70 | #endif |
| 71 | |
Andy Lutomirski | 5ff3e2c | 2016-08-10 02:29:16 -0700 | [diff] [blame] | 72 | static inline size_t real_mode_size_needed(void) |
| 73 | { |
| 74 | if (real_mode_header) |
| 75 | return 0; /* already allocated. */ |
| 76 | |
| 77 | return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); |
| 78 | } |
| 79 | |
Matteo Croce | f560bd1 | 2019-03-28 12:42:33 +0100 | [diff] [blame] | 80 | static inline void set_real_mode_mem(phys_addr_t mem) |
| 81 | { |
| 82 | real_mode_header = (struct real_mode_header *) __va(mem); |
| 83 | } |
| 84 | |
Yinghai Lu | 4f7b9226 | 2013-01-24 12:19:51 -0800 | [diff] [blame] | 85 | void reserve_real_mode(void); |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 86 | |
Tom Lendacky | 46d010e | 2017-07-17 16:10:25 -0500 | [diff] [blame] | 87 | #endif /* __ASSEMBLY__ */ |
| 88 | |
Jarkko Sakkinen | 084ee1c6 | 2012-05-08 21:22:26 +0300 | [diff] [blame] | 89 | #endif /* _ARCH_X86_REALMODE_H */ |