blob: c53682303c9c1252a79d90cf8dd19a96d126db93 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +03002#ifndef _ARCH_X86_REALMODE_H
3#define _ARCH_X86_REALMODE_H
4
Tom Lendacky46d010e2017-07-17 16:10:25 -05005/*
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 Sakkinen084ee1c62012-05-08 21:22:26 +030014#include <linux/types.h>
15#include <asm/io.h>
16
17/* This must match data at realmode.S */
18struct real_mode_header {
19 u32 text_start;
20 u32 ro_end;
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030021 /* SMP trampoline */
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030022 u32 trampoline_start;
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030023 u32 trampoline_status;
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030024 u32 trampoline_header;
25#ifdef CONFIG_X86_64
26 u32 trampoline_pgd;
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030027#endif
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030028 /* ACPI S3 wakeup */
Jarkko Sakkinenc9b77cc2012-05-08 21:22:29 +030029#ifdef CONFIG_ACPI_SLEEP
30 u32 wakeup_start;
31 u32 wakeup_header;
32#endif
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030033 /* APM/BIOS reboot */
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030034 u32 machine_real_restart_asm;
H. Peter Anvin65051392012-06-16 21:47:37 -070035#ifdef CONFIG_X86_64
36 u32 machine_real_restart_seg;
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030037#endif
Jarkko Sakkinencda846f2012-05-08 21:22:46 +030038};
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030039
40/* This must match data at trampoline_32/64.S */
41struct trampoline_header {
42#ifdef CONFIG_X86_32
43 u32 start;
Jarkko Sakkinencda846f2012-05-08 21:22:46 +030044 u16 gdt_pad;
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030045 u16 gdt_limit;
46 u32 gdt_base;
47#else
48 u64 start;
H. Peter Anvin638d9572012-05-16 14:02:05 -070049 u64 efer;
Jarkko Sakkinencda846f2012-05-08 21:22:46 +030050 u32 cr4;
Tom Lendacky46d010e2017-07-17 16:10:25 -050051 u32 flags;
Jarkko Sakkinenf37240f2012-05-08 21:22:43 +030052#endif
Jarkko Sakkinencda846f2012-05-08 21:22:46 +030053};
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030054
Jarkko Sakkinenb429dbf2012-05-08 21:22:41 +030055extern struct real_mode_header *real_mode_header;
56extern unsigned char real_mode_blob_end[];
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030057
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030058extern unsigned long initial_code;
59extern unsigned long initial_gs;
Josh Poimboeufb32f96c2016-08-18 10:59:03 -050060extern unsigned long initial_stack;
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030061
62extern unsigned char real_mode_blob[];
63extern unsigned char real_mode_relocs[];
64
Jarkko Sakkinen48927bb2012-05-08 21:22:28 +030065#ifdef CONFIG_X86_32
66extern unsigned char startup_32_smp[];
67extern unsigned char boot_gdt[];
68#else
69extern unsigned char secondary_startup_64[];
70#endif
71
Andy Lutomirski5ff3e2c2016-08-10 02:29:16 -070072static 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 Crocef560bd12019-03-28 12:42:33 +010080static inline void set_real_mode_mem(phys_addr_t mem)
81{
82 real_mode_header = (struct real_mode_header *) __va(mem);
83}
84
Yinghai Lu4f7b92262013-01-24 12:19:51 -080085void reserve_real_mode(void);
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030086
Tom Lendacky46d010e2017-07-17 16:10:25 -050087#endif /* __ASSEMBLY__ */
88
Jarkko Sakkinen084ee1c62012-05-08 21:22:26 +030089#endif /* _ARCH_X86_REALMODE_H */