From patchwork Wed Feb 28 03:56:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129911 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp569696lja; Tue, 27 Feb 2018 20:00:57 -0800 (PST) X-Google-Smtp-Source: AG47ELtz81LK9QxhMQCGOrUSckPefR7YZ59TkCn4Vbu28kpdXqEEP2JevSQZNdSUnOqjqb4iyh8m X-Received: by 10.101.75.18 with SMTP id r18mr7023775pgq.36.1519790457061; Tue, 27 Feb 2018 20:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519790457; cv=none; d=google.com; s=arc-20160816; b=qU+LrhsooK3K544Ojmh6tTs9PVosiPWlZTSfij1jJLx58wqkI1B+Kfw0s9AMUTPXao nJXc1BWDXYGwLjWSDRZlzuOtgp5MZQb1CLAxC1Ooaj+fKw34EgEZcr05gjsVFJ/pwmD1 4MbL/KxXSfOdL3KMrSwWjaIbXpbOHTFOXmnAqSiQmLd9ULb+lh06evXDe/WTPMoUS8rV hmlOMhs4fE9oPe2vFQKt6ZVhly/3RLDlFv8k9xomu3wNsq4he9L66SzDhpPH6nUppdUS iQ18sWEqAPSyjoWQJrNkiUac92uFA4UejT20UkZXLbCWLtJdmiyqmbGOEd4E0yV3oYip zcCw== 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:dkim-signature:arc-authentication-results; bh=61Y8iHNGS/LyzooAj6849j03LY7srEwVDjkJR8E93VM=; b=K5K79XLuCgemYGMVpWuR8Z94Kiu5RfuvkT0XxxoA5sUh4PxgMxYXUN5Jb8ygPJQ7z6 +d3qnuQ754htidjTLSfyI7Fmh6kVIvGXngMxGvccMZacnimsbjxQ9t0ictRKJkV85t2T WFPTNylFWNCMh15nZBW1gyzANyxhMTssmvzOBvCH3Tu16038Dtt0VNKXjWWoE7///FvL D7MIC1/00bZNTZPW/Ca+37I/FRYVHXjpjuhLlR70e9ek11c2cOG19anKORw47AdgR/Q/ wdN/tvPDJ6Jl40qSfB4WJQR65T7BEmAtsq42Yznt0Tkm9p/kgJbTG/rCEkDC26STjcwp cGcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dNmpN4p3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5-v6si604191pll.90.2018.02.27.20.00.56; Tue, 27 Feb 2018 20:00: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; dkim=pass header.i=@linaro.org header.s=google header.b=dNmpN4p3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbeB1EAw (ORCPT + 28 others); Tue, 27 Feb 2018 23:00:52 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43232 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404AbeB1EAu (ORCPT ); Tue, 27 Feb 2018 23:00:50 -0500 Received: by mail-pg0-f66.google.com with SMTP id e9so479698pgs.10 for ; Tue, 27 Feb 2018 20:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=61Y8iHNGS/LyzooAj6849j03LY7srEwVDjkJR8E93VM=; b=dNmpN4p3DuNhT6OkTUsJidqsJqV3/2TZy78JIsvqzoZCZPfgInieDltAXrRq73IKJ4 KH5muFiLLSY8CKHCXpg5y2rVFDprDz0D0QLZGjzlYQIKvgMloEgruc5z//80VK/friq7 i6aVzoOHY2ggfaUy3cRdXoqM2Zvwoh4Eb+/bM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=61Y8iHNGS/LyzooAj6849j03LY7srEwVDjkJR8E93VM=; b=O6t1HDOMvkh5Rx0nLVWmYWlCqHUKxl+UpbwXfFto/ikGqIvwkH7MM0qzvJvBsv4/AX ALwnqBCSM4/CMjlyERgJTJxmU/RQDGbNaDFLMMbJH/vb1RCvP+7IV2LRPdwWl9RgUOrN qTGHVqNugIkoxMb9PY0zXAeOx0pm1Weh7o/MLrHc7mGCQhZWZ7f+W9tPawg0uGpJwAeP wrWwWCt3/OSFf9OcCLs3f9nJBoVfNecA+FKplGaXvgFlKBBJfRCDZXQS5+xfFRuwKENI UNAlDdWwJP3+llEikTwcuUZ7zWheaBxGLHiiM4tLLMZ/F9CvINhpnydKz01PunLKhzdx lCUQ== X-Gm-Message-State: APf1xPCLxxz1DurGxHvlqr96nvEInOJ8FFqVUd6P9uof7Ihc1HPFDHL4 kR9kuVlH7v1CVQTPigLyzGkZOA== X-Received: by 10.98.89.156 with SMTP id k28mr16092279pfj.130.1519790449826; Tue, 27 Feb 2018 20:00:49 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id q17sm739911pgt.7.2018.02.27.20.00.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 20:00:49 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 27/29] arm64: Force KPTI to be disabled on Cavium ThunderX Date: Wed, 28 Feb 2018 11:56:49 +0800 Message-Id: <1519790211-16582-28-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> References: <1519790211-16582-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 6dc52b15c4a4 upstream. Cavium ThunderX's erratum 27456 results in a corruption of icache entries that are loaded from memory that is mapped as non-global (i.e. ASID-tagged). As KPTI is based on memory being mapped non-global, let's prevent it from kicking in if this erratum is detected. Signed-off-by: Marc Zyngier [will: Update comment] Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Alex Shi Conflicts: using old function read_system_reg/cpus_have_cap to replace read_sanitised_ftr_reg/cpus_have_const_cap in arch/arm64/kernel/cpufeature.c --- arch/arm64/kernel/cpufeature.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 0fba610..760c851 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -753,12 +753,23 @@ static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, int __unused) { + char const *str = "command line option"; u64 pfr0 = read_system_reg(SYS_ID_AA64PFR0_EL1); - /* Forced on command line? */ + /* + * For reasons that aren't entirely clear, enabling KPTI on Cavium + * ThunderX leads to apparent I-cache corruption of kernel text, which + * ends as well as you might imagine. Don't even try. + */ + if (cpus_have_cap(ARM64_WORKAROUND_CAVIUM_27456)) { + str = "ARM64_WORKAROUND_CAVIUM_27456"; + __kpti_forced = -1; + } + + /* Forced? */ if (__kpti_forced) { - pr_info_once("kernel page table isolation forced %s by command line option\n", - __kpti_forced > 0 ? "ON" : "OFF"); + pr_info_once("kernel page table isolation forced %s by %s\n", + __kpti_forced > 0 ? "ON" : "OFF", str); return __kpti_forced > 0; }