From patchwork Tue Mar 20 23:02:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 10298153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E349B600F6 for ; Tue, 20 Mar 2018 23:04:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D62B8296C0 for ; Tue, 20 Mar 2018 23:04:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4311296C6; Tue, 20 Mar 2018 23:04:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F74F296C0 for ; Tue, 20 Mar 2018 23:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fcGiA0EMzV+n5/OM7XOL2pCsDW6ZvY83cVoNW0+/8K4=; b=fnw/vZzqsboEBO8BM3DlTchwFb GdgdTUscFqtfhngehSfHcpJfImPIrREEPVfXwdVH+KX+dUVO25C+XdEPSyueJOrbJ3NZozdwbIGHR isziohfla+FikOn+WYb7e3SaodV211bQkFjpunnu4w1MxewA4h5a7x3mgCjrvJeOgY8gxa2M79usX hpOMbD/PeUyw9P5DG6P9h4nf9+3PMYn46YPE/YImhn4Rm1+k2U5S3oxMw8ygoIvsQw/Kqv+DJ8Fjj td5LeWaixSUkAyHUQ6ro25xFR1sNWE9HKb8UTSJQCWLaLfnIqRiSgMK1yhe4f4/qAFjDyVnxXrJan aaa5kGEw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1eyQIu-00024O-41; Tue, 20 Mar 2018 23:04:28 +0000 Received: from mail.kmu-office.ch ([2a02:418:6a02::a2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1eyQH3-00012B-AK for linux-arm-kernel@lists.infradead.org; Tue, 20 Mar 2018 23:02:37 +0000 Received: from trochilidae.lan (unknown [IPv6:2001:1620:c6e::587]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 57A665C1EA2; Wed, 21 Mar 2018 00:01:57 +0100 (CET) From: Stefan Agner To: linux@armlinux.org.uk, ard.biesheuvel@linaro.org, arnd@arndb.de Subject: [PATCH 3/5] ARM: trusted_foundations: do not use naked function Date: Wed, 21 Mar 2018 00:02:04 +0100 Message-Id: <20180320230206.25289-4-stefan@agner.ch> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180320230206.25289-1-stefan@agner.ch> References: <20180320230206.25289-1-stefan@agner.ch> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1521586917; bh=i5PTnqPB0qhbCrVjCncsPbWuGUohgmpYV288c0ortqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=sbiMYtl7FzpjkgtRd/t2nP33o19P9IFCx64Y8VlJSWejT+ooxJG6Jy4/H4ySgC2I6oiKYqUGEh+BdTKAoS/jlH0+sUbj2nv/W09ZyBzKLDjzz45x94y2fNX+rBdLoOpDjIPdjWpg8JElvH2eGSPLQAUH4fiDxdnUpwAiTFUwN1M= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180320_160233_618506_8591032C X-CRM114-Status: GOOD ( 14.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicolas.pitre@linaro.org, keescook@chromium.org, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, Stefan Agner , mka@chromium.org, linux-arm-kernel@lists.infradead.org, Bernhard.Rosenkranzer@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As documented in GCC naked functions should only use Basic asm syntax. The Extended asm or mixture of Basic asm and "C" code is not guaranteed. Currently this works because it was hard coded to follow and check GCC behavior for arguments and register placement. Furthermore with clang using parameters in Extended asm in a naked function is not supported: arch/arm/firmware/trusted_foundations.c:47:10: error: parameter references not allowed in naked functions : "r" (type), "r" (arg1), "r" (arg2) ^ Use a regular function to be more portable. This aligns also with the other smc call implementations e.g. in qcom_scm-32.c and bcm_kona_smc.c. Additionally also make sure all callee-saved registers get saved as it has been done before. Signed-off-by: Stefan Agner --- arch/arm/firmware/trusted_foundations.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 3fb1b5a1dce9..426d732e6591 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -31,21 +31,23 @@ static unsigned long cpu_boot_addr; -static void __naked tf_generic_smc(u32 type, u32 arg1, u32 arg2) +static void tf_generic_smc(u32 type, u32 arg1, u32 arg2) { + register u32 r0 asm("r0") = type; + register u32 r1 asm("r1") = arg1; + register u32 r2 asm("r2") = arg2; + asm volatile( ".arch_extension sec\n\t" - "stmfd sp!, {r4 - r11, lr}\n\t" __asmeq("%0", "r0") __asmeq("%1", "r1") __asmeq("%2", "r2") "mov r3, #0\n\t" "mov r4, #0\n\t" "smc #0\n\t" - "ldmfd sp!, {r4 - r11, pc}" : - : "r" (type), "r" (arg1), "r" (arg2) - : "memory"); + : "r" (r0), "r" (r1), "r" (r2) + : "memory", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10"); } static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr)