2020-03-01 15:38:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-03-01 15:38:09 +01:00
|
|
|
*/
|
|
|
|
|
2021-06-21 17:34:09 +02:00
|
|
|
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
2021-06-23 21:54:41 +02:00
|
|
|
#include <Kernel/Panic.h>
|
2020-03-01 15:38:09 +01:00
|
|
|
#include <Kernel/VM/MemoryManager.h>
|
|
|
|
#include <Kernel/VM/ProcessPagingScope.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
ProcessPagingScope::ProcessPagingScope(Process& process)
|
|
|
|
{
|
2021-02-23 20:42:32 +01:00
|
|
|
VERIFY(Thread::current() != nullptr);
|
2020-03-01 15:38:09 +01:00
|
|
|
m_previous_cr3 = read_cr3();
|
|
|
|
MM.enter_process_paging_scope(process);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessPagingScope::~ProcessPagingScope()
|
|
|
|
{
|
|
|
|
InterruptDisabler disabler;
|
2021-06-26 19:57:16 +02:00
|
|
|
Thread::current()->regs().cr3 = m_previous_cr3;
|
2020-03-01 15:38:09 +01:00
|
|
|
write_cr3(m_previous_cr3);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|