diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-10 01:16:08 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-10 02:49:37 +0200 |
commit | 9babb92a4b6682f13fef661fc80502611d54c265 (patch) | |
tree | 59edde0e3a28b10782d3d5e7fdc0881be322984a /Kernel/Syscalls | |
parent | 369e3da6a2ed81c217cc579ccc13a7952afcf87f (diff) | |
download | serenity-9babb92a4b6682f13fef661fc80502611d54c265.zip |
Kernel/SMP: Make entering/leaving critical sections multi-processor safe
By making these functions static we close a window where we could get
preempted after calling Processor::current() and move to another
processor.
Co-authored-by: Tom <tomut@yahoo.com>
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 437320f726..b4b328fe9a 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -297,7 +297,7 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::AddressSpace> FlatPtr load_base_address = 0; String elf_name = object_description.absolute_path(); - VERIFY(!Processor::current().in_critical()); + VERIFY(!Processor::in_critical()); Memory::MemoryManager::enter_space(*new_space); @@ -495,7 +495,7 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description RefPtr<FileDescription> interpreter_description, Thread*& new_main_thread, u32& prev_flags, const ElfW(Ehdr) & main_program_header) { VERIFY(is_user_process()); - VERIFY(!Processor::current().in_critical()); + VERIFY(!Processor::in_critical()); auto path = main_program_description->absolute_path(); dbgln_if(EXEC_DEBUG, "do_exec: {}", path); @@ -686,7 +686,7 @@ KResult Process::do_exec(NonnullRefPtr<FileDescription> main_program_description u32 lock_count_to_restore; [[maybe_unused]] auto rc = big_lock().force_unlock_if_locked(lock_count_to_restore); VERIFY_INTERRUPTS_DISABLED(); - VERIFY(Processor::current().in_critical()); + VERIFY(Processor::in_critical()); return KSuccess; } @@ -912,7 +912,7 @@ KResult Process::exec(String path, Vector<String> arguments, Vector<String> envi return result; VERIFY_INTERRUPTS_DISABLED(); - VERIFY(Processor::current().in_critical()); + VERIFY(Processor::in_critical()); auto current_thread = Thread::current(); if (current_thread == new_main_thread) { @@ -920,14 +920,14 @@ KResult Process::exec(String path, Vector<String> arguments, Vector<String> envi // and it will be released after the context switch into that // thread. We should also still be in our critical section VERIFY(!g_scheduler_lock.own_lock()); - VERIFY(Processor::current().in_critical() == 1); + VERIFY(Processor::in_critical() == 1); g_scheduler_lock.lock(); current_thread->set_state(Thread::State::Running); Processor::assume_context(*current_thread, prev_flags); VERIFY_NOT_REACHED(); } - Processor::current().leave_critical(prev_flags); + Processor::leave_critical(prev_flags); return KSuccess; } |