From patchwork Thu Mar 10 12:37:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 63742 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp413080lbc; Thu, 10 Mar 2016 04:38:17 -0800 (PST) X-Received: by 10.67.23.161 with SMTP id ib1mr4423553pad.156.1457613497017; Thu, 10 Mar 2016 04:38:17 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c73si5818919pfj.246.2016.03.10.04.38.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Mar 2016 04:38:16 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-423042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-return-423042-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-423042-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=NxZY7PWn1q4RA95f3H 7o+YYwCggCtcb6f8UdjeJcB9ju5QzeyOXWYW3OOvX0QgeijVGmV6YtxNekmpBJ/I 08VFtSUZfm7tEI/8Q/6rl7WKOCBwHAXyuyQhhbtBuX33IhIQb7niH2ihlZn80iif dFU66mb2Yb+6BbgYY+bEC0plE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=0GUtYzAPtuvBej+nGH2HXp2X uBY=; b=a+U5E44FoXiGcgROq89aeTSTa7onAVJdlLwKTj/hCAI6KrJxb0Fh8N5J j3s7EOMc3FftSj1kLTLI3zljlQ5F1uI1vLfBgO2MmT5Cal/7V3WGubnTLpYzz+45 RfvwG19pmEPWU6mj/0INUkcCPWP9HS0B1NmsAaRZytqg4Q7VOms= Received: (qmail 77651 invoked by alias); 10 Mar 2016 12:37:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 77641 invoked by uid 89); 10 Mar 2016 12:37:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=calle, sk:AARCH64, Var, Init X-HELO: mail-qg0-f49.google.com Received: from mail-qg0-f49.google.com (HELO mail-qg0-f49.google.com) (209.85.192.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 10 Mar 2016 12:37:52 +0000 Received: by mail-qg0-f49.google.com with SMTP id y89so68593826qge.2 for ; Thu, 10 Mar 2016 04:37:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=p+Sa6wTJ6AxITtqg1ZShJA6PBM9N2xf1XE5urSKT6MY=; b=V7xjU/GbCBvvD23XhII5P3a2rqH4BWGsPIHGNgk7f5osnn8TGrl9/83RpWrjLZGVs1 lh6NVvYMw+jkRWzlDRwmyU7Zi3lJw9tLOvHnxSbr3QzOUbweKSYGkWOKkpa7krug2cy5 ly1G3b4sphk4aIObVDjFaSsOTIK5O7tnbtOdb57S3MO7PNm1B1a9fvpZYJhyAB0xz3hJ 9asRkjzK9pgqgMD7QP901X0+zfvoV/IsshDVEMzTazDM0t1qkZUj24mSYw7rS2+NKu05 Mfc+7wbg0snONfrLOXce5EmISfjS2UOc/wbTnTdjZ9Ki8ECVe9sMyrND8OtEmKhlO5ou U4gA== X-Gm-Message-State: AD7BkJI38SC1KW28TcvwpyFe5+uO1+UiJNlim2hbxmcg14CK4QH6sdISAm880HdookraU2tuWONH++RsVlolAWjV MIME-Version: 1.0 X-Received: by 10.140.22.139 with SMTP id 11mr3754870qgn.34.1457613470786; Thu, 10 Mar 2016 04:37:50 -0800 (PST) Received: by 10.140.22.164 with HTTP; Thu, 10 Mar 2016 04:37:50 -0800 (PST) In-Reply-To: <20160310114348.GB38000@arm.com> References: <20160310114348.GB38000@arm.com> Date: Thu, 10 Mar 2016 13:37:50 +0100 Message-ID: Subject: Re: [AArch64] Disable pcrelative_literal_loads with fix-cortex-a53-843419 From: Christophe Lyon To: James Greenhalgh Cc: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan X-IsSubscribed: yes On 10 March 2016 at 12:43, James Greenhalgh wrote: > On Tue, Jan 26, 2016 at 03:43:36PM +0100, Christophe Lyon wrote: >> With the attachment.... >> >> >> On 26 January 2016 at 15:42, Christophe Lyon wrote: >> > Hi, >> > >> > This is a followup to PR63304. >> > >> > As discussed in bugzilla, this patch disables pcrelative_literal_loads >> > when -mfix-cortex-a53-843419 (or its default configure option) is >> > used. >> > >> > I copied the behavior of -mfix-cortex-a53-835769 (e.g. in >> > aarch64_can_inline_p), and I have tested by building the Linux kernel >> > using -mfix-cortex-a53-843419 and checked that >> > R_AARCH64_ADR_PREL_PG_HI21 relocations are not emitted anymore (under >> > CONFIG_ARM64_ERRATUM_843419). >> > >> > For reference, this is motivated by: >> > https://bugs.linaro.org/show_bug.cgi?id=1994 >> > and further details on Launchpad: >> > https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1533009 >> > >> > OK for trunk? > > Thanks, this looks like a clear regression from GCC 5 (we can no longer > build the kernel, so this workaround is fine to go in now). Please remember > to add the link to the relevant PR in the ChangeLog. > > I'd also really appreciate a nice big comment over this code: > >> + /* If it is not set on the command line, we default to no pc >> + relative literal loads, unless the workaround for Cortex-A53 >> + erratum 843419 is in effect. */ >> + if (opts->x_nopcrelative_literal_loads == 2 >> + && !TARGET_FIX_ERR_A53_843419) > > Explaining why this is important (i.e. some summary of the discussion > in PR63304 regarding the kernel module loader). > > Can you repost with that comment added? I don't have any other objections > to the patch. > OK, here is an updated version. > Thanks, > James > > 2016-03-10 Christophe Lyon PR target/70113. * config/aarch64/aarch64.h (TARGET_FIX_ERR_A53_843419_DEFAULT): Always define to 0 or 1. (TARGET_FIX_ERR_A53_843419): New macro. * config/aarch64/aarch64-elf-raw.h (TARGET_FIX_ERR_A53_843419_DEFAULT): Update for above changes. * config/aarch64/aarch64-linux.h: Likewise. * config/aarch64/aarch64.c (aarch64_override_options_after_change_1): Do not default aarch64_nopcrelative_literal_loads to true if Cortex-A53 erratum 843419 is on. (aarch64_attributes): Handle fix-cortex-a53-843419. (aarch64_can_inline_p): Likewise. * config/aarch64/aarch64.opt (aarch64_fix_a53_err843419): Save. diff --git a/gcc/config/aarch64/aarch64-elf-raw.h b/gcc/config/aarch64/aarch64-elf-raw.h index 2dcb6d4..9097017 100644 --- a/gcc/config/aarch64/aarch64-elf-raw.h +++ b/gcc/config/aarch64/aarch64-elf-raw.h @@ -35,7 +35,7 @@ " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}" #endif -#ifdef TARGET_FIX_ERR_A53_843419_DEFAULT +#if TARGET_FIX_ERR_A53_843419_DEFAULT #define CA53_ERR_843419_SPEC \ " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}" #else diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h index 6064b26..5fcaa59 100644 --- a/gcc/config/aarch64/aarch64-linux.h +++ b/gcc/config/aarch64/aarch64-linux.h @@ -53,7 +53,7 @@ " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}" #endif -#ifdef TARGET_FIX_ERR_A53_843419_DEFAULT +#if TARGET_FIX_ERR_A53_843419_DEFAULT #define CA53_ERR_843419_SPEC \ " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}" #else diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 801f95a..51dfe79 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -8132,9 +8132,18 @@ aarch64_override_options_after_change_1 (struct gcc_options *opts) if (opts->x_nopcrelative_literal_loads == 1) aarch64_nopcrelative_literal_loads = false; - /* If it is not set on the command line, we default to no - pc relative literal loads. */ - if (opts->x_nopcrelative_literal_loads == 2) + /* If it is not set on the command line, we default to no pc + relative literal loads, unless the workaround for Cortex-A53 + erratum 843419 is in effect. */ + /* This is PR70113. When building the Linux kernel with + CONFIG_ARM64_ERRATUM_843419, support for relocations + R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADR_PREL_PG_HI21_NC is + removed from the kernel to avoid loading objects with possibly + offending sequences. With nopcrelative_literal_loads, we would + generate such relocations, preventing the kernel build from + succeeding. */ + if (opts->x_nopcrelative_literal_loads == 2 + && !TARGET_FIX_ERR_A53_843419) aarch64_nopcrelative_literal_loads = true; /* In the tiny memory model it makes no sense @@ -8818,6 +8827,8 @@ static const struct aarch64_attribute_info aarch64_attributes[] = OPT_mgeneral_regs_only }, { "fix-cortex-a53-835769", aarch64_attr_bool, true, NULL, OPT_mfix_cortex_a53_835769 }, + { "fix-cortex-a53-843419", aarch64_attr_bool, true, NULL, + OPT_mfix_cortex_a53_843419 }, { "cmodel", aarch64_attr_enum, false, NULL, OPT_mcmodel_ }, { "strict-align", aarch64_attr_mask, false, NULL, OPT_mstrict_align }, { "omit-leaf-frame-pointer", aarch64_attr_bool, true, NULL, @@ -9232,6 +9243,12 @@ aarch64_can_inline_p (tree caller, tree callee) 2, TARGET_FIX_ERR_A53_835769_DEFAULT)) return false; + if (!aarch64_tribools_ok_for_inlining_p ( + caller_opts->x_aarch64_fix_a53_err843419, + callee_opts->x_aarch64_fix_a53_err843419, + 2, TARGET_FIX_ERR_A53_843419)) + return false; + /* If the user explicitly specified -momit-leaf-frame-pointer for the caller and calle and they don't match up, reject inlining. */ if (!aarch64_tribools_ok_for_inlining_p ( diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 8b463c9..ec96ce3 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -179,6 +179,20 @@ extern unsigned aarch64_architecture_version; ((aarch64_fix_a53_err835769 == 2) \ ? TARGET_FIX_ERR_A53_835769_DEFAULT : aarch64_fix_a53_err835769) +/* Make sure this is always defined so we don't have to check for ifdefs + but rather use normal ifs. */ +#ifndef TARGET_FIX_ERR_A53_843419_DEFAULT +#define TARGET_FIX_ERR_A53_843419_DEFAULT 0 +#else +#undef TARGET_FIX_ERR_A53_843419_DEFAULT +#define TARGET_FIX_ERR_A53_843419_DEFAULT 1 +#endif + +/* Apply the workaround for Cortex-A53 erratum 843419. */ +#define TARGET_FIX_ERR_A53_843419 \ + ((aarch64_fix_a53_err843419 == 2) \ + ? TARGET_FIX_ERR_A53_843419_DEFAULT : aarch64_fix_a53_err843419) + /* ARMv8.1 Adv.SIMD support. */ #define TARGET_SIMD_RDMA (TARGET_SIMD && AARCH64_ISA_RDMA) diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index 49ef0c6..c637ff4 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -73,7 +73,7 @@ Target Report Var(aarch64_fix_a53_err835769) Init(2) Save Workaround for ARM Cortex-A53 Erratum number 835769. mfix-cortex-a53-843419 -Target Report +Target Report Var(aarch64_fix_a53_err843419) Init(2) Save Workaround for ARM Cortex-A53 Erratum number 843419. mlittle-endian