From: Amelia Coutard Date: Sat, 5 Aug 2023 00:43:31 +0000 (+0200) Subject: Fixed memory laundering and an assert X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=815dc60a2c312aa0182b85243fc38444865a902a;p=voyage-au-centre-des-fichiers.git Fixed memory laundering and an assert --- diff --git a/kernel/src/kernel.cpp b/kernel/src/kernel.cpp index 5b70c4c..e467397 100644 --- a/kernel/src/kernel.cpp +++ b/kernel/src/kernel.cpp @@ -43,7 +43,7 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr 1024 * 1024 * 1024, "Error: processes array too big."); + static_assert(sizeof(os::processes) <= 1024 * 1024 * 1024, "Error: processes array too big."); { const auto index = os::paging::calc_page_table_indices(&os::processes).pml4e; PML4T.contents[index] = {.P = 1, .R_W = 1, .U_S = 0, .PWT = 0, .PCD = 0, .base_address = 0, .NX = 0}; diff --git a/kernel/src/ring3.hpp b/kernel/src/ring3.hpp index 252e7c1..78b6cb8 100644 --- a/kernel/src/ring3.hpp +++ b/kernel/src/ring3.hpp @@ -79,7 +79,6 @@ struct process { std::uint64_t r15; std::uint64_t rip; incrementing_int64_map ports; - // char test[65536]; }; static_assert(0xFFFF'C000'0000'0000 + sizeof(incrementing_int64_map) < 0xFFFF'FFFF'8000'0000); diff --git a/kernel/src/utils.hpp b/kernel/src/utils.hpp index 95c4109..83baa58 100644 --- a/kernel/src/utils.hpp +++ b/kernel/src/utils.hpp @@ -66,11 +66,11 @@ public: } T& get(std::int64_t index) { os::assert(present(index), "Tried getting non-existant element of incrementing_int64_map."); - return *reinterpret_cast(&elems[index].buffer[0]); + return *std::launder(reinterpret_cast(&elems[index].buffer[0])); } const T& get(std::int64_t index) const { os::assert(present(index), "Tried getting non-existant element of incrementing_int64_map."); - return *reinterpret_cast(&elems[index].buffer[0]); + return *std::launder(reinterpret_cast(&elems[index].buffer[0])); } private: