Browse Source

Kernel/TypedMapping: Round up length with offset_in_page

Fixes #6948.
Liav A 4 năm trước cách đây
mục cha
commit
4499b0418c
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      Kernel/VM/TypedMapping.h

+ 2 - 1
Kernel/VM/TypedMapping.h

@@ -27,7 +27,8 @@ template<typename T>
 static TypedMapping<T> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
 static TypedMapping<T> map_typed(PhysicalAddress paddr, size_t length, Region::Access access = Region::Access::Read)
 {
 {
     TypedMapping<T> table;
     TypedMapping<T> table;
-    table.region = MM.allocate_kernel_region(paddr.page_base(), page_round_up(length), {}, access);
+    size_t mapping_length = page_round_up(paddr.offset_in_page() + length);
+    table.region = MM.allocate_kernel_region(paddr.page_base(), mapping_length, {}, access);
     table.offset = paddr.offset_in_page();
     table.offset = paddr.offset_in_page();
     return table;
     return table;
 }
 }