aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/memory.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-11-13 11:40:07 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-11-22 14:20:35 +0100
commit60ba364ec3c458b6bcf3d048781c8dd88937cd0e (patch)
treee1496703981b5f64d396e2b11c5c914c3124ff62 /kernel/kapi/memory.cpp
parent32a0bc18a741f5599e6447add4cd69a6e25a31be (diff)
downloadkernel-60ba364ec3c458b6bcf3d048781c8dd88937cd0e.tar.xz
kernel-60ba364ec3c458b6bcf3d048781c8dd88937cd0e.zip
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.
Diffstat (limited to 'kernel/kapi/memory.cpp')
-rw-r--r--kernel/kapi/memory.cpp8
1 files changed, 4 insertions, 4 deletions
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<kapi::memory::frame> 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);
}