x86: Invalidate LDT before handoff
diff --git a/stage23/lib/spinup.asm b/stage23/lib/spinup.asm
index 2d7ab54f..9d832854 100644
--- a/stage23/lib/spinup.asm
+++ b/stage23/lib/spinup.asm
@@ -12,6 +12,9 @@ common_spinup:
lidt [invalid_idt]
+ xor eax, eax
+ lldt ax
+
; We don't need the return address
add esp, 4
diff --git a/stage23/lib/spinup.asm64 b/stage23/lib/spinup.asm64
index 73518f7f..f41452d2 100644
--- a/stage23/lib/spinup.asm64
+++ b/stage23/lib/spinup.asm64
@@ -53,6 +53,9 @@ bits 32
mov gs, ax
mov ss, ax
+ xor eax, eax
+ lldt ax
+
mov eax, 0x00000011
mov cr0, eax
diff --git a/stage23/sys/smp_trampoline.real b/stage23/sys/smp_trampoline.real
index 81a6fc8c..86968c20 100644
--- a/stage23/sys/smp_trampoline.real
+++ b/stage23/sys/smp_trampoline.real
@@ -31,6 +31,9 @@ smp_trampoline:
mov gs, ax
mov ss, ax
+ xor eax, eax
+ lldt ax
+
xor eax, eax
mov cr4, eax
