summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2020-07-31Kernel: Remove SmapDisabler in sys$setsockopt()Andreas Kling
2020-07-31Kernel: Remove SmapDisabler in sys$ioctl()Andreas Kling
Use copy_{to,from}_user() in the various File::ioctl() implementations instead of disabling SMAP wholesale in sys$ioctl(). This patch does not port IPv4Socket::ioctl() to those API's since that will be more involved. That function now creates a local SmapDisabler.
2020-07-30Kernel: Rename region_from_foo() => find_region_from_foo()Andreas Kling
Let's emphasize that these functions actually go out and find regions.
2020-07-30Kernel: Turn Process::FileDescriptionAndFlags into a proper classAndreas Kling
2020-07-30Kernel: Simplify the ScopedSpinLock templateAndreas Kling
We can just templatize the LockType here. This makes my Qt Creator syntax highlighting work again. :^)
2020-07-30Kernel: Move syscall implementations out of Process.cppAndreas Kling
This is something I've been meaning to do for a long time, and here we finally go. This patch moves all sys$foo functions out of Process.cpp and into files in Kernel/Syscalls/. It's not exactly one syscall per file (although it could be, but I got a bit tired of the repetitive work here..) This makes hacking on individual syscalls a lot less painful since you don't have to rebuild nearly as much code every time. I'm also hopeful that this makes it easier to understand individual syscalls. :^)
2020-07-30Kernel: Run clang-format on Scheduler.cppAndreas Kling
2020-07-30Kernel: Make BXVGA detection actually detect VBoxVGALuke
I decided to play around with trying to run Serenity in VirtualBox. It crashed WindowServer with a beautiful array of multi-color flashing letters :^) Skipping getting side-tracked seeing that it chose MBVGA in the serial debug and trying to debug why it caused such a display, I finally checked BXVGA. While find_framebuffer_address checks for VBoxVGA, init_stage2 didn't. Whoops!
2020-07-28Net: Fix IPv4 fragmentation not working for larger payloadsAndreas Kling
We were masking the fragment offset bits incorrectly in the IPv4 header sent out with fragments. This worked up to ~32KB but after that, things would get very confused. :^)
2020-07-28Kernel: Use AK::Span a bunch in the network adapter codeAndreas Kling
2020-07-27Kernel+LibC: Add sys$set_process_name() for changing the process nameAndreas Kling
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.