Skip to content

Commit f16b9a6

Browse files
committed
Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcher
1 parent cd8d52e commit f16b9a6

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Kernel/Arch/x86/common/Processor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <AK/Types.h>
1111

1212
#include <Kernel/Interrupts/APIC.h>
13-
#include <Kernel/Memory/ProcessPagingScope.h>
13+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
1414
#include <Kernel/Process.h>
1515
#include <Kernel/Sections.h>
1616
#include <Kernel/StdLib.h>
@@ -522,7 +522,7 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
522522
thread.cpu(),
523523
[&]() {
524524
dbgln("CPU[{}] getting stack for cpu #{}", Processor::current_id(), proc.id());
525-
ProcessPagingScope paging_scope(thread.process());
525+
ScopedAddressSpaceSwitcher switcher(thread.process());
526526
VERIFY(&Processor::current() != &proc);
527527
VERIFY(&thread == Processor::current_thread());
528528
// 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
548548
// stack. Before switching out of that thread, it switch_context
549549
// pushed the callee-saved registers, and the last of them happens
550550
// to be ebp.
551-
ProcessPagingScope paging_scope(thread.process());
551+
ScopedAddressSpaceSwitcher switcher(thread.process());
552552
auto& regs = thread.regs();
553553
auto* stack_top = reinterpret_cast<FlatPtr*>(regs.sp());
554554
if (Memory::is_user_range(VirtualAddress(stack_top), sizeof(FlatPtr))) {

Kernel/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ set(KERNEL_SOURCES
152152
Memory/PhysicalRegion.cpp
153153
Memory/PhysicalZone.cpp
154154
Memory/PrivateInodeVMObject.cpp
155-
Memory/ProcessPagingScope.cpp
155+
Memory/ScopedAddressSpaceSwitcher.cpp
156156
Memory/Region.cpp
157157
Memory/RingBuffer.cpp
158158
Memory/ScatterGatherList.cpp

Kernel/Coredump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <Kernel/FileSystem/VirtualFileSystem.h>
1616
#include <Kernel/KLexicalPath.h>
1717
#include <Kernel/Locking/Spinlock.h>
18-
#include <Kernel/Memory/ProcessPagingScope.h>
18+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
1919
#include <Kernel/Process.h>
2020
#include <Kernel/RTC.h>
2121
#include <LibC/elf.h>
@@ -343,7 +343,7 @@ KResultOr<ByteBuffer> Coredump::create_notes_segment_data() const
343343
KResult Coredump::write()
344344
{
345345
SpinlockLocker lock(m_process->address_space().get_lock());
346-
ProcessPagingScope scope(m_process);
346+
ScopedAddressSpaceSwitcher switcher(m_process);
347347

348348
auto notes_segment_result = create_notes_segment_data();
349349
if (notes_segment_result.is_error())

Kernel/Devices/AsyncDeviceRequest.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <AK/IntrusiveList.h>
1010
#include <AK/NonnullRefPtr.h>
11-
#include <Kernel/Memory/ProcessPagingScope.h>
11+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
1212
#include <Kernel/Process.h>
1313
#include <Kernel/Thread.h>
1414
#include <Kernel/UserOrKernelBuffer.h>
@@ -85,7 +85,7 @@ class AsyncDeviceRequest : public RefCounted<AsyncDeviceRequest> {
8585
{
8686
if (in_target_context(buffer))
8787
return buffer.write(forward<Args>(args)...);
88-
ProcessPagingScope paging_scope(m_process);
88+
ScopedAddressSpaceSwitcher switcher(m_process);
8989
return buffer.write(forward<Args>(args)...);
9090
}
9191

@@ -94,7 +94,7 @@ class AsyncDeviceRequest : public RefCounted<AsyncDeviceRequest> {
9494
{
9595
if (in_target_context(buffer))
9696
return buffer.write_buffered<BUFFER_BYTES>(forward<Args>(args)...);
97-
ProcessPagingScope paging_scope(m_process);
97+
ScopedAddressSpaceSwitcher switcher(m_process);
9898
return buffer.write_buffered<BUFFER_BYTES>(forward<Args>(args)...);
9999
}
100100

@@ -103,7 +103,7 @@ class AsyncDeviceRequest : public RefCounted<AsyncDeviceRequest> {
103103
{
104104
if (in_target_context(buffer))
105105
return buffer.read(forward<Args>(args)...);
106-
ProcessPagingScope paging_scope(m_process);
106+
ScopedAddressSpaceSwitcher switcher(m_process);
107107
return buffer.read(forward<Args>(args)...);
108108
}
109109

@@ -112,7 +112,7 @@ class AsyncDeviceRequest : public RefCounted<AsyncDeviceRequest> {
112112
{
113113
if (in_target_context(buffer))
114114
return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(args)...);
115-
ProcessPagingScope paging_scope(m_process);
115+
ScopedAddressSpaceSwitcher switcher(m_process);
116116
return buffer.read_buffered<BUFFER_BYTES>(forward<Args>(args)...);
117117
}
118118

Kernel/Memory/ProcessPagingScope.cpp renamed to Kernel/Memory/ScopedAddressSpaceSwitcher.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
#include <Kernel/Arch/x86/InterruptDisabler.h>
88
#include <Kernel/Memory/MemoryManager.h>
9-
#include <Kernel/Memory/ProcessPagingScope.h>
9+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
1010

1111
namespace Kernel {
1212

13-
ProcessPagingScope::ProcessPagingScope(Process& process)
13+
ScopedAddressSpaceSwitcher::ScopedAddressSpaceSwitcher(Process& process)
1414
{
1515
VERIFY(Thread::current() != nullptr);
1616
m_previous_cr3 = read_cr3();
1717
MM.enter_process_address_space(process);
1818
}
1919

20-
ProcessPagingScope::~ProcessPagingScope()
20+
ScopedAddressSpaceSwitcher::~ScopedAddressSpaceSwitcher()
2121
{
2222
InterruptDisabler disabler;
2323
Thread::current()->regs().cr3 = m_previous_cr3;

Kernel/Memory/ProcessPagingScope.h renamed to Kernel/Memory/ScopedAddressSpaceSwitcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
2+
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
33
*
44
* SPDX-License-Identifier: BSD-2-Clause
55
*/
@@ -11,10 +11,10 @@
1111

1212
namespace Kernel {
1313

14-
class ProcessPagingScope {
14+
class ScopedAddressSpaceSwitcher {
1515
public:
16-
explicit ProcessPagingScope(Process&);
17-
~ProcessPagingScope();
16+
explicit ScopedAddressSpaceSwitcher(Process&);
17+
~ScopedAddressSpaceSwitcher();
1818

1919
private:
2020
u32 m_previous_cr3 { 0 };

Kernel/Syscalls/ptrace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <AK/ScopeGuard.h>
99
#include <Kernel/Memory/MemoryManager.h>
1010
#include <Kernel/Memory/PrivateInodeVMObject.h>
11-
#include <Kernel/Memory/ProcessPagingScope.h>
1211
#include <Kernel/Memory/Region.h>
12+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
1313
#include <Kernel/Memory/SharedInodeVMObject.h>
1414
#include <Kernel/Process.h>
1515
#include <Kernel/ThreadTracer.h>
@@ -168,7 +168,7 @@ KResultOr<u32> Process::peek_user_data(Userspace<const u32*> address)
168168
{
169169
// This function can be called from the context of another
170170
// process that called PT_PEEK
171-
ProcessPagingScope scope(*this);
171+
ScopedAddressSpaceSwitcher switcher(*this);
172172
uint32_t data;
173173
TRY(copy_from_user(&data, address));
174174
return data;
@@ -180,7 +180,7 @@ KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
180180
auto* region = address_space().find_region_containing(range);
181181
if (!region)
182182
return EFAULT;
183-
ProcessPagingScope scope(*this);
183+
ScopedAddressSpaceSwitcher switcher(*this);
184184
if (region->is_shared()) {
185185
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
186186
// to prevent the write operation from changing any shared inode data

Kernel/Thread.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <Kernel/KSyms.h>
1717
#include <Kernel/Memory/MemoryManager.h>
1818
#include <Kernel/Memory/PageDirectory.h>
19-
#include <Kernel/Memory/ProcessPagingScope.h>
19+
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
2020
#include <Kernel/Panic.h>
2121
#include <Kernel/PerformanceEventBuffer.h>
2222
#include <Kernel/Process.h>
@@ -911,7 +911,7 @@ DispatchSignalResult Thread::dispatch_signal(u8 signal)
911911
VERIFY(previous_mode() == PreviousMode::UserMode);
912912
VERIFY(current_trap());
913913

914-
ProcessPagingScope paging_scope(m_process);
914+
ScopedAddressSpaceSwitcher switcher(m_process);
915915

916916
u32 old_signal_mask = m_signal_mask;
917917
u32 new_signal_mask = action.mask;
@@ -1157,7 +1157,7 @@ String Thread::backtrace()
11571157
auto& process = const_cast<Process&>(this->process());
11581158
auto stack_trace = Processor::capture_stack_trace(*this);
11591159
VERIFY(!g_scheduler_lock.is_locked_by_current_processor());
1160-
ProcessPagingScope paging_scope(process);
1160+
ScopedAddressSpaceSwitcher switcher(process);
11611161
for (auto& frame : stack_trace) {
11621162
if (Memory::is_user_range(VirtualAddress(frame), sizeof(FlatPtr) * 2)) {
11631163
recognized_symbols.append({ frame });

0 commit comments

Comments
 (0)