mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-22 23:55:12 +00:00
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++! :^)
This commit is contained in:
@@ -682,10 +682,15 @@ void MemoryManager::dump_kernel_regions()
|
||||
ProcessPagingScope::ProcessPagingScope(Process& process)
|
||||
{
|
||||
ASSERT(current);
|
||||
asm("movl %%cr3, %%eax"
|
||||
: "=a"(m_previous_cr3));
|
||||
MM.enter_process_paging_scope(process);
|
||||
}
|
||||
|
||||
ProcessPagingScope::~ProcessPagingScope()
|
||||
{
|
||||
MM.enter_process_paging_scope(current->process());
|
||||
InterruptDisabler disabler;
|
||||
current->tss().cr3 = m_previous_cr3;
|
||||
asm volatile("movl %%eax, %%cr3" ::"a"(m_previous_cr3)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user