Received: by 10.223.185.116 with SMTP id b49csp2296264wrg; Thu, 15 Feb 2018 09:25:14 -0800 (PST) X-Google-Smtp-Source: AH8x225EDBJ1xcccswTeKF7P3MqAltc46CIEQpEmp44DG8LxMLaI33U4UPi8M1Fv0+2c29VN+Nb0 X-Received: by 10.99.135.65 with SMTP id i62mr2766836pge.331.1518715514808; Thu, 15 Feb 2018 09:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715514; cv=none; d=google.com; s=arc-20160816; b=W1PAv3pObY49eStzCjjAfIhJSIi3JipU2GN1jmLpo2aC0AR9F8bUQo7wiY1Fq0euaM pOjMqGisEANu1QCErQJprs6nvukgcBSeT2SALJu3zSbZN5MmjdKksy/gtBYSUjxL5u9d dAcLV7hMWuAXvbbET8vgOfQMHPdL7dFa6dR/M+Ey63dBcV//PBeCwHEBVrOoZAHHCXiW uRQ0vhPmkfTl0+H6GXlKvfqsd75ebNMA2huvUA34BHBSDpSU4fXydUs8UrLHLPzWubwB lHOLzhu9eNN6okq/v8r/IAy1BhEmqsCGEMwAdzycnWJixcDZsXrJisWZMDWBw/cgovyx wbOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gtgNAJybfmZa4D10vOmQzYl88A3wWImGJ8+ZmnISQVE=; b=h9j41cI5/TBxZQWLkqQM40HcXhKaCZrSktK/BWZ6RV8XaxZGVmytCTQ+YoA78L22GL Ee3uwJPFoTboIFNVU2KXQjSL+qeQKUjhmPI2mZ+r3Qn0C31rQQ4s+Hnliyefk+0DcFMA VF9cICyr1AToE15IuHleSAAF1y8HqieFLg6vM/k8nAYNrhtEBHUbwvvMWgC2RK10eVQZ BieVXu8u3RsURhQ2oAMIOKdkRtOa275sxhs/hGhuadDUFsPdNfuL6cyQxSks2BOoQYDB DxeW/8Cbh8UxrS092AfxWdmP+6xavQ572c2TngZV/Mid3kayPszGTOgEKEfvE0mNSnYq dc1A== ARC-Authentication-Results: i=1; mx.google.com; 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 s9si151473pgn.281.2018.02.15.09.24.59; Thu, 15 Feb 2018 09:25:14 -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; 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 S1422879AbeBORXX (ORCPT + 99 others); Thu, 15 Feb 2018 12:23:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57338 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422676AbeBOPfE (ORCPT ); Thu, 15 Feb 2018 10:35:04 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5130610FD; Thu, 15 Feb 2018 15:35:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Pieralisi , Robin Murphy , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon Subject: [PATCH 4.14 090/195] [Variant 2/Spectre-v2] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 15 Feb 2018 16:16:21 +0100 Message-Id: <20180215151710.204919867@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: Marc Zyngier Commit e78eef554a91 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: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/psci.c | 27 +++++++++++++++++++++++++++ include/linux/psci.h | 6 ++++++ 2 files changed, 33 insertions(+) --- 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(voi 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(); } --- 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;