; Start interrupts
sti
- ; Initialise System Calls (SYSCALL/SYSRET)
- ; Set IA32_EFER.SCE
- mov ecx, 0xC0000080
- rdmsr
- or eax, 1
- wrmsr
; Set IA32_LSTAR (RIP of handler)
mov ecx, 0xC0000082 ; IA32_LSTAR
mov eax, SyscallStub - 0xFFFFFFFF00000000
*/
int MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs)
{
+// Log_Debug("MMVirt", "Addr = %p, ErrorCode = %x", Addr, ErrorCode);
+
+ // Catch reserved bits first
+ if( ErrorCode & 0x8 )
+ {
+ Log_Warning("MMVirt", "Reserved bits trashed!");
+ Log_Warning("MMVirt", "PML4 Ent = %P", PAGEMAPLVL4(Addr>>39));
+ if( !(PAGEMAPLVL4(Addr>>39) & PF_PRESENT) ) goto print_done;
+ Log_Warning("MMVirt", "PDP Ent = %P", PAGEDIRPTR(Addr>>30));
+ if( !(PAGEDIRPTR(Addr>>30) & PF_PRESENT) ) goto print_done;
+ Log_Warning("MMVirt", "PDir Ent = %P", PAGEDIR(Addr>>21));
+ if( !(PAGEDIR(Addr>>21) & PF_PRESENT) ) goto print_done;
+ Log_Warning("MMVirt", "PTable Ent = %P", PAGETABLE(Addr>>12));
+ if( !(PAGETABLE(Addr>>12) & PF_PRESENT) ) goto print_done;
+ print_done:
+
+ for(;;);
+ }
+
// TODO: Implement Copy-on-Write
#if 1
if( PAGEMAPLVL4(Addr>>39) & PF_PRESENT
or eax, 0x80|0x20|0x10
mov cr4, eax
+ ; Initialise System Calls (SYSCALL/SYSRET)
+ ; Set IA32_EFER.(NXE|SCE)
+ mov ecx, 0xC0000080
+ rdmsr
+ or eax, (1 << 11)|(1 << 0) ; NXE, SCE
+ wrmsr
+
; Load PDP4
mov eax, gInitialPML4 - KERNEL_BASE
mov cr3, eax