From patchwork Sun Mar 25 18:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Agner X-Patchwork-Id: 10306829 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 B584E600CC for ; Sun, 25 Mar 2018 22:19:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98EF8291BF for ; Sun, 25 Mar 2018 22:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D86C2933D; Sun, 25 Mar 2018 22:19:04 +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=unavailable 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 176D8291BF for ; Sun, 25 Mar 2018 22:19:04 +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=mCmQWLeRiRusemyWV83l1B2S9OQ3VqrTSD4PU1gDzno=; b=NsRM+0+s3sWAgsAPisiAY2XLGJ ilGybFqaFts2JP5J7X9DjGPy6wF5cEPFDzqhXL4QFDmye++YL/2QIFN1y7PKuAGRiAX93aOXdrBlL FNN/jlAgVllCN61E6e/EQHzkJfnVE13wc31NXjAa/XAQGF4K+jnlXWJLYfPaxrm6kjeMA2Qvznx8E RuRQirJCjCi3sWcjiNAZCko59PRz1PYN/OoMUNKhDLX/VNE+6ZU11CwvSIIbcBBiznD0kophLnwVq 8gzE+TSAWYC4ZUP13emTr667gXVoHZk2RE+PXp8Eis8PuYacxf9r1zjwPlv5SgC21P5m9sMTJB8mt 3qdmCQCQ==; 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 1f0DyY-0002Yx-55; Sun, 25 Mar 2018 22:18:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0Dpu-00021r-EV for linux-arm-kernel@bombadil.infradead.org; Sun, 25 Mar 2018 22:09:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dypalZVp2/wP/mSB41f4bi7GqZwUVkj0LbP0nihfGaE=; b=pLa8dEFctZqjM2qaauIRCd2e7 DI27RtWRyBZ92LoJxEynuk4PKGWtGlUbJ3oF+H4CSUTB6jv1Ito7714RYm+4arJGav082KY1qqcTZ NEQNMmJdtzl4TeuhqUQwSLXA5cHXI9akmGfrFBWG7JgYgzXXoVXixTsNJEiITST/hd0P/H+qXX/7a lflh3mdKsnVN7hSGog+CLx9xU4+p8KVlrrzGj4UWyqQ3TI/2WhqlrELYp2v/DOVfPrqZk9Jv2hFio CyF8yYhqLpbAU7FoRzaZ67pQQcRWhhpOOD2ysdPwzR07OwZj02IhSUx7MJscYO+Th6nartagT6yUB pBoXFIxcw==; Received: from mail.kmu-office.ch ([2a02:418:6a02::a2]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0A6v-0002qG-Ue for linux-arm-kernel@lists.infradead.org; Sun, 25 Mar 2018 18:11:21 +0000 Received: from trochilidae.lan (unknown [IPv6:2001:1620:c6e:0:814c:3584:bd88:6cb6]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 53D465C1FB7; Sun, 25 Mar 2018 20:09:36 +0200 (CEST) From: Stefan Agner To: linux@armlinux.org.uk, ard.biesheuvel@linaro.org, arnd@arndb.de Subject: [PATCH v2 3/6] ARM: trusted_foundations: do not use naked function Date: Sun, 25 Mar 2018 20:09:56 +0200 Message-Id: <20180325180959.28008-4-stefan@agner.ch> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180325180959.28008-1-stefan@agner.ch> References: <20180325180959.28008-1-stefan@agner.ch> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1522001376; bh=dypalZVp2/wP/mSB41f4bi7GqZwUVkj0LbP0nihfGaE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=xW0bE5Q6C5L3ZEjaj8u6It0mzAZr8ZKTqrk3M6AZIOa5OjFgiTEam6TD+enZO4LzxHubCq1wyNJVarGfyxUQr6se8y75U5NNJusUm2OZBVNxJjLpHvawDg8E2exLrQSPP2q3epG/0MxucVxgX2ExlKwEYocRA79E8L7lNjX3N2g= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180325_191118_027265_32B617F4 X-CRM114-Status: GOOD ( 11.57 ) 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, Stephen Warren , keescook@chromium.org, marc.zyngier@arm.com, linux-kernel@vger.kernel.org, Stefan Agner , mka@chromium.org, Dmitry Osipenko , Thierry Reding , robin.murphy@arm.com, 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. Cc: Dmitry Osipenko Cc: Stephen Warren Cc: Thierry Reding Signed-off-by: Stefan Agner --- Changes in v2: - Keep stmfd/ldmfd to avoid potential ABI issues arch/arm/firmware/trusted_foundations.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 3fb1b5a1dce9..689e6565abfc 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -31,21 +31,25 @@ 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" + "stmfd sp!, {r4 - r11}\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}" + "ldmfd sp!, {r4 - r11}\n\t" : - : "r" (type), "r" (arg1), "r" (arg2) - : "memory"); + : "r" (r0), "r" (r1), "r" (r2) + : "memory", "r3", "r12", "lr"); } static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr)