From 29e067867e7a437d12351b481024d4bab431b202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Mon, 12 May 2025 13:51:12 +0000 Subject: Fix crashes because of are frame allocator copy --- arch/x86_64/include/arch/context_switching/syscall/main.hpp | 6 +++--- arch/x86_64/include/arch/memory/heap/memory_block.hpp | 2 ++ arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'arch/x86_64/include') diff --git a/arch/x86_64/include/arch/context_switching/syscall/main.hpp b/arch/x86_64/include/arch/context_switching/syscall/main.hpp index 8587ab2..9d61f97 100644 --- a/arch/x86_64/include/arch/context_switching/syscall/main.hpp +++ b/arch/x86_64/include/arch/context_switching/syscall/main.hpp @@ -60,8 +60,8 @@ namespace teachos::arch::context_switching::syscall */ struct response { - error error_code; ///< Error code returned by the syscall. If it failed all the values will be 0. - arguments values; ///< Optional return values of the syscall implementation. + error error_code; ///< Error code returned by the syscall. If it failed all the values will be 0. + arguments values = {}; ///< Optional return values of the syscall implementation. }; /** @@ -78,7 +78,7 @@ namespace teachos::arch::context_switching::syscall * in the arguments struct. So the value can be read and used for further processing. */ [[gnu::section(".user_text")]] - auto syscall(type syscall_number, arguments args) -> response; + auto syscall(type syscall_number, arguments args = {}) -> response; } // namespace teachos::arch::context_switching::syscall diff --git a/arch/x86_64/include/arch/memory/heap/memory_block.hpp b/arch/x86_64/include/arch/memory/heap/memory_block.hpp index e1cd288..9d1fb02 100644 --- a/arch/x86_64/include/arch/memory/heap/memory_block.hpp +++ b/arch/x86_64/include/arch/memory/heap/memory_block.hpp @@ -18,6 +18,7 @@ namespace teachos::arch::memory::heap * @param size Amount of free memory of this specific hole. * @param next Optional pointer to the next free memory. */ + [[gnu::section(".user_text")]] memory_block(std::size_t size, memory_block * next); /** @@ -26,6 +27,7 @@ namespace teachos::arch::memory::heap * @note Used so the memory can be reused to construct other classes into, without having the old values. * Required because we cannot call delete, because it causes "undefined reference to `sbrk`". */ + [[gnu::section(".user_text")]] ~memory_block(); std::size_t size; ///< Amount of free memory this hole contains, has to always be atleast 16 bytes to hold the diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index 756eeb1..ca7e2f9 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -45,7 +45,7 @@ namespace teachos::arch::memory::paging kernel::cpu::write_control_register(kernel::cpu::control_register::CR4, cr4 | 0x80); temporary_page temporary_page{virtual_page{0xCAFEBABE}, allocator}; - auto & active_table = active_page_table::create_or_get(); + decltype(auto) active_table = active_page_table::create_or_get(); auto const frame = allocator.allocate_frame(); exception_handling::assert(frame.has_value(), "[Kernel Mapper] Frame could not be allocated and therefore kernel not mapped"); -- cgit v1.2.3