From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102796 invoked by alias); 19 Jan 2017 20:56:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 102785 invoked by uid 89); 19 Jan 2017 20:56:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Cook, noticeably, needless, cook X-HELO: mail-pf0-f182.google.com Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Jan 2017 20:56:47 +0000 Received: by mail-pf0-f182.google.com with SMTP id f144so16189725pfa.2 for ; Thu, 19 Jan 2017 12:56:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=/qcWB3hb4Uea9Ma+T6CX7GBjvpxDAE9N6B1dYwpfZ/g=; b=JM6/N73D1XcHkhmvgcVsF7NXPs988GVQ+/7ZdrgKNo6ZoA1XU6VjicJqFB/4nxeICW /u9pBQMfQp5t/+jJTWLKPWxc2rhozDuZPA+J9ezqqM7kQCodRKBZNCz2RZ/dh8ZOcJ2V tXMs5o4+EK8mcp6A8m0atkZ/xVIeNRSjFrPCKj1DOqCupZ/4PDDgikVZEb3qY0O7S40w 8JTA/dO117vtx/mWYN1D49+eCIefk+fgCMin+qImoeUpWgrFnBD6Zad+SaQBjvXZekFu ziSEHVnSa1fzXt4HkHIpLp6D7j74RyOTTwDHT6lDePoJ2apYf+gJZkypuw53b7Hi4Z3K p16w== X-Gm-Message-State: AIkVDXLkkG4mQqvisq7IXs4b0r77S4l+dPctm2+69afPThhAdLAvwkj7Gc5+GwJ5rlBTIVdi X-Received: by 10.84.232.10 with SMTP id h10mr16061858plk.121.1484859406380; Thu, 19 Jan 2017 12:56:46 -0800 (PST) Received: from www.outflux.net ([2002:ada4:7085:0:f1e5:684a:7a:ece2]) by smtp.gmail.com with ESMTPSA id a25sm11022809pgd.26.2017.01.19.12.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 12:56:45 -0800 (PST) Date: Thu, 19 Jan 2017 20:56:00 -0000 From: Kees Cook To: gdb-patches@sourceware.org Cc: Yao Qi , Doug Evans , brian.murray@canonical.com, matthias.klose@canonical.com Subject: [PATCH v2] Fix PTRACE_GETREGSET failure for compat inferiors on arm64 Message-ID: <20170119205644.GA86795@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-SW-Source: 2017-01/txt/msg00396.txt.bz2 When running a 32-bit ARM inferior with a 32-bit ARM GDB on a 64-bit AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA registers (NT_PRFPREG) are not available so GDB must not request them, as this will fail with -EINVAL. This is most noticeably exposed when running "generate-core-file": (gdb) generate-core-file myprog.core Unable to fetch the floating point registers.: Invalid argument. ptrace(PTRACE_GETREGSET, 27642, NT_FPREGSET, 0xffcc67f0) = -1 EINVAL (Invalid argument) gdb/ChangeLog: 2016-12-19 Kees Cook * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float. --- v2: - check have_fpa_registers instead, dropped needless other change: qiyaoltc --- gdb/arm-linux-nat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index d11bdc6..12a3fa9 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -384,17 +384,19 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops, if (-1 == regno) { fetch_regs (regcache); - fetch_fpregs (regcache); if (tdep->have_wmmx_registers) fetch_wmmx_regs (regcache); if (tdep->vfp_register_count > 0) fetch_vfp_regs (regcache); + if (tdep->have_fpa_registers) + fetch_fpregs (regcache); } - else + else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) fetch_regs (regcache); - else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) + else if (tdep->vfp_register_count == 0 + && regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) fetch_fpregs (regcache); else if (tdep->have_wmmx_registers && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM) @@ -420,11 +422,12 @@ arm_linux_store_inferior_registers (struct target_ops *ops, if (-1 == regno) { store_regs (regcache); - store_fpregs (regcache); if (tdep->have_wmmx_registers) store_wmmx_regs (regcache); if (tdep->vfp_register_count > 0) store_vfp_regs (regcache); + if (tdep->have_fpa_registers) + store_fpregs (regcache); } else { -- 2.7.4 -- Kees Cook Nexus Security