From patchwork Tue May 22 21:04:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omair Javaid X-Patchwork-Id: 136605 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp79129lji; Tue, 22 May 2018 14:06:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpjJtdtpPHnZjjxKw8NEpZKYulwUMsagGJCADZjIhWsJ1dXCZhSptR37DPIOP69+stf8UKh X-Received: by 2002:a65:65ce:: with SMTP id y14-v6mr73314pgv.270.1527023207960; Tue, 22 May 2018 14:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527023207; cv=none; d=google.com; s=arc-20160816; b=p4kiGZVHAuHAkXkeaNQJGrFS4pwE0KLtFoNbIYh4LtOoiAj+tHBruMerFwrNKXFWGU A6+6bxrnRklmQcqEu38jGIifCVe55fGds7Blqj2sosGkCO/febPGbgyzOQ76/5vgjjNe JtG2weT0GCKmuSUKyQ4W82SlD6pjgMcPuKMKvoCvCgX/7DJC0Q2kMPOwKlpSgbbhsh4p 9/VNMRnxOcdBEURB5RulHW8557/4KiNIKQcL+uIbmlaC1v8riAEb/jRfq0Tpiq//JxEX GcDLD6H85QKwJC/ufn8jYzFWoLG2730ORuEkY4DdedU0U+q/H6GXAf70g8GfmF9U2EDF wwzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from: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=DWfmwY46cXmWdhot3P6nkATC1YDouojfsUt+ZXPBuOw=; b=lUNXHY252iXiXGw1XZvJjhJYIvYmjmT8N1gYTj/Qa7t9fNoBLqLbVTNSGGjL4kmDZu QjBDOuKftvLS2BShqYQ6G2HewVNefnGGH0aK10yWDE59jOrDnoszwlSqshmaJ20pfKQG 9/PxGJ9xcWk7wnTz540xnoB2LoHDCUXkUlp7qzKYuLwByMwUrpSVBU0tUrndms6xinyt 7iVs8C/meGVAtPamDAjrnqFMcbBPdgYP+RScpIeZxic1sN+pxp62PoHHGeWduszMTi03 wixfRJThrqzIWBBYPZ/pVxMqsi0eYr+x6nwsas7t0fFYbOyMt0oBErBnP8OASSuzg/H0 bz8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pMJ/1WSr; spf=pass (google.com: domain of gdb-patches-return-147548-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-147548-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 64-v6si611286plk.33.2018.05.22.14.06.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 14:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-147548-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=pMJ/1WSr; spf=pass (google.com: domain of gdb-patches-return-147548-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gdb-patches-return-147548-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:from:to:cc:subject:date:message-id; q=dns; s= default; b=Ku0am3aZOZvU6B2NwvmaxO/+yOCJ6bz5md1iMcX1Q3yZVvut5JTwY dbLqbJdz6AGf+bC1rfsmjwk1AWNOKvjg2dBzcHUTDT8jMZxeHpig7/c19L2t+ver 6VY5XxhjI0JJaT/zwvc/14s+ztusRE4fx30vneOP8O7uEiyyDO7nu4= 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:from:to:cc:subject:date:message-id; s=default; bh=BUTREp24G+ITlMgGt2kH/39eNv8=; b=pMJ/1WSrgtUTUB7OQ0SfsJU7+eGF 40xnRn2v1N0qCvfexoLiiM9alF3JcdwFozHJQBdGndJl0frl1LI36mBKRa4mALt4 9oZPGfims7bnUV9bQyTpPt0jebBKUcXSFf/8Xxx88SxFZvhJrhwjIH6zzUqnuMrJ VIa6DhHkM2PD/Zc= Received: (qmail 46397 invoked by alias); 22 May 2018 21:06:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 46366 invoked by uid 89); 22 May 2018 21:06:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=23210, gdbarch.c, Hx-languages-length:2419, gdbarchc X-HELO: mail-wr0-f179.google.com Received: from mail-wr0-f179.google.com (HELO mail-wr0-f179.google.com) (209.85.128.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 May 2018 21:06:38 +0000 Received: by mail-wr0-f179.google.com with SMTP id 94-v6so22598909wrf.5 for ; Tue, 22 May 2018 14:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DWfmwY46cXmWdhot3P6nkATC1YDouojfsUt+ZXPBuOw=; b=IuHT8ae3/zOB5JQPhPAa2ta6PaFMG/nLq477aI99+Ly05fA0OLB67PDI+Z093TAIZP iZPMyEoF1F/4Dv996zKpNxSR53XxAkTSraNjUv2XLOv90hGFSWAos+KixxdFn3iaRiXz o9Ag083HwM+ywm8XbOWNQz1v95D7a+TgCXbk0sS3H0ceo35DjF+hLNp67IRr4hfrPtkg 1YuCA0UBF9qCVQJLbsDi6XtzvjwRgjOCtjsQ4U1DnrYUr5twWuM7wP10xSSPRDabbbnn D85l5jKAp9HzVHuQK1Ioefv8OTirkli806ZKhw5NAQ2IEfr91GSaykNb6CLLA5WUJpmR wxiA== X-Gm-Message-State: ALKqPwdOrbgdKDRWt1JRSBF0OQbwvhvrGxz+MlEDeo9Dwzaa5UupS7hp L2GH5NTFr8Ie2o+BKeqYkJXyH9z18Hc= X-Received: by 2002:adf:8406:: with SMTP id 6-v6mr52794wrf.105.1527023196286; Tue, 22 May 2018 14:06:36 -0700 (PDT) Received: from localhost.localdomain ([119.152.132.180]) by smtp.gmail.com with ESMTPSA id 187-v6sm967245wmu.41.2018.05.22.14.06.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 May 2018 14:06:35 -0700 (PDT) From: Omair Javaid To: gdb-patches@sourceware.org Cc: Omair Javaid Subject: [PATCH] [PR gdb/23210] Unset gdbarch significant_addr_bit by default Date: Wed, 23 May 2018 02:04:48 +0500 Message-Id: <1527023088-10837-1-git-send-email-omair.javaid@linaro.org> X-IsSubscribed: yes This patch fixes a bug introduced by fix to AArch64 pointer tagging. In our fix for tagged pointer support our agreed approach was to sign extend user-space address after clearing tag bits. This is not same for all architectures and this patch allows sign extension for addresses on targets which specifically set significant_addr_bit. More information about patch that caused the issues and discussion around tagged pointer support can be found in links below: https://sourceware.org/ml/gdb-patches/2018-05/msg00000.html https://sourceware.org/ml/gdb-patches/2017-12/msg00159.html gdb/ChangeLog: 2018-05-23 Omair Javaid * gdbarch.c (verify_gdbarch): Update. * utils.c (address_significant): Update. --- gdb/gdbarch.c | 3 +-- gdb/utils.c | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index c430ebe..5593911 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -615,8 +615,7 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of stabs_argument_has_addr, invalid_p == 0 */ /* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */ /* Skip verify of addr_bits_remove, invalid_p == 0 */ - if (gdbarch->significant_addr_bit == 0) - gdbarch->significant_addr_bit = gdbarch_addr_bit (gdbarch); + /* Skip verify of significant_addr_bit, invalid_p == 0 */ /* Skip verify of software_single_step, has predicate. */ /* Skip verify of single_step_through_delay, has predicate. */ /* Skip verify of print_insn, invalid_p == 0 */ diff --git a/gdb/utils.c b/gdb/utils.c index 9c5bf68..91c0f2b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2708,10 +2708,11 @@ address_significant (gdbarch *gdbarch, CORE_ADDR addr) /* Clear insignificant bits of a target address and sign extend resulting address, avoiding shifts larger or equal than the width of a CORE_ADDR. The local variable ADDR_BIT stops the compiler reporting a shift overflow - when it won't occur. */ + when it won't occur. Skip updating of target address if current target has + not set gdbarch significant_addr_bit. */ int addr_bit = gdbarch_significant_addr_bit (gdbarch); - if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) + if (addr_bit && (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))) { CORE_ADDR sign = (CORE_ADDR) 1 << (addr_bit - 1); addr &= ((CORE_ADDR) 1 << addr_bit) - 1;