Received: by 10.223.185.116 with SMTP id b49csp2298442wrg; Thu, 15 Feb 2018 09:27:04 -0800 (PST) X-Google-Smtp-Source: AH8x2252lJQEgkaFtqT4fJ50lSQ9QMkmkx4063Y35Gtb3y4FtClxm4Pmugy7Wsm/W2Q7ijuV9yT8 X-Received: by 2002:a17:902:34a:: with SMTP id 68-v6mr3261976pld.276.1518715623979; Thu, 15 Feb 2018 09:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715623; cv=none; d=google.com; s=arc-20160816; b=vvNMO0IIs4c8LMnSfNUXNPItk2gK2qaWcTk48jmpQmDQzn05Z1Zwp8A2nh0vQyyoCC MHFQUhwvDOc/Bt9LU2md1EDacAmWAroCLxV7vjCBkXcrhO+Nql2QowrgCCHafiqjCX5D L7N4Ps7KxyxU+KLtZBLxGCohm7AvkOeg9rZ+FEeDzuOUUSXsm5tTvTObZaRDIqnxlyT3 jJpMrxv+cRzIB4lZFGdiRcvYYvK5HQL/4/ASIraEus0lzeSuF5kXRhxiRkh6GcKkF4TO 1LKrC0c0I0mC2dj1+d6Ws/J5aMRA8Gk4zGQdXo+PlXui69xRr2VZK3F/VTjpShjYAiWM 6UHw== 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=oEWElBpeHxXzBrUO4fs0JqLTtU/jxCHVpp/e71ZKB8w=; b=M7jKccA9boqqWbHCXIQfrSbFKq0ZmVbXp0pWYSQE3T5gV6pEcCvIWMGmPEIBxNrvqc MHln3y/lIYhCssNMt9Ls/wWsm68j/B23/XJNQLSLite1+K2kmBtUx4OmTlpRksnMC6+1 cwqBVOwFB+IXAu7ai6iaYlpJujtauh1jAhl5kdosWsx9l60C4zAUKdmmh2+y+0W804Jl 4lEO4hyOxG2z8hwi17DP16YVKqFjvswJA/kmcYvPyFlMpMxGPFqKIjkS9+DJsYlfELtF lVbNJ9BT45bm6H9Q/eUI4b0Ut9dI4RPmJQ1fS7FhIXj+Ubs3H0Br7HH6wqQmkl/gQZRV F/QQ== 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 l11si489328pgc.327.2018.02.15.09.26.49; Thu, 15 Feb 2018 09:27:03 -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 S1427312AbeBORZO (ORCPT + 99 others); Thu, 15 Feb 2018 12:25:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57252 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165149AbeBOPeq (ORCPT ); Thu, 15 Feb 2018 10:34:46 -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 88C5C1118; Thu, 15 Feb 2018 15:34:45 +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 089/195] [Variant 2/Spectre-v2] firmware/psci: Expose PSCI conduit Date: Thu, 15 Feb 2018 16:16:20 +0100 Message-Id: <20180215151710.158532521@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 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: Ard Biesheuvel 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;