1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Recursively map last P4 entry to itself

This allows us to use specially-crafted virtual memory addresses to
remove indirection levels and access the actual page table entries.
This commit is contained in:
Achilleas Anagnostopoulos 2017-05-31 14:09:16 +01:00
parent 1a6ade8ced
commit 99e4bedb74

View File

@ -247,6 +247,12 @@ _rt0_populate_initial_page_tables:
or eax, PAGE_PRESENT | PAGE_WRITABLE
mov ebx, page_table_l4 - PAGE_OFFSET
mov [ebx], eax
; Recursively map the last P4 entry to itself. This allows us to use
; specially crafted memory addresses to access the page tables themselves
mov ecx, ebx
or ecx, PAGE_PRESENT | PAGE_WRITABLE
mov [ebx + 511*8], ecx
; Also map the addresses starting at PAGE_OFFSET to the same P3 table.
; To find the P4 index for PAGE_OFFSET we need to extract bits 39-47