diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-16 23:18:03 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-16 23:19:30 -0400 |
commit | 8ae23738c78f58bea882dba11080d7052453e71d (patch) | |
tree | 93268fc5e4f8ca1025f882795c5badc0a56ec181 /src/sys/arch/amd64/cpu | |
parent | c5ada50b5e897683c2317591331fa94f3ec1a2b1 (diff) |
kern/amd64: cpu: Make GDT per-cpu to match TSS
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/arch/amd64/cpu')
-rw-r--r-- | src/sys/arch/amd64/cpu/cpu_conf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/sys/arch/amd64/cpu/cpu_conf.c b/src/sys/arch/amd64/cpu/cpu_conf.c index 5eb1cbe..e462ef3 100644 --- a/src/sys/arch/amd64/cpu/cpu_conf.c +++ b/src/sys/arch/amd64/cpu/cpu_conf.c @@ -34,6 +34,7 @@ #include <machine/trap.h> #include <machine/lapic.h> #include <machine/gdt.h> +#include <string.h> /* * Initialize interrupt vectors @@ -58,8 +59,20 @@ init_vectors(void) void cpu_conf(struct pcore *pcore) { + struct mdcore *mdcore; + struct gdtr *gdtr; + + /* Copy the template GDT */ + mdcore = &pcore->md; + memcpy(mdcore->gdt, &g_gdt_data, sizeof(g_gdt_data)); + + /* Set up the GDTR */ + gdtr = &mdcore->gdtr; + gdtr->offset = (uintptr_t)&mdcore->gdt[0]; + gdtr->limit = sizeof(g_gdt_data) - 1; + /* We use %GS to store the processor */ - gdt_load(); + gdt_load(&mdcore->gdtr); pcore->self = pcore; wrmsr(IA32_GS_BASE, (uintptr_t)pcore); |