mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Kernel: Implement ScopedAddressSpaceSwitcher using PageDirectory
This makes the code architecture independent, and thus makes it work for aarch64.
This commit is contained in:
parent
6a8581855d
commit
7440112cd9
Notes:
sideshowbarker
2024-07-17 06:24:08 +09:00
Author: https://github.com/FireFox317 Commit: https://github.com/SerenityOS/serenity/commit/7440112cd9 Pull-request: https://github.com/SerenityOS/serenity/pull/18149 Reviewed-by: https://github.com/IdanHo ✅
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Timon Kruiper <timonkruiper@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@ -7,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/PageDirectory.h>
|
||||
#include <Kernel/Forward.h>
|
||||
|
||||
namespace Kernel {
|
||||
@ -17,7 +19,7 @@ public:
|
||||
~ScopedAddressSpaceSwitcher();
|
||||
|
||||
private:
|
||||
u32 m_previous_cr3 { 0 };
|
||||
LockRefPtr<Memory::PageDirectory> m_previous_page_directory;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user