mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:37:34 +00:00
Kernel: Simplify PageDirectory swapping in sys$execve()
Swap out both the PageDirectory and the Region list at the same time, instead of doing the Region list slightly later.
This commit is contained in:
parent
d394267f50
commit
1dc9fa9506
1 changed files with 2 additions and 10 deletions
|
@ -727,9 +727,8 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
||||||
return -ETXTBSY;
|
return -ETXTBSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 entry_eip = 0;
|
|
||||||
// FIXME: Is there a race here?
|
|
||||||
auto old_page_directory = move(m_page_directory);
|
auto old_page_directory = move(m_page_directory);
|
||||||
|
auto old_regions = move(m_regions);
|
||||||
m_page_directory = PageDirectory::create_for_userspace(*this);
|
m_page_directory = PageDirectory::create_for_userspace(*this);
|
||||||
#ifdef MM_DEBUG
|
#ifdef MM_DEBUG
|
||||||
dbgprintf("Process %u exec: PD=%x created\n", pid(), m_page_directory.ptr());
|
dbgprintf("Process %u exec: PD=%x created\n", pid(), m_page_directory.ptr());
|
||||||
|
@ -761,20 +760,13 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
||||||
|
|
||||||
ASSERT(region);
|
ASSERT(region);
|
||||||
|
|
||||||
// NOTE: We yank this out of 'm_regions' since we're about to manipulate the vector
|
|
||||||
// and we don't want it getting lost.
|
|
||||||
auto executable_region = m_regions.take_last();
|
|
||||||
|
|
||||||
Region* master_tls_region { nullptr };
|
Region* master_tls_region { nullptr };
|
||||||
size_t master_tls_size = 0;
|
size_t master_tls_size = 0;
|
||||||
size_t master_tls_alignment = 0;
|
size_t master_tls_alignment = 0;
|
||||||
|
u32 entry_eip = 0;
|
||||||
|
|
||||||
OwnPtr<ELFLoader> loader;
|
OwnPtr<ELFLoader> loader;
|
||||||
{
|
{
|
||||||
// Okay, here comes the sleight of hand, pay close attention..
|
|
||||||
auto old_regions = move(m_regions);
|
|
||||||
m_regions.append(move(executable_region));
|
|
||||||
|
|
||||||
ArmedScopeGuard rollback_regions_guard([&]() {
|
ArmedScopeGuard rollback_regions_guard([&]() {
|
||||||
ASSERT(¤t->process() == this);
|
ASSERT(¤t->process() == this);
|
||||||
m_page_directory = move(old_page_directory);
|
m_page_directory = move(old_page_directory);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue