cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

realmode.h (2124B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef _ARCH_X86_REALMODE_H
      3#define _ARCH_X86_REALMODE_H
      4
      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
     14#include <linux/types.h>
     15#include <asm/io.h>
     16
     17/* This must match data at realmode/rm/header.S */
     18struct real_mode_header {
     19	u32	text_start;
     20	u32	ro_end;
     21	/* SMP trampoline */
     22	u32	trampoline_start;
     23	u32	trampoline_header;
     24#ifdef CONFIG_AMD_MEM_ENCRYPT
     25	u32	sev_es_trampoline_start;
     26#endif
     27#ifdef CONFIG_X86_64
     28	u32	trampoline_start64;
     29	u32	trampoline_pgd;
     30#endif
     31	/* ACPI S3 wakeup */
     32#ifdef CONFIG_ACPI_SLEEP
     33	u32	wakeup_start;
     34	u32	wakeup_header;
     35#endif
     36	/* APM/BIOS reboot */
     37	u32	machine_real_restart_asm;
     38#ifdef CONFIG_X86_64
     39	u32	machine_real_restart_seg;
     40#endif
     41};
     42
     43/* This must match data at realmode/rm/trampoline_{32,64}.S */
     44struct trampoline_header {
     45#ifdef CONFIG_X86_32
     46	u32 start;
     47	u16 gdt_pad;
     48	u16 gdt_limit;
     49	u32 gdt_base;
     50#else
     51	u64 start;
     52	u64 efer;
     53	u32 cr4;
     54	u32 flags;
     55#endif
     56};
     57
     58extern struct real_mode_header *real_mode_header;
     59extern unsigned char real_mode_blob_end[];
     60
     61extern unsigned long initial_code;
     62extern unsigned long initial_gs;
     63extern unsigned long initial_stack;
     64#ifdef CONFIG_AMD_MEM_ENCRYPT
     65extern unsigned long initial_vc_handler;
     66#endif
     67
     68extern unsigned char real_mode_blob[];
     69extern unsigned char real_mode_relocs[];
     70
     71#ifdef CONFIG_X86_32
     72extern unsigned char startup_32_smp[];
     73extern unsigned char boot_gdt[];
     74#else
     75extern unsigned char secondary_startup_64[];
     76extern unsigned char secondary_startup_64_no_verify[];
     77#endif
     78
     79static inline size_t real_mode_size_needed(void)
     80{
     81	if (real_mode_header)
     82		return 0;	/* already allocated. */
     83
     84	return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE);
     85}
     86
     87static inline void set_real_mode_mem(phys_addr_t mem)
     88{
     89	real_mode_header = (struct real_mode_header *) __va(mem);
     90}
     91
     92void reserve_real_mode(void);
     93void load_trampoline_pgtable(void);
     94
     95#endif /* __ASSEMBLY__ */
     96
     97#endif /* _ARCH_X86_REALMODE_H */