mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
Kernel/Memory: Split the MemoryManager.h file from user address checks
This commit is contained in:
parent
7550b4175e
commit
3b09560251
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/3b09560251 Pull-request: https://github.com/SerenityOS/serenity/pull/20037 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
@ -13,6 +13,7 @@
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Memory/AllocationStrategy.h>
|
||||
#include <Kernel/Memory/MemorySections.h>
|
||||
#include <Kernel/Memory/PhysicalPage.h>
|
||||
#include <Kernel/Memory/PhysicalRegion.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
@ -299,27 +300,6 @@ private:
|
||||
SpinlockProtected<GlobalData, LockRank::None> m_global_data;
|
||||
};
|
||||
|
||||
inline bool is_user_address(VirtualAddress vaddr)
|
||||
{
|
||||
return vaddr.get() < USER_RANGE_CEILING;
|
||||
}
|
||||
|
||||
inline bool is_user_range(VirtualAddress vaddr, size_t size)
|
||||
{
|
||||
if (vaddr.offset(size) < vaddr)
|
||||
return false;
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
if (size <= 1)
|
||||
return true;
|
||||
return is_user_address(vaddr.offset(size - 1));
|
||||
}
|
||||
|
||||
inline bool is_user_range(VirtualRange const& range)
|
||||
{
|
||||
return is_user_range(range.base(), range.size());
|
||||
}
|
||||
|
||||
inline bool PhysicalPage::is_shared_zero_page() const
|
||||
{
|
||||
return this == &MM.shared_zero_page();
|
||||
|
36
Kernel/Memory/MemorySections.h
Normal file
36
Kernel/Memory/MemorySections.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/Memory/VirtualAddress.h>
|
||||
#include <Kernel/Memory/VirtualRange.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
inline bool is_user_address(VirtualAddress vaddr)
|
||||
{
|
||||
return vaddr.get() < USER_RANGE_CEILING;
|
||||
}
|
||||
|
||||
inline bool is_user_range(VirtualAddress vaddr, size_t size)
|
||||
{
|
||||
if (vaddr.offset(size) < vaddr)
|
||||
return false;
|
||||
if (!is_user_address(vaddr))
|
||||
return false;
|
||||
if (size <= 1)
|
||||
return true;
|
||||
return is_user_address(vaddr.offset(size - 1));
|
||||
}
|
||||
|
||||
inline bool is_user_range(VirtualRange const& range)
|
||||
{
|
||||
return is_user_range(range.base(), range.size());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user