aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-11-14 15:59:11 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-11-22 14:20:36 +0100
commit36a2fd5eb75e87bfe6f6f6c775ebac3d80902110 (patch)
tree8f615968e2536a84d36b736968578285ed1637c5
parent718d7f46a22220a7c4a53195dadc7291431ff912 (diff)
downloadkernel-36a2fd5eb75e87bfe6f6f6c775ebac3d80902110.tar.xz
kernel-36a2fd5eb75e87bfe6f6f6c775ebac3d80902110.zip
x86_64/memory: panic on huge page mappings
The x86_64 platform's higher half memory mapper currently has not support for huge page mappings. However, the previous implementation did not explicitly exclude huge page mappings, instead potentially corrupting the contents of huge pages by treating them as regular pages. The kernel now panics whenever an attempt is made to map a page inside a region covered by a huge page, or when trying to unmap a huge page or a range covered by a huge page.
-rw-r--r--arch/x86_64/arch/memory/higher_half_mapper.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86_64/arch/memory/higher_half_mapper.cpp b/arch/x86_64/arch/memory/higher_half_mapper.cpp
index 814cc991..cd0f943a 100644
--- a/arch/x86_64/arch/memory/higher_half_mapper.cpp
+++ b/arch/x86_64/arch/memory/higher_half_mapper.cpp
@@ -70,6 +70,11 @@ namespace arch::memory
return std::nullopt;
}
+ if (entry.huge())
+ {
+ kapi::system::panic("[ARCH:MEM] Tried to unmap a huge page, which is not supported!");
+ }
+
auto next_table = to_higher_half_pointer<page_table>(entry.frame()->start_address());
auto next_index = pml_index(level - 1, page);
table_path[4 - (level - 1)] = std::pair{next_table, next_index};
@@ -121,6 +126,11 @@ namespace arch::memory
auto index = pml_index(level, page);
auto & entry = (*table)[index];
+ if (entry.huge())
+ {
+ kapi::system::panic("[ARCH:MEM] Tried map an entry in a huge page, which is not supported!");
+ }
+
if (!entry.present())
{
auto table_frame = kapi::memory::allocate_frame();