stivale: Load up invalid IDT before jumping to kernel instead of leaking internal one

This commit is contained in:
mintsuki 2021-05-19 08:29:21 +02:00
parent eb51e5a14a
commit 9676a3d09c
2 changed files with 14 additions and 1 deletions

View File

@ -14,6 +14,15 @@ __attribute__((noreturn)) void stivale_spinup_32(
(uint64_t)stack_lo | ((uint64_t)stack_hi << 32)
};
// Load invalid IDT
uint64_t invalid_idt[2] = {0, 0};
asm volatile (
"lidt %0"
:
: "m" (invalid_idt)
: "memory"
);
if (bits == 64) {
if (level5pg) {
// Enable CR4.LA57

View File

@ -8,6 +8,7 @@ smp_trampoline:
mov ebx, cs
shl ebx, 4
o32 lidt [cs:invalid_idt]
o32 lgdt [cs:passed_info.gdtr]
lea eax, [ebx + .mode32]
@ -157,9 +158,12 @@ parking64:
align 16
temp_stack:
times 1024 db 0
times 128 db 0
.top:
invalid_idt:
times 2 dq 0
align 16
passed_info:
.booted_flag db 0