summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-07-27Kernel: Support file-backed mmap() with non-zero offsetAndreas Kling
As it turns out, this works just fine and all we had to do was remove the assertion! :^) Fixes #2597.
2020-07-26Kernel: Switch to using AK::is and AK::downcastAndreas Kling
2020-07-26Refactor: Change the AK::binary_search signature to use AK::Span.asynts
2020-07-25Kernel: Allow Thread::sleep for more than 388 daysBen Wiederhake
Because Thread::sleep is an internal interface, it's easy to check that there are only few callers: Process::sys$sleep, usleep, and nanosleep are happy with this increased size, because now they support the entire range of their arguments (assuming small-ish values for ticks_per_second()). SyncTask doesn't care. Note that the old behavior wasn't "cap out at 388 days", which would have been reasonable. Instead, the code resulted in unsigned overflow, meaning that a very long sleep would "on average" end after about 194 days, sometimes much quicker.
2020-07-25Kernel: Make clock_nanosleep aware of dynamic tick lengthBen Wiederhake
On my system, ticks_per_second() returns 1280. So Serenity was very fast at sleeping! :P
2020-07-25Kernel: Make usleep aware of dynamic tick lengthBen Wiederhake
On my system, ticks_per_second() returns 1280. So Serenity was always 20% too fast when sleeping!
2020-07-25Kernel: Allow process creation during low-entropy conditionBen Wiederhake
Fixes #2871. Ignoring the 'securely generated bytes' constraint seems to be fine for Linux, so it's probably fine for Serenity. Note that there *might* be more bottlenecks down the road if Serenity is started in a non-GUI way. Currently though, loading the GUI seems to generate enough interrupts to seed the entropy pool, even on my non-RDRAND setup. Yay! :^)
2020-07-19Kernel: Implement FIFOs/named pipesPeter Elliott
2020-07-18Kernel: Remove special-casing of sys$gettid() in syscall entryAndreas Kling
We had a fast-path for the gettid syscall that was useful before we started caching the thread ID in LibC. Just get rid of it. :^)
2020-07-17Kernel: Make all 6 VirtualConsoles available via shortcutFlorian Angermeier
Add all 6 shortcuts even if the switch between VirtualConsoles is currently not available in the graphical console. Also make the case statement more compact.
2020-07-17Kernel: Ensure there are all VirtualConsoles properly initializedFlorian Angermeier
It is possible to switch to VirtualConsoles 1 to 4 via the shortcut ALT + [1-4]. Therefor the array of VirtualConsoles should be guaranteed to be initialized. Also add an constant for the maximum number of VirtualConsoles to guarantee consistency.
2020-07-17Kernel: Make the VirtualConsole index const unsigned instead of unsignedFlorian Angermeier
const: The index should not be modified in the constructor to avoid unexpected behavior
2020-07-15Kernel: Fix crash on cat /proc/PID/vmobjectsAndreas Kling
A Region starts at an offset into a VMObject, and if that offset is non-zero, we need to subtract it from the VMObject page index here. Fixes #2803.
2020-07-15LibC+Kernel: Start implementing sysconfNico Weber
For now, only the non-standard _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN are implemented. Use them to make ninja pick a better default -j value. While here, make the ninja package script not fail if no other port has been built yet.
2020-07-11ProcFS: JSONify /proc/cpuinfoLinus Groh
To be more in line with other parts of Serenity's procfs, the "key: value" format of /proc/cpuinfo was replaced with JSON, namely an array of objects (one for each core). The available keys remain the same, though "features" has been changed from a space-separated string to an array of strings.
2020-07-11LibC: Implement tcflush(3)Peter Elliott
2020-07-09Kernel: Fix some flaws that caused crashes or hangs during bootTom
We need to halt the BSP briefly until all APs are ready for the first context switch, but we can't hold the same spinlock by all of them while doing so. So, while the APs are waiting on each other they need to release the scheduler lock, and then once signaled re-acquire it. Should solve some timing dependent hangs or crashes, most easily observed using qemu with kvm disabled.
2020-07-09Kernel: Protect Inode list with SpinLock (#2748)Tom
Fixes crashes when a context switch happens in the middle of modifying it, or when another thread on another processor modifies it at the same time.
2020-07-08Kernel: Detect syscall/sysenter supportTom
2020-07-07Kernel: Fix checking BlockResultTom
We now have BlockResult::WokeNormally and BlockResult::NotBlocked, both of which indicate no error. We can no longer just check for BlockResult::WokeNormally and assume anything else must be an interruption.
2020-07-07Kernel+LibELF: Expose ELF Auxiliary Vector to UserspaceAndrew Kaster
The AT_* entries are placed after the environment variables, so that they can be found by iterating until the end of the envp array, and then going even further beyond :^)
2020-07-06Kernel: Aggregate TLB flush requests for Regions for SMPTom
Rather than sending one TLB flush request for each page, aggregate them so that we're not spamming the other processors with FlushTLB IPIs.
2020-07-06Kernel: Minor MM optimization for SMPTom
MemoryManager::quickmap_pd and MemoryManager::quickmap_pt can only be called by one processor at the time anyway, since anything using these must have the MM lock held. So, no need to inform the other CPUs to flush their TLBs, we can just flush our own.
2020-07-06Kernel: Add SMP IPI supportTom
We can now properly initialize all processors without crashing by sending SMP IPI messages to synchronize memory between processors. We now initialize the APs once we have the scheduler running. This is so that we can process IPI messages from the other cores. Also rework interrupt handling a bit so that it's more of a 1:1 mapping. We need to allocate non-sharable interrupts for IPIs. This also fixes the occasional hang/crash because all CPUs now synchronize memory with each other.
2020-07-06Kernel: Tidy up SpinLock and related classes a little bitAndreas Kling
2020-07-06Kernel: Thread::wait_on() must always leave interrupts enabled on exitAndreas Kling
The short-circuit path added for waiting on a queue that already had a pending wake was able to return with interrupts disabled, which breaks the API contract of wait_on() always returning with IF=1. Fix this by adding a way to override the restored IF in ScopedCritical.
2020-07-06Kernel: Tidy up the ScopedCritical class a little bitAndreas Kling
2020-07-06Kernel: Enhance WaitQueue to remember pending wakesTom
If WaitQueue::wake_all, WaitQueue::wake_one, or WaitQueue::wake_n is called but nobody is currently waiting, we should remember that fact and prevent someone from waiting after such a request. This solves a race condition where the Finalizer thread is notified to finalize a thread, but it is not (yet) waiting on this queue. Fixes #2693
2020-07-06Kernel: Various context switch fixesTom
These changes solve a number of problems with the software context swithcing: * The scheduler lock really should be held throughout context switches * Transitioning from the initial (idle) thread to another needs to hold the scheduler lock * Transitioning from a dying thread to another also needs to hold the scheduler lock * Dying threads cannot necessarily be finalized if they haven't switched out of it yet, so flag them as active while a processor is running it (the Running state may be switched to Dying while it still is actually running)
2020-07-06Kernel: Add a SpinLock to the WaitQueueTom
We need to be able to prevent a WaitQueue from being modified by another CPU. So, add a SpinLock to it. Because this pushes some other class over the 64 byte limit, we also need to add another 128-byte bucket to the slab allocator.
2020-07-06Kernel: Require a reason to be passed to Thread::wait_onTom
The Lock class still permits no reason, but for everything else require a reason to be passed to Thread::wait_on. This makes it easier to diagnose why a Thread is in Queued state.
2020-07-05Kernel: Add Plan9FS :^)Sergey Bugaev
This is an (incomplete, and not very stable) implementation of the client side of the 9P protocol.
2020-07-05Kernel: Split BlockBasedFileSystem off FileBackedFileSystemSergey Bugaev
FileBackedFileSystem is one that's backed by (mounted from) a file, in other words one that has a "source" of the mount; that doesn't mean it deals in blocks. The hierarchy now becomes: * FS * ProcFS * DevPtsFS * TmpFS * FileBackedFS * (future) Plan9FS * BlockBasedFS * Ext2FS
2020-07-05Kernel: Fix .. directory entry at mount point handling a littleSergey Bugaev
It's still broken, but at least it now appears to work if the file system doesn't return the same inode for "..".
2020-07-05Kernel: Make sure to drop region with interrupts enabledSergey Bugaev
A region can drop an inode if it was mmaped from the inode and held the last reference to it, and that may require some locking.
2020-07-05AK: Make Vector::unstable_remove() return the removed valueSergey Bugaev
...and rename it to unstable_take(), to align with other take...() methods.
2020-07-05Kernel: Fix KBufferBuilder::append()Sergey Bugaev
insertion_ptr() already includes the offset.
2020-07-04Kernel: Move headers intended for userspace use into Kernel/API/Andreas Kling
2020-07-04Kernel: Add "child added" and "child removed" InodeWatcher eventsAndreas Kling
The child name is not yet accessible to userspace, but will be in a future patch.
2020-07-04Kernel: Remove debug spam in finalizer taskAndreas Kling
2020-07-04Kernel: Change the value of SO_KEEPALIVE to reflect LibC's constantAnotherTest
This change was partially introduced in 861eb8d, which changed the constant in LibC without changing the one in the kernel.
2020-07-03Kernel: Remove /proc/PID/regsTom
There isn't an easy way to retreive all register contents anymore, so remove this functionality. We do have the ability to trace processes, so it shouldn't really be needed anymore.
2020-07-03Kernel: Fix retreiving frame pointer from a threadTom
If we're trying to walk the stack for another thread, we can no longer retreive the EBP register from Thread::m_tss. Instead, we need to look at the top of the kernel stack, because all threads not currently running were last in kernel mode. Context switches now always trigger a brief switch to kernel mode, and Thread::m_tss only is used to save ESP and EIP. Fixes #2678
2020-07-03LibC: Remove a few comments now that we have man pages for this.Nico Weber
2020-07-03Kernel: Consolidate features into CPUFeature enumTom
This allows us to consolidate printing out all the CPU features into one log statement. Also expose them in /proc/cpuinfo
2020-07-03Kernel: Fix signal deliveryTom
When delivering urgent signals to the current thread we need to check if we should be unblocked, and if not we need to yield to another process. We also need to make sure that we suppress context switches during Process::exec() so that we don't clobber the registers that it sets up (eip mainly) by a context switch. To be able to do that we add the concept of a critical section, which are similar to Process::m_in_irq but different in that they can be requested at any time. Calls to Scheduler::yield and Scheduler::donate_to will return instantly without triggering a context switch, but the processor will then asynchronously trigger a context switch once the critical section is left.
2020-07-03Kernel: Allow recursion when writing to the debug logTom
This allows printing in the case e.g. a page fault happens during a log statement
2020-07-03Kernel: Change kmalloc lock to be recursiveTom
If the heap code dumps a stack trace (e.g. out of memory) then it may recursively call into it. Rather than deadlocking, allow recursion.
2020-07-03Kernel: Split initialization of Processor structureTom
We need to very early on initialize the Processor structure so that we can use RecursiveSpinLock early on.
2020-07-03Kernel: Fix non-blocking write() blocking instead of short-writingAndreas Kling
If a partial write succeeded, we could then be in an unexpected state where the file description was non-blocking, but we could no longer write to it. Previously, the kernel would block in that state, but instead we now handle this as a proper short write and return the number of bytes we were able to write. Fixes #2645.