mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcher
This commit is contained in:
parent
cd8d52e6ae
commit
f16b9a691f
8 changed files with 24 additions and 24 deletions
|
@ -10,7 +10,7 @@
|
|||
#include <AK/Types.h>
|
||||
|
||||
#include <Kernel/Interrupts/APIC.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Sections.h>
|
||||
#include <Kernel/StdLib.h>
|
||||
|
@ -522,7 +522,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
|
|||
thread.cpu(),
|
||||
[&]() {
|
||||
dbgln("CPU[{}] getting stack for cpu #{}", Processor::current_id(), proc.id());
|
||||
ProcessPagingScope paging_scope(thread.process());
|
||||
ScopedAddressSpaceSwitcher switcher(thread.process());
|
||||
VERIFY(&Processor::current() != &proc);
|
||||
VERIFY(&thread == Processor::current_thread());
|
||||
// NOTE: Because the other processor is still holding the
|
||||
|
@ -548,7 +548,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
|
|||
// stack. Before switching out of that thread, it switch_context
|
||||
// pushed the callee-saved registers, and the last of them happens
|
||||
// to be ebp.
|
||||
ProcessPagingScope paging_scope(thread.process());
|
||||
ScopedAddressSpaceSwitcher switcher(thread.process());
|
||||
auto& regs = thread.regs();
|
||||
auto* stack_top = reinterpret_cast<FlatPtr*>(regs.sp());
|
||||
if (Memory::is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) {
|
||||
|
|
|
@ -152,7 +152,7 @@ set(KERNEL_SOURCES
|
|||
Memory/PhysicalRegion.cpp
|
||||
Memory/PhysicalZone.cpp
|
||||
Memory/PrivateInodeVMObject.cpp
|
||||
Memory/ProcessPagingScope.cpp
|
||||
Memory/ScopedAddressSpaceSwitcher.cpp
|
||||
Memory/Region.cpp
|
||||
Memory/RingBuffer.cpp
|
||||
Memory/ScatterGatherList.cpp
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
||||
#include <Kernel/KLexicalPath.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/RTC.h>
|
||||
#include <LibC/elf.h>
|
||||
|
@ -343,7 +343,7 @@ KResultOr<ByteBuffer> Coredump::create_notes_segment_data() const
|
|||
KResult Coredump::write()
|
||||
{
|
||||
SpinlockLocker lock(m_process->address_space().get_lock());
|
||||
ProcessPagingScope scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
|
||||
auto notes_segment_result = create_notes_segment_data();
|
||||
if (notes_segment_result.is_error())
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/Thread.h>
|
||||
#include <Kernel/UserOrKernelBuffer.h>
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.write(forward<Args>(args)...);
|
||||
ProcessPagingScope paging_scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
return buffer.write(forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.write_buffered<BUFFER_BYTES>(forward<Args>(args)...);
|
||||
ProcessPagingScope paging_scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
return buffer.write_buffered<BUFFER_BYTES>(forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.read(forward<Args>(args)...);
|
||||
ProcessPagingScope paging_scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
return buffer.read(forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
{
|
||||
if (in_target_context(buffer))
|
||||
return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(args)...);
|
||||
ProcessPagingScope paging_scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
|
||||
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
ProcessPagingScope::ProcessPagingScope(Process& process)
|
||||
ScopedAddressSpaceSwitcher::ScopedAddressSpaceSwitcher(Process& process)
|
||||
{
|
||||
VERIFY(Thread::current() != nullptr);
|
||||
m_previous_cr3 = read_cr3();
|
||||
MM.enter_process_address_space(process);
|
||||
}
|
||||
|
||||
ProcessPagingScope::~ProcessPagingScope()
|
||||
ScopedAddressSpaceSwitcher::~ScopedAddressSpaceSwitcher()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
Thread::current()->regs().cr3 = m_previous_cr3;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -11,10 +11,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
class ProcessPagingScope {
|
||||
class ScopedAddressSpaceSwitcher {
|
||||
public:
|
||||
explicit ProcessPagingScope(Process&);
|
||||
~ProcessPagingScope();
|
||||
explicit ScopedAddressSpaceSwitcher(Process&);
|
||||
~ScopedAddressSpaceSwitcher();
|
||||
|
||||
private:
|
||||
u32 m_previous_cr3 { 0 };
|
|
@ -8,8 +8,8 @@
|
|||
#include <AK/ScopeGuard.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/PrivateInodeVMObject.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/ThreadTracer.h>
|
||||
|
@ -168,7 +168,7 @@ KResultOr<u32> Process::peek_user_data(Userspace<const u32*> address)
|
|||
{
|
||||
// This function can be called from the context of another
|
||||
// process that called PT_PEEK
|
||||
ProcessPagingScope scope(*this);
|
||||
ScopedAddressSpaceSwitcher switcher(*this);
|
||||
uint32_t data;
|
||||
TRY(copy_from_user(&data, address));
|
||||
return data;
|
||||
|
@ -180,7 +180,7 @@ KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
|
|||
auto* region = address_space().find_region_containing(range);
|
||||
if (!region)
|
||||
return EFAULT;
|
||||
ProcessPagingScope scope(*this);
|
||||
ScopedAddressSpaceSwitcher switcher(*this);
|
||||
if (region->is_shared()) {
|
||||
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
|
||||
// to prevent the write operation from changing any shared inode data
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Memory/MemoryManager.h>
|
||||
#include <Kernel/Memory/PageDirectory.h>
|
||||
#include <Kernel/Memory/ProcessPagingScope.h>
|
||||
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
||||
#include <Kernel/Panic.h>
|
||||
#include <Kernel/PerformanceEventBuffer.h>
|
||||
#include <Kernel/Process.h>
|
||||
|
@ -911,7 +911,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
|
|||
VERIFY(previous_mode() == PreviousMode::UserMode);
|
||||
VERIFY(current_trap());
|
||||
|
||||
ProcessPagingScope paging_scope(m_process);
|
||||
ScopedAddressSpaceSwitcher switcher(m_process);
|
||||
|
||||
u32 old_signal_mask = m_signal_mask;
|
||||
u32 new_signal_mask = action.mask;
|
||||
|
@ -1157,7 +1157,7 @@ String Thread::backtrace()
|
|||
auto& process = const_cast<Process&>(this->process());
|
||||
auto stack_trace = Processor::capture_stack_trace(*this);
|
||||
VERIFY(!g_scheduler_lock.is_locked_by_current_processor());
|
||||
ProcessPagingScope paging_scope(process);
|
||||
ScopedAddressSpaceSwitcher switcher(process);
|
||||
for (auto& frame : stack_trace) {
|
||||
if (Memory::is_user_range(VirtualAddress(frame), sizeof(FlatPtr) * 2)) {
|
||||
recognized_symbols.append({ frame });
|
||||
|
|
Loading…
Add table
Reference in a new issue