From patchwork Sun Oct 27 21:01:23 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: 177873 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2545999ill; Sun, 27 Oct 2019 14:27:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ2MopgjqIuO2gVprdXREIJJifK8X9VXuMFr185yT1fWSBHLBGQGLG1ADGWu+T94+5wHAz X-Received: by 2002:a17:906:6094:: with SMTP id t20mr13862383ejj.316.1572211660079; Sun, 27 Oct 2019 14:27:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572211660; cv=none; d=google.com; s=arc-20160816; b=MEGKKU7Q7kayRV3xvs9GmjdPMLwfSq9u9xVt4cQH3QsmERh3TfE9FjAPzbDivTfEMe 28IrIR0/IKwr/6il9IXis6R57+sckBsdx06+pCzRwli5iI9RmwCXpNCvCBAyPVX7lzbB FkqV9il+uCzFsR9SzD4kmbw4mJMe68fKsT+JTUUmF0po3KZOlFfFUsbc4TWVGolHTwym lpT0m8NlmZZGQI3SJF2qMHmtKkbEvly5gynnLe8tvlLW5WIYKcDtUCjuoOYrU9ozIQzu 412E9JWM/dLP896+WTFJbBZ0j1lwPFe1hhPnxaulwyCk/vCWAXOSdsx0mTVABNHq008q 4xOQ== 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=vc3ODk0s234v6d8PJ6G4C9QcZC/WdsvrPA5/RgeTT/8=; b=URL+q5AifAU8Yq/QavpyV69vPrZ2suFLiPGk3qlVRPt3eUEZDlzPJhtIlLWUqSp5jy 2BJ8yLI8/LE9V7b0EfQFr5mEfZeoSIa6ClkFj5krk+4Hr4pTsQrPm+yu7qK1+ryq5RR6 biUvODd6QhW6CDdzkbhYBWiLWDpZaxEyrbtwBWE/ciy96D34EWUoizNjVL1Sa2jND83C TY2iMkNFQbC5goXaNefBC8Y6fGyWvvKa0NNLpi9Tx8J9x74OVBRT4OCqAPvCRUZOhRg4 2+UtPQmEgYKUWa5jiJUoTYMtRQM1PcIb23JHtidCnl1Xi5mUNyxSKDuv7I9unj864p0g 8vbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t6n2K/Ve"; 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 p4si5122759ejj.334.2019.10.27.14.27.39; Sun, 27 Oct 2019 14:27:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b="t6n2K/Ve"; 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 S1730924AbfJ0VYp (ORCPT + 26 others); Sun, 27 Oct 2019 17:24:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:46338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732563AbfJ0VYk (ORCPT ); Sun, 27 Oct 2019 17:24:40 -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 00DEB21726; Sun, 27 Oct 2019 21:24:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211479; bh=qjjUIQQK/K3d1S3afzT05FRefX9ssSgQs8oma/kfAOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6n2K/Ve9gd0hErcT7LukVYRyemUDfRgJhI9cvAWLp9/h6yJYCX9X17WSQWXkb5Y5 pKh73LPt+sXL2482cgDf2T/LRfkL8XQNk/NjZtJel1cV+ZjuW8TOFAqtl0lL2bqLy0 h/jMuyjiBMnKo1yno+Qjw5jUt2hSAuW5kO+x2CiA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Will Deacon Subject: [PATCH 5.3 165/197] arm64: Enable workaround for Cavium TX2 erratum 219 when running SMT Date: Sun, 27 Oct 2019 22:01:23 +0100 Message-Id: <20191027203403.176764398@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 93916beb70143c46bf1d2bacf814be3a124b253b upstream. It appears that the only case where we need to apply the TX2_219_TVM mitigation is when the core is in SMT mode. So let's condition the enabling on detecting a CPU whose MPIDR_EL1.Aff0 is non-zero. Cc: Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/cpu_errata.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -12,6 +12,7 @@ #include #include #include +#include static bool __maybe_unused is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope) @@ -623,6 +624,30 @@ check_branch_predictor(const struct arm6 return (need_wa > 0); } +static const __maybe_unused struct midr_range tx2_family_cpus[] = { + MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN), + MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2), + {}, +}; + +static bool __maybe_unused +needs_tx2_tvm_workaround(const struct arm64_cpu_capabilities *entry, + int scope) +{ + int i; + + if (!is_affected_midr_range_list(entry, scope) || + !is_hyp_mode_available()) + return false; + + for_each_possible_cpu(i) { + if (MPIDR_AFFINITY_LEVEL(cpu_logical_map(i), 0) != 0) + return true; + } + + return false; +} + #ifdef CONFIG_HARDEN_EL2_VECTORS static const struct midr_range arm64_harden_el2_vectors[] = { @@ -857,6 +882,14 @@ const struct arm64_cpu_capabilities arm6 ERRATA_MIDR_RANGE_LIST(tx2_family_cpus), }, #endif +#ifdef CONFIG_CAVIUM_TX2_ERRATUM_219 + { + .desc = "Cavium ThunderX2 erratum 219 (KVM guest sysreg trapping)", + .capability = ARM64_WORKAROUND_CAVIUM_TX2_219_TVM, + ERRATA_MIDR_RANGE_LIST(tx2_family_cpus), + .matches = needs_tx2_tvm_workaround, + }, +#endif { } };