Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2558197yba; Mon, 15 Apr 2019 14:23:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwPAUzkXpzemBkNkm8Ru7pfENNoQQAcJ26+tY/jrEtj/wlEA/Zr3zWng6LAx2zEgg5mi6K X-Received: by 2002:a17:902:266:: with SMTP id 93mr39838661plc.201.1555363428808; Mon, 15 Apr 2019 14:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555363428; cv=none; d=google.com; s=arc-20160816; b=xpL/CxzF039uPfFmVDx5nbn8xTrjlQ5VHIo92KJkgr6Jskotf1nXX4e6q6jKgw8Z5O iBhOOc2PKpGnqpOPYmKOsp514tbJUlulGvGl+D39ulbNtEfOWdgq3z4CM6hChgj6JoZq gzOIqL3jzCzX4w38EjCtwS0mEUPcIaDm0nHkNuiIbop28/VEBrP8ItorBzbv68dZHjmy 1I1qcSk0QnHB+edwawz+xihD10eid+pJIKRh9BDpzEErdecIXOeQvYrpYz+GGd4Z49qu f28zcZdNt85vBjeNqINcgWONB0mpv1FHVOyQw4t1oiCOVP8cGZvHzmMnfrW5bDcGfzdQ 8yMg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IdW32AdxoA9VbkjcaG360AzZjbEGPKAgmSzvLha/H38=; b=lpu2vhOJhoIw4+zdKfg1rgpCNCZGZiA1KeACDkRFif1ucu5aO+20TYHXJu86RpJ7AD oNQtf4lWcCfjzpoUCi91tie39KVfgY30no5t/DnwVMoGVYZLVG4AnNke6wlwrpfzAY8+ 0sJaAhssVD/GSg3cpJ5neGSKuJBa+2J79aoikFgR4/aaJ3cGlcALqaBpbSA/+TUGLtrV 6sqAuMVoqnteTZigrhFvHtsP0ND1p6NjhG/iACTsDK87+G7xsXz/gfQE9fYJ2hKag7Ia 3YLAtZr84jUSwz+pchPwF1pFYprjke4DUhut7tMdASHxeY7JfpiFpKxP1q3scOxpukHC Sb6g== 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 u63si46365695pgc.553.2019.04.15.14.23.32; Mon, 15 Apr 2019 14:23:48 -0700 (PDT) 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 S1728168AbfDOVWN (ORCPT + 99 others); Mon, 15 Apr 2019 17:22:13 -0400 Received: from foss.arm.com ([217.140.101.70]:42926 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727760AbfDOVVm (ORCPT ); Mon, 15 Apr 2019 17:21:42 -0400 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 3E41FA78; Mon, 15 Apr 2019 14:21:42 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 96AD13F68F; Mon, 15 Apr 2019 14:21:41 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, marc.zyngier@arm.com, suzuki.poulose@arm.com, Dave.Martin@arm.com, shankerd@codeaurora.org, julien.thierry@arm.com, mlangsdo@redhat.com, stefan.wahren@i2se.com, Andre.Przywara@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton , Andre Przywara Subject: [v8 05/10] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 Date: Mon, 15 Apr 2019 16:21:24 -0500 Message-Id: <20190415212129.1112-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190415212129.1112-1-jeremy.linton@arm.com> References: <20190415212129.1112-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Andre Przywara Reviewed-by: Catalin Marinas Tested-by: Stefan Wahren --- 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 032f1a4dbea2..60cf87c4deb7 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -230,22 +230,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: -- 2.20.1