From: Mark Kettenis Date: Thu, 14 Jun 2018 00:16:43 +0200 Subject: [U-Boot] [PATCH v2 1/3] ARM: HYP/non-sec: migrate stack In-Reply-To: <20180613221645.12992-1-kettenis@openbsd.org> References: <20180613221645.12992-1-kettenis@openbsd.org> Message-ID: <20180613221645.12992-2-kettenis@openbsd.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- arch/arm/cpu/armv7/nonsec_virt.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/armv7/nonsec_virt.S b/arch/arm/cpu/armv7/nonsec_virt.S index 56bdba1d38..a7764c1458 100644 --- a/arch/arm/cpu/armv7/nonsec_virt.S +++ b/arch/arm/cpu/armv7/nonsec_virt.S @@ -52,9 +52,9 @@ _secure_monitor: bl psci_stack_setup @ Configure the PSCI backend - push {r0, r1, r2, ip} + push {r0, r1, r2, r3, ip} bl psci_arch_init - pop {r0, r1, r2, ip} + pop {r0, r1, r2, r3, ip} #endif #ifdef CONFIG_ARM_ERRATA_773022 @@ -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) -- 2.16.2