summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-09-12Kernel+Userland: Introduce a new way to reboot and poweroff the machineLiav A
This change removes the halt and reboot syscalls, and create a new mechanism to change the power state of the machine. Instead of how power state was changed until now, put a SysFS node as writable only for the superuser, that with a defined value, can result in either reboot or poweroff. In the future, a power group can be assigned to this node (which will be the GroupID responsible for power management). This opens an opportunity to permit to shutdown/reboot without superuser permissions, so in the future, a userspace daemon can take control of this node to perform power management operations without superuser permissions, if we enforce different UserID/GroupID on that node.
2021-09-12Kernel/SysFS: Make it possible to have custom permissions for nodesLiav A
2021-09-12Kernel: Unify BIOS and ACPI components in the SysFS firmware directoryLiav A
Both should reside in the SysFS firmware directory which is normally located in /sys/firmware. Also, apply some OOM-safety patterns when creating the BIOS and ACPI directories.
2021-09-12Kernel: Move ACPI and BIOS code into the new Firmware directoryLiav A
This will somwhat help unify them also under the same SysFS directory in the commit. Also, it feels much more like this change reflects the reality that both ACPI and the BIOS are part of the firmware on x86 computers.
2021-09-12Kernel+LibC: Implement fsyncTheFightingCatfish
2021-09-12Kernel/SysFS: Move the PCI bus directory to the /sys/bus directoryLiav A
The USB bus directory is already in /sys/bus directory, so I don't see a reason why the PCI bus directory shouldn't be in that directory too.
2021-09-11Kernel+Userland: Remove loadable kernel modulessLiav A
These interfaces are broken for about 9 months, maybe longer than that. At this point, this is just a dead code nobody tests or tries to use, so let's remove it instead of keeping a stale code just for the sake of keeping it and hoping someone will fix it. To better justify this, I read that OpenBSD removed loadable kernel modules in 5.7 release (2014), mainly for the same reason we do - nobody used it so they had no good reason to maintain it. Still, OpenBSD had LKMs being effectively working, which is not the current state in our project for a long time. An arguably better approach to minimize the Kernel image size is to allow dropping drivers and features while compiling a new image.
2021-09-11Kernel: Run clang-format on SerialDevice.hIdan Horowitz
2021-09-11Kernel: Initialize and expose SerialDevice(s) properlyLiav A
I forgot that we need to also initialize SerialDevice and also to ensure it creates a sysfs node properly. Although I had a better fix for this, it keeps the CI happy, so for now it's more than enough :)
2021-09-11Kernel/Devices: Defer creation of SysFS component after the constructorLiav A
Instead of doing so in the constructor, let's do immediately after the constructor, so we can safely pass a reference of a Device, so the SysFSDeviceComponent constructor can use that object to identify whether it's a block device or a character device. This allows to us to not hold a device in SysFSDeviceComponent with a RefPtr. Also, we also call the before_removing method in both SlavePTY::unref and File::unref, so because Device has that method being overrided, it can ensure the device is removed always cleanly.
2021-09-11Kernel: Fix off-by-one in Memory::is_user_range() checkAndreas Kling
This function was checking 1 byte after the provided range, which caused it to reject valid userspace ranges that happened to end exactly at the top of the user address space. This fixes a long-standing issue with mysterious Optional errors in Coredump::write_regions(). (It happened when trying to add a memory region at the very top of the address space to a coredump.)
2021-09-11Kernel: Add _SC_HOST_NAME_MAXLinus Groh
2021-09-10Kernel/CommandLine: Verify ACPI feature level cannot have invalid stringLiav A
The allowed options are "on", "limited" and "off". Anything else is now not allowed and will result in kernel panic.
2021-09-10Kernel/ACPI: Simplify parser initializationLiav A
Let's remove the DynamicParser class, as it really did nothing yet in the Kernel. Instead, when we add support for AML parsing, we can figure out how to do it properly without the need of a derived class that just complicates everything for no good reason.
2021-09-10Kernel: Add kernelearlyputstr and use it in dbgln in very-early bootIdan Horowitz
This variant of dbgputstr does not lock the global log lock, as it is called before the current or any other processor was initialized, meaning that: A) The $gs base was not setup yet, so we cannot enter into critical sections, and as a result we cannot use SpinLocks B) No other processors may try to print at the same time anyway
2021-09-10Kernel: Replace inline assembly for turning on IA32_EFER.NXE with MSRIdan Horowitz
This fixes a triple fault that occurs when compiling serenity with the i686 clang toolchain. (The underlying issue is that the old inline assembly did not specify that it clobbered the eax/ecx/edx registers and as such the compiler assumed they were not changed and used their values across it) Co-authored-by: Brian Gianforcaro <bgianf@serenityos.org>
2021-09-10AK+Kernel: Reduce the number of template parameters of IntrusiveRBTreeAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10AK+Everywhere: Reduce the number of template parameters of IntrusiveListAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-10Kernel: Fix null dereference in IPv4Socket::receive_packet_buffered()Andreas Kling
This was a mistake in the move away from KBuffer-as-a-value type. We need to check `packet` here, not `packet->data`. Regressed in b300f9aa2fd11796e63b5029008b33a1ae735928. Fixes #9888.
2021-09-09Kernel: Use KString all the way in sys$execve()Andreas Kling
This patch converts all the usage of AK::String around sys$execve() to using KString instead, allowing us to catch and propagate OOM errors. It also required changing the kernel CommandLine helper class to return a vector of KString for the userspace init program arguments.
2021-09-09Kernel: Define INADDR_BROADCAST constantRodrigo Tobar
This is required by some programs, notably python's socket module, which fails to compile without this definition.
2021-09-09Kernel/VFS: Restrict special unveil rule for Loader.soRalf Donau
2021-09-08Kernel: Make TextModeConsole store VGA window base as VirtualAddressAndreas Kling
2021-09-08Kernel: Remove some unused code in Graphics::TextModeConsoleAndreas Kling
2021-09-08Kernel: Add KBuffer::bytes() and use itAndreas Kling
(Instead of hand-wrapping { data(), size() } in a bunch of places.)
2021-09-08Kernel: Use an IntrusiveRedBlackTree for storing the cr3 mappingsIdan Horowitz
This ensures we don't allocate when intializing the PageDirectory.
2021-09-08Kernel: Fix a typo in LockRank::Process's commentIdan Horowitz
2021-09-08Kernel/VirtIO: Determine names without PCI access in IRQ contextLiav A
This is a fix so the VirtIO code doesn't lead to assertion because we try to determine the name based on the PCI values of the VirtIO device, because trying to read from the PCI configuration space requires to acquire a Mutex, which fails in an IRQ context. To ensure we never encounter a situation when we call a pure virtual function in an IRQ context, let's make class_name() method to be a non-pure virtual function, so it can be still called at anytime.
2021-09-08Kernel/ACPI: Return Optional container after table searchLiav A
This is a better pattern than returning a PhysicalAddress with a zero value, so the code is more understandable now.
2021-09-08Kernel: Don't link Prekernel against libsupc++Nico Weber
It isn't needed. Also, we stopped linking Kernel against it in 67f0c0d5f074. libsupc++ depends on symbols like free() or realloc() which we removed from Kernel/StdLib.cpp after 67f0c0d5f074 and which don't exist in Prekernel either. (It also happens to make the aarc64 link fail in less obvious ways.)
2021-09-08Kernel/Storage: Implement basic AHCI hotplug supportLiav A
This is really a basic support for AHCI hotplug events, so we know how to add a node representing the device in /sys/dev/block and removing it according to the event type (insertion/removal). This change doesn't take into account what happens if the device was mounted or a read/write operation is being handled. For this to work correctly, StorageManagement now uses the Singleton container, as it might be accessed simultaneously from many CPUs for hotplug events. DiskPartition holds a WeakPtr instead of a RefPtr, to allow removal of a StorageDevice object from the heap. StorageDevices are now stored and being referenced to via an IntrusiveList to make it easier to remove them on hotplug event. In future changes, all of the stated above might change, but for now, this commit represents the least amount of changes to make everything to work correctly.
2021-09-08Kernel+SystemServer: Simplify the DevTmpFS designLiav A
We are no longer have a separate Inode object class for the pts directory. With a small exception to this, all chmod and chown code is now at one place. It's now possible to create any name of a sub-directory in the filesystem.
2021-09-08Kernel: Rename DevFS => DevTmpFSLiav A
The current implementation of DevFS resembles the linux devtmpfs, and not the traditional DevFS, so let's rename it to better represent the direction of the development in regard to this filesystem. The abbreviation for DevTmpFS is still "dev", because it doesn't add value as a commandline option to make it longer. In quick summary - DevFS in unix OSes is simply a static filesystem, so device nodes are generated and removed by the kernel code. DevTmpFS is a "modern reinvention" of the DevFS, so it is much more like a TmpFS in the sense that not only it's stored entirely in RAM, but the userland is responsible to add and remove devices nodes as it sees fit, and no kernel code is directly being involved to keep the filesystem in sync.
2021-09-08Kernel/DevFS: Add the ability to remove device nodesLiav A
In order to make this kind of operation simpler, we no longer use a Vector to store pointers to DevFSDeviceInode, but an IntrusiveList is used instead. Also, we only allow to remove device nodes for now, but in theory we can allow to remove all kinds of files from the DevFS.
2021-09-08Kernel: Expose device presence in /sys/dev/char and /sys/dev/blockLiav A
These files are not marked as block devices or character devices so they are not meant to be used as device nodes. The filenames are formatted to the pattern "major:minor", but a Userland program need to call the parse these format and inspect the the major and minor numbers and create the real device nodes in /dev. Later on, it might be a good idea to ensure we don't create new SysFSComponents on the heap for each Device, but rather generate them only when required (and preferably to not create a SysFSComponent at all if possible).
2021-09-08Kernel/Devices: Ensure appropriate locking on the Device map singletonLiav A
Devices might be removed and inserted at anytime, so let's ensure we always do these kind of operations with a good known state of the HashMap. The VirtIO code was modified to create devices outside the IRQ handler, so now it works with the new locking of the devices singleton, but a better approach might be needed later on.
2021-09-08Kernel/Devices: Remove required_mode and device_name methodsLiav A
These methods are no longer needed because SystemServer is able to populate the DevFS on its own. Device absolute_path no longer assume a path to the /dev location, because it really should not assume any path to a Device node. Because StorageManagement still needs to know the storage name, we declare a virtual method only for StorageDevices to override, but this technique should really be removed later on.
2021-09-08Kernel/VFS: Silence mknod debug spamLiav A
Since we populate the DevFS now in userspace, this creates a bunch of unnecessary noise in the kernel log.
2021-09-08Kernel+SystemServer: Defer creation of device nodes to userspaceLiav A
Don't create these device nodes in the Kernel, so we essentially enforce userspace (SystemServer) to take control of this operation and to decide how to create these device nodes. This makes the DevFS to resemble linux devtmpfs, and allows us to remove a bunch of unneeded overriding implementations of device name creation in the Kernel.
2021-09-08Kernel/DevFS: Simplify nodes insertion and lookupLiav A
Use IntrusiveList instead of a Vector to add inodes to a directory.
2021-09-07Kernel: Stop leaking TmpFS inodesAndreas Kling
TmpFS inodes rely on the call to Inode::one_ref_left() to unregister themselves from the inode cache in TmpFS. When moving various kernel classes to ListedRefCounted for safe unref() while participating on lists, I forgot to make ListedRefCounted check for (and call) one_ref_left() & will_be_destroyed() on the CRTP class.
2021-09-07Kernel/TmpFS: Stop leaking directory entry metadataAndreas Kling
When creating and removing a child to a TmpFS directory, we were forgetting to delete the TmpFSInode::Child struct.
2021-09-07Kernel: Remove a bunch of unused TimerQueue functionsAndreas Kling
2021-09-07Kernel: Make PerformanceEventBuffer::to_json() return a KResultAndreas Kling
There's a ton of things inside to_json() that could go wrong but we don't know about it yet. One step at a time.
2021-09-07Kernel: Add const variant of Process::perf_events()Andreas Kling
This lets us get rid of some const_casts.
2021-09-07Kernel: Use OOM-safe absolute path serialization in InodeFile::mmap()Andreas Kling
Switch from OpenFileDescription::absolute_path() to the OOM-safe try_serialize_absolute_path() (and propagate any errors to the caller.)
2021-09-07Kernel: Build MiniStdLib.cpp in aarch64 buildsNico Weber
2021-09-07Kernel: Build UBSanitizer.cpp in aarch64 buildsNico Weber
All these symbols will be needed once we build MiniStdLib.cpp.
2021-09-07Kernel: Remove two unused includes from Prekernel/UBSanitizer.cppNico Weber
2021-09-07Kernel: Make Device request creation return KResultOrAndreas Kling
This allows us to propagate errors in a bunch of new places.