]> git.sur5r.net Git - u-boot/commitdiff
ARM: PSCI: Allocate PSCI stack in secure stack section
authorChen-Yu Tsai <wens@csie.org>
Sun, 19 Jun 2016 04:38:37 +0000 (12:38 +0800)
committerHans de Goede <hdegoede@redhat.com>
Fri, 15 Jul 2016 13:54:57 +0000 (15:54 +0200)
Now that we have a secure stack section that guarantees usable memory,
allocate the PSCI stacks in that section.

Also add a diagram detailing how the stacks are placed in memory.

Reserved space for the target PC remains unchanged. This should be
moved to global variables within a secure data section in the future.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
arch/arm/cpu/armv7/psci.S

index 46fcf770c214b9e6adc1f5c71592aec445f4b38f..bfc4475e360c5127d112a280e795e0c7bf04ec8d 100644 (file)
@@ -196,18 +196,28 @@ ENTRY(psci_cpu_off_common)
        bx      lr
 ENDPROC(psci_cpu_off_common)
 
-@ expects CPU ID in r0 and returns stack top in r0
+@ The stacks are allocated in reverse order, i.e.
+@ the stack for CPU0 has the highest memory address.
+@
+@ --------------------  __secure_stack_end
+@ |  CPU0 target PC  |
+@ |------------------|
+@ |                  |
+@ |    CPU0 stack    |
+@ |                  |
+@ |------------------|  __secure_stack_end - 1KB
+@ |        .         |
+@ |        .         |
+@ |        .         |
+@ |        .         |
+@ --------------------  __secure_stack_start
+@
+@ This expects CPU ID in r0 and returns stack top in r0
 ENTRY(psci_get_cpu_stack_top)
-       mov     r3, #0x400                      @ 1kB of stack per CPU
-       mul     r0, r0, r3
-
-       ldr     r3, =psci_text_end              @ end of monitor text
-       add     r3, r3, #0x2000                 @ Skip two pages
-       lsr     r3, r3, #12                     @ Align to start of page
-       lsl     r3, r3, #12
-       sub     r3, r3, #4                      @ reserve 1 word for target PC
-       sub     r0, r3, r0                      @ here's our stack!
-
+       @ stack top = __secure_stack_end - (cpuid << ARM_PSCI_STACK_SHIFT)
+       ldr     r3, =__secure_stack_end
+       sub     r0, r3, r0, LSL #ARM_PSCI_STACK_SHIFT
+       sub     r0, r0, #4              @ Save space for target PC
        bx      lr
 ENDPROC(psci_get_cpu_stack_top)