summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2023-05-28Kernel/aarch64: Add RPi/MMIO.cpp to `SOURCES_RUNNING_WITHOUT_MMU`Daniel Bertalan
Otherwise, `MMIO::MMIO` will fault on the RPi 3 due to accessing `__stack_chk_guard` before the kernel is mapped into high memory.
2023-05-28Kernel/aarch64: Make `Processor::capture_stack_trace` stub non-crashingDaniel Bertalan
This is the only kernel issue blocking us from running the test suite. Having userspace backtraces printed to the debug console during crashes isn't vital to the system's function, so let's just return an empty trace and print a FIXME instead of crashing.
2023-05-27AK+Everywhere: Don't crash on invalid monthsBen Wiederhake
Sadly, we don't have proper error propagation here. However, crashing the Kernel just because a CDROM contains an invalid month seems like a bad idea.
2023-05-27AK: Test from_unix_time_parts intensivelyBen Wiederhake
2023-05-27Kernel: Mark sys$get_dir_entries as not needing the big lockLiav A
After examination of all overriden Inode::traverse_as_directory methods it seems like proper locking is already existing everywhere, so there's no need to take the big process lock anymore, as there's no access to shared process structures anyway.
2023-05-27Kernel: Make Ext2FSInode::traverse_as_directory to take m_inode_lockLiav A
The contents of the directory inode could change if we are not taking so we must take the m_inode_lock to prevent corruption when reading the directory contents.
2023-05-27Kernel: Mark sys$fork as not needing the big lockLiav A
All shared structures are already protected by "atomic" spinlocks for those structures, so there's no need to take the big process lock.
2023-05-27Kernel: Mark sys$umount as not needing the big lockLiav A
All accesses to the mount table are already serialized by the actual spinlock of that table.
2023-05-27Kernel: Don't lock ProcFS mutex when calling traverse_as_directoryLiav A
This is not needed, because when we are doing this traversing, functions that are called from this function are using proper and more "atomic" locking.
2023-05-27Kernel: Don't lock SysFS filesystem mutex calling traverse_as_directoryLiav A
This locking is simply not needed because the associated SysFS component will use proper and more "atomic" locking on its own.
2023-05-26Kernel/aarch64: Use the correct MMIO base address in the MMUCaoimhe
2023-05-25Kernel/aarch64: Fix build after #17842Daniel Bertalan
2023-05-24Everywhere: Use MonotonicTime instead of Durationkleines Filmröllchen
This is easily identifiable by anyone who uses Duration::now_monotonic, and any downstream users of that data.
2023-05-24Kernel: Use UnixDateTime wherever applicablekleines Filmröllchen
"Wherever applicable" = most places, actually :^), especially for networking and filesystem timestamps. This includes changes to unzip, which uses DOSPackedTime, since that is changed for the FAT file systems.
2023-05-24AK: Rename Time to Durationkleines Filmröllchen
That's what this class really is; in fact that's what the first line of the comment says it is. This commit does not rename the main files, since those will contain other time-related classes in a little bit.
2023-05-21Kernel: Move NVMeInterruptQueue initialization out of its constructorPankaj Raghav
Add a helper initialize_interrupt_queue() helper to enable_irq instead of doing it as part of its object construction as it can fail. This is similar to how AHCI initializes its interrupt as well.
2023-05-21Kernel/NVMe: Add try_create() to NVMe{Poll|Interrupt}QueuePankaj Raghav
NVMe{Poll|Interrupt}Queue don't have a try_create() method. Add one to keep it consistent with how we create objects. Also this commit is in preparation to moving any initialization related code out of the constructor.
2023-05-21Kernel: Convert rw_dma_page to NonnullRefPtr in NVMeQueuePankaj Raghav
Propagate error if the rw_dma_page is NULL in try_create and use relase_nonnull to convert RefPtr to NonnullRefPtr before passing it to the NVMeQueue.
2023-05-21Kernel: Remove the unused {cq|sq}_dma_page from NVMeQueuePankaj Raghav
{cq|sq}_dma_page are not used by the NVMeQueue class. Remove them.
2023-05-21Kernel: Move handle_interrupt out-of-line in PCIIRQHandlerPankaj Raghav
Upgrade to GCC 13.1.0 triggered an UBSAN in PCIIRQHandler. Moving the handle_interrupt() function out-of-line fixes this issue.
2023-05-21Kernel/aarch64: Detect if access faults come from SafeMemDaniel Bertalan
This commit lets us differentiate whether access faults are caused by accessing junk memory addresses given to us by userspace or if we hit a kernel bug. The stub implementations of the `safe_*` functions currently don't let us jump back into them and return a value indicating failure, so we panic if such a fault happens. Practically, this means that we still crash, but if the access violation was caused by something else, we take the usual kernel crash code path and print a register and memory dump, rather than hitting the `TODO_AARCH64` in `handle_safe_access_fault`.
2023-05-21Kernel/aarch64: Flatten `safe_{memset,strnlen,memcpy}()`Daniel Bertalan
We want to detect if an access fault comes from within these operations, so they cannot be calling out to the non-safe variants.
2023-05-21Kernel/aarch64: Stub out atomic SafeMem functionsDaniel Bertalan
These are used in futexes, which are needed if we want to get further in `run-tests`. For now, we have no way to return a non-fatal error if an access fault is raised while executing these, so the kernel will panic. Some would consider this a DoS vulnerability where a malicious userspace app can crash the kernel by passing bogus pointers to it, but I prefer to call it progress :^)
2023-05-19Kernel: Enable data and instruction cache on aarch64Andrew Kaster
Enabling these will fix the Unsupported Exclusive or Atomic access data fault we get on bare metal Raspberry Pi 3. On A53/A57 chips (and newer), atomic compare-exchange operations require the data cache to be enabled.
2023-05-19Kernel: Update reset value and register names of SCTLR_EL1 per Arm ARMAndrew Kaster
Referencing ARM DDI 0487J.a, update the names of previously reserved fields, and set the reset_value() of the SCTLR_EL1 struct to reflect the defaults we want for this register on reboot.
2023-05-19Kernel: Check only for the first equal sign in the kernel command lineHediadyoin1
... key-value decomposition The RaspberryPi firmware will give us a value for the 'video' key that contains multiple equal signs: ``` video=HDMI-A-1:1920x1080M@30D,margin_left=48,margin_right=48,[...] ``` Instead of asserting that this only has one equal sign, let's just split it by the first one.
2023-05-19Kernel/ScatterGatherList: Add region_name as a part of try_create APIPankaj Raghav
Remove the hardcoded "AHCI Scattered DMA" for region name as it is a part of a common API. Add region_name parameter to the try_create API so that this API can be used by other drivers with the correct Memory region name.
2023-05-19Kernel/ScatterGatherList: Move constructor init code to try_createPankaj Raghav
The constructor code of ScatterGatherList had code that can return error. Move it to try_create for better error propagation. This removes one TODO() and one release_value_but_fixme_should_propagate_errors().
2023-05-19Kernel/ScatterGatherList: Return ErrorOr from try_createPankaj Raghav
This removes the TODO from the try_create API to return ErrorOr. This is also a preparation patch to move the init code in the constructor that can fail to this try_create function.
2023-05-19Kernel: Move a bunch of generic devices code into new subdirectoryLiav A
2023-05-17Kernel+Userland: Split bind-mounting and re-mounting from mount syscallLiav A
These 2 are an actual separate types of syscalls, so let's stop using special flags for bind mounting or re-mounting and instead let userspace calling directly for this kind of actions.
2023-05-17Kernel: Fix memory mapping size of the BootFramebufferConsoleDaniel Bertalan
The Multiboot header stores the framebuffer's pitch in bytes, so multiplying it by the pixel's size is not necessary. We ended up allocating 4 times as much memory as needed, which caused us to overlap the MMIO reserved memory area on the Raspberry Pi.
2023-05-17Kernel: Flush data cache before passing a buffer to the VC MailboxDaniel Bertalan
Otherwise, the message's contents might be in the cache only, so VideoCore will read stale/garbage data from main memory. This fixes framebuffer setup on bare metal with the data cache enabled.
2023-05-17Kernel: Add character device driver for the RPi "mini UART" (UART1)Daniel Bertalan
While the PL011-based UART0 is currently reserved for the kernel console, UART1 is free to be exposed to the userspace as `/dev/ttyS0`. This will be used as the stdout of `run-tests-and-shutdown.sh` when testing the AArch64 kernel.
2023-05-17Kernel: Add `RPi::Timer::get_clock_rate()`Daniel Bertalan
2023-05-17Kernel: Add RPi Watchdog and use it for system shutdownDaniel Bertalan
The Raspberry Pi hardware doesn't support a proper software-initiated shutdown, so this instead uses the watchdog to reboot to a special partition which the firmware interprets as an immediate halt on shutdown. When running under Qemu, this causes the emulator to exit.
2023-05-17Kernel: Unify x86-64 and AArch64 `__panic` implementationDaniel Bertalan
We now have everything in the AArch64 kernel to be able to use the full `__panic` implementation, so we can share the code with x86-64. I have kept `__assertion_failed` separate for now, as the x86-64 version directly executes inline assembly, thus `Kernel/Arch/aarch64/Panic.cpp` could not be removed.
2023-05-17Kernel: Alias `_SC_PAGE_SIZE` to `_SC_PAGESIZE`Tim Schumacher
Both of those are specified by POSIX.
2023-05-16Kernel: Add MSI support to AHCIPankaj Raghav
Add MSI support to AHCI. Prefer MSI interrupts over pin-based interrupts.
2023-05-16Kernel: Add MSI support in PCI DevicePankaj Raghav
Extend reserve_irqs, allocate_irq, enable_interrupt and disable_interrupt API to add MSI support in PCI device. The current changes only implement single MSI message support. TODOs have been added to support Multiple MSI Message (MME) support in the future.
2023-05-16Kernel: Implement {enable,disable}_msi interrupts in PCI DevicePankaj Raghav
Implement enabling and disabling MSI interrupts for a PCI device. Removes two more TODO()s from PCI::Device.cpp :^)
2023-05-16Kernel: Use PCIDeviceIdentifier is_msi_capable() to retrieve MSI statusPankaj Raghav
Instead of iterating through the capabilities, use the is_msi_capable() API from the PCIDeviceIdentifier class that belongs to the device.
2023-05-16Kernel: Add MSIInfo struct to PCI DeviceIdentifierPankaj Raghav
Add a struct named MSIInfo that stores all the relevant MSI information as a part of PCI DeviceIdentifier struct. Populate the MSI struct during the PCI device init.
2023-05-16Kernel: Restore kernel8.img for aarch64 buildAndrew Kaster
This was erroneously deleted in 420952a4334b05d6ac639429e876150c78866963
2023-05-15Kernel/aarch64: Make REGISTER_STATE_SIZE a multiple of 16 bytesTimon Kruiper
This ensure that the stack pointer also stays 16 byte aligned. This fixes a baremetal issue when getting an exception.
2023-05-15Kernel/aarch64: Dump registers when unknown exception occursTimon Kruiper
This is useful when debugging baremetal issues.
2023-05-15Kernel: Remove `FIFO::{attach,detach}(Direction)`Daniel Bertalan
These functions would have caused a `-Woverloaded-virtual` warning with GCC 13, as they shadow `File::{attach,detach}(OpenFileDescription&)`. Both of these functions had a single call site. This commit inlines `attach` into its only caller, `FIFO::open_direction`. Instead of explicitly checking `is_fifo()` in `~OpenFileDescription` before running the `detach(Direction)` overload, let's just override the regular `detach(OpenFileDescription&)` for `FIFO` to perform this action instead.
2023-05-14Meta: Remove unused debug flags, add missing GENERATE_DEBUGBen Wiederhake
Commands that were helpful while investigating this: ``` grep -P '^set' Meta/CMake/all_the_debug_macros.cmake \ | sed -Ee 's,set\((.+) ON\)$,\1,' > macros.lst for i in $(cat macros.lst); do echo -n "$i "; git grep -Pn '\b'"$i"'\b' | wc -l done | tee matches.lst sort -k2 -n matches.lst ```
2023-05-13Kernel/aarch64: Remove drawing of logo on the framebuffer during initLiav A
This logo was actually used as a first sign of life in the very early days of the aarch64 port. Now that we boot into the graphical mode of the system just fine there's no need to keep this.
2023-05-07Kernel: Add MSIx support to NVMePankaj Raghav
Add MSIx support to NVMe. Prefer MSIx over pin-based interrupts as they are more efficient and all modern hardware support them.