]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Fixed memory laundering and an assert
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Sat, 5 Aug 2023 00:43:31 +0000 (02:43 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Sat, 5 Aug 2023 00:43:31 +0000 (02:43 +0200)
kernel/src/kernel.cpp
kernel/src/ring3.hpp
kernel/src/utils.hpp

index 5b70c4c79e8a64424ec77fc698c8b4c2563b986e..e46739733155dcada6a5c39494fbe515de8d3aec 100644 (file)
@@ -43,7 +43,7 @@ extern "C" void kmain(unsigned long magic, os::phys_ptr<const multiboot2::info_s
 
        // Allocate those pages so that I only ever need to update the mapping once when I create a new process or port.
        // TODO: Not an emergency, but adapt in case we need multiple PML4Es. (*NOT* the case right now.)
-       static_assert(sizeof(os::processes) > 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};
index 252e7c1957a89a798e2478f36c91a753bb962267..78b6cb84cfa5237ce258a519e732c19cb3453aad 100644 (file)
@@ -79,7 +79,6 @@ struct process {
        std::uint64_t r15;
        std::uint64_t rip;
        incrementing_int64_map<port> ports;
-       // char test[65536];
 };
 
 static_assert(0xFFFF'C000'0000'0000 + sizeof(incrementing_int64_map<process>) < 0xFFFF'FFFF'8000'0000);
index 95c4109a6ec07ffc77b3c0c1792a1729f2304ba1..83baa58e28e81bcd453c704aea3fee934f7f153a 100644 (file)
@@ -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<T*>(&elems[index].buffer[0]);
+               return *std::launder(reinterpret_cast<T*>(&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<T*>(&elems[index].buffer[0]);
+               return *std::launder(reinterpret_cast<T*>(&elems[index].buffer[0]));
        }
 
 private: