Kernel: Quickly reject userspace addresses in kernel_region_from_vaddr()
This avoids taking and releasing the MM lock just to reject an address that we can tell from just looking at it that it won't ever be in the kernel regions tree.
This commit is contained in:
parent
145eeb57ab
commit
5092813a45
Notes:
sideshowbarker
2024-07-17 20:04:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5092813a45d
1 changed files with 3 additions and 0 deletions
|
@ -645,6 +645,9 @@ UNMAP_AFTER_INIT void MemoryManager::initialize(u32 cpu)
|
|||
|
||||
Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
|
||||
{
|
||||
if (is_user_address(vaddr))
|
||||
return nullptr;
|
||||
|
||||
SpinlockLocker lock(s_mm_lock);
|
||||
auto* region = MM.m_kernel_regions.find_largest_not_above(vaddr.get());
|
||||
if (!region || !region->contains(vaddr))
|
||||
|
|
Loading…
Add table
Reference in a new issue