summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-05-21Kernel/Graphics: Choose VMObject considering enabled state when mmapingLiav A
When mmaping a Framebuffer from userspace, we need to check whether the framebuffer device is actually enabled (e.g. graphical mode is being used) or a textual VirtualConsole is active. Considering the above state, we mmap the right VMObject to ensure we don't have graphical artifacts if we change the resolution from DisplaySettings, changed to textual mode and after the resolution change was reverted, we will see the Desktop reappearing even though we are still in textual mode.
2021-05-21Kernel: Fix framebuffer resolution modesetting after bootLiav A
If we tried to change the resolution before of this patch, we triggered a kernel crash due to mmaping the framebuffer device again. Therefore, on mmaping of the framebuffer device, we create an entire new set of VMObjects and Regions for the new settings. Then, when we change the resolution, the framebuffersconsole needs to be updated with the new resolution and also to be refreshed with the new settings. To ensure we handle both shrinking of the resolution and growth of it, we only copy the right amount of available data from the cells Region.
2021-05-21Kernel/TTY: Don't flush dirty lines if VirtualConsole is not activeLiav A
2021-05-21Kernel: Process request to change virtual console from the IO Work queueLiav A
Instead of processing the input after receiving an IRQ, we shift the responsibility to the io work queue to handle this for us, so if a page fault occurs when trying to switch the VirtualConsole, the kernel can handle that.
2021-05-20Kernel: Close a Thread tid lookup raceTom
There is a window between dropping a thread's last reference and it being removed from the list. Found in #5541
2021-05-20Kernel: Stop allocating the PS2KeyboardDevice in the eternal heapIdan Horowitz
The PS2KeyboardDevice can be free'd in try_to_initialize if the initialization failed, resulting in an assertion.
2021-05-20Meta: Make generate_state_machine() generate a proper targetAli Mohammad Pur
And use GENERATED_SOURCES (or add_dependencies) to make LibVT depend on that target. Fixes a FIXME.
2021-05-20Kernel: Fix regression, removing a ProcessGroup that not in the listBrian Gianforcaro
I introduced this bug in e95eb7a51, where it's possible that the ProcessGroup is created, but we never add it to the list. Make sure we check that we are in the list before removal. This only broke booting in self-test mode oddly enough. Reported-By: Andrew Kaster <andrewdkaster@gmail.com>
2021-05-20Kernel: Use the Function class for smp_broadcast()/smp_unicast()Gunnar Beutner
This avoids allocations for smp_broadcast() and smp_unicast() by using the Function class.
2021-05-20Kernel: Use the Function class for deferred_call_queue()Gunnar Beutner
This avoids allocations for deferred_call_queue().
2021-05-20Kernel: Remove an allocation when blocking a threadGunnar Beutner
When blocking a thread with a timeout we would previously allocate a Timer object. This removes the allocation for that Timer object.
2021-05-20Kernel: Avoid allocating under spinlock in ProcessGroup::find_or_createBrian Gianforcaro
Avoid allocating while holding the g_process_groups_lock spinlock, it's a pattern that has a negative effect on performance and scalability, especially given that it is a global lock, reachable by all processes.
2021-05-20Kernel: Make ProcessGroup::find_or_create API OOM safeBrian Gianforcaro
Make ProcessGroup::find_or_create & ProcessGroup::create OOM safe, by moving to adopt_ref_if_nonnull.
2021-05-20Kernel: Remove s_processor_lock by making s_processors statically sizedBrian Gianforcaro
Currently in SMP mode we hard code support for up to only 8 processors. There is no reason for this to be a dynamic allocation that needs to be guarded by a spinlock. Instead use a Array<T* with inline storage of 8, allowing each processor to initialize it self in place, avoiding all the need for locks.
2021-05-20Kernel: Do not allocate AnonymousVMObject's under spin lockBrian Gianforcaro
Spinlocks guard short regions, with hopefully no other locks being taken in the process. Violating constraints usually had detrimental effects on platform stability as well as performance and scalability. Allocating memory takes it own locks, and can in some cases even allocate new regions, and thus violates these tenants. Move the AnonymousVMObject creation outside of the spinlock as creation does not modify any shared state.
2021-05-19Kernel: Generate page fault events from the kernel profilerBrian Gianforcaro
Hook the kernel page fault handler and capture page fault events when the fault has a current thread attached in TLS. We capture the eip and ebp so we can unwind the stack and locate which pieces of code are generating the most page faults. Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-19Kernel: Avoid an allocation in sys$pollGunnar Beutner
2021-05-19Kernel: Add support for profiling kmalloc()/kfree()Gunnar Beutner
2021-05-19Kernel+LibC: Add support for filtering profiling eventsGunnar Beutner
This adds the -t command-line argument for the profile tool. Using this argument you can filter which event types you want in your profile.
2021-05-19Kernel: Track performance events for context switchesGunnar Beutner
2021-05-19Kernel: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-19Kernel: Use plain Function objects for the WorkQueueGunnar Beutner
The WorkQueue class previously had its own inline storage functionality for function pointers. With the recent changes to the Function class this is no longer necessary.
2021-05-19Kernel: Add statvfs & fstatvfs SyscallsJustin
These syscalls fill a statvfs struct with various data about the mount on the VFS.
2021-05-19Kernel: Expose FileSystem's fragment sizeJustin
This commit will add a fragment_size() function similar to the block_size() function.
2021-05-19Kernel: Ignore null parent custody without error in VFS::openMax Wipfli
This modifies the error checks in VFS::open after the call to resolve_path to ignore a null parent custody if there is no error, as this is expected when the path to resolve points to "/". Rather, a null parent custody only constitutes an error if it is accompanied by ENOENT. This behavior is documented in the VFS::resolve_path_without_veil method. To accompany this change, the order of the error checks have been changed to more naturally fit the new logic.
2021-05-18Kernel: Implement mprotect for multiple RegionsHendiadyoin1
2021-05-18Kernel: Don't update write_pos in DoubleBuffer if userspace copy failsSahan Fernando
2021-05-18Kernel: Acknowledge partial writes from TTYsSahan Fernando
Fixes a bug where TTY::write will attempt to write into the underlying device but will not acknowledge the result of that write, instead assuming that the write fully completed.
2021-05-18Kernel: Fix subtle race condition in sys$write implementationSahan Fernando
There is a slight race condition in our implementation of write(). We call File::can_write() before attempting to write to it (blocking if it returns false). If it returns true, we assume that we can write to the file, and our code assumes that File::write() cannot possibly fail by being blocked. There is, however, the rare case where another process writes to the file and prevents further writes in between the call to Files::can_write() and File::write() in the first process. This would result in the first process calling File::write() when it cannot be written to. We fix this by adding a mechanism for File::can_write() to signal that it was blocked, making it the responsibilty of File::write() to check whether it can write and then finally making sys$write() check if the write failed due to it being blocked.
2021-05-18Kernel: Add support for multiple serial ports per deviceIdan Horowitz
This commit adds support for initializing multiple serial ports per PCI board, as well as initializing multiple different pci serial boards Currently we just choose the first PCI serial port seen as the debug port, but this should probably be made configurable some how in the future.
2021-05-18Kernel: Avoid allocations when receiving network packetsGunnar Beutner
This avoids two allocations when receiving network packets. One for inserting a PacketWithTimestamp into m_packet_queue and another one when inserting buffers into the list of unused packet buffers. With this fixed the only allocations in NetworkTask happen when initially allocating the PacketWithTimestamp structs and when switching contexts.
2021-05-18BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
Problem: - `BitmapView` permits changing the underlying `Bitmap`. This violates the idea of a "view" since views are simply overlays which can themselves change but do not change the underlying data. Solution: - Migrate all non-`const` member functions to Bitmap.
2021-05-17Kernel: Disable profile timer when the process exitsGunnar Beutner
When profiling a single process we didn't disable the profile timer. enable_profile_timer()/disable_profiler_timer() support nested calls so no special care has to be taken here to only disable the timer when nobody else is using it.
2021-05-17Kernel: Fix return value for {enable,disable}_profile_timer()Gunnar Beutner
These functions should return success when being called when profiling has been requested from multiple callers because enabling/disabling the timer is a no-op in that case and thus didn't fail.
2021-05-17Kernel: Stop overriding built-in serial port with PCI serial portIdan Horowitz
On a second thought, theres nothing stopping us from allowing poeple to use both if they want to :^)
2021-05-17Kernel: Add support for QEMU's emulated pci serial (-pci-serial option)Idan Horowitz
2021-05-17Build: Stop using precompiled headers (PCH)Andreas Kling
This had very bad interactions with ccache, often leading to rebuilds with 100% cache misses, etc. Ali says it wasn't that big of a speedup in the end anyway, so let's not bother with it. We can always bring it back in the future if it seems like a good idea.
2021-05-17Kernel: Fix spelling mistake in HPETComparator::try_to_set_frequencyIdan Horowitz
2021-05-17Kernel: Set InterruptEnable on HPET Comparators when frequency is setIdan Horowitz
This fixes non-periodic comparators not receiving interrupts, as we were never setting the InterruptEnable bit in their capabilities register (unlike periodic comparators's bit, which was set as a side effect of calling set_periodic on them to set their periodic bit). This should help getting profiling work on bare-metal SerenityOS installations, which were not guaranteed to have 2 periodic comparators available.
2021-05-17Everywhere: Fix a bunch of typosLinus Groh
2021-05-17Revert "BitmapView: Disable mutations of the underlying Bitmap"Andreas Kling
This reverts commit f25209113fcd15df5778938c4accf13c5139d278.
2021-05-17LibVT: Fix newline handlingDaniel Bertalan
Before this commit, we would jump to the first column after receiving the '\n' line feed character. This is not the correct behavior, as it should only move the cursor now. Translating the typed Return key into the correct CR LF ("\r\n") is the TTY's job, which was fixed in #7184. Fixes #6820 Fixes #6960
2021-05-17BitmapView: Disable mutations of the underlying BitmapLenny Maiorani
Problem: - `BitmapView` permits changing the underlying `Bitmap`. This violates the idea of a "view" since views are simply overlays which can themselves change but do not change the underlying data. Solution: - Migrate all non-`const` member functions to Bitmap.
2021-05-17Kernel: Implement a PCI Serial Device driverIdan Horowitz
This simple driver simply finds a device in a device definitions list and then sets up a SerialDevice instance based on the definition. The driver currently only supports "WCH CH382 2S" pci serial boards, as that is the only device available for me to test with, but most other pci serial devices should be as easily addable as adding a board_definitions entry.
2021-05-17Kernel: Use IOAddress instead of direct IO calls in SerialDeviceIdan Horowitz
2021-05-17Kernel: Add a put_char(char) method to SerialDeviceIdan Horowitz
This can be used to print a single char to the serial port the SerialDevice instance handles.
2021-05-17Kernel: Bit mask line control options in SerialDevice::set_line_controlIdan Horowitz
The line control option bits (parity, stop bits, word length) were masked and then combined incorrectly, resulting in them not being set when requested.
2021-05-17Kernel: Swap baud rate divisor registers in SerialDevice::set_baudIdan Horowitz
These were accidentally the wrong way around (LSB part of the divisor into the MSB register, MSB part of the divisor into the LSB register) as can be seen in the specification (and in the comments themselves)
2021-05-17Kernel: Use unsigned instead of signed types in SerialDeviceIdan Horowitz
Addresses are unsigned by definition, and the conversion from signed to unsigned and back in SerialDevice looked a bit dubious.
2021-05-17Kernel: Initialize the PCI Bus earlier in the boot sequenceIdan Horowitz
We now initialize the PCI Bus as early as possible, to allow for early boot (PCI based) serial logging.