summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
This isn't a complete conversion to ErrorOr<void>, but a good chunk. The end goal here is to propagate buffer allocation failures to the caller, and allow the use of TRY() with formatting functions.
2021-11-17Kernel: Reject writable shared file mappingsDaniel Bertalan
We have no way of writing changes to memory-mapped files back to disk, and software relying on this functionality for output would fail miserably. Let's just return ENOTSUP instead to allow callers to fall back to standard file IO instead of silently discarding writes. This makes the LLD port work, which uses memory-mapped files to write its output by default.
2021-11-16AK+Kernel: Remove implicit conversion from Userspace<T*> to FlatPtrAndrew Kaster
This feels like it was a refactor transition kind of conversion. The places that were relying on it can easily be changed to explicitly ask for the ptr() or a new vaddr() method on Userspace<T*>. FlatPtr can still implicitly convert to Userspace<T> because the constructor is not explicit, but there's quite a few more places that are relying on that conversion.
2021-11-16Kernel: Use static_ptr_cast to convert between Userspace<T*> typesAndrew Kaster
Some calls of copy_to_user were converting Userspace<T*> to Userspace<U*> via the implicit conversion to FlatPtr. Change them to use the static_ptr_cast overload that is designed to express this conversion
2021-11-16Kernel: Remove unnecessary StringBuilder from sys$create_thread()Andrew Kaster
A series of refactors changed Threads to always have a name, and to store their name as a KString. Before the refactors a StringBuilder was used to format the default thread name for a non-main thread, but it is since unused. Remove it and the AK/String related header includes from the thread syscall implementation file.
2021-11-14Kernel: Avoid redundant bool comparisons in Kernel::ThreadAndrew Kaster
Two instances of comparing a bool with == true or == false, and one instance where we can just return an expression instead of checking it to return true on succeess and false on failure.
2021-11-14Kernel: Remove unused forward declaration of Syscall::StringArgumentAndrew Kaster
The real struct is in Kernel::Syscall::StringArgument, so the namespace was wrong anyway. But regardless, this forward declaration was unused.
2021-11-14Kernel: Avoid else after return in Process and ThreadSafeRefCountedAndrew Kaster
2021-11-14Kernel: Convert Process-related const member functions to staticAndrew Kaster
Process::get_syscall_path_argument() and ProcFSExposedComponent::modified_time() both are independent of this.
2021-11-14Kernel: Make OpenFileDescriptions::max_open() static and constexprAndrew Kaster
This method was just returning a static constexpr member variable verbatim, so there's no point requiring a member function to observe its value.
2021-11-14Kernel: Suppress clang-tidy warning on declaration of s_mm_lockAndrew Kaster
Seems we are declaring this guy as extern RecursiveSpinLock s_mm_lock; in both Thread.h and MemoryManager.h. Smells funny for sure.
2021-11-14Kernel: Mark private members of SharedCommittedCowPages as privateAndrew Kaster
They were marked public, which seems like an obvious typo.
2021-11-14Kernel: Remove redundant return statement from Spinlock::lock()Andrew Kaster
Also from RecursiveSpinlock::lock()
2021-11-14Kernel: Stop truncating PageTableEntry::raw(), and make set_bit privateAndrew Kaster
set_bit() in both PageDirectory and PageTableEntry are now private, and remove a useless cast from PageTableEntry::raw().
2021-11-14Kernel: Resolve clang-tidy readability-qualified-auto warningAndrew Kaster
... In files included by Kernel/Process.cpp or Kernel/Thread.cpp
2021-11-14Kernel: Resolve clang-tidy readability-make-member-function-constAndrew Kaster
... In files included from Kernel/Thread.cpp or Kernel/Process.cpp Some places the warning is suppressed, because we do not want a const object do have non-const access to the returned sub-object.
2021-11-14Kernel: Resolve clang-tidy readability-implicit-bool-conversion warningsAndrew Kaster
... In files included from Kernel/Process.cpp and Kernel/Thread.cpp
2021-11-14AK+Kernel: Suppress clang-tidy warnings from the cert-* categoryAndrew Kaster
cert-dcl50-cpp: No variadic functions, suppressed in RefCounted and ThreadSafeRefCounted for implementing the magic one_ref_left and will_be_destroyed functions. cert-dcl58-cpp: No opening ::std, suppressed in the places we put names in ::std to aid tools (move, forward, nullptr_t, align_val_t, etc).
2021-11-13Kernel/AHCI: Simplify wait and timeout pattern significantlyLiav A
Instead of repeating ourselves with the pattern of waiting for some condition to be met, we can have a general method for this task, and then we can provide the retry count, the required delay and a lambda function for the checked condition.
2021-11-13Kernel/AHCI: Remove unnecessary AHCIPort class memberLiav A
2021-11-13Kernel/Storage: Don't use interrupts when resetting SATA AHCI devicesLiav A
Don't use interrupts when trying to reset a device that is connected to a port on the AHCI controller, and instead poll for changes in status to break out from the loop. At the worst case scenario we can wait 0.01 seconds for each SATA reset.
2021-11-13Kernel/Storage: Don't use interrupts when identifying AHCI devicesLiav A
Don't use interrupts when trying to identify a device that is connected to a port on the AHCI controller, and instead poll for changes in status to end the transaction. Not only this simplifies the initialization sequence, it ensures that for whatever reason the controller doesn't send an IRQ, we are never getting stuck at this point.
2021-11-13Kernel/Storage: Move all ATA related code to a new subdirectoryLiav A
Like what happened with the PCI and USB code, this feels like the right thing to do because we can improve on the ATA capabilities and keep it distinguished from the rest of the subsystem.
2021-11-13Kernel+LibC: Pass off_t to pread() via a pointerDaniel Bertalan
`off_t` is a 64-bit signed integer, so passing it in a register on i686 is not the best idea. This fix gets us one step closer to making the LLVM port work.
2021-11-12Kernel: Drain I8042 PS/2 keyboard output after enablingJelle Raaijmakers
As soon as we enable the first PS/2 port on the I8042 controller, the output buffer may become full. We need to drain it before attempting any new commands with the controller (such as enabling the second PS/2 port). Fixes #10872.
2021-11-11Everywhere: Pass AK::ReadonlyBytes by valueAndreas Kling
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-11Kernel/Ext2FS: Propagate HashMap errors instead of panickingAndreas Kling
2021-11-11AK: Make HashTable and HashMap try_* functions return ErrorOr<T>Andreas Kling
This allows us to use TRY() and MUST() with them.
2021-11-10Kernel/Ext2FS: Propagate errors from block list computation functionsAndreas Kling
2021-11-10Kernel: Propagate Vector append errors in two places in Ext2FSAndreas Kling
There are a bunch more of these, just taking care of some simple ones.
2021-11-10Kernel: Make Inode::traverse_as_directory() callback return ErrorOrAndreas Kling
This allows us to propagate errors from inside the callback with TRY().
2021-11-10AK: Make Vector::try_* functions return ErrorOr<void>Andreas Kling
Instead of signalling allocation failure with a bool return value (false), we now use ErrorOr<void> and return ENOMEM as appropriate. This allows us to use TRY() and MUST() with Vector. :^)
2021-11-10AK+Everywhere: Stop including Vector.h from StringView.hAndreas Kling
Preparation for using Error.h from Vector.h. This required moving some things out of line.
2021-11-10Kernel: Make (f)statvfs report filesystem ID correctlyBen Wiederhake
2021-11-10Kernel: Fix TOCTOU in fstatvfsBen Wiederhake
In particular, fstatvfs used to assume that a file that was earlier opened using some path will forever be at that path. This is wrong, and in the meantime new mounts and new filesystems could take up the filename or directories, leading to a completely inaccurate result. This commit improves the situation: - All filesystem information is now always accurate. - The mount flags *might* be erroneously zero, if the custody for the open file is not available. I don't know when that might happen, but it is definitely not the typical case.
2021-11-10AK+Kernel: Make BitmapView read-onlyBen Wiederhake
2021-11-10Everywhere: Remove unused AK/Bitmap includesBen Wiederhake
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-11-08Kernel: Expose inode information in /proc/pid/fdsBen Wiederhake
2021-11-06Kernel: Initialize regs.fs in Processor::init_contextAMACB
Commit f285241c replaced the line that sets regs.fs with a line that sets regs.gs, but not vice versa.
2021-11-05Kernel: Return ENOTIMPL when trying to read from SysFS inodesLiav A
Instead of asserting, just return reasonable error back to userland.
2021-11-04Kernel: Process available VMWare mouse events immediatelyJelle Raaijmakers
The Qemu I8042 controller does not send one IRQ per event, it sends over four since it will not stop trying to emulate the PS/2 mouse. If the VMWare backdoor is active, a fake I8042 mouse event will be sent that we can then use to check if there are VMWare mouse events present. However, we were only processing one mouse event at a time, even though multiple events could have been queued up. Luckily this does not often lead to issues, since after the first IRQ we would still get three additional interrupts that would then empty the queue. This change makes sure we always empty the event queue immediately, instead of waiting on the next interrupt to happen. Functionally this changes nothing - it could merely improve latency by not waiting for new interrupts to come in. Coincidently, this brings our implementation closer to how Linux deals with the VMMouse.
2021-11-04Kernel: Clean up VMWareMouseDevice and VMWareBackdoorJelle Raaijmakers
No functional changes.
2021-11-03Revert "Kernel: Prevent VMWareMouseDevice from handling invalid mouse packets"Andreas Kling
This reverts commit 4131b3585164761e3841bb1c9609b302658ee2c0. We're swallowing way too many mouse events from QEMU with this code enabled. Something is not right, so let's revert it for now.
2021-11-02Kernel: Move TTY subsystem to use KString instead of `AK::String`Brian Gianforcaro
This is minor progress on removing the `AK::String` API from the Kernel in the interest of improving OOM safety.
2021-11-02Kernel: Remove duplicate constructor from TTY/VirtualConsoleBrian Gianforcaro
This removes some code dupe from the constructors. By removing this duplicate constructor we can utilize the main VirtualConsole::create factory implementation and call that from the VirtualConsole::create_with_preset_log factory method.
2021-11-02Kernel: Switch BIOSSysFSComponent constructor to AK::StringViewBrian Gianforcaro
These are constants, they don't need to be dynamically allocated. Another minor step towards removing `AK::String` from the Kernel and improving OOM safety.
2021-10-31Kernel: Do not try opening the same file when dumping perfcoreSeekingBlues
Dumping perfcore would always fail with EEXIST. This regressed in #10707 because of an incorrect indentation in the for loop.
2021-10-31Kernel: Don't crash on writes to ProcFSBen Wiederhake