From 55bc49598e3e4541cbc986aaf19d3e85cf37b6bd Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Thu, 6 Aug 2020 19:07:51 -0700 Subject: [PATCH] [kernel] Assert all PDs exist in kernel space The bootloader now creates all PD tables in kernel space, so remove memory_bootstrap.cpp code that dealt with cases where there was no PD for a given range, and kassert that all PDs exist. Also deal with the case where the final PD exists, which never committed the last address range. --- src/kernel/memory_bootstrap.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/kernel/memory_bootstrap.cpp b/src/kernel/memory_bootstrap.cpp index 404a59a..3216b7d 100644 --- a/src/kernel/memory_bootstrap.cpp +++ b/src/kernel/memory_bootstrap.cpp @@ -118,14 +118,7 @@ memory_initialize_post_ctors(args::header *kargs) page_table *kpml4 = reinterpret_cast(kargs->pml4); for (unsigned i = pml4e_kernel; i < pml4e_offset; ++i) { page_table *pdp = kpml4->get(i); - - if (!pdp) { - if (current_bytes) - g_kernel_space.commit(current_start, current_bytes); - current_start = 0; - current_bytes = 0; - continue; - } + kassert(pdp, "Bootloader did not create all kernelspace PDs"); walk_page_table( pdp, page_table::level::pdp, @@ -133,6 +126,9 @@ memory_initialize_post_ctors(args::header *kargs) g_kernel_space); } + if (current_bytes) + g_kernel_space.commit(current_start, current_bytes); + g_frame_allocator.free( reinterpret_cast(kargs->page_table_cache), kargs->num_free_tables);