diff --git a/arch/x86/kernel/entry64.asm b/arch/x86/kernel/entry64.asm index cb09efc5..aec3b4c7 100644 --- a/arch/x86/kernel/entry64.asm +++ b/arch/x86/kernel/entry64.asm @@ -319,10 +319,6 @@ init_paging: mov DWORD [edi], boot_pdpt or DWORD [edi], 0x07 ; set present, user and writable flags - add edi, (PAGE_MAP_ENTRIES-1)*8 ; setup recursive paging - mov DWORD [edi], boot_pml4 ; boot_pml4[511] -> boot_pml4 - or DWORD [edi], 0x03 ; set present and writable flags - mov edi, boot_pdpt mov DWORD [edi], boot_pgd or DWORD [edi], 0x03 ; set present and writable flags diff --git a/arch/x86/mm/page64.c b/arch/x86/mm/page64.c index b2178823..58b30eda 100644 --- a/arch/x86/mm/page64.c +++ b/arch/x86/mm/page64.c @@ -524,6 +524,9 @@ int arch_paging_init(void) irq_uninstall_handler(14); irq_install_handler(14, pagefault_handler); + // setup recursive paging + boot_pml4.entries[PAGE_MAP_ENTRIES-1] = (size_t) &boot_pml4 | KERN_TABLE; + /* * In longmode the kernel is already maped into the kernel space (see entry64.asm) * this includes .data, .bss, .text, VGA, the multiboot & multiprocessing (APIC) structures