summaryrefslogtreecommitdiff
path: root/Kernel/VM/MemoryManager.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-19 13:44:53 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-19 13:44:53 +0100
commit6eab7b398d2ce658b56f2650c721454a4e41fa2b (patch)
tree72fb36dcc59cb78e638530800001d68bf7a60fa6 /Kernel/VM/MemoryManager.h
parentad3f9317072697895436af93de71eb13f08c176e (diff)
downloadserenity-6eab7b398d2ce658b56f2650c721454a4e41fa2b.zip
Kernel: Make ProcessPagingScope restore CR3 properly
Instead of restoring CR3 to the current process's paging scope when a ProcessPagingScope goes out of scope, we now restore exactly whatever the CR3 value was when we created the ProcessPagingScope. This fixes breakage in situations where a process ends up with nested ProcessPagingScopes. This was making profiling very fragile, and with this change it's now possible to profile g++! :^)
Diffstat (limited to 'Kernel/VM/MemoryManager.h')
-rw-r--r--Kernel/VM/MemoryManager.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h
index 27210ac609..0cd372022d 100644
--- a/Kernel/VM/MemoryManager.h
+++ b/Kernel/VM/MemoryManager.h
@@ -190,9 +190,13 @@ private:
bool m_quickmap_in_use { false };
};
-struct ProcessPagingScope {
- ProcessPagingScope(Process&);
+class ProcessPagingScope {
+public:
+ explicit ProcessPagingScope(Process&);
~ProcessPagingScope();
+
+private:
+ u32 m_previous_cr3 { 0 };
};
template<typename Callback>