summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2023-04-06Kernel: Implement ScopedAddressSpaceSwitcher using PageDirectoryTimon Kruiper
This makes the code architecture independent, and thus makes it work for aarch64.
2023-04-06Kernel/aarch64: Flush entire TLB cache when changing TTBR0_EL1Timon Kruiper
Setting the page table base register (ttbr0_el1) is not enough, and will not flush the TLB caches, in contrary with x86_64 where setting the CR3 register will actually flush the caches. This commit adds the necessary code to properly flush the TLB caches when context switching. This commit also changes Processor::flush_tlb_local to use the vmalle1 variant, as previously we would be flushing the tlb's of all the cores in the inner-shareable domain.
2023-04-06Kernel: Implement TimeManagement::boot_time() for aarch64Timon Kruiper
For now just return 0 as we have no RTC support on aarch64 yet, and add a FIXME to return the correct value.
2023-04-06Kernel: Extend the lifetime of Regions during page fault handlingIdan Horowitz
Previously we had a race condition in the page fault handling: We were relying on the affected Region staying alive while handling the page fault, but this was not actually guaranteed, as an munmap from another thread could result in the region being removed concurrently. This commit closes that hole by extending the lifetime of the region affected by the page fault until the handling of the page fault is complete. This is achieved by maintaing a psuedo-reference count on the region which counts the number of in-progress page faults being handled on this region, and extending the lifetime of the region while this counter is non zero. Since both the increment of the counter by the page fault handler and the spin loop waiting for it to reach 0 during Region destruction are serialized using the appropriate AddressSpace spinlock, eventual progress is guaranteed: As soon as the region is removed from the tree no more page faults on the region can start. And similarly correctness is ensured: The counter is incremented under the same lock, so any page faults that are being handled will have already incremented the counter before the region is deallocated.
2023-04-06Kernel: Store a pointer to the owner process in PageDirectoryIdan Horowitz
This replaces the previous owning address space pointer. This commit should not change any of the existing functionality, but it lays down the groundwork needed to let us properly access the region table under the address space spinlock during page fault handling.
2023-04-06Kernel: Restructure execve to ensure Process::m_space is always in useIdan Horowitz
Instead of setting up the new address space on it's own, and only swap to the new address space at the end, we now immediately swap to the new address space (while still keeping the old one alive) and only revert back to the old one if we fail at any point. This is done to ensure that the process' active address space (aka the contents of m_space) always matches actual address space in use by it. That should allow us to eventually make the page fault handler process- aware, which will let us properly lock the process address space lock.
2023-04-06Kernel: Mark sys$msync as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$mremap as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$munmap as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$set_mmap_name as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$mprotect as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$mmap as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Remove unused credentials() call in validate_inode_mmap_protIdan Horowitz
For some reason GCC did not complain about this.
2023-04-06Kernel: Mark sys$map_time_page as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-06Kernel: Mark sys$madvise as not needing the big lockIdan Horowitz
All accesses to shared mutable data are already serialized behind the process address space spinlock.
2023-04-05Kernel/NVMeQueue: Use waitqueue in submit_sync_sqePankaj Raghav
The current way we handle sync commands is very ugly and depends on lot of preconditions. Now that we have an end_io handler for a request, we can use WaitQueue to do sync commands more elegantly. This does depend on block layer sending one request at a time but this change is a step forward towards better IO handling.
2023-04-05Kernel/NVMe: Redesign the tracking of requests in an NVMe QueuePankaj Raghav
There was a private variable named m_current_request which was used to track a single request at a time. This guarantee is given by the block layer where we wait on each IO. This design will break down in the driver once the block layer removes that constraint. Redesign the IO handling in a completely asynchronous way by maintaining requests up to queue depth. NVMeIO struct is introduced to track an IO submitted along with other information such whether the IO is still being processed and an endio callback which will be called during the end of a request. A hashmap private variable is created which will key based on the command id of a request with a value of NVMeIO. endio handler will come in handy if we are doing a sync request and we want to wake up the wait queue during the end. This change also simplified the code by removing some special condition in submit_sqe function, etc that were marked as FIXME for a long time.
2023-04-05Kernel/NVMe: Use an Atomic for command id instead of sq indexPankaj Raghav
Using sq_tail as cid makes an inherent assumption that we send only one IO at a time. Use an atomic variable instead for command id of a submission queue entry. As sq_tail is not used as cid anymore, remove m_prev_sq_tail which used to hold the last used sq_tail value.
2023-04-05Kernel: Mark sys$setpgid as not needing the big lockAndreas Kling
This function is already serialized by access to process protected data.
2023-04-05Kernel: Make Credentials the authority on process SIDAndreas Kling
The SID was duplicated between the process credentials and protected data. And to make matters worse, the credentials SID was not updated in sys$setsid. This patch fixes this by removing the SID from protected data and updating the credentials SID everywhere.
2023-04-05Kernel: Mark sys$setsid as not needing the big lockAndreas Kling
This function is now serialized by access to the process group list, and to the current process's protected data.
2023-04-05Kernel: Make ProcessGroup a ListedRefCounted and fix two racesAndreas Kling
This closes two race windows: - ProcessGroup removed itself from the "all process groups" list in its destructor. It was possible to walk the list between the last unref() and the destructor invocation, and grab a pointer to a ProcessGroup that was about to get deleted. - sys$setsid() could end up creating a process group that already existed, as there was a race window between checking if the PGID is used, and actually creating a ProcessGroup with that PGID.
2023-04-05Kernel: Make SlavePTY store pointer to MasterPTY as NonnullRefPtrAndreas Kling
No need for LockRefPtr here, as the pointer never changes after initialization.
2023-04-05Kernel: Move Process's TTY pointer into protected dataAndreas Kling
2023-04-05Kernel: Move Process's process group pointer into protected dataAndreas Kling
Now that it's no longer using LockRefPtr, we can actually move it into protected data. (LockRefPtr couldn't be stored there because protected data is immutable at times, and LockRefPtr uses some of its own bits for locking.)
2023-04-05Kernel: Stop using *LockRefPtr for TTYAndreas Kling
TTY was only stored in Process::m_tty, so make that a SpinlockProtected.
2023-04-05Kernel: Remove ancient InterruptDisabler in sys$setsidAndreas Kling
This was some pre-SMP historical artifact.
2023-04-05Kernel: Mark sys$faccessat as not needing the big lockAndreas Kling
2023-04-04Kernel: Mark inode watcher syscalls as not needing the big lockAndreas Kling
These syscalls are already protected by existing locking mechanisms, including the mutex inside InodeWatcher.
2023-04-04Kernel: Mark sys$killpg as not needing the big lockAndreas Kling
Same as sys$kill, nothing here that isn't already protected by existing locks.
2023-04-04Kernel: Mark sys$kill as not needing the big lockAndreas Kling
This syscall sends a signal to other threads or itself. This mechanism is already guarded by locking mechanisms, and widely used within the kernel without help from the big lock.
2023-04-04Kernel: Remove ancient InterruptDisablers in the kill/killpg syscallsAndreas Kling
These are artifacts from the pre-SMP times.
2023-04-04Kernel: Mark sys$getrusage as not needing the big lockAndreas Kling
Same deal as sys$times, nothing here that needs locking at the moment.
2023-04-04Kernel: Make the getsockname/getpeername syscall helper a bit nicerAndreas Kling
Instead of templatizing on a bool parameter, use an enum for clarity.
2023-04-04Kernel: Make sys$times not use the big lockAndreas Kling
...and also make the Process tick counters clock_t instead of u32. It seems harmless to get interrupted in the middle of reading these counters and reporting slightly fewer ticks in some category.
2023-04-04Kernel+Userland: Make some of the POSIX types largerAndreas Kling
Expand the following types from 32-bit to 64-bit: - blkcnt_t - blksize_t - dev_t - nlink_t - suseconds_t - clock_t This matches their size on other 64-bit systems.
2023-04-04Kernel: Mark sys$umask as not needing the big lockAndreas Kling
The body of this syscall is already serialized by calling with_mutable_protected_data().
2023-04-04Kernel: Mark sys$sigtimedwait as not needing the big lockAndreas Kling
Yet another syscall that only messes with the current thread.
2023-04-04Kernel: Mark sys$sigpending as not needing the big lockAndreas Kling
Another one that only touches the current thread.
2023-04-04Kernel: Mark sys$sigprocmask as not needing the big lockAndreas Kling
Another one that only messes with the current thread.
2023-04-04Kernel: Mark sys$sigsuspend as not needing the big lockAndreas Kling
This syscall is only concerned with the current thread.
2023-04-04Kernel: Mark sys$sigreturn as not needing the big lockAndreas Kling
This syscall is only concerned with the current thread (except in the case of a pledge violation, when it will add some details about that to the process coredump metadata. That stuff is already serialized.)
2023-04-04Kernel: Mark sys$open as not needing the big lockAndreas Kling
All the individual sub-operations of this syscall are protected by their own locking mechanisms, so it should be okay to get it off the big lock.
2023-04-04Kernel: Use custody_for_dirfd() in more syscallsAndreas Kling
This simplifies a lot of syscalls, some of which were doing very unnecessarily verbose things instead of calling this.
2023-04-04Kernel: Make custody_for_dirfd() fail on files other than directoriesAndreas Kling
2023-04-04Kernel: Make sys$getsid not require the big lockAndreas Kling
Reorganize the code slightly to avoid creating a TOCTOU bug, then mark the syscall as not needing the big lock anymore.
2023-04-04Kernel: Mark sys$getpgrp as not needing the big lockAndreas Kling
Access to the process's process group is already serialized by SpinlockProtected.
2023-04-04Kernel: Mark sys$getpgid as not needing the big lockAndreas Kling
Access to the process's process group is already serialized by SpinlockProtected.
2023-04-04Kernel: Mark sys$fcntl as not needing the big lockAndreas Kling
This syscall operates on the file descriptor table, and on individual open file descriptions. Both of those are already protected by scoped locking mechanisms.
2023-04-04Kernel: Make sys$disown not require the big lockAndreas Kling
This syscall had a TOCTOU where it checked the peer's PPID before locking the protected data (where the PPID is stored). After closing the race window, we can mark the syscall as not needing the big lock.