From 60ba364ec3c458b6bcf3d048781c8dd88937cd0e Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 13 Nov 2026 11:40:07 +0100 Subject: kapi/memory: fix page unmap logic Previously, the page mapper was expected to automatically free all frames that had become unused. However, this only works if all mappings refer to plain memory frames. In the case of MMIO frames, the mapper would still try to release the frame via the global frame allocator, which is incorrect, leading to undefined behavior in the worst case. This problem was discovered during work the PCI/PCIe subsystem, since we want to unmap any unused buses during enumeration. --- kernel/kapi/memory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'kernel/kapi/memory.cpp') diff --git a/kernel/kapi/memory.cpp b/kernel/kapi/memory.cpp index 666910ba..c1b48ea3 100644 --- a/kernel/kapi/memory.cpp +++ b/kernel/kapi/memory.cpp @@ -51,14 +51,14 @@ namespace kapi::memory system::panic("[OS:MEM] Tried to map a page without an active mapper."); } - auto unmap(page) -> void override + auto unmap(page) -> kapi::memory::frame override { system::panic("[OS:MEM] Tried to unmap a page without an active mapper."); } - auto try_unmap(page) noexcept -> bool override + auto try_unmap(page) noexcept -> std::optional override { - return false; + return std::nullopt; } }; @@ -109,7 +109,7 @@ namespace kapi::memory return active_page_mapper->map(page, frame, flags); } - auto unmap(page page) -> void + auto unmap(page page) -> frame { return active_page_mapper->unmap(page); } -- cgit v1.2.3