aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/kapi
diff options
context:
space:
mode:
authorLukas Oesch <lukasoesch20@gmail.com>2026-03-16 19:51:53 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-17 16:44:26 +0100
commit3733baef9603581d6de2d35fda4535d37b6826b0 (patch)
treed7cfbe9647b9a0766b8c7dc84ff21d6fe11183eb /arch/x86_64/kapi
parentbcedba978671d4947c63bdcd044e10fae9a7be66 (diff)
downloadteachos-3733baef9603581d6de2d35fda4535d37b6826b0.tar.xz
teachos-3733baef9603581d6de2d35fda4535d37b6826b0.zip
protect multiboot2 boot modules
Diffstat (limited to 'arch/x86_64/kapi')
-rw-r--r--arch/x86_64/kapi/memory.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/x86_64/kapi/memory.cpp b/arch/x86_64/kapi/memory.cpp
index d6c0ad5..d9fbe28 100644
--- a/arch/x86_64/kapi/memory.cpp
+++ b/arch/x86_64/kapi/memory.cpp
@@ -174,9 +174,19 @@ namespace kapi::memory
auto mbi_start = frame::containing(mbi_address);
auto mbi_end = frame::containing(mbi_address + mbi_size) + 1;
- // TODO BA-FS26: Protect MB2 boot modules
-
std::ranges::for_each(std::views::iota(mbi_start, mbi_end), [&](auto frame) { new_allocator.mark_used(frame); });
+
+ auto modules = boot::bootstrap_information.mbi->modules();
+ for (auto module : modules)
+ {
+ auto module_physical_start = physical_address{module.start_address};
+ auto module_size = module.end_address - module.start_address;
+ auto module_start = frame::containing(module_physical_start);
+ auto module_end = frame::containing(module_physical_start + module_size) + 1;
+
+ std::ranges::for_each(std::views::iota(module_start, module_end),
+ [&](auto frame) { new_allocator.mark_used(frame); });
+ }
}
} // namespace