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: 10246765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E29DF60362 for ; Wed, 28 Feb 2018 04:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D372320453 for ; Wed, 28 Feb 2018 04:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C85F420748; Wed, 28 Feb 2018 04:12:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 462FC20453 for ; Wed, 28 Feb 2018 04:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RKB64JrCSxD4dbSGpvyHUkJcZXlvqL6IKxHUEu8VmOE=; b=CErV/IguZlATun6FrvXTNC4GWn FjYIGslTZ0W8cb0N/5OoTf7AuhgADXzLMyWXi67wuUxc6ovMH6Pfs2aWbkVZQ8PLURUECm1cZAiiz Z9ThcHM/XBtzJDX2ki+Rd5VUK4oxl+n1RiypO9Sg5hykxVO/9VMBKjvyQ6Ew4WjYn5W/dd2h4GfZ5 lFXoBuxnH+joEfnfY17NjMo6tU9o2ZwZgBF7HdPVa4pMAm6UnJoMOlAOZTCQrsrnzKVlJFF5oI6LT EbnW9x51PNHHvwIzcaxRfEulJWgWG+Pc467c7uUIGlLPLmOZzkV7ftJ/RdpIeCash7ivWQnMHJErP 3strmI9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqt6c-0001Kv-SF; Wed, 28 Feb 2018 04:12:38 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqsvM-0001JR-KM for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 04:02:32 +0000 Received: by mail-pg0-x242.google.com with SMTP id g12so491963pgs.0 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=Vx7ffPbVy2Oot7zsH5ftD6MofyrWkzns8NZLh1YjfJusA9l9HDxDVh+lkac/KWfYMu Fs8wv+7z5/ChHHzbw26wMX8om2UvIUYj4QpcWGXbvOSi6V6pFWbiCeJfib2Y1jGEJYBH Nqx67n+Xucs/ecGSlvuwiRnAMKnKJVFE/2cO5dePnC1ZMPUCBiWuODRFDPX7O3/orIKC PB+rXq7UWi6baCCpeHSnHwTEA6cIBxHSHOXTwQL5RBzQ084eSyOTpGCA4OIXAQbqh58+ aWV8aDRjoX/Z/RFVa6RxYoudY8tZPEWMSTAqw9ZmpDCMBithK6LoEepgsrT/cG8O4ZGL VXqQ== X-Gm-Message-State: APf1xPC1f1T1JlKmoSVNny2b12z0iXb2MLWhTN0g7TZWPVfR4YKEQ8Lh /Srek/EyS0PstPjZ2tdyLLpqGw== X-Google-Smtp-Source: AH8x224sO3tK3v8mdNzockHnBxio9++P4ASCw19fhUjfOLeViSJe33kzC/OOReUREt2fmAZOGvnfqg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_200101_521526_1F3C8192 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }