Received: by 10.223.185.116 with SMTP id b49csp2236167wrg; Thu, 15 Feb 2018 08:32:05 -0800 (PST) X-Google-Smtp-Source: AH8x2254S56IPuGbK5eVT+i9tkkPYKzydr2Ndi0SEfnKmZHAlw9orn+D3DgoPdXceZnPhdvP8FA8 X-Received: by 10.98.18.65 with SMTP id a62mr3172938pfj.115.1518712325889; Thu, 15 Feb 2018 08:32:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518712325; cv=none; d=google.com; s=arc-20160816; b=bj7z3zArludQK0M4tJyEBSpUdbQ5DplymLAMMOAbEnf/ZWwd2af+nms8E4qxifdd5j Q2xlqLnk2LLA3T9Mq6Xil9nhlh0bjWHpEISiJx1vY+hO4m4+X8tGumCvefDxvf3xG1hM Wjw7EosXAdkH7GakvlPOYhs3plpGAtDIZGJCT+VFpr7W5MY9xBYq+PEvUdk3f2YaGPGB pzReTOHyV8uWPUEny3g8d26gDGvsY0DwNCr7ckmweT7d3TQXs64bd83baXO68WfRPTBA wUfxxse8HuknxxtMPizDalgcoSON2659Ay3hfsHBiCF8t7UKVqjJWLnkPQJCWNRRb1RJ g28Q== 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=hMqZgG9o1WZczKIjS5tUEaPJROfds2ua/VTdPhCQ6eM=; b=G3S9McpH2o0YzqerijZyhzc1d3gysXbXZkUGY6DxF+6Tcr5Z6jvJ+xE1G41Bf+O0Ef 0PNfOmgQJwPnQOO7tBNEC6G6AF38XuNitK0h1dANmcpnVSm3kB1CPhU/G5ciziwiJ2DW v+Hm6oGerKtf308kGbq2wxSY06J9gvK5S8SRKY3JToiZQgxyQ0/T0Ec/cJ4cUuZMq7H5 Q98uyLQXaxvDxEDguF3GCxv3V2avVlDd7Ust0iWilQ3cnSFWEyD5kukuPj5tUjfS26/F IIY4OdpjwCZWtnio7jt/oN+a9Qo17DG7pIIdZZLgl88T/0OaHzaVEQwzPpZYKD7g37nW PiOg== 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 v34-v6si1581498plg.803.2018.02.15.08.31.50; Thu, 15 Feb 2018 08:32:05 -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 S1425957AbeBOQai (ORCPT + 99 others); Thu, 15 Feb 2018 11:30:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33258 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424147AbeBOPmU (ORCPT ); Thu, 15 Feb 2018 10:42:20 -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 D48E6F91; Thu, 15 Feb 2018 15:42:19 +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 082/202] [Variant 2/Spectre-v2] firmware/psci: Expose PSCI conduit Date: Thu, 15 Feb 2018 16:16:22 +0100 Message-Id: <20180215151717.765998565@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 09a8d6d48499 upstream. In order to call into the firmware to apply workarounds, it is useful to find out whether we're using HVC or SMC. Let's expose this through the psci_ops. 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 | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -59,7 +59,9 @@ bool psci_tos_resident_on(int cpu) return cpu == resident_cpu; } -struct psci_operations psci_ops; +struct psci_operations psci_ops = { + .conduit = PSCI_CONDUIT_NONE, +}; typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); @@ -210,6 +212,22 @@ static unsigned long psci_migrate_info_u 0, 0, 0); } +static void set_conduit(enum psci_conduit conduit) +{ + switch (conduit) { + case PSCI_CONDUIT_HVC: + invoke_psci_fn = __invoke_psci_fn_hvc; + break; + case PSCI_CONDUIT_SMC: + invoke_psci_fn = __invoke_psci_fn_smc; + break; + default: + WARN(1, "Unexpected PSCI conduit %d\n", conduit); + } + + psci_ops.conduit = conduit; +} + static int get_set_conduit_method(struct device_node *np) { const char *method; @@ -222,9 +240,9 @@ static int get_set_conduit_method(struct } if (!strcmp("hvc", method)) { - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); } else if (!strcmp("smc", method)) { - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); } else { pr_warn("invalid \"method\" property: %s\n", method); return -EINVAL; @@ -654,9 +672,9 @@ int __init psci_acpi_init(void) pr_info("probing for conduit method from ACPI.\n"); if (acpi_psci_use_hvc()) - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); else - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); return psci_probe(); } --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -25,6 +25,12 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_init_idle(unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); +enum psci_conduit { + PSCI_CONDUIT_NONE, + PSCI_CONDUIT_SMC, + PSCI_CONDUIT_HVC, +}; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); @@ -34,6 +40,7 @@ struct psci_operations { int (*affinity_info)(unsigned long target_affinity, unsigned long lowest_affinity_level); int (*migrate_info_type)(void); + enum psci_conduit conduit; }; extern struct psci_operations psci_ops;