Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Klaus Gerlicher <klaus.gerlicher@intel.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] aarch64: fix a crash during maintenance print cooked-registers
Date: Mon, 3 Feb 2025 14:27:45 +0000	[thread overview]
Message-ID: <b40b1e93-5326-4e8a-aa0d-fdcab9e3f2a9@arm.com> (raw)
In-Reply-To: <20250203135240.1030561-1-klaus.gerlicher@intel.com>

Hi,

On 2/3/25 13:52, Klaus Gerlicher wrote:
> Hi all, Luis,
> 
> I found this accidently while looking at Thiago's GDBserver improvements. Luis
> I think added the pseudo register in question, so maybe he can comment
> on this issue. I used a aarch64 qemu 9.2.

Thanks for catching this.

> 
> Thanks
> Klaus
> 
> On aarch64 with pauth enabled I can see a crash when
> using "maintenance print cooked-registers".
> 
> This happens because the register dump code tries to read
> a pseudo reg that is not handled here because it is supposedly
> only used in unwinding.

Indeed. ra_sign_state is only used to track which frames have PAC enabled or not.

I was wondering why I had not caught this before, and I just noticed my VM had pauth disabled. :-(

Enabling it, now I see the crash. In any case...

> 
> Fix this by returning a zero value typed as a built-in uint64.
> ---
>  gdb/aarch64-tdep.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
> index 840f9877361..6e712b12b86 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -3290,6 +3290,9 @@ aarch64_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame,
>      return aarch64_pseudo_read_value_1 (next_frame, pseudo_reg_num,
>  					pseudo_offset - AARCH64_SVE_V0_REGNUM);
>  
> +  if (tdep->has_pauth () && pseudo_reg_num == tdep->ra_sign_state_regnum)
> +    return value::zero (builtin_type (gdbarch)->builtin_uint64, lval_register);
> +
>    gdb_assert_not_reached ("regnum out of bound");
>  }
>  

... the fix above looks OK to me. Though it makes me wonder why we starting hitting this.

Internally we don't assign a name to this register so it technically doesn't show up in any
listing. Maybe something changed and we now list even pseudo registers without a name?

Approved-By: Luis Machado <luis.machado@arm.com>

  reply	other threads:[~2025-02-03 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 13:52 Klaus Gerlicher
2025-02-03 14:27 ` Luis Machado [this message]
2025-02-03 14:38   ` Gerlicher, Klaus
2025-02-03 14:40     ` Luis Machado
2025-02-13 11:09       ` [PUSHED][PATCH " Gerlicher, Klaus

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=b40b1e93-5326-4e8a-aa0d-fdcab9e3f2a9@arm.com \
    --to=luis.machado@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=klaus.gerlicher@intel.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