summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-09-07Kernel: Avoid string creation for simple string comparisonBrian Gianforcaro
2021-09-07Kernel: Specify a lock rank for s_mm_lockBrian Gianforcaro
2021-09-07Kernel: Specify a lock rank for Thread::m_lockBrian Gianforcaro
2021-09-07Kernel/Locking: Add lock rank tracking to Spinlock/RecursiveSpinlockBrian Gianforcaro
2021-09-07Kernel/Locking: Add lock rank tracking per thread to find deadlocksBrian Gianforcaro
This change adds a static lock hierarchy / ranking to the Kernel with the goal of reducing / finding deadlocks when running with SMP enabled. We have seen quite a few lock ordering deadlocks (locks taken in a different order, on two different code paths). As we properly annotate locks in the system, then these facilities will find these locking protocol violations automatically The `LockRank` enum documents the various locks in the system and their rank. The implementation guarantees that a thread holding one or more locks of a lower rank cannot acquire an additional lock with rank that is greater or equal to any of the currently held locks.
2021-09-07Kernel: Track when a thread is in the middle of crashingBrian Gianforcaro
There are certain checks that we should skip if the system is crashing. The system can avoid stack overflow during crash, or even triple faulting while while handling issues that can causes recursive panics or aborts.
2021-09-07Kernel: Add a comment explaining an alternate path in Process::exec()Andreas Kling
I had to look at this for a moment before I realized that sys$execve() and the spawning of /bin/SystemServer at boot are taking two different paths out of exec(). Add a comment to help the next person looking at it. :^)
2021-09-07Kernel: Fix file description leak in sys$execve()Andreas Kling
Before this patch, we were leaking a ref on the open file description used for the interpreter (the dynamic loader) in sys$execve(). This surfaced when adapting the syscall to use TRY(), since we were now correctly transferring ownership of the interpreter to Process::exec() and no longer holding on to a local copy of it (in `elf_result`). Fixing the leak uncovered another problem. The interpreter description would now get destroyed when returning from do_exec(), which led to a kernel panic when attempting to acquire a mutex. This happens because we're in a particularly delicate state when returning from do_exec(). Everything is primed for the upcoming context switch into the new executable image, and trying to block the thread at this point will panic the kernel. We fix this by destroying the interpreter description earlier in do_exec(), at the point where we no longer need it.
2021-09-07Kernel: Don't seek the program executable description in sys$execve()Andreas Kling
The dynamic loader doesn't care if the kernel has moved the file cursor around before it gains control.
2021-09-07Kernel: Hoist allocation of main program FD in sys$execve()Andreas Kling
When executing a dynamically linked program, we need to pass the main program executable via a file descriptor to the dynamic loader. Before this patch, we were allocating an FD for this purpose long after it was safe to do anything fallible. If we were unable to allocate an FD we would simply panic the kernel(!) We now hoist the allocation so it can fail before we've committed to a new executable.
2021-09-07Kernel: Reorganize ELF loading so it can use TRY()Andreas Kling
Due to the use of ELF::Image::for_each_program_header(), we were previously unable to use TRY() in the ELF loading code (since the return statement inside TRY() would only return from the iteration callback.)
2021-09-07Kernel: Remove redundant [[nodiscard]] on KResult return valuesAndreas Kling
Both KResult and KResultOr are [[nodiscard]] at the class level, so there's no need to have functions return `[[nodiscard]] KResult`.
2021-09-07Kernel: Make copy_time_from_user() helpers use KResultOr<Time>Andreas Kling
...and use TRY() for smooth error propagation everywhere.
2021-09-06Kernel: Let aarch64 port call into C++Nico Weber
Put all but the first core into a loop, make room for some stack, and call init().
2021-09-06Kernel: Don't try to allocate ProcessProcFSTraits in Process constructorAndreas Kling
2021-09-06Kernel: Use TRY() in ProcessProcFSTraits::to_inode()Andreas Kling
2021-09-06Kernel: Use TRY() in MemoryDevice::mmap()Andreas Kling
2021-09-06Kernel/KCOV: Use TRY() in KCOVInstance::buffer_allocate()Andreas Kling
2021-09-06Kernel: Wrap two VirtualFileSystem directory traversals in TRY()Andreas Kling
2021-09-06Kernel: Wrap ISO9660FS directory traversal in TRY()Andreas Kling
2021-09-06Kernel: Use TRY() once more in LocalSocket::try_create_connected_pair()Andreas Kling
2021-09-06Kernel: Use TRY() in TmpFSInode::write_bytes()Andreas Kling
2021-09-06Kernel: Use TRY() in sys$module_load() and sys$module_unload()Andreas Kling
2021-09-06Kernel: Make KString factories return KResultOr + use TRY() everywhereAndreas Kling
There are a number of places that don't have an error propagation path right now, so I've added FIXME's about that.
2021-09-06Kernel: Don't allocate so much when generating coredumpsAndreas Kling
Instead of creating a bunch of ByteBuffers and concatenating them to generate the "notes" segment, we now simply create a KBufferBuilder and tell each of the notes generator helpers to write into the builder. This allows the code to flow more naturally, with some bonus additional error propagation. :^)
2021-09-06Kernel: Make SysFS and ProcFS generator functions return KResultAndreas Kling
This allows us to propagate a whole bunch of KBufferBuilder errors.
2021-09-06Kernel: Make KBufferBuilder::append() & friends return KResultAndreas Kling
This allows callers to react to a failed append (due to OOM.)
2021-09-06Kernel: Tidy up Coredump constructionAndreas Kling
- Use KResultOr and TRY to propagate errors - Return more specific errors now that they have a path out from here
2021-09-06Kernel: Use TRY() in CoredumpAndreas Kling
2021-09-06Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcherAndreas Kling
2021-09-06Kernel: Improve API names for switching address spacesAndreas Kling
- enter_space => enter_address_space - enter_process_paging_scope => enter_process_address_space
2021-09-06Kernel: Allocate signal trampoline before committing to a sys$execve()Andreas Kling
Once we commit to a new executable image in sys$execve(), we can no longer return with an error to whoever called us from userspace. We must make sure to surface any potential errors before that point. This patch moves signal trampoline allocation before the commit. A number of other things remain to be moved.
2021-09-06Kernel: Use TRY() more in sys$execve()Andreas Kling
I just keep finding more and more places to make use of this. :^)
2021-09-06Kernel: Use TRY() in find_elf_interpreter_for_executable()Andreas Kling
2021-09-06Kernel: Improve find_elf_interpreter_for_executable() parameter namesAndreas Kling
2021-09-06Kernel: Don't turn I/O errors during sys$execve() into ENOEXECAndreas Kling
Instead, just propagate whatever the real error was.
2021-09-06Kernel: Improve arguments retrieval error propagation in sys$execve()Andreas Kling
Instead of turning any arguments related error into an EFAULT, we now propagate the innermost error during arguments retrieval.
2021-09-06Kernel: Use KResultOr and TRY() for {Shared,Private}InodeVMObjectAndreas Kling
2021-09-06Kernel: Make Memory::Region::map() return KResultAndreas Kling
..and use TRY() at the call sites to propagate errors. :^)
2021-09-06Kernel: Make Threads always have a nameAndreas Kling
We previously allowed Thread to exist in a state where its m_name was null, and had to work around that in various places. This patch removes that possibility and forces those who would create a thread (or change the name of one) to provide a NonnullOwnPtr<KString> with the name.
2021-09-06Kernel: Improvements to Custody absolute path serializationAndreas Kling
- Renamed try_create_absolute_path() => try_serialize_absolute_path() - Use KResultOr and TRY() to propagate errors - Don't call this when it's only for debug logging
2021-09-06Kernel/USB: Use TRY() and adopt_nonnull_own_or_enomem() some moreAndreas Kling
2021-09-06Kernel: Use TRY() in sys$alarm()Andreas Kling
2021-09-06Kernel/Ext2FS: Wrap calls to traverse_as_directory() in TRY()Andreas Kling
Nothing says we can't TRY() a multi-line function call. :^)
2021-09-06Kernel: Use TRY() more in Plan9FSAndreas Kling
2021-09-06Kernel: Tidy up Plan9FS construction a bitAndreas Kling
2021-09-06Kernel: Tidy up Ext2FS construction a bitAndreas Kling
2021-09-06Kernel: Tidy up SysFS constructionAndreas Kling
- Use KResultOr and TRY() to propagate errors - Check for OOM errors - Move allocation out of constructors There's still a lot more to do here, as SysFS is still quite brittle in the face of memory pressure.
2021-09-06Kernel: Tidy up DevFS construction and handle OOM errorsoAndreas Kling
- Use KResultOr and TRY() to propagate errors - Check for OOM - Move allocations out of the DevFS constructor
2021-09-06Kernel: Tidy up DevPtsFS construction and handle OOM errorsAndreas Kling
- Use KResultOr and TRY() to propagate errors - Check for OOM when creating new inodes