mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +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:
parent
ad3f931707
commit
6eab7b398d
3 changed files with 16 additions and 7 deletions
|
@ -734,7 +734,8 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
|||
#ifdef MM_DEBUG
|
||||
dbgprintf("Process %u exec: PD=%x created\n", pid(), m_page_directory.ptr());
|
||||
#endif
|
||||
ProcessPagingScope paging_scope(*this);
|
||||
|
||||
MM.enter_process_paging_scope(*this);
|
||||
|
||||
Region* region { nullptr };
|
||||
|
||||
|
@ -775,11 +776,10 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
|||
m_regions.append(move(executable_region));
|
||||
|
||||
ArmedScopeGuard rollback_regions_guard([&]() {
|
||||
m_page_directory = move(old_page_directory);
|
||||
ASSERT(¤t->process() == this);
|
||||
MM.enter_process_paging_scope(*this);
|
||||
executable_region = m_regions.take_first();
|
||||
m_page_directory = move(old_page_directory);
|
||||
m_regions = move(old_regions);
|
||||
MM.enter_process_paging_scope(*this);
|
||||
});
|
||||
|
||||
loader = make<ELFLoader>(region->vaddr().as_ptr(), loader_metadata.size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue