From patchwork Thu Nov 30 11:36:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Smith X-Patchwork-Id: 120138 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp548143qgn; Thu, 30 Nov 2017 03:36:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMZt7zr+DCya7pibQ0ms+cy/eIVz1Gqtg7vbNCNHwiLe/eSOztR4SQvtIAjNxuWUMP8ZVjvo X-Received: by 10.101.72.193 with SMTP id o1mr2089075pgs.197.1512041792943; Thu, 30 Nov 2017 03:36:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512041792; cv=none; d=google.com; s=arc-20160816; b=h1ly2tan7DZET9fxTuJ5cLwoQKI/W6+VIqMo9ZP3s0bopVBR8zpLpXlN6dv1Btqk40 6GMcq6xRo5MNjUaS3anCZ8aJGYmZ4Jbp0ZKX1UTXUHomurg+WHInDeu1NkUOxxFmZLj5 H2j4szH0HWMJu7yyS/SPdt4VziUhwys+cNe/li3rOWpig/PC7K8A83Gv343b6fNQg5VV JJ4LJsuBEhVW9jUL41aiGJiPeqNWkdY684BAvyR7WdN+Z36DK7mHYVusJ+Yl8AdYI6qV m+uWiYgmcGTAl3xF8aGDnQReJyrt9EJeFQM70k1mTvi/F14MbUZ5CgsTemrE7RbTNtgD YVmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=8R8AJGgNhcPkw8qhoLduoC0pxNuBo40a6LyTLE5IZs4=; b=OStTJA24E94DsmD2/W7TOw4UPisSkbS4ic6kvrPbAt0nj7jDfGlsZYiVeucJYJ0NSv x2XEA2stRVFsYWBk9DGArxTlIaQvOyw2Rsj49XxsSBX/hdlPi6twA0cQdWA8ZGT7RdSk N5rGsSa5QbJbd1t9nrxfdn7Gmy4NYR3S1eMmvBFS2TSNnY/trc58ilUpvOR0O+5nOGE1 RA6UYFSF60OkL1H576xq4UZIfLe1tz3F6iIqegK0357S89hg5B0Y6+glP/vcbThXSxY6 bzxMKKUTATPm/KZboIZtL2gR3ToaNaZttjBAQ42h23xW3vn8uJ4iwqcivoTxxJA7RB8N g5sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=c+QlvayM; spf=pass (google.com: domain of binutils-return-99612-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-99612-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g12si3010440plj.261.2017.11.30.03.36.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 03:36:32 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-return-99612-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=c+QlvayM; spf=pass (google.com: domain of binutils-return-99612-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=binutils-return-99612-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=QjI0V8iCaYinj5h2+aG+FM5JwMgAd 39veVsw8MUQ6u8qNemn/oCZtIoNYDvm3AuFUjRbDci/4Y0V2rSzDZ1x4YbA8Iq2T 3p/Je1FBUKY1AIBagrXVV0xRc0kIJHJPa/2P3lnwiu3OEkMXXFVfxEHY2srohf6d Z2uoE/2qWn7MWI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=gYqB3l6/QZX0D9U8sUOc3nCDV1Q=; b=c+Q lvayM5GQ9SajTqBeobQCT1VHw98cnfNnBGiRjfL1+aN11eesIJygOKvhK/bXqxEh M08+f3dkYUyJttCs8dEzdLUJ/qU/ughvjL1IY/DS6MzwSWjvN0TyV12YOZy+VGRe b0pvMR4RakL/tRzBDsjk04KjQwONaCKclVrGiSa4= Received: (qmail 99739 invoked by alias); 30 Nov 2017 11:36:20 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 99728 invoked by uid 89); 30 Nov 2017 11:36:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Nov 2017 11:36:17 +0000 Received: by mail-wm0-f43.google.com with SMTP id b76so11844813wmg.1 for ; Thu, 30 Nov 2017 03:36:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=qE6EIS0xvE0UUXLYd1AMElg3ZaBDQJrQR3MXQA1v9jo=; b=HNKI5KJA60Q8Nu25n3ofgWHWTXWLRu1zOgZqfgE8fSF/Sj8CxoM1SFQuRJniQItiHu 9P2MF/lq+l9JTDyOdU6Uk1hW1hIX68QdbQlBMXrA3xYirbg22brXt4ei5gt8OIIr1Faw 6gdAGx1pAVw2jB6o+AiBZ4odpju97DHYGxu9yhEQiWlHAP/UKrM0tzdBaYb1yd0qh4SF a/KT3n1VRcjfNFDDudaNin3+NKGJb+SXRzLPL/gB5p8mpqPnPU3vAhwjRQLthgwf1cl0 gxKCtMLntEU7RP+x3kefVcvhZCXAYBbGFfDPDOb0jJZ282wkw8Ta5Rwv/xD3ISaLsdBe Nzvg== X-Gm-Message-State: AJaThX4ojgbfHPWe2GfutOjPJ/etuJM5HVMZqQynSJBHuax8QGvAUhh+ RVEsJIfOmvZFypfZrZgd5kmjhg0X0M2VeyCE8rpCmDw3X/I= X-Received: by 10.28.216.212 with SMTP id p203mr346878wmg.50.1512041774919; Thu, 30 Nov 2017 03:36:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.156.202 with HTTP; Thu, 30 Nov 2017 03:36:14 -0800 (PST) From: Peter Smith Date: Thu, 30 Nov 2017 11:36:14 +0000 Message-ID: Subject: [PATCH][GOLD] gold aarch64 erratum stubs are created but not always applied To: binutils@sourceware.org Hello, As a result of looking into fixing https://sourceware.org/bugzilla/show_bug.cgi?id=20765 I checked over the results of applying --fix-cortex-a53-843419 to a very large program (gitit) with two stub tables and thousands of erratum fixes. I noticed that all the erratum_stubs were being created but about 1/3 of them were being skipped over by fix_errata_and_relocate_erratum_stubs(). By skipped over I mean no branch relocation or adrp -> adr transformation was applied to the erratum address, leaving the erratum_stub unreachable, and with a branch with a 0 immediate. The root cause of the skipped over erratum_stubs is Erratum_stub::invalidate_erratum_stub() that is used to set relobj_ to NULL when an erratum_stub has been processed. Unfortunately relobj_ is used in operator<() so altering relobj makes the results from erratum_stubs_.lower_bound() as used in find_erratum_stubs_for_input_section() unreliable. I've proposed a simple fix that adds a new field that can be used in Erratum_stub::invalidate_erratum_stub(). This preserves the order relied upon by erratum_stubs_.lower_bound(). In theory this could hit any program with more than one relobj needing erratum stubs, but in practice I think most small programs will get away with it. The larger the program the greater the chance that erratum_stubs_.lower_bound() incorrectly reporting 0 stubs found for an input section. This bug will be undetectable on hardware that doesn't exhibit the erratum, but it may result on the erratum triggering on faulty hardware even when --fix-cortex-a53-843419 is used. Peter diff --git a/gold/aarch64.cc b/gold/aarch64.cc index 74c411d..2e03127 100644 --- a/gold/aarch64.cc +++ b/gold/aarch64.cc @@ -953,7 +953,7 @@ public: : Stub_base(type), relobj_(relobj), shndx_(shndx), sh_offset_(sh_offset), erratum_insn_(invalid_insn), - erratum_address_(this->invalid_address) + erratum_address_(this->invalid_address), valid_(true) {} ~Erratum_stub() {} @@ -1064,13 +1064,13 @@ public: void invalidate_erratum_stub() { - gold_assert(this->relobj_ != NULL); - this->relobj_ = NULL; + gold_assert(this->valid_ == true); + this->valid_ = false; } bool is_invalidated_erratum_stub() - { return this->relobj_ == NULL; } + { return this->valid_ == false; } protected: virtual void @@ -1087,6 +1087,8 @@ private: Insntype erratum_insn_; // The address of the above insn. AArch64_address erratum_address_; + // After the erratum stub has been fully processed valid_ will be false + bool valid_; }; // End of "Erratum_stub".