From patchwork Mon Aug 22 14:53:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 9293659 X-Patchwork-Delegate: agross@codeaurora.org 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 98122607D0 for ; Mon, 22 Aug 2016 14:53:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A95B28832 for ; Mon, 22 Aug 2016 14:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F27E289EF; Mon, 22 Aug 2016 14:53:30 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B824C28A0E for ; Mon, 22 Aug 2016 14:53:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755895AbcHVOx2 (ORCPT ); Mon, 22 Aug 2016 10:53:28 -0400 Received: from foss.arm.com ([217.140.101.70]:53900 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755891AbcHVOx1 (ORCPT ); Mon, 22 Aug 2016 10:53:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 84C543C; Mon, 22 Aug 2016 07:55:04 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 681E23F215; Mon, 22 Aug 2016 07:53:26 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id C778B1AE2DB3; Mon, 22 Aug 2016 15:53:26 +0100 (BST) Date: Mon, 22 Aug 2016 15:53:26 +0100 From: Will Deacon To: Andy Gross Cc: linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Catalin Marinas , Srinivas Kandagatla , Stephen Boyd , stanimir.varbanov@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org, Bjorn Andersson , lorenzo.pieralisi@arm.com, sudeep.holla@arm.com Subject: Re: [PATCH 1/2] arm64: kernel: Add SMC Session ID to results Message-ID: <20160822145326.GK14680@arm.com> References: <1471672274-19317-1-git-send-email-andy.gross@linaro.org> <1471672274-19317-2-git-send-email-andy.gross@linaro.org> <20160822134313.GJ14680@arm.com> <20160822140246.GA30923@hector.attlocal.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160822140246.GA30923@hector.attlocal.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Aug 22, 2016 at 09:02:46AM -0500, Andy Gross wrote: > On Mon, Aug 22, 2016 at 02:43:14PM +0100, Will Deacon wrote: > > On Sat, Aug 20, 2016 at 12:51:13AM -0500, Andy Gross wrote: > > > This patch adds the SMC Session ID to the results passed back from SMC > > > calls. The Qualcomm SMC implementation provides for interrupted SMC > > > functions. When this occurs, the SMC call will return a session ID that > > > is required to be used when resuming the interrupted SMC call. > > > > > > Signed-off-by: Andy Gross > > > --- > > > arch/arm64/kernel/asm-offsets.c | 1 + > > > arch/arm64/kernel/smccc-call.S | 1 + > > > include/linux/arm-smccc.h | 4 +++- > > > 3 files changed, 5 insertions(+), 1 deletion(-) > > > > [...] > > > > > diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h > > > index b5abfda..82d919f 100644 > > > --- a/include/linux/arm-smccc.h > > > +++ b/include/linux/arm-smccc.h > > > @@ -63,18 +63,20 @@ > > > /** > > > * struct arm_smccc_res - Result from SMC/HVC call > > > * @a0-a3 result values from registers 0 to 3 > > > + * @a6 Session ID register (optional) > > > */ > > > struct arm_smccc_res { > > > unsigned long a0; > > > unsigned long a1; > > > unsigned long a2; > > > unsigned long a3; > > > + unsigned long a6; > > > }; > > > > > > /** > > > * arm_smccc_smc() - make SMC calls > > > * @a0-a7: arguments passed in registers 0 to 7 > > > - * @res: result values from registers 0 to 3 > > > + * @res: result values from registers 0 to 3 and optional register 6 > > > > AFAICT from reading the SMCCC spec, parameter register 6 is "Unpredictable, > > Scratch registers" in return state, so I don't think this is correct. > > > > What am I missing? > > In the case of Qualcomm's implementation, they return a value in register 6 that > may or may not be used in subsequent calls. If I want to leverage the arm_smccc > functions, then I need to extend them to include the optional return value. The > downside to this is that everyone who uses this is exposed to it. Yes, I'm not keen on forcing this behaviour for everybody, as you never know what other firmware might do with unexpected a6 values. Could we perhaps quirk it, along the lines of the completely untested patch below? Will --->8 --- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 05070b72fc28..1895e87d0240 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -141,6 +141,8 @@ int main(void) #endif DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0)); DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2)); + DEFINE(ARM_SMCCC_RES_QUIRK_ID_OFFS, offsetof(struct arm_smccc_res, quirk.id)); + DEFINE(ARM_SMCCC_RES_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_res, quirk.state)); BLANK(); DEFINE(HIBERN_PBE_ORIG, offsetof(struct pbe, orig_address)); DEFINE(HIBERN_PBE_ADDR, offsetof(struct pbe, address)); diff --git a/arch/arm64/kernel/smccc-call.S b/arch/arm64/kernel/smccc-call.S index ae0496fa4235..3c6c976eaf5c 100644 --- a/arch/arm64/kernel/smccc-call.S +++ b/arch/arm64/kernel/smccc-call.S @@ -12,6 +12,7 @@ * */ #include +#include #include .macro SMCCC instr @@ -20,7 +21,12 @@ ldr x4, [sp] stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] - ret + ldr x9, [x4, #ARM_SMCCC_RES_QUIRK_ID_OFFS] + cbz x9, 1f /* ARM_SMCCC_QUIRK_NONE */ + cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 + b.ne 1f + str x6, [x4, ARM_SMCCC_RES_QUIRK_STATE_OFFS] +1: ret .cfi_endproc .endm diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h index b5abfda80465..a3a6e291feb6 100644 --- a/include/linux/arm-smccc.h +++ b/include/linux/arm-smccc.h @@ -14,9 +14,6 @@ #ifndef __LINUX_ARM_SMCCC_H #define __LINUX_ARM_SMCCC_H -#include -#include - /* * This file provides common defines for ARM SMC Calling Convention as * specified in @@ -60,6 +57,21 @@ #define ARM_SMCCC_OWNER_TRUSTED_OS 50 #define ARM_SMCCC_OWNER_TRUSTED_OS_END 63 +#define ARM_SMCCC_QUIRK_NONE 0 +#define ARM_SMCCC_QUIRK_QCOM_A6 1 /* Save/restore register a6 */ + +#ifndef __ASSEMBLY__ + +#include +#include + +struct arm_smccc_quirk { + int id; + union { + unsigned long a6; + } state; +}; + /** * struct arm_smccc_res - Result from SMC/HVC call * @a0-a3 result values from registers 0 to 3 @@ -69,6 +81,7 @@ struct arm_smccc_res { unsigned long a1; unsigned long a2; unsigned long a3; + struct arm_smccc_quirk quirk; }; /** @@ -101,4 +114,5 @@ asmlinkage void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a5, unsigned long a6, unsigned long a7, struct arm_smccc_res *res); +#endif /* !__ASSEMBLY__ */ #endif /*__LINUX_ARM_SMCCC_H*/