summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-04-16Kernel: Add some missing socket ioctlssin-ack
This patch adds a few missing ioctls which were required by Wine. SIOCGIFNETMASK, SIOCGIFBRDADDR and SIOCGIFMTU are fully implemented, while SIOCGIFFLAGS and SIOCGIFCONF are stubs.
2021-04-15Everything: Add `-Wnon-virtual-dtor` flagNicholas-Baron
This flag warns on classes which have `virtual` functions but do not have a `virtual` destructor. This patch adds both the flag and missing destructors. The access level of the destructors was determined by a two rules of thumb: 1. A destructor should have a similar or lower access level to that of a constructor. 2. Having a `private` destructor implicitly deletes the default constructor, which is probably undesirable for "interface" types (classes with only virtual functions and no data). In short, most of the added destructors are `protected`, unless the compiler complained about access.
2021-04-14Kernel: Suppress maybe-uninitialized' warning s_syscall_table in gcc-10.3.0Brian Gianforcaro
2021-04-14Build: Update toolchain include path to gcc 10.3.0Brian Gianforcaro
2021-04-14Kernel: Read the ELF header from the inode rather than the mapped pagesGunnar Beutner
Reading from the mapping doesn't work when the text segment has a non-zero offset because in that case the first mapped page doesn't contain the ELF header.
2021-04-14Kernel: Make sure the offset stays the same when using mremap()Gunnar Beutner
When using mmap() on a file with a non-zero offset subsequent calls to mremap() would incorrectly reset the offset to zero.
2021-04-13Kernel: Fix RAM OK test condition for NE2000NetworkAdapterJean-Baptiste Boric
2021-04-13Kernel: Remove type from StorageDevice classJean-Baptiste Boric
2021-04-12Kernel: Mark s_syscall_table const so it ends up in ro_data.Brian Gianforcaro
2021-04-12Kernel: Replace process' regions vector with a Red Black treeIdan Horowitz
This should provide some speed up, as currently searches for regions containing a given address were performed in O(n) complexity, while this container allows us to do those in O(logn).
2021-04-12Kernel: Remove old region from process' regions vector before splittingIdan Horowitz
This does not affect functionality right now, but it means that the regions vector will now never have any overlapping regions, which will allow the use of balance binary search trees instead of a vector in the future. (since they require keys to be exclusive)
2021-04-11Kernel: Use more if-with-initializer in VFSAndreas Kling
2021-04-11Ext2FS: Use if-with-initializer a lot moreAndreas Kling
This pattern felt really cluttery: auto result = something(); if (result.is_error()) return result; Since it leaves "result" lying around in the no-error case. Let's use some C++17 if initializer expressions to improve this: if (auto result = something(); result.is_error()) return result; Now the "result" goes out of scope if we don't need it anymore. This is doubly nice since we're also free to reuse the "result" name later in the same function.
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
2021-04-10Ext2FS: Support reading from file holesAndreas Kling
It's perfectly valid for ext2 inodes to have blocks with index 0. It means that no physical block was allocated for that area of an inode and we should treat it as if it's filled with zeroes. Fixes #6139.
2021-04-10Ext2FS: Clarify error handling in Ext2FSInode::read_bytes() somewhatAndreas Kling
2021-04-09Kernel: Do some basic metadata integrity verification in kmalloc/kfreeAndreas Kling
Use BitmapView::set_range_and_verify_that_all_bits_flip() to validate the heap chunk metadata bits as we go through them in kmalloc/kfree.
2021-04-09Kernel: Add some basic double-kfree() detectionAndreas Kling
Double kfree() is exceedingly rare in our kernel since we use automatic memory management and smart pointers for almost all code. However, it doesn't hurt to do some basic checking that might one day catch bugs. This patch makes us VERIFY that we don't already consider the first chunk of a kmalloc() allocation free when kfree()'ing it.
2021-04-08Kernel/LibC: Make memset implementations the sameHendiadyoin1
I dont know why we do a fast path in the Kernel, but not in Userspace Also simplified the byte explosion in memset to "explode_byte" it even seemed so, that we missed the highest byte when memseting something
2021-04-08Kernel: Introduce two new boot arguments to assist with bare metal debugLiav A
The first one is for disabling the PS2 controller, the other one is for disabling physical storage enumeration. We can't be sure any machine will work with our implementation, therefore this will help us to test more machines.
2021-04-07Kernel: Remove unused UHCI_ENABLED flagAndreas Kling
2021-04-06Kernel/PCI: Disable ECAM method by defaultLiav A
Until I figure out what's going wrong with it on bare-metal, disable it unless explicitly enabled by the user.
2021-04-06Kernel/Storage: Wait a few microseconds after selecting the IDE driveLiav A
We need to do it to let real hardware to put the correct voltages on the wire. Apparently my ICH7 machine refused to boot, and was reading lots of garbage from an unconnected IDE channel. It was fixed after I added a delay of 20 microseconds. It probably can be reduced, I just took a safe value and it seems to work correctly without any problems :)
2021-04-06Kernel/PCI + CPU: Allow to access unaligned dataLiav A
2021-04-06Kernel/PCI: Don't expose virtual addresses on the kernel logLiav A
2021-04-06Kernel: Don't crash if unable to map ramdisk inside kernel address spaceJean-Baptiste Boric
2021-04-06Kernel: Fix KUBSAN crash with RamdiskDeviceJean-Baptiste Boric
2021-04-06Kernel+LibCore: Note whether a process is kernel mode in /proc/allAndreas Kling
2021-04-04Kernel+CrashReporter: Add metadata about page faults to crash reportsAndreas Kling
Crash reports for page faults now tell you what kind of memory access failed and where. :^)
2021-04-04Kernel: Reading past the end of an Ext2FSInode should return 0Andreas Kling
Fixes #5763.
2021-04-03Kernel/PCI: Introduce a new ECAM access mechanismLiav A
Now the kernel supports 2 ECAM access methods. MMIOAccess was renamed to WindowedMMIOAccess and is what we had until now - each device that is detected on boot is assigned to a memory-mapped window, so IO operations on multiple devices can occur simultaneously due to creating multiple virtual mappings, hence the name is a memory-mapped window. This commit adds a new class called MMIOAccess (not to be confused with the old MMIOAccess class). This class creates one memory-mapped window. On each IO operation on a configuration space of a device, it maps the requested PCI bus region to that window. Therefore it holds a SpinLock during the operation to ensure that no other PCI bus region was mapped during the call. A user can choose to either use PCI ECAM with memory-mapped window for each device, or for an entire bus. By default, the kernel prefers to map the entire PCI bus region.
2021-04-03Kernel: Enable PCI ECAM method again if availableLiav A
Apparently we don't enable PCI ECAM (MMIO access to the PCI configuration space) even if we can. This is a regression, as it was enabled in the past and in unknown time it was regressed. The CommandLine::is_mmio_enabled method was renamed to CommandLine::is_pci_ecam_enabled to better represent the meaning of this method and what it determines. Also, an UNMAP_AFTER_INIT macro was removed from a method in the MMIOAccess class as it halted the system when the kernel tried to access devices after the boot process.
2021-04-03Kernel: Introduce a new HID subsystemLiav A
The end goal of this commit is to allow to boot on bare metal with no PS/2 device connected to the system. It turned out that the original code relied on the existence of the PS/2 keyboard, so VirtualConsole called it even though ACPI indicated the there's no i8042 controller on my real machine because I didn't plug any PS/2 device. The code is much more flexible, so adding HID support for other type of hardware (e.g. USB HID) could be much simpler. Briefly describing the change, we have a new singleton called HIDManagement, which is responsible to initialize the i8042 controller if exists, and to enumerate its devices. I also abstracted a bit things, so now every Human interface device is represented with the HIDDevice class. Then, there are 2 types of it - the MouseDevice and KeyboardDevice classes; both are responsible to handle the interface in the DevFS. PS2KeyboardDevice, PS2MouseDevice and VMWareMouseDevice classes are responsible for handling the hardware-specific interface they are assigned to. Therefore, they are inheriting from the IRQHandler class.
2021-04-03Revert "Kernel/PCI: Allow to set the PCI IRQ line of a device"Liav A
This reverts commit 36a82188a88c95315e03f6fcede237bc66831702. This register is write-only for the firmware (BIOS), and read-only for us so we shouldn't set the PCI IRQ line never. The firmware figured out the IRQ routing to the PIC for us, so changing it won't affect anything. I was mistaken when I thought that changing the value of this register will allow us to change its interrupt line, like when changing a PCI BAR to relocate device resources as desired with the requirements of the OS.
2021-04-03Kernel/Storage: Add support for IDE controllers in PCI native modeLiav A
Also handle native and compatibility channel modes together, so if only one IDE channel was set to work on PCI native mode, we need to handle it separately, so the other channel continue to operate with the legacy IO ports and interrupt line.
2021-04-03Kernel: NetworkTask: Remove 10.0.2.x as default IP for NIC interfacesBrendan Coles
2021-03-31Kernel: Send SIGCHLD to the parent process when changing stopped stateAnotherTest
This is done also by linux (signal.c:936 in v5.11) at least. It's a pretty handy notification that allows the parent process to skip going through a `waitpid` and guesswork to figure out the current state of a child process.
2021-03-31Kernel: Added TIOCSTI ioctl placeholder (#6037)Baitinq
Added a dummy TIOCSTI ioctl placeholder. This is a dangerous ioctl that can be used to inject input into a tty. Added for compatibility. Always fails with EIO.
2021-03-30Kernel: Don't dump regions twice when crashing due to bad accessAndreas Kling
For whatever reason we were dumping regions when first handling the page fault, and then again when tearing down the process.
2021-03-30Kernel: Clarify Thread::block() a little bit with a better local nameAndreas Kling
2021-03-29Kernel: Support write() after setting O_APPEND on a non-seekable fileItamar
Previously, Process::do_write would error if the O_APPEND flag was set on a non-seekable file. Other systems (such as Linux) seem to be OK with doing this, so we now do not attempt to seek to the end the file if it's not seekable.
2021-03-29Kernel: Let's also not reverse the blocking flag for FIONBIO..Andreas Kling
2021-03-29Kernel: Let's allow unsetting non-blocking mode with FIONBIO as wellAndreas Kling
Thanks to almightyhydra for pointing this out! :^)
2021-03-28LibCoreDump+CrashDaemon: Compress coredumpsIdan Horowitz
Most coredumps contain large amounts of consecutive null bytes and as such are a prime candidate for compression. This commit makes CrashDaemon compress files once the kernel finishes emitting them, as well as adds the functionality needed in LibCoreDump to then parse them.
2021-03-28Kernel+LibC: Implement sys$ioctl() FIONBIOAndreas Kling
This is another (older) way of making a file descriptor non-blocking.
2021-03-27Kernel/Storage: Select the drive before working with busmaster registerLiav A
This is a "quirk" I've observed on a Intel ICH7 test machine. Apparently we need to select the device (master or slave) before starting to work with the bus master register. It's very possible that other machines are requiring this step to happen before the DMA transfer can occur correctly. Also, when reading with DMA, we should set the transfer direction before clearing the interrupt status. For the sake of completeness, I added a few lines in places that I deemed it to be reasonable to clear the interrupt status there.
2021-03-27Kernel/Storage: Add some debug printing about IDE controllersLiav A
2021-03-27Kernel/Storage: Remove redundant public declaration in IDEController.hLiav A
2021-03-27Kernel/Storage: Use more locking in the IDE codeLiav A
This change should make it less possible for race conditions to happen and cause fatal errors when accessing the hardware.
2021-03-27Kernel/Storage: Add support for non-bus mastering IDE controllersLiav A
Although unlikely to happen, a user can have an IDE controller that doesn't support bus master capability. If that's the case, we need to check for this, and create an IDEChannel (not BMIDEChannel) to allow IO operations with the controller.