From patchwork Thu Feb 25 01:44:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 8415721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C35489F2F0 for ; Thu, 25 Feb 2016 01:47:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D960320204 for ; Thu, 25 Feb 2016 01:47:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF701201EF for ; Thu, 25 Feb 2016 01:47:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYkzn-0005k6-SS; Thu, 25 Feb 2016 01:45:35 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYkzj-0005hh-S0 for linux-arm-kernel@lists.infradead.org; Thu, 25 Feb 2016 01:45:33 +0000 Received: by mail-pa0-x22f.google.com with SMTP id yy13so22627260pab.3 for ; Wed, 24 Feb 2016 17:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IOCb+ZVH39QcPbU7NMOZLJLQhxcJG2QQHKEgSfKgrM0=; b=w+9aqgewQ5hh3wNeE2jNKnXrCI+UN8L7QzQDuFXT8R2Ozt+iv/HRhEGvjGT6uN9H2l oQ1ymeyWf9QYc5iXwMfMqUeF8Y0tAOACh9r/kqI7f0O9e84OCsMI2TvXHfud7OaNyCF2 ESD+FbLvV9O6HDSI7S4jnAYB94XqzI0Fq3nWHVLU1wG83hdS9B+2FmxROTAB7zzFRSWU Cj46rXNaK/cPmoSglxSKac7M9ut8OAEfG4nyrHfsDqE7fNPT6xTvssKakr34lxCTDuRw ErnGTBh9UpzDB1WwbmVO/xY4K0tSC6cILXU2J6wm9+u0TvzEfUNRQmosciB4HmhQSzDM Fh8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IOCb+ZVH39QcPbU7NMOZLJLQhxcJG2QQHKEgSfKgrM0=; b=MsVVuV9Mot4QlITwoJaPpvN9k8NOuAVN2jnblbs6cJDfAKukawdzNqVJRp4XV+vj5z W0Ov5lv2eK459OWDeqjAxf9vEMGqpb0cYXUq1i3FnKqKEUiFGE9Yb5FxctRnoya/PO4d O+Y6HYnuFeI/YrqnbkNcocrnnLZn2aVscAQXKxSaVYlb6alTqPQwPJTN1dpcHSgk5Iug hFRFugECN9RxAE3qiw+pJpBksNDrdCVCc63G/rANMUAAptxbnFkgb/87fDQq8eBoZIAQ cXein9i/4FDk0HstrDYKM4/89YS5lSRVfT11lV+9uo/hVIk7LdrEGvyToPnAGVAlVjUs 7hmQ== X-Gm-Message-State: AG10YORBo6YM2vL3T0waJVy7ZtW7ClE0oQ5FZVx4diwr6Z+WJU74Ae53FWuio5e+Vz6FIw== X-Received: by 10.66.253.193 with SMTP id ac1mr59403398pad.121.1456364711244; Wed, 24 Feb 2016 17:45:11 -0800 (PST) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id xa9sm7718105pab.44.2016.02.24.17.45.08 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Feb 2016 17:45:09 -0800 (PST) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u1P1j8Yc025117; Wed, 24 Feb 2016 17:45:08 -0800 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u1P1j7aQ025116; Wed, 24 Feb 2016 17:45:07 -0800 From: David Daney To: Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Catalin Marinas , Marc Zyngier Subject: [PATCH v4] arm64: Add workaround for Cavium erratum 27456 Date: Wed, 24 Feb 2016 17:44:57 -0800 Message-Id: <1456364697-25083-1-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_174531_964989_C9E0421F X-CRM114-Status: GOOD ( 17.13 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney , linux-kernel@vger.kernel.org, Andrew Pinski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Pinski On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI instructions may cause the icache to become corrupted if it contains data for a non-current ASID. This patch implements the workaround (which invalidates the local icache when switching the mm) by using code patching. Signed-off-by: Andrew Pinski Signed-off-by: David Daney Reviewed-by: Will Deacon --- v4: - Add Reviewed-by - Improve wording of changlog and Kconfig help - Updated capability constant hoping that it eases merging with KVM patches Documentation/arm64/silicon-errata.txt | 1 + arch/arm64/Kconfig | 11 +++++++++++ arch/arm64/include/asm/cpufeature.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/mm/proc.S | 12 ++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt index 58b71dd..ba4b6ac 100644 --- a/Documentation/arm64/silicon-errata.txt +++ b/Documentation/arm64/silicon-errata.txt @@ -56,3 +56,4 @@ stable kernels. | | | | | | Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 | | Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 | +| Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b646091..97cd2b9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -435,6 +435,17 @@ config CAVIUM_ERRATUM_23154 If unsure, say Y. +config CAVIUM_ERRATUM_27456 + bool "Cavium erratum 27456: Broadcast TLBI instructions may cause icache corruption" + default y + help + On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI + instructions may cause the icache to become corrupted if it + contains data for a non-current ASID. The fix is to + invalidate the icache when changing the mm context. + + If unsure, say Y. + endmenu diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 37a53fc..727e594 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -33,8 +33,9 @@ #define ARM64_HAS_NO_HW_PREFETCH 8 #define ARM64_HAS_UAO 9 #define ARM64_ALT_PAN_NOT_UAO 10 +#define ARM64_WORKAROUND_CAVIUM_27456 12 -#define ARM64_NCAPS 11 +#define ARM64_NCAPS 13 #ifndef __ASSEMBLY__ diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index e6bc988..06afd04 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -88,6 +88,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { MIDR_RANGE(MIDR_THUNDERX, 0x00, 0x01), }, #endif +#ifdef CONFIG_CAVIUM_ERRATUM_27456 + { + /* Cavium ThunderX, T88 pass 1.x - 2.1 */ + .desc = "Cavium erratum 27456", + .capability = ARM64_WORKAROUND_CAVIUM_27456, + MIDR_RANGE(MIDR_THUNDERX, 0x00, + (1 << MIDR_VARIANT_SHIFT) | 1), + }, +#endif { } }; diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 0c19534..543f519 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "proc-macros.S" @@ -137,7 +139,17 @@ ENTRY(cpu_do_switch_mm) bfi x0, x1, #48, #16 // set the ASID msr ttbr0_el1, x0 // set TTBR0 isb +alternative_if_not ARM64_WORKAROUND_CAVIUM_27456 ret + nop + nop + nop +alternative_else + ic iallu + dsb nsh + isb + ret +alternative_endif ENDPROC(cpu_do_switch_mm) .pushsection ".idmap.text", "ax"