summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/machdep.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2023-12-11 22:46:45 -0500
committerIan Moffett <ian@osmora.org>2023-12-11 22:46:45 -0500
commit30495d6f06108864c151e744ec1aad98e70c3334 (patch)
treeb11dad71341da6ccf5d5a3107f2d6c623bacf96a /sys/arch/amd64/machdep.c
parentc9a79b6dc5deb2294e8c125bc18413408a7cee68 (diff)
kernel/amd64: Add Task State Segment
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/machdep.c')
-rw-r--r--sys/arch/amd64/machdep.c19
1 files changed, 19 insertions, 0 deletions
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 <machine/gdt.h>
#include <machine/ioapic.h>
#include <machine/lapic.h>
+#include <machine/tss.h>
#include <machine/spectre.h>
#include <machine/cpu.h>
@@ -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)