From patchwork Thu Oct 10 08:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175726 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1983820ill; Thu, 10 Oct 2019 01:48:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3V/XYF7dND+ri4hrczUPGr7E9ZDR6CwAP7TpssTJ2EJsioTuuBwhprWkBPlB6ZVicQWLp X-Received: by 2002:a17:907:2132:: with SMTP id qo18mr6845581ejb.247.1570697337307; Thu, 10 Oct 2019 01:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697337; cv=none; d=google.com; s=arc-20160816; b=eXgTQyWaTjHnHJrVAc8mxOqzU/pPu4bilpd6FjJk7xJDR9NIsr7vOdtATol2dYdrSz mA5tkAsRxWfcHGa/NCI95Z5kzK8glkoat9+GNMhSSrBOPR3sbFY4mBivtAYRBYh8ncfC LBd9REM4aBeCvkc7G0/dJBJ/skz7WQc8BexfhYRk7e/UURdcsCrp0qp+VLVMYblwUswl KABElMZqinn6ZGxBixe4PSl5aJPa9VLTnDz975qahs+T7+3Y1vvpsIk3+2EMnTIhCCub 2LWz5+SIlxFw4LIYj1MAcWhWtwOs8Ho4pLwdkT7a6z1WzqncbzGnAAQPfa1R4wJreQ4/ UBUw== 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=AeX1gPbsg5zXfEpXNnx0RWD3wMjrAiUPSzk1iBfLcFk=; b=ToG317XusoamSklAJA9YQSboawYlcw7EqTrZ4adaFal0iTdXfZ5oz0P3Pl276IkboL Y9VxBvINzkilCcAD+1Ou9RkCdgS8EMaGJZ/G0tOswEKOTy5XfZy2TndIaSZkL/5eOopP 0XU0B9nJ985ApU/2PDBDPUYmESq7+0RH1u+uF7735ltIR0G6mNSTVE5bxR5Y/oUgCgBy 3FZHFZOBymrt7/JB7UtpVt2A994SqY8DEQN5L1ilEcjE0FtYw23A0feLtLq4SinAHfb3 l/PAy/Xhu1PthAgrDNs+fQc1G/1++yNMGN0tIXhZMwA18BpduXean6gmR1v2146TbTnO Fg5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yq6Ck7RC; 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 x19si2831512eju.15.2019.10.10.01.48.57; Thu, 10 Oct 2019 01:48:57 -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=Yq6Ck7RC; 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 S2389715AbfJJIs4 (ORCPT + 13 others); Thu, 10 Oct 2019 04:48:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389713AbfJJIsz (ORCPT ); Thu, 10 Oct 2019 04:48:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 69DC22064A; Thu, 10 Oct 2019 08:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697334; bh=S+0Okuy49xg+IxUOb8mc1qP1Q2gPrQqsCjKimb1zDNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yq6Ck7RClMeZdbGEkk7oSbNVvgPsxu+weTGT1uba8Sd3X8N8N6H0OU2KfqOgczcPC KkxUiu5stn5Z1Wndsw7cgHKUliGHIyjqHA3mF7riZ3EI81SNLySUMWYlVGYic2kSrb FSekAmFkaoJ6n7rNEAQrhIpAaHxKAfgUjjHIQRhU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Jeremy Linton , Andre Przywara , Catalin Marinas , Stefan Wahren , Will Deacon , Ard Biesheuvel Subject: [PATCH 4.19 104/114] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 Date: Thu, 10 Oct 2019 10:36:51 +0200 Message-Id: <20191010083613.719382595@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083544.711104709@linuxfoundation.org> References: <20191010083544.711104709@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 commit 517953c2c47f9c00a002f588ac856a5bc70cede3 upstream. 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 @@ -198,22 +198,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: