:: commit 572bcdae3bcfbab90c19a0b22d55df69ccd60024

mintsuki <mintsuki@protonmail.com> — 2021-07-06 00:13

parents: fa2a2d77bb

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
 
tab: 248 wrap: offon