From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121111 invoked by alias); 21 Mar 2019 20:51:00 -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 121100 invoked by uid 89); 21 Mar 2019 20:51:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=Wang, hc X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Mar 2019 20:50:58 +0000 Received: from [172.16.0.89] (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 56A2D1E4F4; Thu, 21 Mar 2019 16:50:56 -0400 (EDT) Subject: Re: [PATCH v2 2/8] AArch64: Use HWCAP to detect pauth feature To: Alan Hayward , "gdb-patches@sourceware.org" Cc: nd References: <20190306133325.2531-1-alan.hayward@arm.com> <20190306133325.2531-3-alan.hayward@arm.com> From: Simon Marchi Message-ID: Date: Thu, 21 Mar 2019 20:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190306133325.2531-3-alan.hayward@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2019-03/txt/msg00471.txt.bz2 On 2019-03-06 8:33 a.m., Alan Hayward wrote: > Add aarch64_get_hwcap functions for reading the HWCAP. > From this extract the PACA value and use this to enable pauth. > > gdb/ChangeLog: > > 2019-03-06 Alan Hayward > Jiong Wang > > * aarch64-linux-nat.c > (aarch64_linux_nat_target::read_description): Read PACA hwcap. > * aarch64-linux-tdep.c > (aarch64_linux_core_read_description): Likewise. > (aarch64_linux_get_hwcap): New function. > * aarch64-linux-tdep.h (AARCH64_HWCAP_PACA): New define. > (aarch64_linux_get_hwcap): New declaration. > > gdb/gdbserver/ChangeLog: > > 2019-03-06 Alan Hayward > Jiong Wang > > * linux-aarch64-low.c (AARCH64_HWCAP_PACA): New define. > (aarch64_get_hwcap): New function. > (aarch64_arch_setup): Read APIA hwcap. > --- > gdb/aarch64-linux-nat.c | 7 +++++-- > gdb/aarch64-linux-tdep.c | 16 +++++++++++---- > gdb/aarch64-linux-tdep.h | 6 ++++++ > gdb/gdbserver/linux-aarch64-low.c | 33 +++++++++++++++++++++++++++++-- > 4 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > index f58a41e195..8a7006165e 100644 > --- a/gdb/aarch64-linux-nat.c > +++ b/gdb/aarch64-linux-nat.c > @@ -606,8 +606,11 @@ aarch64_linux_nat_target::read_description () > if (ret == 0) > return tdesc_arm_with_neon; > > - /* pauth not yet supported. */ > - return aarch64_read_description (aarch64_sve_get_vq (tid), false); > + CORE_ADDR hwcap = 0; > + bool pauth_p = aarch64_linux_get_hwcap (&hwcap) > + && (hwcap & AARCH64_HWCAP_PACA); > + > + return aarch64_read_description (aarch64_sve_get_vq (tid), pauth_p); > } > > /* Convert a native/host siginfo object, into/from the siginfo in the > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index 445019accc..5eeafa456c 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -637,12 +637,11 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, > { > CORE_ADDR aarch64_hwcap = 0; > > - if (target_auxv_search (target, AT_HWCAP, &aarch64_hwcap) != 1) > - return NULL; > + if (!aarch64_linux_get_hwcap (&aarch64_hwcap)) > + return nullptr; > > - /* pauth not yet supported. */ > return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd), > - false); > + aarch64_hwcap & AARCH64_HWCAP_PACA); > } > > /* Implementation of `gdbarch_stap_is_single_operand', as defined in > @@ -1420,6 +1419,15 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch) > return NULL; > } > > +/* See aarch64-linux-tdep.h. */ > + > +bool > +aarch64_linux_get_hwcap (CORE_ADDR *hwcap) > +{ > + *hwcap = 0; > + return target_auxv_search (current_top_target (), AT_HWCAP, hwcap) == 1; > +} > + I don't know if it actually matters, but when the target_aux_search call was in aarch64_linux_core_read_description, it used the TARGET parameter, rather than using current_top_target. So, perhaps that new function should take a target_ops parameter and use it? The other call in aarch64_linux_nat_target::read_description would pass "this". And this function does nothing AArch64-specific, so I think it would be nice to have it in linux-tdep.{h,c} and update other arches to use it. But I would say, don't bother with that in this series, we can do it after. Simon