Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7451481imu; Thu, 31 Jan 2019 10:17:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN5DmZeL4Jju5rDMutzdN9R6asJ2wSKj67vZaEKYsXhV8HSnblG1kNhyhha6Y7eAU7+i8YE2 X-Received: by 2002:a17:902:201:: with SMTP id 1mr35533636plc.62.1548958659994; Thu, 31 Jan 2019 10:17:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548958659; cv=none; d=google.com; s=arc-20160816; b=vqUmCPj+IJRfGH5qiGrRa7M+AU32z7qE3k1S1p5CY2MTbcBmHb7AvSbXWLXKNzj1bE ZEjMZqWW7xqVtkHPw77NWx5or2imi+8Z07W/+mDpduWSw1V2tapVLforR1fm8fNKvfHh oNQtxmy2i5sZS6DDTOABMRnl/1rBhcp/q8Hs9LbYcqvfrt1NpHdJcXBCewNhBVO7fYJO 4eoAMbbD4yx/+M2agrVnuWgdQfn/gqNSBXa+GiMVNRNZ/zShuiq3KpPs8LLpZx0/dKC3 H+fx3KBm8lRTS/8DfGg5ozs/pFKQsoUFuiXKD4mnSxLfgD1EtuIQpRjrUDyjfi2SU4m1 XWYw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=2NrfWMYvIUyZ1/g/M0wujMN3wmF+E3eDnKrYif/xPDQ=; b=0KlvtgHCJZUZUSnO0tblAUzDQYg+C+mhw4X7sjbs+mLBgXCbKQQlfzIh33WHVymNnO SAzi5fdikGBiEuj4SN6WcMz5oZQlpgVqL0KY2TMIq234QxXKAlbi3dqUrTe/Jc9Se3qO 6lu4h/Tp/3nrZvj6zFJXBPLcD06y6KP9RMkijVcXsCzX+o0GfGRx7GGa878EU5WsfpWb LPv8aBXCS4hu5u6SAT5pt46TkOiXwhzB6OqHXg3DzGh03JdQ6Q7BtUHsHZP3nJfrNod2 OFQ7Gb9iXo+cjpgnpfg0zZAaVSccLQnMay44u2riT8GK3D71Ooet32xocXmLgIoiINdp swww== 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 k125si4971645pfc.21.2019.01.31.10.17.24; Thu, 31 Jan 2019 10:17:39 -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 S1727321AbfAaRzJ (ORCPT + 99 others); Thu, 31 Jan 2019 12:55:09 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48846 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbfAaRzI (ORCPT ); Thu, 31 Jan 2019 12:55:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 490F4A78; Thu, 31 Jan 2019 09:55:08 -0800 (PST) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D82133F59C; Thu, 31 Jan 2019 09:55:05 -0800 (PST) Date: Thu, 31 Jan 2019 17:55:02 +0000 From: Andre Przywara To: Jeremy Linton Cc: linux-arm-kernel@lists.infradead.org, stefan.wahren@i2se.com, mlangsdo@redhat.com, suzuki.poulose@arm.com, marc.zyngier@arm.com, catalin.marinas@arm.com, julien.thierry@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, steven.price@arm.com, ykaukab@suse.de, dave.martin@arm.com, shankerd@codeaurora.org Subject: Re: [PATCH v4 09/12] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 Message-ID: <20190131175502.12bed0f0@donnerap.cambridge.arm.com> In-Reply-To: <20190125180711.1970973-10-jeremy.linton@arm.com> References: <20190125180711.1970973-1-jeremy.linton@arm.com> <20190125180711.1970973-10-jeremy.linton@arm.com> Organization: ARM X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Jan 2019 12:07:08 -0600 Jeremy Linton wrote: > From: Marc Zyngier > > 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 Yes, I stumbled over this in the firmware spec as well: Reviewed-by: Andre Przywara Cheers, Andre. > --- > arch/arm64/kernel/cpu_errata.c | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > > diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c > index 4d23b4d4cfa8..024c83ffff99 100644 > --- a/arch/arm64/kernel/cpu_errata.c > +++ b/arch/arm64/kernel/cpu_errata.c > @@ -217,22 +217,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: