[kernel] Use constants for known pml4e indices

There were a few lingering bugs due to places where 510/511 were
hard-coded as the kernel-space PML4 entries. These are now constants
defined in kernel_memory.h instead.

Tags: boot memory paging
This commit is contained in:
Justin C. Miller
2020-05-24 22:06:24 -07:00
parent cc9cde9bfe
commit 83b330bf2b
6 changed files with 57 additions and 87 deletions

View File

@@ -165,7 +165,7 @@ add_current_mappings(page_table *new_pml4)
asm volatile ( "mov %%cr3, %0" : "=r" (old_pml4) );
// Only copy mappings in the lower half
for (int i = 0; i < 256; ++i) {
for (int i = 0; i < ::memory::pml4e_kernel; ++i) {
uint64_t entry = old_pml4->entries[i];
if (entry & 1)
new_pml4->entries[i] = entry;