summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2022-02-07Kernel: Fix bug in TCP state handling in SynSentJamie Mansfield
When receiving SYN while in SynSent, we now reply with SYN|ACK in addition to the SynSent->SynReceived transition.
2022-02-07Kernel: Robustify and rename Inode bound socket APIAndreas Kling
Rename the bound socket accessor from socket() to bound_socket(). Also return RefPtr<LocalSocket> instead of a raw pointer, to make it harder for callers to mess up.
2022-02-07Kernel: Ensure socket is suitable for writing in sys$sendmsgsin-ack
Previously we would return a bytes written value of 0 if the writing end of the socket was full. Now we either exit with EAGAIN if the socket description is non-blocking, or block until the description can be written to. This is mostly a copy of the conditions in sys$write but with the "total nwritten" parts removed as sys$sendmsg does not have that.
2022-02-06Kernel: Fix bugs in TCP state handling in FinWait1 & FinWait2Andreas Kling
1. When receiving FIN while in FinWait1, we now reply with ACK in addition to the FinWait1->Closing transition. 2. When receiving FIN|ACK while in FinWait1, we now reply with ACK and transition from FinWait1->TimeWait. 3. When receiving FIN while in FinWait2, we now reply with ACK.
2022-02-06Kernel: Send only FIN when shutting down TCP socket from ESTABLISHEDAndreas Kling
We were previously sending FIN|ACK for some reason.
2022-02-06AK: Move integral log2 and exp to IntegerMath.hHendiadyoin1
2022-02-06Kernel: Propagate sys$profiling_enable() buffer allocation failureAndreas Kling
Caught a kernel panic when enabling profiling of all threads when there was very little memory available.
2022-02-05Kernel: Put kmalloc heap expansion debug spam behind KMALLOC_DEBUGAndreas Kling
2022-02-05Kernel/Interrupts: Remove stale MSIHandler classLiav A
When we implement MSI support, we can rely on the IRQHandler class for installing IRQ handlers at the right location.
2022-02-04Kernel: Disable BootFramebufferConsole when drivers create a new oneTom
When GraphicsManagement initializes the drivers we can disable the bootloader framebuffer console. Right now we don't yet fully destroy the no longer needed console as it may be in use by another CPU.
2022-02-04Kernel: Set up an initial boot framebuffer consoleTom
Instead of seeing a black screen until GraphicsManagement was fully initialized, this allows us to see the console output much earlier. So, if the bootloader provided us with a framebuffer, set up a console as early as possible.
2022-02-04Kernel: Separate GenericFramebufferConsole implementationTom
The GenericFramebufferConsoleImpl class implements the logic without taking into account any other details such as synchronization. The GenericFramebufferConsole class then is a simple wrapper around GenericFramebufferConsoleImpl that takes care of synchronization. This allows us to re-use this implementation with e.g. different synchronization schemes.
2022-02-03Kernel: Remove the infallible make_ref_counted<T> factory functionIdan Horowitz
This function had no users, nor should it ever be used, as all allocation failures in the Kernel should be explicitly checked.
2022-02-03Kernel: Convert try_make_ref_counted to use ErrorOrIdan Horowitz
This allows more ergonomic memory allocation failure related error checking using the TRY macro.
2022-02-03Kernel: Stop using the make<T> factory method in the KernelIdan Horowitz
As make<T> is infallible, it really should not be used anywhere in the Kernel. Instead replace with fallible `new (nothrow)` calls, that will eventually be error-propagated.
2022-02-03Kernel: Ignore allocation failures when trying to retransmit packetsIdan Horowitz
We ignore allocation failures above the first 16 guaranteed socket slots, as we will just retransmit their packets the next time around.
2022-02-03Kernel: Stop allocating VirtIO configuration structs on the heapIdan Horowitz
These are trivially-copyable 12-byte structs, so there's no point in allocating them on the heap.
2022-02-03Revert "Kernel: Protect InodeWatcher internals with spinlock instead of mutex"Andreas Kling
This reverts commit 0bebf013e348f52f218535ebd3d82c9599ea5818. This caused a deadlock when handling a crashed process, so let's revert it until we can figure out what went wrong.
2022-02-03Kernel: Protect Inode flock list with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Remove unnecessary mutex for ubsan-is-deadly ProcFS nodeAndreas Kling
2022-02-03AK+Kernel+LibSanitizer: Store "ubsan-is-deadly" flag as Atomic<bool>Andreas Kling
2022-02-03Kernel: Protect InodeWatcher internals with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect PCI access with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Turn VirtIOGPU operation lock from mutex into spinlockAndreas Kling
2022-02-03Kernel: Protect FramebufferDevice with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect global device map with spinlock instead of mutxAndreas Kling
2022-02-03Kernel: Protect Inode's list of watchers with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect mounted filesystem list with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect network adapter list with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect PTYMultiplexer freelist with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Protect ARP table with spinlock instead of mutexAndreas Kling
2022-02-03Kernel: Convert OpenFileDescriptor from mutex to spinlockAndreas Kling
A mutex is useful when we need to be able to block the current thread until it's available. This is overkill for OpenFileDescriptor. First off, this patch wraps the main state member variables inside a SpinlockProtected<State> to enforce synchronized access. This also avoids "free locking" where figuring out which variables are guarded by which lock is left as an unamusing exercise for the reader. Then we remove mutex locking from the functions that simply call through to the underlying File or Inode, since those fields never change anyway, and the target objects perform their own synchronization.
2022-02-03Kernel: Move Spinlock lock/unlock functions out of lineAndreas Kling
I don't see why these have to be inlined everywhere in the kernel.
2022-02-02Kernel: Add polling support to NVMePankaj Raghav
Add polling support to NVMe so that it does not use interrupt to complete a IO but instead actively polls for completion. This probably is not very efficient in terms of CPU usage but it does not use interrupts to complete a IO which is beneficial at the moment as there is no MSI(X) support and it can reduce the latency of an IO in a very fast NVMe device. The NVMeQueue class has been made the base class for NVMeInterruptQueue and NVMePollQueue. The factory function `NVMeQueue::try_create` will return the appropriate queue to the controller based on the polling boot parameter. The polling mode can be enabled by adding an extra boot parameter: `nvme_poll`.
2022-02-02Kernel: Add conditional call to disable_irq in IRQHandler constructorPankaj Raghav
There is no use in calling disable_irq function in the IRQHandler constructor if irq was not registered before. So add a condition where we call disable_irq only if the irq was registered before.
2022-02-02Kernel: Add nvme_poll command line parametersPankaj Raghav
As we don't currently support MSI(X) interrupts, it could be an issue to boot on some newer hardware. NVMe devices support polling mode where the driver actively polls for completion instead of waiting for an interrupt.
2022-02-02Revert "Kernel: Only update page tables for faulting region"Andreas Kling
This reverts commit 1c5ffaae41be4e67f81b46c3bfdce7f54a1dc8e0. This broke shared memory as used by OutOfProcessWebView. Let's do a revert until we can figure out what went wrong.
2022-02-02Kernel: Only update page tables for faulting regionAndreas Kling
When a page fault led to the mapping of a new physical page, we were updating the page tables for *every* region that shared the same underlying VMObject. Let's just not do that, avoiding a bunch of unnecessary page table updates and TLB invalidations.
2022-01-30Kernel/Interrupts: Initialize two spurious handlers when PIC is disabledLiav A
Even if the PIC was disabled it can still generate noise (spurious IRQs) so we need to register two handlers for handling such cases. Also, we declare interrupt service routine offset 0x20 to 0x2f as reserved, so when the PIC is disabled, we can handle spurious IRQs from the PIC at separate handlers.
2022-01-30Kernel: Use a constexpr declaration for the disabled PIC IRQ baseLiav A
2022-01-30Kernel: Don't mark current thread as inactive after successful exec()Andreas Kling
At the end of sys$execve(), we perform a context switch from the old executable into the new executable. However, the Kernel::Thread object we are switching to is the *same* thread as the one we are switching from. So we must not assume the from_thread and to_thread are different threads. We had a bug caused by this misconception, where the "from" thread would always get marked as "inactive" when switching to a new thread. This meant that threads would always get switched into "inactive" mode on first context switch into them. If a thread then tried blocking on a kernel mutex within its first time slice, we'd end up in Thread::block(Mutex&) with an inactive thread. Once a thread is inactive, the scheduler believes it's okay to reactivate the thread (by scheduling it.) If a thread got re-scheduled prematurely while setting up a mutex block, things would fall apart and we'd crash in Thread::block() due to the thread state being "Runnable" instead of the expected "Running".
2022-01-30Kernel: Release page directory and MM locks sooner in space finalizationAndreas Kling
We don't need to hold these locks when tearing down the region tree. Release them as soon as unmapping is finished.
2022-01-30Kernel: Take scheduler lock before block lock in unblock_from_mutex()Andreas Kling
This matches the acquisition order used elsewhere.
2022-01-30Kernel: Remove unused bool return values from scheduler functionsAndreas Kling
Turns out nobody actually cared whether the scheduler switched to a new thread or not (which is what we were returning.)
2022-01-30Kernel: Simplify x86 IOPL sanity checkAndreas Kling
Move this architecture-specific sanity check (IOPL must be 0) out of Scheduler and into the x86 enter_thread_context(). Also do this for every thread and not just userspace ones.
2022-01-30Kernel: VERIFY that Scheduler::context_switch() always has a from-threadAndreas Kling
We always context_switch() from somewhere, so there's no need to handle the case where from_thread is null.
2022-01-30Kernel: Enforce that Thread::unblock_from_mutex() doesn't happen in IRQAndreas Kling
Mutexes are not usable from IRQ handlers, so unblock_from_mutex() can simply VERIFY() that the current processor is not in an IRQ.
2022-01-30Kernel: Update terminology around Thread's "blocking mutex"Andreas Kling
It's more accurate to say that we're blocking on a mutex, rather than blocking on a lock. The previous terminology made sense when this code was using something called Kernel::Lock, but since it was renamed to Kernel::Mutex, this updates brings the language back in sync.
2022-01-30Kernel: Make Thread::State an `enum class` and use it consistentlyAndreas Kling
It was annoyingly hard to spot these when we were using them with different amounts of qualification everywhere. This patch uses Thread::State::Foo everywhere instead of Thread::Foo or just Foo.
2022-01-30Kernel: Don't dispatch signals in Thread::block_impl()Andreas Kling
If the blocker is interrupted by a signal, that signal will be delivered to the process when returning to userspace (at the syscall exit point.) We don't have to perform the dispatch manually in Thread::block_impl().