mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-21 02:22:51 +00:00
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.
This commit is contained in:
parent
59b6169b51
commit
308396bca1
Notes:
sideshowbarker
2024-07-18 08:43:13 +09:00
Author: https://github.com/bgianfo
Commit: 308396bca1
Pull-request: https://github.com/SerenityOS/serenity/pull/8864
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/gunnarbeutner ✅
Reviewed-by: https://github.com/tomuta ✅
5 changed files with 16 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue