Received: by 10.192.165.156 with SMTP id m28csp243915imm; Tue, 17 Apr 2018 09:24:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4806EzgeCctENPgH5H6hW6LvyYoC7rDa1KHUyyNOK6TvEXB0CL0uPGUU+Vhml49VaQZUH39 X-Received: by 10.98.159.20 with SMTP id g20mr2576427pfe.75.1523982260180; Tue, 17 Apr 2018 09:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982260; cv=none; d=google.com; s=arc-20160816; b=qCs71O0NklPcWsHF0mIbccy3v17KyH2YJqH511DqSTqeMwGFEMMoQipNwzN7gboxT1 MbqKZb8aDYTLBGo3THiRNsfciho+SwVOJvyuEw5ILjjohIUq87Yw/W8TcO3DQuGAGI86 1AZigpg2OpIQoSFHPZ9+TyhFuKEpInTWwwX+CCCTY0eIpD8CyYnNYEZ+DPLzaE4rgcuz KNWg7rTQiVvqdhCQ6n9CC2sCCaqI7V/E+rvzFHUurw253B/bvOlpF8z4zEzT1pAbu0fK ZGVGVCvQ9XQZ+mmDtmjgL8uwe/HSz6MaGSJuJmOyha6JFvcC0PVuPZZ9wWzZLGsyoMHv ISrQ== 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=k52/znow8PSu1JxJl6UmFKfaDSUynOGcFf/uroqttjk=; b=G/nt4tHbVIGkmTivdc16ncuaDjcK7MKKcJ6J0xG5L4P9JcB47FOoziSBv/meUpbNAG i5R9lerZYNqd3kB+dLi1XUU69+VJkrvSCd9yC++JInxV+hb0BDNQOowspI6T5L4Hfe3k lnI2bOqhZEXq8rqg5q+tkX0B0iVhnXPt4WJFK3lRivsYbgv8WT1R0ZCmYTj108ReyHxq 2Fmo1yQObLOKmSDyAhV2ebDjncsf7wQFwu1LJfkPH97HAuK9NWPFzIh4yKbpbrTfl/MT /7CfqEXQYumpPVC2ET7BoscDFAhn0f2bf2St1a7uCZT19g8t438/21lQs3C/vSvzZu5n iVEA== 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 e4-v6si2911194pln.331.2018.04.17.09.24.06; Tue, 17 Apr 2018 09:24:20 -0700 (PDT) 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 S1755684AbeDQQJs (ORCPT + 99 others); Tue, 17 Apr 2018 12:09:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36198 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755669AbeDQQJp (ORCPT ); Tue, 17 Apr 2018 12:09:45 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 006B9BC4; Tue, 17 Apr 2018 16:09:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Lorenzo Pieralisi , Robin Murphy , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 46/66] firmware/psci: Expose SMCCC version through psci_ops Date: Tue, 17 Apr 2018 17:59:19 +0200 Message-Id: <20180417155647.883306120@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland 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] Tested-by: Greg Hackmann 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;