ARM: HYP/non-sec: migrate stack
authorMark Kettenis <kettenis@openbsd.org>
Fri, 15 Jun 2018 21:47:11 +0000 (23:47 +0200)
committerAlexander Graf <agraf@suse.de>
Wed, 25 Jul 2018 12:57:43 +0000 (14:57 +0200)
The current code that switches into HYP mode doesn't bother to set
up a stack for HYP mode.  This doesn't work for EFI applications
as they expect a usable stack.  Fix this by migrating the stack
pointer from SP_svc to SP_hyp while in Monitor mode.
This restores the stack pointer when we drop into HYP mode.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/arm/cpu/armv7/nonsec_virt.S

index 56bdba1d38d5834e0977c1e6a18e322471db54ab..1773fae205c9e1f92269bf1ff39ce5045639552e 100644 (file)
@@ -80,6 +80,8 @@ _secure_monitor:
 #ifdef CONFIG_ARMV7_VIRT
        orreq   r5, r5, #0x100                  @ allow HVC instruction
        moveq   r6, #HYP_MODE                   @ Enter the kernel as HYP
+       mrseq   r3, sp_svc
+       msreq   sp_hyp, r3                      @ migrate SP
 #endif
 
        mcr     p15, 0, r5, c1, c1, 0           @ write SCR (with NS bit set)