From 33b8fcecfbff405a22f950e4dfd83d6e57500e23 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Fri, 26 Aug 2022 08:08:24 -0600 Subject: [PATCH] Sync x86_64 trampoline with bootloader --- src/asm/x86_64/trampoline.asm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/asm/x86_64/trampoline.asm b/src/asm/x86_64/trampoline.asm index 0fff14fa..538ff1b7 100644 --- a/src/asm/x86_64/trampoline.asm +++ b/src/asm/x86_64/trampoline.asm @@ -26,24 +26,22 @@ startup_ap: ; initialize stack to invalid value mov sp, 0 - ;cr3 holds pointer to PML4 + ; cr3 holds pointer to PML4 mov edi, [trampoline.page_table] mov cr3, edi - ; Enable FPU + ; enable FPU mov eax, cr0 and al, 11110011b ; Clear task switched (3) and emulation (2) or al, 00100010b ; Set numeric error (5) monitor co-processor (1) mov cr0, eax - ; 18: Enable OSXSAVE - ; 10: Unmasked SSE exceptions ; 9: FXSAVE/FXRSTOR ; 7: Page Global ; 5: Page Address Extension ; 4: Page Size Extension mov eax, cr4 - or eax, 1 << 18 | 1 << 10 | 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4 + or eax, 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4 mov cr4, eax ; initialize floating point registers @@ -52,12 +50,13 @@ startup_ap: ; load protected mode GDT lgdt [gdtr] + ; enable long mode mov ecx, 0xC0000080 ; Read from the EFER MSR. rdmsr or eax, 1 << 11 | 1 << 8 ; Set the Long-Mode-Enable and NXE bit. wrmsr - ;enabling paging and protection simultaneously + ; enabling paging and protection simultaneously mov ebx, cr0 ; 31: Paging ; 16: write protect kernel -- GitLab