arm64: include stack storage within ramstage
Instead of defining the stacks by Kconfig options include the stack sizes for all the CPUs including each of their exception stacks. This allows for providing each CPU on startup a stack to work with. Note: this currently inherits CONFIG_STACK_SIZE from x86 because of the Kconfig mess of options not being guarded. BUG=chrome-os-partner:31545 BRANCH=None TEST=Built and booted into the kernel on ryu. Change-Id: Ie5fa1a8b78ed808a14efeb1717b98d6b0dd85eef Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 6524993f016aac2ac8cd9dba9fbdd9a59260a2b6 Original-Change-Id: Ica09dc256e6ce1dd032433d071894af5f445acdb Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/214669 Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/9013 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
1c6512962a
commit
a5c7f66810
|
@ -52,4 +52,10 @@ struct cpu_info *cpu_info(void);
|
||||||
*/
|
*/
|
||||||
unsigned int smp_processor_id(void);
|
unsigned int smp_processor_id(void);
|
||||||
|
|
||||||
|
/* Return the top of the stack for the specified cpu. */
|
||||||
|
void *cpu_get_stack(unsigned int cpu);
|
||||||
|
|
||||||
|
/* Return the top of the exception stack for the specified cpu. */
|
||||||
|
void *cpu_get_exception_stack(unsigned int cpu);
|
||||||
|
|
||||||
#endif /* __ARCH_CPU_H__ */
|
#endif /* __ARCH_CPU_H__ */
|
||||||
|
|
|
@ -30,13 +30,58 @@
|
||||||
#error Need to know what ELx processor starts up in.
|
#error Need to know what ELx processor starts up in.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STACK_SZ CONFIG_STACK_SIZE
|
||||||
|
#define EXCEPTION_STACK_SZ CONFIG_STACK_SIZE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The stacks for each of the armv8 cores grows down from _estack. It is sized
|
||||||
|
* according to MAX_CPUS. Additionally provide exception stacks for each CPU.
|
||||||
|
*/
|
||||||
|
.section .bss, "aw", @nobits
|
||||||
|
.global _stack
|
||||||
|
.global _estack
|
||||||
|
.balign STACK_SZ
|
||||||
|
_stack:
|
||||||
|
.space CONFIG_MAX_CPUS*STACK_SZ
|
||||||
|
_estack:
|
||||||
|
|
||||||
|
.global _stack_exceptions
|
||||||
|
.global _estack_exceptions
|
||||||
|
.balign EXCEPTION_STACK_SZ
|
||||||
|
_stack_exceptions:
|
||||||
|
.space CONFIG_MAX_CPUS*EXCEPTION_STACK_SZ
|
||||||
|
_estack_exceptions:
|
||||||
|
|
||||||
|
ENTRY(cpu_get_stack)
|
||||||
|
mov x1, #STACK_SZ
|
||||||
|
mul x0, x0, x1
|
||||||
|
ldr x1, 1f
|
||||||
|
sub x0, x1, x0
|
||||||
|
ret
|
||||||
|
.align 3
|
||||||
|
1:
|
||||||
|
.quad _estack
|
||||||
|
ENDPROC(cpu_get_stack)
|
||||||
|
|
||||||
|
ENTRY(cpu_get_exception_stack)
|
||||||
|
mov x1, #EXCEPTION_STACK_SZ
|
||||||
|
mul x0, x0, x1
|
||||||
|
ldr x1, 1f
|
||||||
|
sub x0, x1, x0
|
||||||
|
ret
|
||||||
|
.align 3
|
||||||
|
1:
|
||||||
|
.quad _estack_exceptions
|
||||||
|
ENDPROC(cpu_get_exception_stack)
|
||||||
|
|
||||||
|
|
||||||
ENTRY(seed_stack)
|
ENTRY(seed_stack)
|
||||||
/*
|
/*
|
||||||
* Initialize the stack to a known value. This is used to check for
|
* Initialize the stack to a known value. This is used to check for
|
||||||
* stack overflow later in the boot process.
|
* stack overflow later in the boot process.
|
||||||
*/
|
*/
|
||||||
ldr x0, .stack_bottom
|
ldr x0, .stack_bottom
|
||||||
ldr x1, .stack_top
|
mov x1, sp
|
||||||
ldr x2, =0xdeadbeefdeadbeef
|
ldr x2, =0xdeadbeefdeadbeef
|
||||||
ldr x3, =0x8
|
ldr x3, =0x8
|
||||||
|
|
||||||
|
@ -59,36 +104,26 @@ ENDPROC(seed_stack)
|
||||||
* stack while keeping SP_ELx reserved for exception entry.
|
* stack while keeping SP_ELx reserved for exception entry.
|
||||||
*/
|
*/
|
||||||
ENTRY(arm64_c_environment)
|
ENTRY(arm64_c_environment)
|
||||||
ldr x0, .exception_stack_top
|
bl smp_processor_id /* x0 = cpu */
|
||||||
cmp x0, #0
|
mov x24, x0
|
||||||
b.eq 2f
|
|
||||||
|
|
||||||
|
/* Set the exception stack for this cpu. */
|
||||||
|
bl cpu_get_exception_stack
|
||||||
msr SPSel, #1
|
msr SPSel, #1
|
||||||
isb
|
isb
|
||||||
|
|
||||||
mov sp, x0
|
mov sp, x0
|
||||||
|
|
||||||
2:
|
|
||||||
/* Have stack pointer use SP_EL0. */
|
/* Have stack pointer use SP_EL0. */
|
||||||
msr SPSel, #0
|
msr SPSel, #0
|
||||||
isb
|
isb
|
||||||
|
|
||||||
/* Load up the stack if non-zero. */
|
/* Set stack for this cpu. */
|
||||||
ldr x0, .stack_top
|
mov x0, x24 /* x0 = cpu */
|
||||||
cmp x0, #0
|
bl cpu_get_stack
|
||||||
b.eq 1f
|
|
||||||
mov sp, x0
|
mov sp, x0
|
||||||
1:
|
|
||||||
|
|
||||||
ldr x1, .entry
|
b seed_stack
|
||||||
br x1
|
|
||||||
|
|
||||||
.align 4
|
|
||||||
.exception_stack_top:
|
|
||||||
.quad CONFIG_EXCEPTION_STACK_TOP
|
|
||||||
.stack_top:
|
|
||||||
.quad _estack
|
|
||||||
.entry:
|
|
||||||
.quad seed_stack
|
|
||||||
ENDPROC(arm64_c_environment)
|
ENDPROC(arm64_c_environment)
|
||||||
|
|
||||||
CPU_RESET_ENTRY(arm64_cpu_startup)
|
CPU_RESET_ENTRY(arm64_cpu_startup)
|
||||||
|
|
Loading…
Reference in New Issue