From 30495d6f06108864c151e744ec1aad98e70c3334 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 11 Dec 2023 22:46:45 -0500 Subject: kernel/amd64: Add Task State Segment Signed-off-by: Ian Moffett --- sys/arch/amd64/machdep.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sys/arch/amd64/machdep.c') diff --git a/sys/arch/amd64/machdep.c b/sys/arch/amd64/machdep.c index 3f3feb0..a466d38 100644 --- a/sys/arch/amd64/machdep.c +++ b/sys/arch/amd64/machdep.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,16 @@ __KERNEL_META("$Hyra$: machdep.c, Ian Marco Moffett, " #define ISR(func) ((uintptr_t)func) #define INIT_FLAG_IOAPIC 0x00000001U +static inline void +init_tss(struct cpu_info *cur_cpu) +{ + struct tss_desc *desc; + + desc = (struct tss_desc *)g_gdt_tss; + write_tss(cur_cpu, desc); + tss_load(); +} + static void interrupts_init(void) { @@ -73,6 +84,8 @@ processor_init(void) /* Indicates what doesn't need to be init anymore */ static uint8_t init_flags = 0; + struct cpu_info *cur_cpu = NULL; + interrupts_init(); gdt_load(&g_gdtr); @@ -82,6 +95,12 @@ processor_init(void) } lapic_init(); /* Per core */ + cur_cpu = this_cpu(); + + CPU_INFO_LOCK(cur_cpu); + cur_cpu->tss = NULL; + init_tss(cur_cpu); + CPU_INFO_UNLOCK(cur_cpu); /* Enable spectre mitigation if enabled */ if (try_spectre_mitigate != NULL) -- cgit v1.2.3