summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-07-10Kernel+Userland: Make the stack alignment comply with the System V ABIGunnar Beutner
The System V ABI for both x86 and x86_64 requires that the stack pointer is 16-byte aligned on entry. Previously we did not align the stack pointer properly. As far as "main" was concerned the stack alignment was correct even without this patch due to how the C++ _start function and the kernel interacted, i.e. the kernel misaligned the stack as far as the ABI was concerned but that misalignment (read: it was properly aligned for a regular function call - but misaligned in terms of what the ABI dictates) was actually expected by our _start function.
2021-07-09LibPthread+Kernel: Add pthread_kill() and the thread_kill syscallAli Mohammad Pur
2021-07-09Kernel: Support multiport for VirtIOConsolex-yl
This involves refactoring VirtIOConsole into VirtIOConsole and VirtIOConsolePort. VirtIOConsole is the VirtIODevice, it owns multiple VirtIOConsolePorts as well as two control queues. Each VirtIOConsolePort is a CharacterDevice.
2021-07-09Kernel: Add support for reading from VirtIOConsolex-yl
This allows two-way communication with the host through a VirtIOConsole. This is necessary for features like clipboard sharing.
2021-07-09Kernel: Stop booting and print if PAE is not supported by the processorLuke
We currently require PAE and not having it causes us to crash. This turns that crash into an error message.
2021-07-08Kernel: Return an already destructed PhysicalPage to the allocatorsTom
By making sure the PhysicalPage instance is fully destructed the allocators will have a chance to reclaim the PhysicalPageEntry for free-list purposes. Just pass them the physical address of the page that was freed, which is enough to lookup the PhysicalPageEntry later.
2021-07-08Kernel: Move PhysicalPage classes out of the heap into an arrayTom
By moving the PhysicalPage classes out of the kernel heap into a static array, one for each physical page, we can avoid the added overhead and easily find them by indexing into an array. This also wraps the PhysicalPage into a PhysicalPageEntry, which allows us to re-use each slot with information where to find the next free page.
2021-07-08Kernel: Use PAE to allow accessing all physical memory beyond 4GBTom
We already use PAE for the NX bit, but this changes the PhysicalAddress structure to be able to hold 64 bit physical addresses. This allows us to use all the available physical memory.
2021-07-08Kernel: Add `memchr` and `malloc` to StdLib.cppDaniel Bertalan
These are needed by `libcxxabi`'s demangle support. `memchr` is taken straight-up from the `LibC/string.cpp` source code.
2021-07-08Kernel: Use range-for wherever possibleDaniel Bertalan
2021-07-08AK+Kernel: Fix perfect forwarding constructors shadowing othersDaniel Bertalan
If a non-const lvalue reference is passed to these constructors, the converting constructor will be selected instead of the desired copy/move constructor. Since I needed to touch `KResultOr` anyway, I made the forwarding converting constructor use `forward<U>` instead of `move`. This meant that previously, if a lvalue was passed to it, a move operation took place even if no `move()` was called on it. Member initializers and if-else statements have been changed to match our current coding style.
2021-07-08Everywhere: Mark debug-only functions `[[maybe_unused]]`Daniel Bertalan
These functions are only used from within `dbgln_if` calls, so in certain build configurations, they go unused. Similarly to variables, we now signal to the compiler that we understand that these are not always in use.
2021-07-08Kernel: Pledge promises accessible via /proc/PID/pledgeRalf Donau
2021-07-07Kernel: Map non-page-aligned text segments correctlyDaniel Bertalan
`.text` segments with non-aligned offsets had their lengths applied to the first page's base address. This meant that in some cases the last PAGE_SIZE - 1 bytes weren't mapped. Previously, it did not cause any problems as the GNU ld insists on aligning everything; but that's not the case with the LLVM toolchain.
2021-07-07Kernel: Print if image has become too large againLiav A
Instead of just disabling interrupts and halting when entering the C++ section, just halt with a printed message indicating the error.
2021-07-07Kernel: Fix race causing modifying a Process to fail with a panicTom
The ProtectedDataMutationScope cannot blindly assume that there is only exactly one thread at a time that may want to unprotect the Process. Most of the time the big lock guaranteed this, but there are some cases such as finalization (among others) where this is not necessarily guaranteed. This fixes random panics due to access violations when the ProtectedDataMutationScope protects the Process instance while another is still modifying it. Fixes #8512
2021-07-07Kernel: Add AtomicEdgeAction classTom
This class acts like a combined ref-count as well as a spin-lock (only when adding the first or removing the last reference), allowing to run a specific action atomically when adding the first or dropping the last reference.
2021-07-07Kernel: Custody::absolute_path() => try_create_absolute_path()Max Wipfli
This converts most users of Custody::absolute_path() to use the new try_create_absolute_path() API, and return ENOMEM if the KString allocation fails.
2021-07-07Kernel: Add formatter function for OwnPtr<KString>Max Wipfli
This adds a formatter function for OwnPtr<KString>. This is added mainly because lots of dbgln() statements generate Strings (such as absolute paths) which are only used for debugging. Instead of catching possible OOM situations at all the dbgln() callsites, this makes it possible to let the formatter code handle those situations by outputting "[out of memory]" if the OwnPtr is null.
2021-07-07Kernel: Add Custody::try_create_absolute_path()Max Wipfli
This adds a way to get a Custody's absolute path as KString, which enables it to fail gracefully on OOM.
2021-07-07Kernel: Add KLexicalPath::try_join and use itMax Wipfli
This adds KLexicalPath::try_join(). As this cannot be done without allocation, it uses KString and can fail. This patch also uses it at one place. All the other cases of String::formatted("{}/{}", ...) currently rely on the return value being a String, which means they cannot easily be converted to use the new API.
2021-07-07Kernel: Replace usage of LexicalPath with KLexicalPathMax Wipfli
This replaces all uses of LexicalPath in the Kernel with the functions from KLexicalPath. This also allows the Kernel to stop including AK::LexicalPath.
2021-07-07Kernel: Add KLexicalPathMax Wipfli
This adds KLexicalPath, which are a few static functions which aim to mostly emulate AK::LexicalPath. They are however constrained to work with absolute paths only, containing no '.' or '..' path segments and no consecutive slashes. This way, it is possible to avoid use StringView for the return values and thus avoid allocating new String objects. As explained above, the functions are currently very strict about the allowed input paths. This seems to not be a problem currently. Since the functions VERIFY this, potential bugs caused by this will become immediately obvious.
2021-07-07Kernel: Stop building ctype.cpp into the KernelMax Wipfli
Since AK no longer includes ctype.h, we don't have to build ctype.cpp in the Kernel anymore.
2021-07-07Kernel+KeyboardSettings: Remove numlock syscall and implement ioctlEdwin Hoksberg
2021-07-07Kernel: Add keyboard ioctl to get num/caps lock stateEdwin Hoksberg
2021-07-07Kernel: Do not hold spinlock while touching user mode futex valuesTom
The user_atomic_* functions are subject to the same rules as copy_from/to/user, which may require preemption.
2021-07-07Kernel: Fix futex race that could lead to thread waiting foreverTom
There is a race condition where we would remove a FutexQueue from our futex map and in the meanwhile another thread started to queue itself into that very same futex, leading to that thread to wait forever as no other wake operation could discover that removed FutexQueue. This fixes the problem by: * Tracking imminent waits, which prevents a new FutexQueue from being deleted that a thread will wait on momentarily * Atomically marking a FutexQueue as removed, which prevents a thread from waiting on it before it is actually removed from the futex map.
2021-07-07Kernel: Fix kernel crash when remote peer resets unexpectedlyngc6302h
2021-07-06Kernel+Toolchain: Remove the kernel-specific toolchainGunnar Beutner
This is no longer necessary now that the kernel doesn't use libsupc++ anymore.
2021-07-06Kernel+LibELF: Don't demangle symbols in the kernelGunnar Beutner
Instead we should just generate kernel.map in such a way that it already contains demangled symbols.
2021-07-06Kernel/x86_64: Print if machine doesn't support x86_64 modeLiav A
We drop to real mode and use two BIOS calls to do this.
2021-07-06Kernel: Don't remap BochsGraphicsAdapter MMIO registers on every accessAndreas Kling
We were creating a new memory mapping every time WindowServer performed a buffer flip. This was very visible in whole-system profiles, as the mapping and unmapping of MMIO registers caused quite a bit of kmalloc() and kfree() churn. Avoid this problem by simply keeping the MMIO registers mapped.
2021-07-06Kernel: Fix method name load_kernel_{sybols => symbols}_from_data()Ali Mohammad Pur
2021-07-06Kernel: Promote various integers to 64 bits in storage layerJean-Baptiste Boric
2021-07-05Kernel+LibC: Remove sys$donate()Andreas Kling
This was an old SerenityOS-specific syscall for donating the remainder of the calling thread's time-slice to another thread within the same process. Now that Threading::Lock uses a pthread_mutex_t internally, we no longer need this syscall, which allows us to get rid of a surprising amount of unnecessary scheduler logic. :^)
2021-07-05Kernel: Print region name+offset for user addresses in thread backtraceTom
This provides more crucial information to be able to do an addr2line lookup on a backtrace captured with Thread::backtrace. Also change the offset to hexadecimal as this is what is require for addr2line.
2021-07-05Kernel: Fix regression in VFS::symlinkMax Wipfli
The create_child method should be called with basename, not the full linkpath.
2021-07-05Kernel: Stricter path checking in validate_path_against_process_veilMax Wipfli
This change enforces that paths passed to VFS::validate_path_against_process_veil are absolute and do not contain any '..' or '.' parts. We should VERIFY here instead of returning EINVAL since the code that calls this should resolve non-canonical paths before calling this function.
2021-07-05Kernel: Use the static LexicalPath::basename(String) in VFSMax Wipfli
This is just for improved code clarity, and shouldn't change anything else.
2021-07-05Kernel: Don't allocate Strings unnecessarily in process veil validationMax Wipfli
Previously, Custody::absolute_path() was called for every call to validate_path_against_process_veil(). For processes that don't have a veil, the path is not used by the function. This means that it is unnecessarily generated. This introduces an overload to validate_path_against_process_veil(), which takes a Custody const& and only generates the absolute path if it there is actually a veil and it is thus needed. This patch results in a speed up of Assistant's file system cache building by around 16 percent.
2021-07-05Kernel: Fix incorrect indentationGunnar Beutner
Looks like a tab and some other things snuck in. :)
2021-07-05Kernel: Replace raw asm functions with naked onesHendiadyoin1
2021-07-05Kernel: Get rid of of some of the duplicate kernel base address macrosGunnar Beutner
2021-07-05Kernel: Merge the x86 and x86_64 boot code into a single fileGunnar Beutner
They're mostly the same apart from some x86_64-specific parts.
2021-07-05KeyboardSettings+Kernel: Setting to enable Num Lock on loginForLoveOfCats
2021-07-04Kernel: Implement buffer flipping for VirtIOGPU framebuffersTom
This solves tearing issues and improves performance when updating the VirtIOGPU framebuffers.
2021-07-04WindowServer: Query driver for framebuffer offsetTom
Depending on the driver, the second buffer may not be located right after the first, e.g. it may be page aligned. This removes this assumption and queries the driver for the appropriate offset.
2021-07-04WindowServer: Implement support for combined buffer flipping + flushingTom
Some devices may require DMA transfers to flush the updated buffer areas prior to flipping. For those devices we track the areas that require flushing prior to the next flip. For devices that do not support flipping, but require flushing, we'll simply flush after updating the front buffer. This also adds a small optimization that skips these steps entirely for a screen that doesn't have any updates that need to be rendered.
2021-07-04Everywhere: Fix incorrect usages of AK::CheckedIdan Horowitz
Specifically, explicitly specify the checked type, use the resulting value instead of doing the same calculation twice, and break down calculations to discrete operations to ensure no intermediary overflows are missed.