Received: by 10.223.185.116 with SMTP id b49csp2180915wrg; Thu, 15 Feb 2018 07:43:55 -0800 (PST) X-Google-Smtp-Source: AH8x227FHsS35NYBRVlljzwGij1Z8lyGdgMThxjw+nkT9tjSNCqCzjzYYRB9MTESyx/Fy0KF/8Hk X-Received: by 2002:a17:902:b417:: with SMTP id x23-v6mr2905977plr.339.1518709435708; Thu, 15 Feb 2018 07:43:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518709435; cv=none; d=google.com; s=arc-20160816; b=BWiVHM8h7EJD/65qhnIfU+j2SC85cSjQkPdreT7MCmWKbgH+y4r2UT7GanfqI0BfKO RDQwO6VT9lkcg3Y3JFY0VWUhLIfQ4T3mYt3L7qAdgl8gxQ1zjGuL0CC5cOs+xg7ue0KC hMtTXA80PyYsdKUAwjZnnOmrup9rz6nu1iMk0NUKjG6thS7BVZNiLKMpI5OLs8k9TUYL u3joDmhKRauiiQuCX3be7tENce2rj2B7q3nUXgfEn4C4BXRrZNr5ofpo6/tbCyldcazT BmiX3cYUGn6dL3udct9+Cw2iKU+NWT3cDa/25sJ8bbyTvQbjhFQgvLIJ1sqYDyJP9pFr gw3w== 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=wzh+J5sSZqtVYG43tfbqKsbQPl2USyYCMyuSFvcw6Ms=; b=b9c/vAfq70iMFenujo3OQ6znd5din58s3DkJ4aZotoi4jyoRgmt9Tfh6IgRnRbXszG YLojQr6qnt18Af/brTQg3CD8CdecMOnBydR3zD+i6ZrKVKxfoD7ydXiaYwdC3Ao9geXw +g91CJ8yQxBfmCje1pchxK7FH7C2DO8ALbrdg0DsRPEl8ybQtylZtqQyOxDdDm8vBRqJ 3l5W/9kRU45DpJcXj9s8jH/YjIT31VKeqeG1m4dNnILw4WdugHgIdAJAVitfkJ7PnjAk xbQRQrTxpfBQ8G+qu7N4jXT8CJjQ3HD9soFK0StwLrLAy3gSjAmvWy7LxGxDX4s8zaj+ V9bw== 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 l6-v6si2277733pls.65.2018.02.15.07.43.40; Thu, 15 Feb 2018 07:43:55 -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 S1424175AbeBOPm3 (ORCPT + 99 others); Thu, 15 Feb 2018 10:42:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33278 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424093AbeBOPmX (ORCPT ); Thu, 15 Feb 2018 10:42:23 -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 834E2102A; Thu, 15 Feb 2018 15:42:22 +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.15 083/202] [Variant 2/Spectre-v2] firmware/psci: Expose SMCCC version through psci_ops Date: Thu, 15 Feb 2018 16:16:23 +0100 Message-Id: <20180215151717.804235463@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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: 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;