summaryrefslogtreecommitdiff
path: root/Kernel/VM/ProcessPagingScope.cpp
blob: 0a7f1708a7d60bffcac6c1aefa1886a22659317c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/ProcessPagingScope.h>

namespace Kernel {

ProcessPagingScope::ProcessPagingScope(Process& process)
{
    VERIFY(Thread::current() != nullptr);
    m_previous_cr3 = read_cr3();
    MM.enter_process_paging_scope(process);
}

ProcessPagingScope::~ProcessPagingScope()
{
    InterruptDisabler disabler;
    Thread::current()->tss().cr3 = m_previous_cr3;
    write_cr3(m_previous_cr3);
}

}