mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:57:36 +00:00
Kernel: Rename region_from_foo() => find_region_from_foo()
Let's emphasize that these functions actually go out and find regions.
This commit is contained in:
parent
2e2de125e5
commit
be7add690d
8 changed files with 21 additions and 21 deletions
|
@ -224,7 +224,7 @@ bool Process::deallocate_region(Region& region)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* Process::region_from_range(const Range& range)
|
Region* Process::find_region_from_range(const Range& range)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
if (m_region_lookup_cache.range == range && m_region_lookup_cache.region)
|
if (m_region_lookup_cache.range == range && m_region_lookup_cache.region)
|
||||||
|
@ -241,7 +241,7 @@ Region* Process::region_from_range(const Range& range)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* Process::region_containing(const Range& range)
|
Region* Process::find_region_containing(const Range& range)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(m_lock);
|
ScopedSpinLock lock(m_lock);
|
||||||
for (auto& region : m_regions) {
|
for (auto& region : m_regions) {
|
||||||
|
|
|
@ -607,8 +607,8 @@ private:
|
||||||
|
|
||||||
RefPtr<TTY> m_tty;
|
RefPtr<TTY> m_tty;
|
||||||
|
|
||||||
Region* region_from_range(const Range&);
|
Region* find_region_from_range(const Range&);
|
||||||
Region* region_containing(const Range&);
|
Region* find_region_containing(const Range&);
|
||||||
|
|
||||||
NonnullOwnPtrVector<Region> m_regions;
|
NonnullOwnPtrVector<Region> m_regions;
|
||||||
struct RegionLookupCache {
|
struct RegionLookupCache {
|
||||||
|
|
|
@ -148,7 +148,7 @@ void syscall_handler(TrapFrame* trap)
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* calling_region = MM.region_from_vaddr(process, VirtualAddress(regs.eip));
|
auto* calling_region = MM.find_region_from_vaddr(process, VirtualAddress(regs.eip));
|
||||||
if (!calling_region) {
|
if (!calling_region) {
|
||||||
dbg() << "Syscall from " << String::format("%p", regs.eip) << " which has no region";
|
dbg() << "Syscall from " << String::format("%p", regs.eip) << " which has no region";
|
||||||
handle_crash(regs, "Syscall from unknown region", SIGSEGV);
|
handle_crash(regs, "Syscall from unknown region", SIGSEGV);
|
||||||
|
|
|
@ -37,7 +37,7 @@ int Process::sys$get_stack_bounds(FlatPtr* user_stack_base, size_t* user_stack_s
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
FlatPtr stack_pointer = Thread::current()->get_register_dump_from_stack().userspace_esp;
|
FlatPtr stack_pointer = Thread::current()->get_register_dump_from_stack().userspace_esp;
|
||||||
auto* stack_region = MM.region_from_vaddr(*this, VirtualAddress(stack_pointer));
|
auto* stack_region = MM.find_region_from_vaddr(*this, VirtualAddress(stack_pointer));
|
||||||
if (!stack_region) {
|
if (!stack_region) {
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -203,7 +203,7 @@ int Process::sys$mprotect(void* addr, size_t size, int prot)
|
||||||
|
|
||||||
Range range_to_mprotect = { VirtualAddress(addr), size };
|
Range range_to_mprotect = { VirtualAddress(addr), size };
|
||||||
|
|
||||||
if (auto* whole_region = region_from_range(range_to_mprotect)) {
|
if (auto* whole_region = find_region_from_range(range_to_mprotect)) {
|
||||||
if (!whole_region->is_mmap())
|
if (!whole_region->is_mmap())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (!validate_mmap_prot(prot, whole_region->is_stack()))
|
if (!validate_mmap_prot(prot, whole_region->is_stack()))
|
||||||
|
@ -222,7 +222,7 @@ int Process::sys$mprotect(void* addr, size_t size, int prot)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we can carve out the desired range from an existing region
|
// Check if we can carve out the desired range from an existing region
|
||||||
if (auto* old_region = region_containing(range_to_mprotect)) {
|
if (auto* old_region = find_region_containing(range_to_mprotect)) {
|
||||||
if (!old_region->is_mmap())
|
if (!old_region->is_mmap())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (!validate_mmap_prot(prot, old_region->is_stack()))
|
if (!validate_mmap_prot(prot, old_region->is_stack()))
|
||||||
|
@ -271,7 +271,7 @@ int Process::sys$madvise(void* address, size_t size, int advice)
|
||||||
if (!is_user_range(VirtualAddress(address), size))
|
if (!is_user_range(VirtualAddress(address), size))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
auto* region = region_from_range({ VirtualAddress(address), size });
|
auto* region = find_region_from_range({ VirtualAddress(address), size });
|
||||||
if (!region)
|
if (!region)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!region->is_mmap())
|
if (!region->is_mmap())
|
||||||
|
@ -309,7 +309,7 @@ int Process::sys$minherit(void* address, size_t size, int inherit)
|
||||||
{
|
{
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
|
|
||||||
auto* region = region_from_range({ VirtualAddress(address), size });
|
auto* region = find_region_from_range({ VirtualAddress(address), size });
|
||||||
if (!region)
|
if (!region)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ int Process::sys$set_mmap_name(const Syscall::SC_set_mmap_name_params* user_para
|
||||||
if (name.is_null())
|
if (name.is_null())
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
auto* region = region_from_range({ VirtualAddress(params.addr), params.size });
|
auto* region = find_region_from_range({ VirtualAddress(params.addr), params.size });
|
||||||
if (!region)
|
if (!region)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!region->is_mmap())
|
if (!region->is_mmap())
|
||||||
|
@ -384,7 +384,7 @@ int Process::sys$munmap(void* addr, size_t size)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
Range range_to_unmap { VirtualAddress(addr), size };
|
Range range_to_unmap { VirtualAddress(addr), size };
|
||||||
if (auto* whole_region = region_from_range(range_to_unmap)) {
|
if (auto* whole_region = find_region_from_range(range_to_unmap)) {
|
||||||
if (!whole_region->is_mmap())
|
if (!whole_region->is_mmap())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
bool success = deallocate_region(*whole_region);
|
bool success = deallocate_region(*whole_region);
|
||||||
|
@ -392,7 +392,7 @@ int Process::sys$munmap(void* addr, size_t size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto* old_region = region_containing(range_to_unmap)) {
|
if (auto* old_region = find_region_containing(range_to_unmap)) {
|
||||||
if (!old_region->is_mmap())
|
if (!old_region->is_mmap())
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ KResult Process::poke_user_data(u32* address, u32 data)
|
||||||
}
|
}
|
||||||
ProcessPagingScope scope(*this);
|
ProcessPagingScope scope(*this);
|
||||||
Range range = { VirtualAddress(address), sizeof(u32) };
|
Range range = { VirtualAddress(address), sizeof(u32) };
|
||||||
auto* region = region_containing(range);
|
auto* region = find_region_containing(range);
|
||||||
ASSERT(region != nullptr);
|
ASSERT(region != nullptr);
|
||||||
if (region->is_shared()) {
|
if (region->is_shared()) {
|
||||||
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
|
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
|
||||||
|
|
|
@ -244,7 +244,7 @@ Region* MemoryManager::user_region_from_vaddr(Process& process, VirtualAddress v
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* MemoryManager::region_from_vaddr(Process& process, VirtualAddress vaddr)
|
Region* MemoryManager::find_region_from_vaddr(Process& process, VirtualAddress vaddr)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
if (auto* region = user_region_from_vaddr(process, vaddr))
|
if (auto* region = user_region_from_vaddr(process, vaddr))
|
||||||
|
@ -252,7 +252,7 @@ Region* MemoryManager::region_from_vaddr(Process& process, VirtualAddress vaddr)
|
||||||
return kernel_region_from_vaddr(vaddr);
|
return kernel_region_from_vaddr(vaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Region* MemoryManager::region_from_vaddr(const Process& process, VirtualAddress vaddr)
|
const Region* MemoryManager::find_region_from_vaddr(const Process& process, VirtualAddress vaddr)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
if (auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr))
|
if (auto* region = user_region_from_vaddr(const_cast<Process&>(process), vaddr))
|
||||||
|
@ -260,7 +260,7 @@ const Region* MemoryManager::region_from_vaddr(const Process& process, VirtualAd
|
||||||
return kernel_region_from_vaddr(vaddr);
|
return kernel_region_from_vaddr(vaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Region* MemoryManager::region_from_vaddr(VirtualAddress vaddr)
|
Region* MemoryManager::find_region_from_vaddr(VirtualAddress vaddr)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
if (auto* region = kernel_region_from_vaddr(vaddr))
|
if (auto* region = kernel_region_from_vaddr(vaddr))
|
||||||
|
@ -285,7 +285,7 @@ PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
|
||||||
#ifdef PAGE_FAULT_DEBUG
|
#ifdef PAGE_FAULT_DEBUG
|
||||||
dbg() << "MM: CPU[" << Processor::current().id() << "] handle_page_fault(" << String::format("%w", fault.code()) << ") at " << fault.vaddr();
|
dbg() << "MM: CPU[" << Processor::current().id() << "] handle_page_fault(" << String::format("%w", fault.code()) << ") at " << fault.vaddr();
|
||||||
#endif
|
#endif
|
||||||
auto* region = region_from_vaddr(fault.vaddr());
|
auto* region = find_region_from_vaddr(fault.vaddr());
|
||||||
if (!region) {
|
if (!region) {
|
||||||
klog() << "CPU[" << Processor::current().id() << "] NP(error) fault at invalid address " << fault.vaddr();
|
klog() << "CPU[" << Processor::current().id() << "] NP(error) fault at invalid address " << fault.vaddr();
|
||||||
return PageFaultResponse::ShouldCrash;
|
return PageFaultResponse::ShouldCrash;
|
||||||
|
|
|
@ -150,8 +150,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Region* region_from_vaddr(Process&, VirtualAddress);
|
static Region* find_region_from_vaddr(Process&, VirtualAddress);
|
||||||
static const Region* region_from_vaddr(const Process&, VirtualAddress);
|
static const Region* find_region_from_vaddr(const Process&, VirtualAddress);
|
||||||
|
|
||||||
void dump_kernel_regions();
|
void dump_kernel_regions();
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ private:
|
||||||
static Region* user_region_from_vaddr(Process&, VirtualAddress);
|
static Region* user_region_from_vaddr(Process&, VirtualAddress);
|
||||||
static Region* kernel_region_from_vaddr(VirtualAddress);
|
static Region* kernel_region_from_vaddr(VirtualAddress);
|
||||||
|
|
||||||
static Region* region_from_vaddr(VirtualAddress);
|
static Region* find_region_from_vaddr(VirtualAddress);
|
||||||
|
|
||||||
RefPtr<PhysicalPage> find_free_user_physical_page();
|
RefPtr<PhysicalPage> find_free_user_physical_page();
|
||||||
u8* quickmap_page(PhysicalPage&);
|
u8* quickmap_page(PhysicalPage&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue