From patchwork Sun Oct 27 21:01:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 177861 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2535016ill; Sun, 27 Oct 2019 14:13:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0aPjmZWSZ0VZHg4oxg4zfODLwrYdugc4hgMLFHTi/u0rqbOUeuu/ZPVRaxHroXkNLIbco X-Received: by 2002:a50:8264:: with SMTP id 91mr16020677edf.69.1572210642069; Sun, 27 Oct 2019 14:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572210642; cv=none; d=google.com; s=arc-20160816; b=E8fw3VLYkXZdrHDLeRIK/OS0o+GK/PWuh0Pc879SI9UYtUBlSbd4QX3QHSSYfUtNlN GLu/ciIYFSYFiwb3+aalCe7YmsGnTHIMs3VHMZoyh9FpejMnh23tBK+3c6rEFzW7E6tH 6pyoyYVWa96SakvT79bvGiX8eFdoxpBboDZ3LTL+rvZeZwPYJq/6s2LPsFtGE2gaJ47x QJNX2jWnB45DYoFPVwe5LtmZwT6x308FXZXFuRRRPCMOX+rkfNuzDStAiuUERtwJtohL s6naw8WeqvkJgkO0mRuDmA9hviUa611hgTZw9AfAIaSacPtiOZ9UqjW7CCSDUWIWArpb x7gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pT76LrD6hih0G4kmU9q+ITl2ZQocLT3rInmbiiZ/RNI=; b=KoACV0eaFMvowgag6euz9XjiQ863Wen0TjVegdpPh7zzjv+g/Wy8lBJ45SnNy09Kdw 0LdkRSLrr02Mei2GhgXZdYJPh0r7egi4U1Tai72ib2WwRssZyhy/Mu24Y8ZIQGEBnt/t iI84kJCQS1RdCceMaaedqAKgkzZT7fMZKGlbLhmPbfwe/lDIYfU9o5y3R/qUHlxl+JdR Ryn2UzXJyzFaafGeVlM+GaP53jL9P8sM9jw//kJF6d11QWR7wuDPAgxNdhdXJtMxnMXI AO9iY9frYGNoXfXQvkIv1vr/53aAXN2x6hlpFMgiFs/Jbn6fqBAIGaCMEvRzWQ8xXlCx PzdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y1yjB3Oh; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 c29si299346ede.50.2019.10.27.14.10.41; Sun, 27 Oct 2019 14:10:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=y1yjB3Oh; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728827AbfJ0VKi (ORCPT + 14 others); Sun, 27 Oct 2019 17:10:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728797AbfJ0VKh (ORCPT ); Sun, 27 Oct 2019 17:10:37 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 819A520873; Sun, 27 Oct 2019 21:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210637; bh=yy9iRurEiMd6hM0tViCdcWOujPSbCP1i+PLRyE2P5Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y1yjB3Oh61SDImSDfYD9gtE2VDXf62Ee9M5nCgwQeBvj32ErgYLftmU3Ao2p+FDhr 8l+c+G/1iTFu5AdjPrppR60oM7UMslaRzuavE+uKjnUeo0/G/aCxklC4g7emDOWx9v LLJlblYA7nsB79B0IucSK70y95YbwA8HNgORibrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Marc Zyngier , Jeremy Linton , Andre Przywara , Catalin Marinas , Stefan Wahren , Will Deacon , Ard Biesheuvel Subject: [PATCH 4.14 083/119] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 Date: Sun, 27 Oct 2019 22:01:00 +0100 Message-Id: <20191027203345.935698895@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203259.948006506@linuxfoundation.org> References: <20191027203259.948006506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier [ Upstream commit 517953c2c47f9c00a002f588ac856a5bc70cede3 ] The SMCCC ARCH_WORKAROUND_1 service can indicate that although the firmware knows about the Spectre-v2 mitigation, this particular CPU is not vulnerable, and it is thus not necessary to call the firmware on this CPU. Let's use this information to our benefit. Signed-off-by: Marc Zyngier Signed-off-by: Jeremy Linton Reviewed-by: Andre Przywara Reviewed-by: Catalin Marinas Tested-by: Stefan Wahren Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/cpu_errata.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -190,22 +190,36 @@ static int detect_harden_bp_fw(void) case PSCI_CONDUIT_HVC: arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 < 0) + switch ((int)res.a0) { + case 1: + /* Firmware says we're just fine */ + return 0; + case 0: + cb = call_hvc_arch_workaround_1; + /* This is a guest, no need to patch KVM vectors */ + smccc_start = NULL; + smccc_end = NULL; + break; + default: return -1; - cb = call_hvc_arch_workaround_1; - /* This is a guest, no need to patch KVM vectors */ - smccc_start = NULL; - smccc_end = NULL; + } break; case PSCI_CONDUIT_SMC: arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, ARM_SMCCC_ARCH_WORKAROUND_1, &res); - if ((int)res.a0 < 0) + switch ((int)res.a0) { + case 1: + /* Firmware says we're just fine */ + return 0; + case 0: + cb = call_smc_arch_workaround_1; + smccc_start = __smccc_workaround_1_smc_start; + smccc_end = __smccc_workaround_1_smc_end; + break; + default: return -1; - cb = call_smc_arch_workaround_1; - smccc_start = __smccc_workaround_1_smc_start; - smccc_end = __smccc_workaround_1_smc_end; + } break; default: