diff --git a/kernel/src/paging.cpp b/kernel/src/paging.cpp index 94f53cde..fd6f3ffb 100644 --- a/kernel/src/paging.cpp +++ b/kernel/src/paging.cpp @@ -212,6 +212,9 @@ size_t paging::physical_address(size_t virt){ return 0; } + // Offset inside the page + auto offset = virt & uint64_t((1 << 13) - 1); + //Find the correct indexes inside the paging table for the physical address auto pml4e = pml4_entry(virt); auto pdpte = pdpt_entry(virt); @@ -223,7 +226,7 @@ size_t paging::physical_address(size_t virt){ auto pd = find_pd(pdpt, pdpte); auto pt = find_pt(pd, pde); - return reinterpret_cast(pt[pte]) & ~0xFFF; + return offset + reinterpret_cast(pt[pte]) & ~0xFFF; } bool paging::page_present(size_t virt){