From patchwork Fri Oct 2 13:24:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 54425 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 8BED6218EF for ; Fri, 2 Oct 2015 13:33:55 +0000 (UTC) Received: by lbbmp1 with SMTP id mp1sf16519095lbb.2 for ; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Jm0N3jqkaPPDeoUuzBo1QjLUSCvZmeXjYVVg9wQMLeI=; b=NnzG3WH/TzladeOaMHhXgwh5CPTZxlxnQpeDKbsZGwlSAHDSenZ0QSwHvJveyS/IuC N7XpmaWRYo6atekJFqwPObTS3Hb0U7v17qsVtT51NQpG2G62Es7NQrWUsvyR+3NWh6CT LppRExVmAONZIrW1Z8aHmrhXptioPqunzd1S+6yaXWOWmBfSbRC9oA4oY2kOXM/l5Nm9 st+TPAEVqKJoF/kF8Nu0+wLgjFMXHd0SSxVB6h4/uHCC/kJAD0U6OxD43TA4VIGLnKW3 95w0nXjqOm9VjL7LXJ4MFOvJ4Y5WRG/EJyJ3LRUddh8MbOSG6oQTw2YuFEvi0bhg5fqj Zp1g== X-Gm-Message-State: ALoCoQkZbDmBpNx6l9G/ZOHLdLmlxnh86t7ke2//0ZTl/JJkZS63/e/ltQ9hpHo6awFsnTRcRo6i X-Received: by 10.112.132.6 with SMTP id oq6mr2571178lbb.1.1443792834486; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.170.72 with SMTP id t69ls202622lfe.56.gmail; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) X-Received: by 10.25.82.79 with SMTP id g76mr3729057lfb.110.1443792834355; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id e136si6260171lfb.88.2015.10.02.06.33.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 06:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by laclj5 with SMTP id lj5so92576631lac.3 for ; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) X-Received: by 10.112.17.34 with SMTP id l2mr5552143lbd.117.1443792834066; Fri, 02 Oct 2015 06:33:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1248139lbq; Fri, 2 Oct 2015 06:33:52 -0700 (PDT) X-Received: by 10.107.134.24 with SMTP id i24mr16760212iod.162.1443792832169; Fri, 02 Oct 2015 06:33:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c30si8632402iod.155.2015.10.02.06.33.51; Fri, 02 Oct 2015 06:33:52 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753435AbbJBNdg (ORCPT + 30 others); Fri, 2 Oct 2015 09:33:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:39572 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753095AbbJBNZq (ORCPT ); Fri, 2 Oct 2015 09:25:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE930ACF3; Fri, 2 Oct 2015 13:25:44 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Will Deacon , Jiri Slaby Subject: [PATCH 3.12 41/84] arm64: errata: add module build workaround for erratum #843419 Date: Fri, 2 Oct 2015 15:24:46 +0200 Message-Id: <86230818ac7bb48f7821d9c41d96a1233c4535c3.1443792303.git.jslaby@suse.cz> X-Mailer: git-send-email 2.6.0 In-Reply-To: <4386f737d429451d61358f771e315ed47e2f451f.1443792303.git.jslaby@suse.cz> References: <4386f737d429451d61358f771e315ed47e2f451f.1443792303.git.jslaby@suse.cz> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Will Deacon 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit df057cc7b4fa59e9b55f07ffdb6c62bf02e99a00 upstream. Cortex-A53 processors <= r0p4 are affected by erratum #843419 which can lead to a memory access using an incorrect address in certain sequences headed by an ADRP instruction. There is a linker fix to generate veneers for ADRP instructions, but this doesn't work for kernel modules which are built as unlinked ELF objects. This patch adds a new config option for the erratum which, when enabled, builds kernel modules with the mcmodel=large flag. This uses absolute addressing for all kernel symbols, thereby removing the use of ADRP as a PC-relative form of addressing. The ADRP relocs are removed from the module loader so that we fail to load any potentially affected modules. Acked-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Jiri Slaby --- arch/arm64/Kconfig | 16 ++++++++++++++++ arch/arm64/Makefile | 4 ++++ arch/arm64/kernel/module.c | 2 ++ 3 files changed, 22 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b07f9f356b87..c6ab435557b2 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -269,6 +269,22 @@ config SYSVIPC_COMPAT def_bool y depends on COMPAT && SYSVIPC +config ARM64_ERRATUM_843419 + bool "Cortex-A53: 843419: A load or store might access an incorrect address" + depends on MODULES + default y + help + This option builds kernel modules using the large memory model in + order to avoid the use of the ADRP instruction, which can cause + a subsequent memory access to use an incorrect address on Cortex-A53 + parts up to r0p4. + + Note that the kernel itself must be linked with a version of ld + which fixes potentially affected ADRP instructions through the + use of veneers. + + If unsure, say Y. + endmenu source "net/Kconfig" diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index d90cf79f233a..4148c05df99a 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -28,6 +28,10 @@ comma = , CHECKFLAGS += -D__aarch64__ +ifeq ($(CONFIG_ARM64_ERRATUM_843419), y) +CFLAGS_MODULE += -mcmodel=large +endif + # Default value head-y := arch/arm64/kernel/head.o diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index ca0e3d55da99..9589a92f6332 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c @@ -390,12 +390,14 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, ovf = reloc_insn_imm(RELOC_OP_PREL, loc, val, 0, 21, INSN_IMM_ADR); break; +#ifndef CONFIG_ARM64_ERRATUM_843419 case R_AARCH64_ADR_PREL_PG_HI21_NC: overflow_check = false; case R_AARCH64_ADR_PREL_PG_HI21: ovf = reloc_insn_imm(RELOC_OP_PAGE, loc, val, 12, 21, INSN_IMM_ADR); break; +#endif case R_AARCH64_ADD_ABS_LO12_NC: case R_AARCH64_LDST8_ABS_LO12_NC: overflow_check = false;