summaryrefslogtreecommitdiff
path: root/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Memory/ScopedAddressSpaceSwitcher.cpp')
-rw-r--r--Kernel/Memory/ScopedAddressSpaceSwitcher.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp b/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp
index 0bbf51601d..5abd6b04b5 100644
--- a/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp
+++ b/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2023, Timon Kruiper <timonkruiper@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -13,23 +14,14 @@ namespace Kernel {
ScopedAddressSpaceSwitcher::ScopedAddressSpaceSwitcher(Process& process)
{
VERIFY(Thread::current() != nullptr);
-#if ARCH(X86_64)
- m_previous_cr3 = read_cr3();
-#elif ARCH(AARCH64)
- TODO_AARCH64();
-#endif
+ m_previous_page_directory = Memory::PageDirectory::find_current();
Memory::MemoryManager::enter_process_address_space(process);
}
ScopedAddressSpaceSwitcher::~ScopedAddressSpaceSwitcher()
{
InterruptDisabler disabler;
-#if ARCH(X86_64)
- Thread::current()->regs().cr3 = m_previous_cr3;
- write_cr3(m_previous_cr3);
-#elif ARCH(AARCH64)
- TODO_AARCH64();
-#endif
+ Memory::activate_page_directory(*m_previous_page_directory, Thread::current());
}
}