From 8cb33f2f18d8383fd78368110b3a78c7732da6f9 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 17 Nov 2020 23:18:08 +0100 Subject: pc/l.s: load virtual gdt pointer after mmu switch before removing the double map at 0, load our initial gdt pointer with its new KZERO based virtual address. this is prerequisite for handling traps early during bootup before mmuinit() loads the final gdt. --- sys/src/9/pc/l.s | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/src/9/pc/l.s b/sys/src/9/pc/l.s index 5f40295ef..d9ee95597 100644 --- a/sys/src/9/pc/l.s +++ b/sys/src/9/pc/l.s @@ -71,8 +71,7 @@ TEXT _multibootentry(SB), $0 STD REP; MOVSB MOVL BX, multibootptr-KZERO(SB) - MOVL $_startPADDR(SB), AX - ANDL $~KZERO, AX + MOVL $_startPADDR-KZERO(SB), AX JMP* AX /* multiboot structure pointer (physical address) */ @@ -98,8 +97,7 @@ TEXT _startPADDR(SB), $0 CLI /* make sure interrupts are off */ /* set up the gdt so we have sane plan 9 style gdts. */ - MOVL $tgdtptr(SB), AX - ANDL $~KZERO, AX + MOVL $tgdtptr-KZERO(SB), AX MOVL (AX), GDTR MOVW $1, AX MOVW AX, MSW @@ -158,9 +156,11 @@ TEXT m0idtptr(SB), $0 WORD $(256*8-1) LONG $IDTADDR -TEXT mode32bit(SB), $0 - /* At this point, the GDT setup is done. */ +TEXT vtgdtptr(SB), $0 + WORD $(3*8) + LONG $tgdt(SB) +TEXT mode32bit(SB), $0 MOVL $((CPU0END-CPU0PDB)>>2), CX MOVL $PADDR(CPU0PDB), DI XORL AX, AX @@ -231,6 +231,9 @@ _setpte: * be initialised here. */ TEXT _startpg(SB), $0 + MOVL $vtgdtptr(SB), AX + MOVL (AX), GDTR + MOVL $0, (PDO(0))(CX) /* undo double-map of KZERO at 0 */ MOVL CX, CR3 /* load and flush the mmu */ -- cgit v1.2.3