summaryrefslogtreecommitdiff
path: root/Kernel/Arch/aarch64
AgeCommit message (Collapse)Author
2023-06-04Kernel: Move InterruptDisabler to the Interrupts subdirectoryLiav A
2023-06-04Kernel: Move all boot-related code to the new Boot subdirectoryLiav A
2023-06-04Kernel: Move ExecutionMode.h to the Security subdirectoryLiav A
2023-06-04Everywhere: Move global Kernel pattern code to Kernel/Library directoryLiav A
This has KString, KBuffer, DoubleBuffer, KBufferBuilder, IOWindow, UserOrKernelBuffer and ScopedCritical classes being moved to the Kernel/Library subdirectory. Also, move the panic and assertions handling code to that directory.
2023-06-04Kernel: Move {Virtual,Physical}Address classes to the Memory directoryLiav A
2023-06-04Kernel: Move Random.{h,cpp} code to Security subdirectoryLiav A
2023-06-04Kernel: Move all tasks-related code to the Tasks subdirectoryLiav A
2023-06-02Kernel: Move the Storage directory to be a new directory under DevicesLiav A
The Storage subsystem, like the Audio and HID subsystems, exposes Unix device files (for example, in the /dev directory). To ensure consistency across the repository, we should make the Storage subsystem to reside in the Kernel/Devices directory like the two other mentioned subsystems.
2023-05-31Kernel/aarch64: Make sure stack pointer is always 16 byte alignedTimon Kruiper
This is enforced by the hardware and an exception is generated when the stack pointer is not properly aligned. This brings us closer to booting the aarch64 Kernel on baremetal.
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-26Kernel/aarch64: Use the correct MMIO base address in the MMUCaoimhe
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-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-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-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 reserve_interrupt_handlers APIPankaj Raghav
MSI(x) interrupts need to reserve IRQs so that it can be programmed by the device. Add an API to reserve contiguous ranges of interrupt handlers so that it can used by PCI devices that use MSI(x) mechanism. This API needs to be implemented by aarch64 architecture.
2023-04-29Kernel/aarch64: Support reading the command line via the RPi MailboxDaniel Bertalan
This reuses the existing `RPi::Mailbox` interface to read the command line via a VideoCore-specific mailbox message. This will have to be replaced if that interface starts being smarter, as this is needed very early, and nothing guarantees that a smarter Mailbox interface wouldn't need to allocate or log, which is a no-no during early boot. As the response string can be arbitrarily long, it's the caller's job to provide a long enough buffer for `Mailbox::query_kernel_command_line`. This commit chose 512 bytes, as it provides a large enough headroom over the 150-200 characters implicitly added by the VC firmware. The portable way would be to parse the `/chosen/bootargs` property of the device tree, but we currently lack the scaffolding for doing that. Support for this in QEMU relies on a patch that has not yet been accepted upstream, but is available via our `Toolchain/BuildQEMU.sh` script. It should, however, work on bare metal. Tested-By: Timon Kruiper <timonkruiper@gmail.com>
2023-04-28Kernel/aarch64: Fix build after `is_sharing_with_others` API removalDaniel Bertalan
This commit fixes the build after the removal of `GenericInterruptHandler::is_sharing_with_others` in 8944ca830f0.
2023-04-13Kernel/aarch64: Add implementation of Processor::for_eachTimon Kruiper
2023-04-13Kernel/aarch64: Change RPi::Framebuffer::PixelOrder to BGRTimon Kruiper
This is what the WindowServer expects. Confusingly the pixel format for MULTIBOOT_FRAMEBUFFER_TYPE_RGB is actually BGRx8888.
2023-04-13Kernel/aarch64: Add volatile modifier to various asm statementsTimon Kruiper
This prevents the optimizer from reordering them, which hopefully prevents future bugs.
2023-04-13Kernel/aarch64: Make sure no reordering of DAIF::read is possibleTimon Kruiper
We were crashing on the VERIFY_INTERRUPTS_DISABLED() in RecursiveSpinlock::unlock, which was caused by the compiler reordering instructions in `sys$get_root_session_id`. In this function, a SpinLock is locked and quickly unlocked again, and since the lock and unlock functions were inlined into `sys$get_root_session_id` and the DAIF::read was missing the `volatile` keyword, the compiler was free to reorder the reads from the DAIF register to the top of this function. This caused the CPU to read the interrupts state at the beginning of the function, and storing the result on the stack, which in turn caused the VERIFY_INTERRUPTS_DISABLED() assertion to fail. By adding the `volatile` modifier to the inline assembly, the compiler will not reorder the instructions. In aa40cef2b7, I mistakenly assumed that the crash was related to the initial interrupts state of the kernel threads, but it turns out that the missing `volatile` keyword was the actual problem. This commit also removes that code again.
2023-04-08Kernel: Fix compilation of aarch64/RPi/Framebuffer.cppBrian Gianforcaro
The definitions were being defined already by `BootInfo.h` and that was being included here via transitive includes. The extern definitions of the variables do not have the `READONLY_AFTER_INIT` attribute in `BootInfo.h`. This causes conflicting definitions of the same variable. The `READONLY_AFTER_INIT` specifier is not needed for extern variables as it only effects their linkage, not their actual use, so just use the versions in `BootInfo.h` instead of re-declaring.
2023-04-07Kernel: Fix typo in the FramebufferGetPitchMboxMessage nameLiav A
2023-04-06Kernel/aarch64: Actually remove Arch/aarch64/init.cppTimon Kruiper
The idea was to remove this file in bd2011406, but that did not actually happen. Let's actually remove it.
2023-04-06Kernel/aarch64: Add getters/setters in RegisterState and ThreadRegistersTimon Kruiper
Specifically this commit implements two setters set_userspace_sp and set_ip in RegisterState.h, and also adds a stack pointer getter (sp) in ThreadRegisters.h. Contributed by konrad, thanks for that.
2023-04-06Kernel/aarch64: Implement copying of kernel regs into ptrace regsTimon Kruiper
And also vice versa. Contributed by konrad, thanks for that.
2023-04-06Kernel+LibC: Modify aarch64's __mcontext to store registers in an arrayTimon Kruiper
This commit also removes the unnecessary ifdefs from sys/arch/aarch64/regs.h. Contributed by konrad, thanks for that.
2023-04-06Kernel/aarch64: Flush entire TLB cache when changing TTBR0_EL1Timon Kruiper
Setting the page table base register (ttbr0_el1) is not enough, and will not flush the TLB caches, in contrary with x86_64 where setting the CR3 register will actually flush the caches. This commit adds the necessary code to properly flush the TLB caches when context switching. This commit also changes Processor::flush_tlb_local to use the vmalle1 variant, as previously we would be flushing the tlb's of all the cores in the inner-shareable domain.
2023-04-06Kernel: Store a pointer to the owner process in PageDirectoryIdan Horowitz
This replaces the previous owning address space pointer. This commit should not change any of the existing functionality, but it lays down the groundwork needed to let us properly access the region table under the address space spinlock during page fault handling.
2023-04-04Kernel: Simplify Process factory functionsAndreas Kling
- Instead of taking the first new thread as an out-parameter, we now bundle the process and its first thread in a struct and use that as the return value. - Make all Process factory functions return ErrorOr. Use this to convert some places to more TRY(). - Drop the "try_" prefix on Process factory functions.
2023-04-04Kernel/aarch64: Implement `Processor::time_spent_idle()`Caoimhe
2023-04-03Kernel: Merge x86_64 and aarch64 init.cpp filesTimon Kruiper
2023-04-03Kernel: Move deferred call code into separate DeferredCallPool classTimon Kruiper
This allows us to share this code between the x86_64 and aarch64 build.
2023-04-03Kernel/aarch64: Correctly implement Processor::leave_criticalTimon Kruiper
2023-04-03Kernel/aarch64: Move query_firmware_version into RPi::MailboxTimon Kruiper
This is for the upcoming commit that merges the x86_64 and aarch64 init.cpp files.
2023-04-03Kernel/aarch64: Move logo drawing and initializing into RPi::FramebufferTimon Kruiper
This is for a upcoming commit that merges the x86_64 and aarch64 init.cpp files.
2023-04-03Kernel/aarch64: Rename Processor::install to Processor::early_initializeTimon Kruiper
Also pass the cpu number to Processor::initialize. This way the init code can be shared between the x86_64 and aarch64 build.
2023-04-03Kernel: Implement Processor::assume_context for AArch64Idan Horowitz
With this implemented sys$execve should be fully working on AArch64.
2023-04-03Kernel: Call exit_trap in AArch64 restore_context_and_eretIdan Horowitz
This matches x86_64's behaviour in common_trap_exit. (called from thread_context_first_enter) Currently thread_context_first_enter is only called when creating new processes from scratch, in which case this doesn't change the actual behaviour. But once thread_context_first_enter is called as part of execve support, this will ensure the Thread's m_current_trap is set correctly to the new trap frame.
2023-04-03Kernel: Abstract Processor::assume_context flags using InterruptsStateIdan Horowitz
The details of the specific interrupt bits that must be turned on are irrelevant to the sys$execve implementation. Abstract it away to the Processor implementations using the InterruptsState enum.