zephyr/arch/x86/include/intel64/kernel_arch_data.h
Andrew Boie e34f1cee06 x86: implement kernel page table isolation
Implement a set of per-cpu trampoline stacks which all
interrupts and exceptions will initially land on, and also
as an intermediate stack for privilege changes as we need
some stack space to swap page tables.

Set up the special trampoline page which contains all the
trampoline stacks, TSS, and GDT. This page needs to be
present in the user page tables or interrupts don't work.

CPU exceptions, with KPTI turned on, are treated as interrupts
and not traps so that we have IRQs locked on exception entry.

Add some additional macros for defining IDT entries.

Add special handling of locore text/rodata sections when
creating user mode page tables on x86-64.

Restore qemu_x86_64 to use KPTI, and remove restrictions on
enabling user mode on x86-64.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-17 16:17:39 -05:00

44 lines
1.1 KiB
C

/*
* Copyright (c) 2019 Intel Corp.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_DATA_H_
#define ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_DATA_H_
#include <arch/x86/mmustructs.h>
#ifndef _ASMLANGUAGE
/* linker symbols defining the bounds of the kernel part loaded in locore */
extern char _locore_start[], _locore_end[];
/*
* Per-CPU bootstrapping parameters. See locore.S and cpu.c.
*/
struct x86_cpuboot {
volatile int ready; /* CPU has started */
u16_t tr; /* selector for task register */
struct x86_tss64 *gs_base; /* Base address for GS segment */
u64_t sp; /* initial stack pointer */
arch_cpustart_t fn; /* kernel entry function */
void *arg; /* argument for above function */
#ifdef CONFIG_X86_MMU
struct x86_page_tables *ptables; /* Runtime page tables to install */
#endif /* CONFIG_X86_MMU */
};
typedef struct x86_cpuboot x86_cpuboot_t;
extern u8_t x86_cpu_loapics[]; /* CPU logical ID -> local APIC ID */
#endif /* _ASMLANGUAGE */
#ifdef CONFIG_X86_KPTI
#define Z_X86_TRAMPOLINE_STACK_SIZE 128
#endif
#endif /* ZEPHYR_ARCH_X86_INCLUDE_INTEL64_KERNEL_ARCH_DATA_H_ */