Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Alan Hayward <Alan.Hayward@arm.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>
Subject: Re: [PATCH v2 2/8] AArch64: Use HWCAP to detect pauth feature
Date: Thu, 21 Mar 2019 20:51:00 -0000	[thread overview]
Message-ID: <d3f29903-dbed-f63e-4c62-33d644cf7617@simark.ca> (raw)
In-Reply-To: <20190306133325.2531-3-alan.hayward@arm.com>

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  <alan.hayward@arm.com>
> 	    Jiong Wang  <jiong.wang@arm.com>
> 
> 	* 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  <alan.hayward@arm.com>
> 	    Jiong Wang  <jiong.wang@arm.com>
> 
> 	* 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


  reply	other threads:[~2019-03-21 20:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-06 13:33 [PATCH v2 0/8] Support for AArch64 Pointer Authentication Alan Hayward
2019-03-06 13:33 ` [PATCH v2 1/8] AArch64: Add pointer authentication feature Alan Hayward
2019-03-06 15:36   ` Eli Zaretskii
2019-03-06 13:33 ` [PATCH v2 3/8] AArch64: Read pauth registers Alan Hayward
2019-03-21 20:56   ` Simon Marchi
2019-03-06 13:33 ` [PATCH v2 4/8] AArch64: gdbserver: read " Alan Hayward
2019-03-21 21:03   ` Simon Marchi
2019-03-06 13:33 ` [PATCH v2 6/8] AArch64: DWARF unwinder support for signed return addresses Alan Hayward
2019-03-06 13:33 ` [PATCH v2 8/8] AArch64: Read pauth section from core files Alan Hayward
2019-03-06 13:33 ` [PATCH v2 2/8] AArch64: Use HWCAP to detect pauth feature Alan Hayward
2019-03-21 20:51   ` Simon Marchi [this message]
2019-03-22 12:06     ` Alan Hayward
2019-03-06 13:33 ` [PATCH v2 7/8] AArch64: Prologue scan unwinder support for signed return addresses Alan Hayward
2019-03-06 13:33 ` [PATCH v2 5/8] AArch64: Add pauth DWARF registers Alan Hayward
2019-03-14 12:34 ` [PATCH v2 0/8] Support for AArch64 Pointer Authentication Alan Hayward
2019-03-21 21:29   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3f29903-dbed-f63e-4c62-33d644cf7617@simark.ca \
    --to=simark@simark.ca \
    --cc=Alan.Hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox