summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-09-07Kernel: TCPSocket always has a scratch bufferAndreas Kling
Let's encode this in the constructor signature.
2021-09-07Kernel/Net: Add a special SOCKET_TRY() and use it in socket codeAndreas Kling
Sockets remember their last error code in the SO_ERROR field, so we need to take special care to remember this when returning an error. This patch adds a SOCKET_TRY() that works like TRY() but also calls set_so_error() on the failure path. There's probably a lot more code that should be using this, but that's outside the scope of this patch.
2021-09-07Kernel: Use TRY() some more in SocketAndreas Kling
2021-09-07Kernel: Use KResultOr and TRY() for ThreadTracerAndreas Kling
Also make the constructor private, since it's only called by the static factory function.
2021-09-07Kernel: Make TCPSocket client construction use KResultOr and TRY()Andreas Kling
We don't really have anywhere to propagate the error in NetworkTask at the moment, since it runs in its own kernel thread and has no direct userspace caller.
2021-09-07Kernel: Use KResultOr and TRY() for FIFOAndreas Kling
2021-09-07Kernel: Use KResultOr and TRY() for MasterPTYAndreas Kling
2021-09-07Kernel: Make DoubleBuffer::try() return KResultOrAndreas Kling
This tidies up error propagation in a number of places.
2021-09-07Kernel: Rename file_description(fd) => open_file_description(fd)Andreas Kling
To go with the class rename.
2021-09-07Kernel: Rename FileDescription => OpenFileDescriptionAndreas Kling
Dr. POSIX really calls these "open file description", not just "file description", so let's call them exactly that. :^)
2021-09-07Kernel: Convert much of sys$execve() to using KStringAndreas Kling
Make use of the new FileDescription::try_serialize_absolute_path() to avoid String in favor of KString throughout much of sys$execve() and its helpers.
2021-09-07LibELF: Use StringView to carry temporary strings in auxiliary vectorAndreas Kling
Let's not force clients to provide a String.
2021-09-07Kernel: Add FileDescription::try_serialize_absolute_path()Andreas Kling
Unlike FileDescription::absolute_path(), this knows that failures can happen and will propagate them to the caller.
2021-09-07Kernel: Avoid unnecessary String allocation in sys$statvfs()Andreas Kling
2021-09-07Everywhere: Behaviour => BehaviorAndreas Kling
2021-09-07Kernel: Store process names as KStringAndreas Kling
2021-09-07Kernel: Tidy up ProcessProcFSTraits construction a bit moreAndreas Kling
Let the constructor take a Process& instead of a WeakPtr<Process> and avoid a bunch of WeakPtr copying.
2021-09-07Kernel: Make UserOrKernelBuffer return KResult from read/write/memsetAndreas Kling
This allows us to simplify a whole bunch of call sites with TRY(). :^)
2021-09-07Kernel/PCI: Turn on memory access by defaultLiav A
This will allow the Kernel to utilize memory access to the PCI configuration space if such method is available.
2021-09-07Kernel/PCI: Simplify the entire subsystemLiav A
A couple of things were changed: 1. Semantic changes - PCI segments are now called PCI domains, to better match what they are really. It's also the name that Linux gave, and it seems that Wikipedia also uses this name. We also remove PCI::ChangeableAddress, because it was used in the past but now it's no longer being used. 2. There are no WindowedMMIOAccess or MMIOAccess classes anymore, as they made a bunch of unnecessary complexity. Instead, Windowed access is removed entirely (this was tested, but never was benchmarked), so we are left with IO access and memory access options. The memory access option is essentially mapping the PCI bus (from the chosen PCI domain), to virtual memory as-is. This means that unless needed, at any time, there is only one PCI bus being mapped, and this is changed if access to another PCI bus in the same PCI domain is needed. For now, we don't support mapping of different PCI buses from different PCI domains at the same time, because basically it's still a non-issue for most machines out there. 2. OOM-safety is increased, especially when constructing the Access object. It means that we pre-allocating any needed resources, and we try to find PCI domains (if requested to initialize memory access) after we attempt to construct the Access object, so it's possible to fail at this point "gracefully". 3. All PCI API functions are now separated into a different header file, which means only "clients" of the PCI subsystem API will need to include that header file. 4. Functional changes - we only allow now to enumerate the bus after a hardware scan. This means that the old method "enumerate_hardware" is removed, so, when initializing an Access object, the initializing function must call rescan on it to force it to find devices. This makes it possible to fail rescan, and also to defer it after construction from both OOM-safety terms and hotplug capabilities.
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