diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-15 16:22:52 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-15 16:22:52 -0400 |
commit | 0f81f3e2adc1528e46ff8df7ef73281917df8adf (patch) | |
tree | 188219f5f2a14713c041db0baf7f4a1f67e12bdb /src/sys/arch | |
parent | 02b1c2dcc955d103e326efd46cc1b529dcd5e3aa (diff) |
kern/amd64: gdt: Load GDT before setting GS_BASE
If we update the GDTR after setting GS_BASE, we wont be referencing any
valid data anymore. Switch out the GDTR early on.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/arch')
-rw-r--r-- | src/sys/arch/amd64/boot/boot_chip.c | 2 | ||||
-rw-r--r-- | src/sys/arch/amd64/cpu/cpu_conf.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/sys/arch/amd64/boot/boot_chip.c b/src/sys/arch/amd64/boot/boot_chip.c index 8cefdac..2442bfb 100644 --- a/src/sys/arch/amd64/boot/boot_chip.c +++ b/src/sys/arch/amd64/boot/boot_chip.c @@ -31,7 +31,6 @@ #include <sys/panic.h> #include <sys/cpuvar.h> #include <machine/uart.h> -#include <machine/gdt.h> #include <machine/boot.h> #include <machine/i8259.h> #include <machine/ioapic.h> @@ -75,7 +74,6 @@ platform_boot(void) panic("platform_boot: could not get core\n"); } - gdt_load(); init_tss(core); i8259_disable(); diff --git a/src/sys/arch/amd64/cpu/cpu_conf.c b/src/sys/arch/amd64/cpu/cpu_conf.c index ee3bb78..b13e027 100644 --- a/src/sys/arch/amd64/cpu/cpu_conf.c +++ b/src/sys/arch/amd64/cpu/cpu_conf.c @@ -33,6 +33,7 @@ #include <machine/idt.h> #include <machine/trap.h> #include <machine/lapic.h> +#include <machine/gdt.h> /* * Initialize interrupt vectors @@ -58,6 +59,7 @@ void cpu_conf(struct pcore *pcore) { /* We use %GS to store the processor */ + gdt_load(); pcore->self = pcore; wrmsr(IA32_GS_BASE, (uintptr_t)pcore); |