Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp744134imu; Fri, 25 Jan 2019 10:09:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4m7oKuy8Z5kG12LQLlx+bMH944d8rGmPKNFqv71tXfUPldCWl3PoWxN5klXhyUsNVOHUaS X-Received: by 2002:a63:1321:: with SMTP id i33mr11005308pgl.380.1548439797257; Fri, 25 Jan 2019 10:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548439797; cv=none; d=google.com; s=arc-20160816; b=BvP6hdhhbxM2R37vOlsxb0VVYg872aTBAThs/LS2dAMcZbRPBvzVnOi5C0NzargjCs EME2DhQuzXzmH8qHZ0NSXOUOLS9NubCrVQqX5DkWuEcGBTOwslZahm2jI7EhSnPnKuhy eXdyacLREimPZZCMibC/8MoEy57Oy54fQiQdHPRqvfURcf44GCke+Y4yw93NBWVcJovI hkBOfdxcEDWJvtnNCP/PtdVWrgjVlH1IwoRehQypH+0TaKRRzEEMQ0NZWned0XBFNmCi goruiHi3qQgHiHasGNXnb+HW8zXy3LLbrf3gKN8hnQWe5FislljqGHtS49B0nm4+joZo RrTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=isEWo00ekroD+hHx+cCcZtCCnan/N/Bz67pHPEmyP9s=; b=Szsj9N0qsjRLkB4Vh/MFegkaBrP6ncVX2TAtQoGy8qLkmyKCerCpCfO5uyC7LeCOlb 0wlAZ1dL/xWHE5cm4S9SNtRg6o+3AjntBNgUqbxNjS2tnevTRmmI+ErXNciVv3QAnADP mD+kYQ4a23YrH/f1scgGUFbeejtDUq/u7izGVgjlzd1jLmd0t2VDNkbYQplETpEyeAdK LBLon2OaA5JiIA9+oqJY3YFFC8uMFyZlo+opMi1DCT9mkbix75KYmu3uZkdypCj4vqYs OtES4hWZouST/IkF6DvuB9ZQylytQFzqohdrVrCCzJJIGQsePnNsbUzgk0ns1JQQHIYm 4nCA== 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 x1si24402182pfn.111.2019.01.25.10.09.42; Fri, 25 Jan 2019 10:09:57 -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 S1729469AbfAYSHx (ORCPT + 99 others); Fri, 25 Jan 2019 13:07:53 -0500 Received: from foss.arm.com ([217.140.101.70]:51868 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729373AbfAYSHb (ORCPT ); Fri, 25 Jan 2019 13:07:31 -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 5B2D1165C; Fri, 25 Jan 2019 10:07:31 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B02193F5AF; Fri, 25 Jan 2019 10:07:30 -0800 (PST) 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, linux-kernel@vger.kernel.org, ykaukab@suse.de, julien.thierry@arm.com, mlangsdo@redhat.com, steven.price@arm.com, stefan.wahren@i2se.com, Jeremy Linton Subject: [PATCH v4 09/12] arm64: Use firmware to detect CPUs that are not affected by Spectre-v2 Date: Fri, 25 Jan 2019 12:07:08 -0600 Message-Id: <20190125180711.1970973-10-jeremy.linton@arm.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190125180711.1970973-1-jeremy.linton@arm.com> References: <20190125180711.1970973-1-jeremy.linton@arm.com> 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 --- 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: -- 2.17.2