diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-12 10:59:50 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-12 10:59:50 +0000 |
| commit | d10bc808b29b0b647cbbb6c92d253fbb8c5cf431 (patch) | |
| tree | bf6b97248f521e163053484bc75ab4a54da89e9c /arch/x86_64/src/memory/paging | |
| parent | 38e5d23fb325c983751f5d3e4f54a60bf1b1e47a (diff) | |
| download | teachos-d10bc808b29b0b647cbbb6c92d253fbb8c5cf431.tar.xz teachos-d10bc808b29b0b647cbbb6c92d253fbb8c5cf431.zip | |
Fix next table overwriting old page handle
Diffstat (limited to 'arch/x86_64/src/memory/paging')
| -rw-r--r-- | arch/x86_64/src/memory/paging/page_table.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86_64/src/memory/paging/page_table.cpp b/arch/x86_64/src/memory/paging/page_table.cpp index a39c235..eb11810 100644 --- a/arch/x86_64/src/memory/paging/page_table.cpp +++ b/arch/x86_64/src/memory/paging/page_table.cpp @@ -100,14 +100,15 @@ namespace teachos::arch::memory::paging auto page_table_handle::is_empty() const -> bool { return table->is_empty(); } - auto page_table_handle::next_table(std::size_t table_index) -> std::optional<page_table_handle> + auto page_table_handle::next_table(std::size_t table_index) const -> std::optional<page_table_handle> { exception_handling::assert(table_level != page_table_handle::LEVEL1, "[Page Table] Attempted to call next_table on level 1 page table"); auto const next_table = table->next_table(table_index); if (next_table.has_value()) { - return page_table_handle{next_table.value(), --table_level}; + auto const new_level = static_cast<page_table_handle::level>(table_level - 1); + return page_table_handle{next_table.value(), new_level}; } return std::nullopt; } |
