Commit graph

26 commits

Author SHA1 Message Date
Daniel Bertalan bd93b4984b Kernel/aarch64: Use unsigned values in the register bitfields
This resolves the various "implicit truncation from int to a one-bit
wide bit-field changes value from 1 to -1" warnings produced by Clang
16+ when assigning to single-bit bitfields.
2023-07-05 08:17:51 +01:00
Andrew Kaster f62c646c28 Kernel: Update reset value and register names of SCTLR_EL1 per Arm ARM
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-19 20:12:25 -06:00
Timon Kruiper baa5cb9e30 Kernel/aarch64: Add volatile modifier to various asm statements
This prevents the optimizer from reordering them, which hopefully
prevents future bugs.
2023-04-13 20:22:08 +02:00
Timon Kruiper 10030038e9 Kernel/aarch64: Make sure no reordering of DAIF::read is possible
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-13 20:22:08 +02:00
Marco Cutecchia 28acf25035 Kernel: Use u64 instead of int for the bitfields of CPACR_EL1
This fixes the Clang build of the aarch64 port
2023-03-25 16:50:36 +00:00
Timon Kruiper e57d35ff53 Kernel/aarch64: Do not trap floating-point instructions
This requires setting the FPEN field of the Architectural Feature Access
Control Register (CPACR_EL1) to 0b11.
2023-02-15 22:53:19 +01:00
Timon Kruiper d5262a540c Kernel/aarch64: Handle SVC exception by calling syscall_handler
The SVC (supervisor call) instruction is used in userland to do
syscalls, and this commit adds the handling of syscalls to
Interrupts.cpp.
2023-02-15 22:53:19 +01:00
konrad d6c620dc4f Kernel: Provide better types in MIDR register accessor for Aarch64
This avoids unnecessary and-masks during reading.
2023-02-10 11:51:47 -07:00
Timon Kruiper 7be7324287 Kernel/aarch64: Set correct ExecutionMode of PageFault
Adds a helper to aarch64/Registers.h to factor out the exception class
encoding.
2023-02-08 18:19:48 +00:00
Timon Kruiper ecf45e191e Kernel/aarch64: Handle instruction aborts
To detect instruction aborts, a helper to Registers.h is added, and used
in Interrupts.cpp. Additionally, the PageFault class gets a setter to
set the PageFaults m_is_instruction_fetch bool, and is also used in
Interrupts.cpp.
2023-02-08 18:19:48 +00:00
konrad 66c65f6e2c Kernel: Add and use accessors to read from Aarch64 CPU ID registers
Following registers accessors are updated and put in use:
* ID_AA64ISAR0_EL1, Instruction Set Attribute Register 0

Accessors for following registers are added and put in use:
* ID_AA64ISAR1_EL1, Instruction Set Attribute Register 1
* ID_AA64ISAR2_EL1, Instruction Set Attribute Register 2
* ID_AA64MMFR1_EL1, AArch64 Memory Model Feature Register 1
* ID_AA64MMFR2_EL1, AArch64 Memory Model Feature Register 2
* ID_AA64MMFR3_EL1, AArch64 Memory Model Feature Register 3
* ID_AA64MMFR4_EL1, AArch64 Memory Model Feature Register 4
* ID_AA64PFR0_EL1, AArch64 Processor Feature Register 0
* ID_AA64PFR1_EL1, AArch64 Processor Feature Register 1
* ID_AA64PFR2_EL1, AArch64 Processor Feature Register 2
* ID_AA64ZFR0_EL1, AArch64 SVE Feature ID register 0
* ID_AA64SMFR0_EL1, AArch64 SME Feature ID register 0
* ID_AA64DFR0_EL1, AArch64 Debug Feature Register 0
* ID_AA64DFR1_EL1, AArch64 Debug Feature Register 1

Additionally, there are few CPU features detected with
* TCR_EL1, Translation Control Register

but detection mechanism using it (for LPA/LPA2) is probably wrong as
this is control register, not a id register, and needs further work.

Finally, following registers are provided. Former one is already used,
while latter is given for future use:
* MIDR_EL1, Main ID Register
* AIDR_EL1, Auxiliary ID Register
2023-01-18 22:58:42 +01:00
Timon Kruiper 9554e5ca48 Kernel/aarch64: Add Saved Program Status Register EL1 (SPSR_EL1) 2022-12-29 19:32:20 -07:00
Timon Kruiper b991cff60f Kernel/aarch64: Add function to convert DFSC to StringView
This is useful for debugging, when hitting a data abort.
2022-12-29 19:32:20 -07:00
konrad 88d0d0d90d Kernel: Add PMCCNTR_EL0, Performance Monitors Cycle Count Register 2022-12-26 14:11:27 +01:00
konrad e1c3bf0ec0 Kernel: Add NZCV, Condition Flags 2022-12-26 14:11:27 +01:00
konrad e7d4bbcde8 Kernel: Add MIDR_EL1, Main ID Register
This register is already provided in a separate class
but will be migrated here for uniform access
2022-12-26 14:11:27 +01:00
konrad d0b73352cc Kernel: Add CNTFRQ_EL0, Counter-timer Frequency Register 2022-12-26 14:11:27 +01:00
konrad 91c3d7199f Kernel: Add MPIDR_EL1, Multiprocessor Affinity Register 2022-12-26 14:11:27 +01:00
konrad d80d7744b6 Kernel: Add ID_AA64ISAR0_EL1, Instruction Set Attribute Register 0 2022-12-26 14:11:27 +01:00
Timon Kruiper 0226390b21 Kernel/aarch64: Add Fault Address Register (FAR_EL1)
And use it for printing the virtual address when an exception has
happened that set the register, such as data aborts and instruction
aborts.
2022-12-21 08:35:14 +00:00
Timon Kruiper 81571bdac9 Kernel/aarch64: Add function to convert Exception Class to StringView
This is useful when printing information about the type of exception
that happened.
2022-12-21 08:35:14 +00:00
Timon Kruiper 80be5f8044 Kernel: Add DAIF system register to aarch64 registers
This register can be used to check whether the 4 different types of
interrupts are masked. A different variant can be used to set/clear
specific interrupt bits.
2022-06-02 13:14:12 +01:00
Timon Kruiper 2c05afaa7b Kernel: Add Exception Syndrome Register to aarch64 Registers.h
This allows us to print more information about what kind of exception
happend.
2022-05-21 20:23:32 +01:00
Timon Kruiper 9f730fab8d Kernel: Add alignment specifier to aarch64 register definitions
When disabling UBSAN, the compiler would complain that the constraints
of the inline assembly could not be met. By adding the alignas specifier
the compiler can now determine that the struct can be passed into a
register, and thus the constraints are met.
2022-05-21 20:23:32 +01:00
Lenny Maiorani b0a54518d8 Everywhere: Remove redundant inline keyword
`constexpr` implies `inline` so when both are used it is redundant.
2022-01-29 21:45:17 +02:00
James Mintram 34709c8d39 Kernel: Rename Aarch64Registers -> Registers and add Aarch64 namespace 2021-11-28 22:01:21 -08:00
Renamed from Kernel/Arch/aarch64/Aarch64Registers.h (Browse further)