document & rename breakpoint_stack to abort_stack

Essentially, the `sp' register is banked between different PMODEs.

https://developer.arm.com/documentation/den0013/d/ARM-Processor-Modes-and-Registers/Registers

We initialise a stack that we will begin on when handling an exception.

Also, only include in the ARM linker script on AArch32 + non-hyp.

Signed-off-by: julia <git.ts@trainwit.ch>
This commit is contained in:
julia 2025-02-05 11:06:54 +11:00 committed by Kent McLeod
parent 697dfb8b9e
commit a13a358806
3 changed files with 12 additions and 5 deletions

View file

@ -153,9 +153,12 @@ BEGIN_FUNC(_start)
/* Hyp kernel always run in Hyp mode. */
#ifndef CONFIG_ARM_HYPERVISOR_SUPPORT
/* Initialise ABORT stack pointer */
/* Initialise ABORT stack pointer.
* For ARM, the `sp' register is banked between PMODEs, so we configure
* a stack for when we take a exception (see traps.S, where we then switch
* modes and load the real kernel stack). */
cps #PMODE_ABORT
ldr sp, =_breakpoint_stack_top
ldr sp, =_abort_stack_top
cps #PMODE_SUPERVISOR
#endif

View file

@ -132,6 +132,8 @@ END_FUNC(arm_prefetch_abort_exception)
BEGIN_FUNC(arm_data_abort_exception)
/* Full save/restore, documented in arm_swi_syscall */
srsia #PMODE_SUPERVISOR
/* This also loads the Supervisor mode's banked registers, switching away
* from the ABORT stack pointer. See also heads.S where it is set up. */
cps #PMODE_SUPERVISOR
stmdb sp, {r0-lr}^

View file

@ -64,10 +64,12 @@ SECTIONS
*(.bss)
*(COMMON) /* fallback in case '-fno-common' is not used */
/* 4k breakpoint stack */
_breakpoint_stack_bottom = .;
#if defined(CONFIG_ARCH_AARCH32) && !defined(CONFIG_ARM_HYPERVISOR_SUPPORT)
/* 4k abort stack, needed for PMODE_ABORT on ARM32 */
_abort_stack_bottom = .;
. = . + 4K;
_breakpoint_stack_top = .;
_abort_stack_top = .;
#endif
/* large data such as the globals frame and global PD */
*(.bss.aligned)