mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
Kernel: Move the expand_range_to_page_boundaries helper to MemoryManager
This helper can (and will) be used in more parts of the kernel besides the mmap-family of syscalls.
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 23:13:43 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/4ca39c71104 Pull-request: https://github.com/SerenityOS/serenity/pull/10674 Reviewed-by: https://github.com/bgianfo Reviewed-by: https://github.com/linusg ✅
@@ -329,4 +329,21 @@ inline bool PhysicalPage::is_lazy_committed_page() const
|
||||
return this == &MM.lazy_committed_page();
|
||||
}
|
||||
|
||||
inline ErrorOr<Memory::VirtualRange> expand_range_to_page_boundaries(FlatPtr address, size_t size)
|
||||
{
|
||||
if (Memory::page_round_up_would_wrap(size))
|
||||
return EINVAL;
|
||||
|
||||
if ((address + size) < address)
|
||||
return EINVAL;
|
||||
|
||||
if (Memory::page_round_up_would_wrap(address + size))
|
||||
return EINVAL;
|
||||
|
||||
auto base = VirtualAddress { address }.page_base();
|
||||
auto end = Memory::page_round_up(address + size);
|
||||
|
||||
return Memory::VirtualRange { base, end - base.get() };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user