From patchwork Fri Aug 12 08:19:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 9276581 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 8624060231 for ; Fri, 12 Aug 2016 08:21:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770B52890D for ; Fri, 12 Aug 2016 08:21:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BB892890F; Fri, 12 Aug 2016 08:21:27 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id EF94E2890D for ; Fri, 12 Aug 2016 08:21:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bY7hH-0000vJ-2L; Fri, 12 Aug 2016 08:20:07 +0000 Received: from mail-pa0-x243.google.com ([2607:f8b0:400e:c03::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bY7hA-0000e2-Qk for linux-arm-kernel@lists.infradead.org; Fri, 12 Aug 2016 08:20:02 +0000 Received: by mail-pa0-x243.google.com with SMTP id ez1so1123429pab.3 for ; Fri, 12 Aug 2016 01:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=R/ogtxdvflwgjQIi6yn13Bce8UuVs+VM8yLw6sJy1hw=; b=VkNhGOh0VCpkL45dynGri5PgAR35J72CMq1boQVjCKbR/wTRpYLhyg8dwHJwoIDnRP 7xhlLZyuUyav5xzY0mzR4v6JXVstH15Hy/9R3B2e1cdhUh596Z+RrDGEQ72ygDuwWXsd 6esCFpcQNUqez5jxgulTme8uMxxqyQ/wEJ52qa7wS7HzpnPtI/PUR3+FpTBArkmplzjS Mtvwi4aYZMZis+m5ssf0TXAo26iZERChtZPEC33evgCq4ZK0RZD+eOAEfz6DNbNt2mxg JS0ETQ06osZ3lks+4lm23T/WOebeeeZhY8Si544MXlykOBXbI5DwIttjdAYD82osfSt5 AklA== 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=R/ogtxdvflwgjQIi6yn13Bce8UuVs+VM8yLw6sJy1hw=; b=NuU9Z9xml95Se9XVkg/iGqsX1rzN9tdfJ40iv2DLgM1DdyM/EpgtgYcLT8ex/6Nnuj kVKK7UyPtJYJOmmJKAT5OoC2aVG+0FRXlQ8krZUnAzrVWLTupz0taNFXbbzGzNUKWCR7 LRvLcIjkrDBaf/EhxDZozzo/sT9Sf+jdPQCM87DJzjJMvr4ThU3h7WM+Fkr0P6rxCVwk t055j8E6jrpuv8Ec7eQlea/gutZ/zZKwCP19L6vcnmcsd7VePxORN4pg66pgiykz/kzO qtPHP5Un7zyhkhZmCrMPo1TnJhy2hn3AipUYyjuOo977UFMHG+i1MFNk0J9KZLfxyU3x QVfA== X-Gm-Message-State: AEkooutpo35V7Yqq9rShW40AfxZiQA2NJ2HMvFVCZXl0MDwnl5kQldwPijVWkzI3MznBzg== X-Received: by 10.66.127.38 with SMTP id nd6mr25121706pab.74.1470989979648; Fri, 12 Aug 2016 01:19:39 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id fj19sm10719046pab.37.2016.08.12.01.19.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Aug 2016 01:19:38 -0700 (PDT) From: Nicholas Piggin To: linux-arm-kernel@lists.infradead.org, Russell King Subject: [PATCH] arm: add an option for erratum 657417 Date: Fri, 12 Aug 2016 18:19:17 +1000 Message-Id: <1470989957-23671-1-git-send-email-npiggin@gmail.com> X-Mailer: git-send-email 2.8.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160812_012000_965330_7F7D473D X-CRM114-Status: GOOD ( 15.63 ) 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: Nicolas Pitre , linux-arch@vger.kernel.org, Segher Boessenkool , Arnd Bergmann , Alan Modra , linux-kbuild@vger.kernel.org, Nicholas Piggin , Julian Brown , Michal Marek , Stephen Rothwell , Sam Ravnborg 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 Erratum 657417 is worked around by the linker by inserting additional branch trampolines to avoid problematic branch target locations. This results in much higher linking time and presumably slower and larger generated code. The workaround also seems to only be required when linking thumb2 code, but the linker applies it for non-thumb2 code as well. The workaround today is left to the linker to apply, which is overly conservative. https://sourceware.org/ml/binutils/2009-05/msg00297.html This patch adds an option which defaults to "y" in cases where we could possibly be running Cortex A8 and using Thumb2 instructions. In reality the workaround might not be required at all for the kernel if virtual instruction memory is linear in physical memory. However it is more conservative to keep the workaround, and it may be the case that the TLB lookup would be required in order to catch branches to unmapped or no-execute pages. In an allyesconfig build, this workaround causes a large load on the linker's branch stub hash and slows down the final link by a factor of 5. Signed-off-by: Nicholas Piggin --- arch/arm/Kconfig | 14 ++++++++++++++ arch/arm/Makefile | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 90542db..3c7dde1 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1033,6 +1033,20 @@ config ARM_ERRATA_460075 ACTLR register. Note that setting specific bits in the ACTLR register may not be available in non-secure mode. +config ARM_ERRATA_657417 + bool "ARM errata: A 32-bit branch instruction that spans two 4K regions can result in an incorrect operation" + depends on CPU_V7 + depends on THUMB2_KERNEL + default y + help + This option enables the workaround for the 657417 Cortex-A8 erratum. + If, while executing code in Thumb or ThumbEE state, a 32-bit Thumb-2 + branch instruction is executed that spans two 4KB regions, and the + target address of the branch falls within the first region, it is + possible for the processor to behave incorrectly. This workaround + enables a linker workaround that adds branch trampolines that bounce + offending branches via a safe location. + config ARM_ERRATA_742230 bool "ARM errata: DMB operation may be faulty" depends on CPU_V7 && SMP diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 274e8a6..b49a2e0 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -43,6 +43,13 @@ ifeq ($(CONFIG_FRAME_POINTER),y) KBUILD_CFLAGS +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog endif +ifneq ($(CONFIG_ARM_ERRATA_657417),y) +# ld-option has to run before we override LD otherwise it fails on +# cross compile with mismatched endian (C compiler outputs one endian, +# LD accepts another) +LDFLAGS +=$(call ld-option, --no-fix-cortex-a8,) +endif + ifeq ($(CONFIG_CPU_BIG_ENDIAN),y) KBUILD_CPPFLAGS += -mbig-endian AS += -EB