summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
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.
2020-07-02Kernel: Remove no-longer-used GDT selector from ThreadAndreas Kling
Now that we use software context switching, each thread no longer has its own GDT entry (yay!) so we can get rid of this Thread member. :^)
2020-07-01Meta: move Kernel/.bochsrc => Meta/bochsrcEmanuele Torre
The run script is not in Kernel/ anymore, let's move `.bochsrc` in Meta/ so that it can be used with the new build system. Also make bochs use `grub_disk_image` instead of `_disk_image`
2020-07-01PATA: Ignore interrupts that weren't generated by the diskTom
2020-07-01PATA: LBA48 uses 16 bit features registerTom
2020-07-01Kernel: Boot all APS all the way into their own idle loopTom
2020-07-01Kernel: Block initializing the Scheduler on the APs until the BSP ↵Tom
initialized global data
2020-07-01Kernel: Add a quickmap region for each processorTom
Threads need to be able to concurrently quickmap things.
2020-07-01Kernel: Protect Console with SpinLockTom
2020-07-01Kernel: Turn Thread::current and Process::current into functionsTom
This allows us to query the current thread and process on a per processor basis
2020-07-01Kernel/LibCore: Expose processor id where a thread last ranTom
2020-07-01Kernel: List all CPUs in /proc/cpuinfoTom
2020-07-01Kernel: Implement software context switching and Processor structureTom
Moving certain globals into a new Processor structure for each CPU allows us to eventually run an instance of the scheduler on each CPU.
2020-07-01PATA: Avoid double-preparing for irqTom
2020-07-01Kernel: Serialize debug outputTom
2020-06-27Kernel: Make Random work on CPUs without rdrandPeter Elliott
- If rdseed is not available, fallback to rdrand. - If rdrand is not available, block for entropy, or use insecure prng depending on if user wants fast or good random.
2020-06-27Kernel: Add g_cpu_supports_rdseed3541
CPUs which support RDRAND do not necessarily support RDSEED. This introduces a flag g_cpu_supports_rdseed which is set appropriately by CPUID. This causes Haswell CPUs in particular (and probably a lot of AMD chips) to now fail to boot with #2634, rather than an illegal instruction. It seems like the KernelRng needs either an initial reseed call or more random events added before the first call to get_good_random, but I don't feel qualified to make that kind of change.
2020-06-25Kernel: Harvest randomness from various driversPeter Elliott
Random now gets entropy from the following drivers: - KeyboardDevice - PATAChannel - PS2MouseDevice - E1000NetworkAdapter - RTL8139NetworkAdapter Of these devices, PS2MouseDevice and PATAChannel provide the vast majority of the entropy.
2020-06-25LibCrypto: Add CTR cipher modePeter Elliott
Kernel: Changed fortuna implementation to use CTR mode instead of manually implementing a counter.
2020-06-25Kernel: Replace existing random implementation with FortunaPeter Elliott
2020-06-25Kernel: Implement the Fortuna PRNG algorithmPeter Elliott
2020-06-25Kernel: Port mounts to reference inodes directlySergey Bugaev
...instead of going through their identifiers. See the previous commit for reasoning.
2020-06-25Kernel: Deemphasize inode identifiersSergey Bugaev
These APIs were clearly modeled after Ext2FS internals, and make perfect sense in Ext2FS context. The new APIs are more generic, and map better to the semantics exported to the userspace, where inode identifiers only appear in stat() and readdir() output, but never in any input. This will also hopefully reduce the potential for races (see commit https://github.com/SerenityOS/serenity/commit/c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2). Lastly, this makes it way more viable to implement a filesystem that only synthesizes its inodes lazily when queried, and destroys them when they are no longer in use. With inode identifiers being used to reference inodes, the only choice for such a filesystem is to persist any inode it has given out the identifier for, because it might be queried at any later time. With direct references to inodes, the filesystem will know when the last reference is dropped and the inode can be safely destroyed.
2020-06-25Kernel: Minor cleanups in sendfd/recvfdAndreas Kling
Applying some nice suggestions by @bugaevc. :^)
2020-06-24Kernel+LibC: Add sys$recvfd() and sys$sendfd() for fd passingAndreas Kling
These new syscalls allow you to send and receive file descriptors over a local domain socket. This will enable various privilege separation techniques and other good stuff. :^)