From patchwork Thu Apr 12 11:11:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 133233 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1572731ljb; Thu, 12 Apr 2018 04:13:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48plF9PTyJHjNErTHxxOgqTaeEvy94C3DpaINJ2pXDl7S27Z6Fqt3ZFf3SFuMrwDZG2UFwl X-Received: by 2002:a17:902:b786:: with SMTP id e6-v6mr544723pls.246.1523531631078; Thu, 12 Apr 2018 04:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531631; cv=none; d=google.com; s=arc-20160816; b=LhBTdoiymfqG1aqb47uVWDzOtM5VezbdzmWtFHw9CFI5v4hFjeLwWY4K+6psv2mWM6 ICLRZCfjO+VI1AfydfArAeabTwKP+71ZWhHEKeJhoGtauqD1u/DYC+gUzoxn4hrz8ZkO WtsatLNiBP2xHG2GIKlPS6Wvy7trNEJTv0kzuvrYOib1DxULkT7LU7qpBF5ufzVugnCn mnSx8AOXBPsDENQxaFTg4d8Jt/GxlB56uTMnXaZtfWd/YZKNUaE//q5wEXstg0ZLJVON yiea6AJl5EQnzFofHPjm8rp+hEiKBCPRrC1iIgo+GIk5Fkisp+ZEUxg4ohXFU3RHwmys Va0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=bKeOHp6OgBKCDkbtJz88BcvR05Y0WbcTHgzDddF1XH8=; b=D0B0aETFZgiZn/s2NXdZefjIAdkRuLScFzizypmvnIm3eKQCBjphdSXKKVgw9gsGB1 vHeEcbkld1w9L+5QU6w+h0IpFLMwwUbMfd0f98dtPEpFKBGy3WAO5dxLekgYnJZYWPlw YSmz3gOLpUBFMQ90BuvoAR9zoYDEKwVGZc8HImFkNBKfDz1jr4aMQUcprCTcoqAkBS8K KGm8PZwQmYngfmrucTpoy9b69S78ZETZR8Ua3zntGU9kp3ED7k9sAqhDIpOt4ILEokGR poakysd4XZVEkY62dpY84abvHEEVuT6AsLgEHG4A/UN8ELfD0K52UkD7bBxbGzOmr/r+ 2kHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 v23si2494850pfk.116.2018.04.12.04.13.50; Thu, 12 Apr 2018 04:13:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752974AbeDLLNu (ORCPT + 11 others); Thu, 12 Apr 2018 07:13:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59666 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752939AbeDLLNt (ORCPT ); Thu, 12 Apr 2018 07:13:49 -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 AA33080D; Thu, 12 Apr 2018 04:13:49 -0700 (PDT) Received: from lakrids.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 019EA3F24A; Thu, 12 Apr 2018 04:13:47 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, ghackmann@google.com, shankerd@codeaurora.org Subject: [PATCH v4.9.y 38/42] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 12 Apr 2018 12:11:34 +0100 Message-Id: <20180412111138.40990-39-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412111138.40990-1-mark.rutland@arm.com> References: <20180412111138.40990-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit e78eef554a912ef6c1e0bbf97619dafbeae3339f upstream. Since PSCI 1.0 allows the SMCCC version to be (indirectly) probed, let's do that at boot time, and expose the version of the calling convention as part of the psci_ops structure. Acked-by: Lorenzo Pieralisi Reviewed-by: Robin Murphy Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] --- drivers/firmware/psci.c | 27 +++++++++++++++++++++++++++ include/linux/psci.h | 6 ++++++ 2 files changed, 33 insertions(+) -- 2.11.0 diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index a49196ae0840..79a48c37fb35 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -61,6 +61,7 @@ bool psci_tos_resident_on(int cpu) struct psci_operations psci_ops = { .conduit = PSCI_CONDUIT_NONE, + .smccc_version = SMCCC_VERSION_1_0, }; typedef unsigned long (psci_fn)(unsigned long, unsigned long, @@ -511,6 +512,31 @@ static void __init psci_init_migrate(void) pr_info("Trusted OS resident on physical CPU 0x%lx\n", cpuid); } +static void __init psci_init_smccc(void) +{ + u32 ver = ARM_SMCCC_VERSION_1_0; + int feature; + + feature = psci_features(ARM_SMCCC_VERSION_FUNC_ID); + + if (feature != PSCI_RET_NOT_SUPPORTED) { + u32 ret; + ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); + if (ret == ARM_SMCCC_VERSION_1_1) { + psci_ops.smccc_version = SMCCC_VERSION_1_1; + ver = ret; + } + } + + /* + * Conveniently, the SMCCC and PSCI versions are encoded the + * same way. No, this isn't accidental. + */ + pr_info("SMC Calling Convention v%d.%d\n", + PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); + +} + static void __init psci_0_2_set_functions(void) { pr_info("Using standard PSCI v0.2 function IDs\n"); @@ -559,6 +585,7 @@ static int __init psci_probe(void) psci_init_migrate(); if (PSCI_VERSION_MAJOR(ver) >= 1) { + psci_init_smccc(); psci_init_cpu_suspend(); psci_init_system_suspend(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index 66ff54787d3e..347077cf19c6 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -31,6 +31,11 @@ enum psci_conduit { PSCI_CONDUIT_HVC, }; +enum smccc_version { + SMCCC_VERSION_1_0, + SMCCC_VERSION_1_1, +}; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); @@ -41,6 +46,7 @@ struct psci_operations { unsigned long lowest_affinity_level); int (*migrate_info_type)(void); enum psci_conduit conduit; + enum smccc_version smccc_version; }; extern struct psci_operations psci_ops;