summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-08-16Kernel: Avoid enumerating all the fds to find a specific one in procfsAli Mohammad Pur
2021-08-16Kernel: Add a Process::FileDescriptions::get_if_valid(index) APIAli Mohammad Pur
Note that this is not the same as ::at(index), which has a different precondition ("allocated" vs "valid").
2021-08-16Kernel: Don't hold thread list lock while invoking ~Thread()Andreas Kling
There is no need for this, and it can cause deadlocks if ~Thread() ends up doing something else that requires a lock (e.g ~Process())
2021-08-16Kernel: Use ProtectedValue for VirtualFileSystem::m_mountsAndreas Kling
This is what VirtualFileSystem::m_lock was actually guarding, and wrapping it in a ProtectedValue makes it so much more obvious how it all works. :^)
2021-08-15Kernel: Cache Custody objects (weakly) to avoid expensive reconstructionAndreas Kling
This patch adds a (spinlock-protected) custody cache. It's a simple intrusive list containing all currently live custody objects. This allows us to re-use existing custodies instead of creating them again and again. This gives a pretty decent performance improvement on "find /" :^)
2021-08-15Kernel/ProcFS: Avoid two unnecessary number-to-string conversionsAndreas Kling
We don't need to create a new string from a number in order to compare an existing string to that number. Converting the existing string to a number is much cheaper, since it does not require any heap allocations. Ran into this while profiling "find /" :^)
2021-08-15Kernel/SysFS: Don't compute exact size of PCI filesAndreas Kling
There's no need for generated files in SysFS to tell you their precise file size when you stat() them. I noticed when profiling "find /" that we were spending a chunk of time generating and throwing away SysFS content just so we could tell you exactly how large it would be. :^)
2021-08-15Kernel: Move ARP debug information to ARP_DEBUGbrapru
Previously when trying to debug the system's routing, the ARP information would clutter the output and make it difficult to focus on the routing decisions. It would be better to specify these debug messages under ARP_DEBUG.
2021-08-15Kernel: Remove unused FIFO::all_fifos() tableAndreas Kling
2021-08-15Kernel: Convert TCP retransmit queue from HashTable to IntrusiveListAndreas Kling
2021-08-15Kernel: Convert IPv4 socket list from HashTable to IntrusiveListAndreas Kling
There was no reason whatsoever to use a HashTable here. IntrusiveList removes all the heap allocations and does everything more efficiently.
2021-08-15Kernel: Use NonnullRefPtr<PhysicalPage> in PageDirectory::m_page_tablesAndreas Kling
We don't care to store null page pointers in the page table map.
2021-08-15Kernel: Make Memory::Region allocation functions return KResultOrsin-ack
This makes for some nicer handling of errors compared to checking an OwnPtr for null state.
2021-08-15Kernel: Make Kernel::VMObject allocation functions return KResultOrsin-ack
This makes for nicer handling of errors compared to checking whether a RefPtr is null. Additionally, this will give way to return different types of errors in the future.
2021-08-15Kernel: Simplify OOM handling in ISO9660FileSystemsin-ack
2021-08-15Kernel: Simplify OOM handling in ProcessProcFSTraitssin-ack
2021-08-15Kernel: Add tightly typed ISO9660Inode::fs() overloadAndreas Kling
We know the fs() is always an ISO9660FS, so let's be nice and make fs() return that when called on an ISO9660Inode. :^)
2021-08-15Kernel: Lock thread list while in Thread::unref()Andreas Kling
This patch does three things: - Convert the global thread list from a HashMap to an IntrusiveList - Combine the thread list and its lock into a SpinLockProtectedValue - Customize Thread::unref() so it locks the list while unreffing This closes the same race window for Thread as @sin-ack's recent changes did for Process. Note that the HashMap->IntrusiveList conversion means that we lose O(1) lookups, but the majority of clients of this list are doing traversal, not lookup. Once we have an intrusive hashing solution, we should port this to use that, but for now, this gets rid of heap allocations during a sensitive time.
2021-08-15Kernel+Userland: Remove chroot functionalityAndreas Kling
We are not using this for anything and it's just been sitting there gathering dust for well over a year, so let's stop carrying all this complexity around for no good reason.
2021-08-15Kernel: Remove copy_string_from_user() as it's no longer usedAndreas Kling
2021-08-15Kernel: Convert remaining users of copy_string_from_user()Andreas Kling
This patch replaces the remaining users of this API with the new try_copy_kstring_from_user() instead. Note that we still convert to a String for continued processing, and I've added FIXME about continuing work on using KString all the way.
2021-08-15Kernel: Don't hold the process list lock while destructing the processsin-ack
Once we remove the process from the process list, we're free to do whatever we want without any locks.
2021-08-15Kernel: Make Process finalsin-ack
This silences a clangd diagnostic about Process holding virtual functions but having a non-virtual destructor.
2021-08-15Kernel: Handle removal of Process from list before unrefsin-ack
This makes the following scenario impossible with an SMP setup: 1) CPU A enters unref() and decrements the link count to 0. 2) CPU B sees the process in the process list and ref()s it. 3) CPU A removes the process from the list and continues destructing. 4) CPU B is now holding a destructed Process object. By holding the process list lock before doing anything with it, we ensure that other CPUs can't find this process in the middle of it being destructed.
2021-08-15Kernel: Move ProcFS related overrides in Process to ProcessProcFSTraitssin-ack
This allows us to 1) let go of the Process when an inode is ref'ing for ProcFSExposedComponent related reasons, and 2) change our ref/unref implementation.
2021-08-15Kernel: Handle allocation failure in ProcFS and friendssin-ack
There were many places in which allocation failure was noticed but ignored.
2021-08-14LibC: Add SOCK_RDM and SOCK_SEQPACKET to socket.hKenneth Myhra
2021-08-14LibC: Add IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP to netin/in.hKenneth Myhra
2021-08-14Kernel/USB: Remove UAF in device removalLuke
I was using a raw pointer instead of a RefPtr to keep the device alive during removal.
2021-08-14Kernel/USB: Update SysFS from the generic hub instead of from UHCILuke
2021-08-14Kernel/USB: Split SysFS code into its own fileLuke
This makes it controller agnostic and allows us to access it from the USB hub code. The copyright says "Liav A." because git blame says he wrote this.
2021-08-14Kernel/USB: Replace PortNumber enum with a raw u8Luke
A hub can technically have up to 255 ports, given that bNbrPorts is a u8 and the DeviceRemovable field is a VLA to support up to 255 ports. Source: USB 2.0 Specification Section 11.23.2.1 That means this enum is not going to scale well in terms of size. Replacing it with a raw u8 allows me to remove the two port assumption and a cast.
2021-08-14Kernel/USB: Remove get_device_{at_port,from_address}Luke
Nothing was using these. These can be put back in the future if required. This also allows removing the devices array in UHCI.
2021-08-14Kernel/USB: Add Hubs and the UHCI Root HubLuke
2021-08-14Kernel/USB: Add the USB 1.x/2.0 hub descriptorLuke
There is a different hub descriptor for USB 3.0, but this isn't included here.
2021-08-14Kernel/USB: Use allocate_kernel_region in Transfer buffer allocationsLuke
Previously it would create a contiguous AVMO manually and pass it to MM. This uses supervisor pages that quickly run out as they never get returned and crash the system. Instead, use allocate_kernel_region as we're only allocating a page so it will be contiguous and will be returned when destroyed. A potentially better solution would be to use a pool of transfers to avoid all the allocations. This just prevents the system from crashing within ~5 seconds from the continuous hub polling.
2021-08-14Kernel/USB: Pass in device address as last argument to Pipe constructorLuke
The order of poll_interval and device_address was flipped.
2021-08-14Kernel/USB: Use "Pipe" instead of "USBPipe" in USBEndpointLuke
This wasn't caught before because nothing was including this header.
2021-08-14Kernel/USB: Add endpoint directions and make endpoint constants publicLuke
2021-08-14Kernel/USB: Add all USB 2.0 bmRequestType fieldsLuke
2021-08-14Kernel/USB: Add header containing all the current USB classesLuke
2021-08-14Kernel: Move {Process,Thread,Session,ProcessGroup}ID to Kernel/Forward.hAndreas Kling
2021-08-14Kernel: Move VFS-internal O_FOO definitions to VirtualFileSystem.hAndreas Kling
2021-08-14Kernel: Remove unused integer typedefs from UnixTypes.hAndreas Kling
2021-08-14Kernel+LibC: Share definitions for sys/statvfs.hAndreas Kling
2021-08-14Kernel+LibC: Share definitions for sched.hAndreas Kling
2021-08-14Kernel+LibC: Share definitions for sys/uio.hAndreas Kling
2021-08-14Kernel+LibC: Share definitions for sys/ptrace.hAndreas Kling
2021-08-14Kernel: Remove some redundant typedefs from UnixTypes.hAndreas Kling
2021-08-14Kernel+LibC: Share definitions for sys/time.hAndreas Kling