Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2527925imu; Thu, 29 Nov 2018 06:26:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/XOM6m+oxpz7mYBsXJiWvs9yfepNyLBxFYWotEREZf/CI70QkA6ZQYbV1HSlNXf5ix08o5h X-Received: by 2002:a63:1e17:: with SMTP id e23mr1419623pge.130.1543501601110; Thu, 29 Nov 2018 06:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501601; cv=none; d=google.com; s=arc-20160816; b=hTKjaLNFxaunpdpeSWNCy9jijJOuer8pjCHSCupsLo/Jd5XcvGxPdINfHkcoMNaE/W Go6fpHJO83eERk8IgVbW8mifJueWtMvbpDrElw5VHp6GrwpsPGf2SgATfTEhL5EWvQJn une9kcCMCrsfgL1aRZx55r460j9INWtPekng0sF9i8Xks3Sdvy5JVyQtojRR8eaVk+pf V6+BAmV6xpVmQnj1j4wMlOjLHlpWIibvr6LZq80eLECVk1VADsdTgLo50OEAY4Ar0T+o 7aHB7ULsSIK8bC4/V/kUP343TqfVIegtIILX8B2xsxfg/0PDtc3/vZnP0s0qBdkTR9Mg wtIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ev2arDqP4fMVUgUtQTZanitBTRLCrecM0BkZfv3Eo/Q=; b=xq4OqveKy4RAZZX61VjspGw/PUwPoDk2ArjzBrky7E+8N85aZxn9B2MURHIFGxwlHa EUJeTlRKXCvmvWpP2Gbj8+tm9PQPFHUQF9ssH/Zog9uosDkR4qxjWri/adiHun0ha3I+ gUvglNPNtKp0cCYN1Nbx+fTZgXJlftf6QYn5pBFchBKjj3fBjDviyqOkSdpysI/R0djD hrTfORGz+yECtDTPaDLsH/YMWWU+2AFmLZqhSV0QRSJ+UpCA68YXy4drdwJyTkrKCq6s bihFdqlnd8MT2nHTOyrpLf3SQAtTtgBAKYJm3BDPC350KiXKRE69RpWCb4uqh7e2lTah NC3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MhnBcyNQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si2130942pgh.172.2018.11.29.06.26.25; Thu, 29 Nov 2018 06:26:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MhnBcyNQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732700AbeK3BaH (ORCPT + 99 others); Thu, 29 Nov 2018 20:30:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:56970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732673AbeK3BaG (ORCPT ); Thu, 29 Nov 2018 20:30:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 74099205C9; Thu, 29 Nov 2018 14:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501474; bh=GfPguvMM3Zl6U31oLZ5lCRKW5fDktYLDicEXV03ATOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MhnBcyNQ9BiTs0b+cAzC9Zz1Pp7A7Nx6B2I42FHtnMKNXnueToUm/2mI4+9ri3t+p tFfw4VswjvXbuwiQhnjrUfxKJzwlZPZGsY9hd7Ge/cQhDH3TAnQcB5Bjp0yPj4iDPq hWqIkpiVtXzFhWTZXMQhq161m38FY0xgvtWE2el0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Osipenko , Stephen Warren , Thierry Reding , Stefan Agner , Nick Desaulniers Subject: [PATCH 4.14 005/100] ARM: trusted_foundations: do not use naked function Date: Thu, 29 Nov 2018 15:11:35 +0100 Message-Id: <20181129140059.340598377@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140058.768942700@linuxfoundation.org> References: <20181129140058.768942700@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Agner (commit 4ea7bdc6b5b33427bbd3f41c333e21c1825462a3 upstream) 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 Signed-off-by: Thierry Reding Signed-off-by: Nick Desaulniers Signed-off-by: Greg Kroah-Hartman --- arch/arm/firmware/trusted_foundations.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- 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)