Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: Luis <luis.machado.foss@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] GDB: aarch64: Fix inferior function call if GCS is present but disabled
Date: Wed, 22 Jul 2026 19:59:07 +0000	[thread overview]
Message-ID: <875x26x0c4.fsf@linaro.org> (raw)
In-Reply-To: <e4fe7288-0af1-49d5-b553-32c66927182e@gmail.com> (Luis's message of "Sun, 19 Jul 2026 09:57:46 +0100")

Hello Luis,

Thank you for the review!

Luis <luis.machado.foss@gmail.com> writes:

> On 08/07/2026 07:03, Thiago Jung Bauermann wrote:
>> On AArch64, even if the Guarded Control Stack feature is present on the
>> system the inferior may not have enabled it.
>> There's a bug in GDB's GCS support in that if the system supports GCS,
>> GDB will always push a GCS entry when doing an inferior function call
>> even if the inferior doesn't have it enabled.  This causes inferior
>> function calls to fail. E.g.:
>>    (gdb) p foo ()
>>    Can't write to Guarded Control Stack.
>> The error message is because the GCSPR doesn't point to a valid memory
>> address.
>> Fix by checking whether GCS is enabled in the inferior before trying to
>> push a GCS entry.
>> Regression tested on an aarch64-linux-gnu QEMU VM with GCS present.
>> ---
>> GCS support first appeared in GDB 17, so if this patch is approved for
>> trunk is it ok to also commit it to the branch?
>
> Sounds good to me.
>
>>   gdb/aarch64-tdep.c | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
>> index 886e7ce1e7b6..b4437dcccc8a 100644
>> --- a/gdb/aarch64-tdep.c
>> +++ b/gdb/aarch64-tdep.c
>> @@ -1934,7 +1934,11 @@ static void
>>   aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr,
>>   			   regcache *regcache)
>>   {
>> -  aarch64_push_gcs_entry (regcache, new_addr);
>> +  bool gcs_is_enabled;
>> +
>> +  gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled);
>> +  if (gcs_is_enabled)
>> +    aarch64_push_gcs_entry (regcache, new_addr);
>>   }
>>     /* Implement the "push_dummy_call" gdbarch method.  */
>
> LGTM, with Baris' suggestion.
>
> Approved-By: Luis Machado <luis.machado.foss@gmail.com>

Pushed as commit 4410648da673, with Baris' suggestion.

Also pushed as commit cbdcbf506376 to gdb-17-branch.

-- 
Thiago
(he/him)

      reply	other threads:[~2026-07-22 19:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  6:03 Thiago Jung Bauermann
2026-07-08  7:50 ` Aktemur, Baris
2026-07-08 19:43   ` Thiago Jung Bauermann
2026-07-21 16:38   ` Tom Tromey
2026-07-22 20:23     ` Thiago Jung Bauermann
2026-07-22 22:27       ` Tom Tromey
2026-07-19  8:57 ` Luis
2026-07-22 19:59   ` Thiago Jung Bauermann [this message]

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=875x26x0c4.fsf@linaro.org \
    --to=thiago.bauermann@linaro.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@gmail.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