summaryrefslogtreecommitdiff
path: root/Kernel/VM/MemoryManager.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-07-18 08:53:37 -0700
committerGunnar Beutner <gunnar@beutner.name>2021-07-20 03:21:14 +0200
commit308396bca1e02a1cd0f5013ca0e2dd5a1aa6660a (patch)
treebdd4909b1a360a505d2985aec4f4d63d75db5589 /Kernel/VM/MemoryManager.cpp
parent59b6169b5184bd34b842d4d644acb5d4aadbc559 (diff)
downloadserenity-308396bca1e02a1cd0f5013ca0e2dd5a1aa6660a.zip
Kernel: No lock validate_user_stack variant, switch to Space as argument
The entire process is not needed, just require the user to pass in the Space. Also provide no_lock variant to use when you already have the VM/Space lock acquired, to avoid unnecessary recursive spinlock acquisitions.
Diffstat (limited to 'Kernel/VM/MemoryManager.cpp')
-rw-r--r--Kernel/VM/MemoryManager.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index 76607faf4e..30f8a54fc7 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -1032,15 +1032,23 @@ void MemoryManager::unquickmap_page()
mm_data.m_quickmap_in_use.unlock(mm_data.m_quickmap_prev_flags);
}
-bool MemoryManager::validate_user_stack(Process const& process, VirtualAddress vaddr) const
+bool MemoryManager::validate_user_stack_no_lock(Space& space, VirtualAddress vaddr) const
{
+ VERIFY(space.get_lock().own_lock());
+
if (!is_user_address(vaddr))
return false;
- ScopedSpinLock lock(s_mm_lock);
- auto* region = find_user_region_from_vaddr(const_cast<Process&>(process).space(), vaddr);
+
+ auto* region = find_user_region_from_vaddr(space, vaddr);
return region && region->is_user() && region->is_stack();
}
+bool MemoryManager::validate_user_stack(Space& space, VirtualAddress vaddr) const
+{
+ ScopedSpinLock lock(space.get_lock());
+ return validate_user_stack_no_lock(space, vaddr);
+}
+
void MemoryManager::register_vmobject(VMObject& vmobject)
{
ScopedSpinLock lock(s_mm_lock);