From patchwork Fri Sep 25 12:00:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 54159 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 82C3F22B1E for ; Fri, 25 Sep 2015 12:01:03 +0000 (UTC) Received: by wisv5 with SMTP id v5sf6940021wis.0 for ; Fri, 25 Sep 2015 05:01:02 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=pJBGLjtfZdonMEbmEqo9cFmg3TYt11ZxrnU2lUd1YSQ=; b=hO1zwIuM3EHbrQrq9zdAMmj0ApgrRLbSQcYqUdDIJaPYLfInW/IDQ61D/Pox3l/KDD LCKS9bTvET2VVvSUzz8xRfWOycApcwFL6Bc2PpRV/jEHxGjuKt2p/yIPwx6wHFflMhEB 7nMPDVvsH4/WqmThcoiH5OMOHURiTQ2X3tUAYnIveEvbLhWStqi3/edagttfQyjZxO6W kUy7IefRUWgMQcKnv1P9ZSGKcdaw5xCvf7SVpxV+hVPfWav8pXv+XkpP8geJe9QC6oWK Bbc1wWJHE6KnL/qLk789pe9kKOhVl8Y9qHVb5GCz1dHLQ8tnc7S9AQoL/fGtawdsz+IX xvEg== X-Gm-Message-State: ALoCoQkB20L0TgKdF+RtB6oYi8SKtN/kHhk5m2rmtcOVWb8h4+N39tsQx+N9j/6IWVISqnXYqsaU X-Received: by 10.180.72.68 with SMTP id b4mr442627wiv.2.1443182462877; Fri, 25 Sep 2015 05:01:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.20.65 with SMTP id k62ls205850lfi.16.gmail; Fri, 25 Sep 2015 05:01:02 -0700 (PDT) X-Received: by 10.25.210.206 with SMTP id j197mr1025577lfg.86.1443182462754; Fri, 25 Sep 2015 05:01:02 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id s62si1566190lfd.169.2015.09.25.05.01.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2015 05:01:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lacdq2 with SMTP id dq2so40397632lac.1 for ; Fri, 25 Sep 2015 05:01:02 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr1560057lbb.35.1443182462473; Fri, 25 Sep 2015 05:01:02 -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 w3csp902950lbq; Fri, 25 Sep 2015 05:01:01 -0700 (PDT) X-Received: by 10.68.218.104 with SMTP id pf8mr6692012pbc.31.1443182442039; Fri, 25 Sep 2015 05:00:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wn10si5223050pab.97.2015.09.25.05.00.41; Fri, 25 Sep 2015 05:00:42 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755941AbbIYMAk (ORCPT + 1 other); Fri, 25 Sep 2015 08:00:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:56690 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755944AbbIYMAh (ORCPT ); Fri, 25 Sep 2015 08:00:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CBC65AD11; Fri, 25 Sep 2015 12:00:35 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: Will Deacon , Jiri Slaby Subject: [patch added to the 3.12 stable tree] arm64: errata: add module build workaround for erratum #843419 Date: Fri, 25 Sep 2015 14:00:22 +0200 Message-Id: <1443182432-19692-8-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1443182432-19692-1-git-send-email-jslaby@suse.cz> References: <1443182432-19692-1-git-send-email-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.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.49 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 This patch has been added to the 3.12 stable tree. If you have any objections, please let us 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;