From patchwork Wed Jun 13 22:41:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kettenis X-Patchwork-Id: 929118 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openbsd.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 415hZV1v9Wz9s0W for ; Thu, 14 Jun 2018 08:41:54 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DBDB1C21CB6; Wed, 13 Jun 2018 22:41:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id ADD12C21DAF; Wed, 13 Jun 2018 22:41:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 65A18C21C27; Wed, 13 Jun 2018 22:41:12 +0000 (UTC) Received: from lb3-smtp-cloud8.xs4all.net (lb3-smtp-cloud8.xs4all.net [194.109.24.29]) by lists.denx.de (Postfix) with ESMTPS id 243F3C21C8B for ; Wed, 13 Jun 2018 22:41:12 +0000 (UTC) Received: from barber.sibelius.xs4all.nl ([83.163.83.176]) by smtp-cloud8.xs4all.net with ESMTP id TERyfTNTBtZGaTERzfYsR1; Thu, 14 Jun 2018 00:41:12 +0200 From: Mark Kettenis To: u-boot@lists.denx.de Date: Thu, 14 Jun 2018 00:41:06 +0200 Message-Id: <20180613224108.13372-2-kettenis@openbsd.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180613224108.13372-1-kettenis@openbsd.org> References: <20180613224108.13372-1-kettenis@openbsd.org> X-CMAE-Envelope: MS4wfKXJg+vRPZra4oQtPfMQWi6AGD/9jCzio1B+hpxpxLF9qmgCXcmEUgVkbCRKDnrNYE2WT7evJro9V7hVxq1owdjrCqe1PTzrECGwDUwi1N7v5mOxgWXa SyInE1pgHgQO3i+DuDVQTW9FmMy0e50ZJDowaxq0jnstU1ESCNSaSDl0lxOASiCP77ezn+mkksLVFgfeZJCTa/SAEvNu0VBhjWmuL47eH5NXYfDUQAoAKFl0 bSmg5sii2QfZARY5fsZXbCIAx/jxg+Ju9pKoJZD67w08pZ7o9Qyjds/S2g4KvTK/ApslTly+hE2dIMPGsmTY6fZ5zrVtfwCy8CfN6bOc6n3g1/KVbkF2iXjw bh48/Gv8 Cc: marc.zyngier@arm.com, xypron.glpk@gmx.de, Mark Kettenis , agraf@suse.de, andre.przywara@arm.com Subject: [U-Boot] [PATCH v3 1/3] ARM: HYP/non-sec: migrate stack X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/cpu/armv7/nonsec_virt.S b/arch/arm/cpu/armv7/nonsec_virt.S index 56bdba1d38..1773fae205 100644 --- a/arch/arm/cpu/armv7/nonsec_virt.S +++ b/arch/arm/cpu/armv7/nonsec_virt.S @@ -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)