From patchwork Tue Apr 3 11:09:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 132730 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3666487ljb; Tue, 3 Apr 2018 04:10:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx48lKEJ9a7VpXD8/AUjxMY5UWG5Cn+4P0gJE95alJGrvfJlVwGwCICEtq2P72zuNtV4Hjy1X X-Received: by 2002:a17:902:7582:: with SMTP id j2-v6mr7083394pll.46.1522753839447; Tue, 03 Apr 2018 04:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522753839; cv=none; d=google.com; s=arc-20160816; b=Zeo/XxXBLEj7CsLLznqtM2zRKp2xwTVI5K3G4+80JnVeArM1ONGeTXVqMxJU2F/huT 34r+2CCJylXL3N3DyM3td0PgC9KD2UvImHAVcXpCab02dXR963gobIK0hgwMYp8jm8gg FKem0HRZ7ZV8NYfLdWki8YS+A5nqxqAkRjpZPflteZlJbiXMe5Ph6VYMlQnw1pDBd3w0 DOrVBA/pA+hEfDlgVxktdLeagnEADcg/YZxrz2kDNxa/YklonM4r9ojtucTPc4TH6Pk/ MOFxw9fMPXeK9I3OIBptMwmr1cm0cCIMA2ZgTV7SRE6u5Pv30H75vOO4orYTre97WgYr 1fpA== 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:arc-authentication-results; bh=mzKQPtYBSLp/5rEejpOTylIbjpD2eXF1kcfkcg+UApw=; b=F52OZRGhfK13GYz8E66xoNEl6N51++FvZ7asLBOzfhwWlXj3Obn8ZPzA59MGYjP9Hi GW0NTyduq66u1HqKLHAgLq0RDKrMWcpS3AbfhMDNhKbWWV50ubXoAYfB4asO84huxxWA XGKBCLsI5LwWSgi8ZjgVoiezqn5DxGNgQjXUsJPIpcwmOSbXVpkX4XMj1FAKYA1t7/RY l4qM8pWYJfmdoIsws8G5f8yPHeL6ItjoOYmFnl7uAYg6HJnY7uhK39lCdICDmZhkeTeP 4GcLB8OoTTRZUSjak9Ziobd5BL9dqDKuI8hUtQWdxjXSXRbc/qSWigWqjw6VK031CLgt Q94A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 q9-v6si295691plr.273.2018.04.03.04.10.39; Tue, 03 Apr 2018 04:10:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755444AbeDCLKh (ORCPT + 11 others); Tue, 3 Apr 2018 07:10:37 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59426 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755267AbeDCLKf (ORCPT ); Tue, 3 Apr 2018 07:10:35 -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 7179F1596; Tue, 3 Apr 2018 04:10:35 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 40E593F587; Tue, 3 Apr 2018 04:10:34 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com Subject: [PATCH v4.9.y 25/27] arm64: Force KPTI to be disabled on Cavium ThunderX Date: Tue, 3 Apr 2018 12:09:21 +0100 Message-Id: <20180403110923.43575-26-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180403110923.43575-1-mark.rutland@arm.com> References: <20180403110923.43575-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 [Alex: use cpus_have_cap as cpus_have_const_cap doesn't exist in v4.9] Signed-off-by: Alex Shi [v4.9 backport] Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm64/kernel/cpufeature.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8d41a3f94954..5056fc597ae9 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; }