* [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-03 15:51 ` Simon Marchi
2026-03-04 3:59 ` Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h " Thiago Jung Bauermann
` (5 subsequent siblings)
6 siblings, 2 replies; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
The code supporting Pointer Authentication duplicates the definition of
AARCH64_HWCAP_PACA and of AARCH64_LINUX_SIZEOF_PAUTH between GDB and
gdbserver, so add two new headers to host those definitions.
The target-dependant code should use AARCH64_HWCAP_PACA in
gdb/arch/aarch64-pauth-linux.h while native code should use HWCAP_PACA,
which will hopefully be defined by the system headers but with a backup
definition in gdb/nat/aarch64-pauth-linux.h if it isn't.
Suggested-by: Luis <luis.machado.foss@gmail.com>
Suggested-by: Simon Marchi <simark@simark.ca>
---
Changes since v3:
- Also create gdb/nat/aarch64-pauth-linux.h header.
- Keep AARCH64_HWCAP_PACA untouched.
gdb/Makefile.in | 2 ++
gdb/aarch64-linux-nat.c | 3 ++-
gdb/aarch64-linux-tdep.c | 1 +
gdb/aarch64-linux-tdep.h | 6 ------
gdb/arch/aarch64-pauth-linux.h | 29 +++++++++++++++++++++++++++++
gdb/arch/aarch64.h | 3 ---
gdb/nat/aarch64-pauth-linux.h | 26 ++++++++++++++++++++++++++
gdbserver/linux-aarch64-low.cc | 9 ++++-----
8 files changed, 64 insertions(+), 15 deletions(-)
create mode 100644 gdb/arch/aarch64-pauth-linux.h
create mode 100644 gdb/nat/aarch64-pauth-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 2aa95be968ac..a412f3b3c592 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1306,6 +1306,7 @@ HFILES_NO_SRCDIR = \
arch/aarch64-insn.h \
arch/aarch64-mte.h \
arch/aarch64-mte-linux.h \
+ arch/aarch64-pauth-linux.h \
arch/aarch64-scalable-linux.h \
arch/amd64.h \
arch/amd64-linux-tdesc.h \
@@ -1549,6 +1550,7 @@ HFILES_NO_SRCDIR = \
nat/aarch64-linux.h \
nat/aarch64-linux-hw-point.h \
nat/aarch64-mte-linux-ptrace.h \
+ nat/aarch64-pauth-linux.h \
nat/aarch64-scalable-linux-ptrace.h \
nat/aarch64-scalable-linux-sigcontext.h \
nat/amd64-linux.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 028de981588b..f64cc0a97d88 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -34,6 +34,7 @@
#include "arch/arm.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
+#include "nat/aarch64-pauth-linux.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "elf/external.h"
@@ -1012,7 +1013,7 @@ aarch64_linux_nat_target::read_description ()
or the streaming vector length, depending on whether streaming mode is
active or not. */
features.vq = aarch64_sve_get_vq (tid);
- features.pauth = hwcap & AARCH64_HWCAP_PACA;
+ features.pauth = hwcap & HWCAP_PACA;
features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index b85c25ecae1d..d3d4c9e1de38 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -54,6 +54,7 @@
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
+#include "arch/aarch64-pauth-linux.h"
#include "arch/aarch64-scalable-linux.h"
#include "arch-utils.h"
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index e926687ff6eb..b99fe91f36bd 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -33,16 +33,10 @@
alignment. */
#define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
-/* The pauth regset consists of 2 X sized registers. */
-#define AARCH64_LINUX_SIZEOF_PAUTH (2 * X_REGISTER_SIZE)
-
/* The MTE regset consists of a 64-bit register. */
#define AARCH64_LINUX_SIZEOF_MTE_REGSET (8)
extern const struct regset aarch64_linux_gregset;
extern const struct regset aarch64_linux_fpregset;
-/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
-#define AARCH64_HWCAP_PACA (1 << 30)
-
#endif /* GDB_AARCH64_LINUX_TDEP_H */
diff --git a/gdb/arch/aarch64-pauth-linux.h b/gdb/arch/aarch64-pauth-linux.h
new file mode 100644
index 000000000000..4174dc3a9ded
--- /dev/null
+++ b/gdb/arch/aarch64-pauth-linux.h
@@ -0,0 +1,29 @@
+/* Common Linux target-dependent definitions for AArch64 PAuth.
+
+ Copyright (C) 2019-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_ARCH_AARCH64_PAUTH_LINUX_H
+#define GDB_ARCH_AARCH64_PAUTH_LINUX_H
+
+/* Feature check for Pointer Authentication Code Extension. */
+#define AARCH64_HWCAP_PACA (1 << 30)
+
+/* The pauth regset consists of 2 64-bit registers. */
+#define AARCH64_LINUX_SIZEOF_PAUTH 16
+
+#endif /* GDB_ARCH_AARCH64_PAUTH_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 0e9715a4268a..7856d95a93b1 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -178,9 +178,6 @@ enum aarch64_regnum
#define AARCH64_PAUTH_DMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 2)
#define AARCH64_PAUTH_CMASK_HIGH_REGNUM(pauth_reg_base) (pauth_reg_base + 3)
-/* This size is only meant for Linux, not bare metal. QEMU exposes 4 masks. */
-#define AARCH64_PAUTH_REGS_SIZE (16)
-
#define AARCH64_X_REGS_NUM 31
#define AARCH64_V_REGS_NUM 32
#define AARCH64_SVE_Z_REGS_NUM AARCH64_V_REGS_NUM
diff --git a/gdb/nat/aarch64-pauth-linux.h b/gdb/nat/aarch64-pauth-linux.h
new file mode 100644
index 000000000000..5ce85fb296c4
--- /dev/null
+++ b/gdb/nat/aarch64-pauth-linux.h
@@ -0,0 +1,26 @@
+/* Common Linux native definitions for AArch64 PAuth.
+
+ Copyright (C) 2019-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_NAT_AARCH64_PAUTH_LINUX_H
+#define GDB_NAT_AARCH64_PAUTH_LINUX_H
+
+/* Feature check for Pointer Authentication Code Extension. */
+#define HWCAP_PACA (1 << 30)
+
+#endif /* GDB_NAT_AARCH64_PAUTH_LINUX_H */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index b19e605f55d6..07ddfb324466 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -22,6 +22,7 @@
#include "linux-low.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
+#include "nat/aarch64-pauth-linux.h"
#include "arch/aarch64-insn.h"
#include "linux-aarch32-low.h"
#include "elf/common.h"
@@ -41,6 +42,7 @@
#include "arch/aarch64.h"
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
+#include "arch/aarch64-pauth-linux.h"
#include "arch/aarch64-scalable-linux.h"
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
@@ -952,7 +954,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
break;
case NT_ARM_PAC_MASK:
if (features.pauth)
- regset->size = AARCH64_PAUTH_REGS_SIZE;
+ regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
break;
case NT_ARM_TAGGED_ADDR_CTRL:
if (features.mte)
@@ -984,9 +986,6 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
}
}
-/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
-#define AARCH64_HWCAP_PACA (1 << 30)
-
/* Implementation of linux target ops method "low_arch_setup". */
void
@@ -1005,7 +1004,7 @@ aarch64_target::low_arch_setup ()
features.vq = aarch64_sve_get_vq (tid);
/* A-profile PAC is 64-bit only. */
- features.pauth = linux_get_hwcap (pid, 8) & AARCH64_HWCAP_PACA;
+ features.pauth = linux_get_hwcap (pid, 8) & HWCAP_PACA;
/* A-profile MTE is 64-bit only. */
features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 5:06 ` [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/ Thiago Jung Bauermann
@ 2026-03-03 15:51 ` Simon Marchi
2026-03-04 4:04 ` Thiago Jung Bauermann
2026-03-04 3:59 ` Thiago Jung Bauermann
1 sibling, 1 reply; 25+ messages in thread
From: Simon Marchi @ 2026-03-03 15:51 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, sunilkumar.dora
> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
> index b19e605f55d6..07ddfb324466 100644
> --- a/gdbserver/linux-aarch64-low.cc
> +++ b/gdbserver/linux-aarch64-low.cc
> @@ -22,6 +22,7 @@
> #include "linux-low.h"
> #include "nat/aarch64-linux.h"
> #include "nat/aarch64-linux-hw-point.h"
> +#include "nat/aarch64-pauth-linux.h"
> #include "arch/aarch64-insn.h"
> #include "linux-aarch32-low.h"
> #include "elf/common.h"
> @@ -41,6 +42,7 @@
> #include "arch/aarch64.h"
> #include "arch/aarch64-gcs-linux.h"
> #include "arch/aarch64-mte-linux.h"
> +#include "arch/aarch64-pauth-linux.h"
> #include "arch/aarch64-scalable-linux.h"
> #include "linux-aarch32-tdesc.h"
> #include "linux-aarch64-tdesc.h"
> @@ -952,7 +954,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
> break;
> case NT_ARM_PAC_MASK:
> if (features.pauth)
> - regset->size = AARCH64_PAUTH_REGS_SIZE;
> + regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
It's not a deal-breaker for this patch series, but I'm just wondering:
is there some "native" thing, provided by Linux, that could give us the
size here, like sizeof(some_type)? If we're trying to use the native
stuff in the native files, then for consistency it would be nice to
avoid relying on our own definition of the sizeof pauth.
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 15:51 ` Simon Marchi
@ 2026-03-04 4:04 ` Thiago Jung Bauermann
2026-03-10 14:18 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 4:04 UTC (permalink / raw)
To: Simon Marchi
Cc: gdb-patches, Chris Packham, Luis, Tom Tromey, sunilkumar.dora
Simon Marchi <simark@simark.ca> writes:
>> diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
>> index b19e605f55d6..07ddfb324466 100644
>> --- a/gdbserver/linux-aarch64-low.cc
>> +++ b/gdbserver/linux-aarch64-low.cc
>> @@ -22,6 +22,7 @@
>> #include "linux-low.h"
>> #include "nat/aarch64-linux.h"
>> #include "nat/aarch64-linux-hw-point.h"
>> +#include "nat/aarch64-pauth-linux.h"
>> #include "arch/aarch64-insn.h"
>> #include "linux-aarch32-low.h"
>> #include "elf/common.h"
>> @@ -41,6 +42,7 @@
>> #include "arch/aarch64.h"
>> #include "arch/aarch64-gcs-linux.h"
>> #include "arch/aarch64-mte-linux.h"
>> +#include "arch/aarch64-pauth-linux.h"
>> #include "arch/aarch64-scalable-linux.h"
>> #include "linux-aarch32-tdesc.h"
>> #include "linux-aarch64-tdesc.h"
>> @@ -952,7 +954,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
>> break;
>> case NT_ARM_PAC_MASK:
>> if (features.pauth)
>> - regset->size = AARCH64_PAUTH_REGS_SIZE;
>> + regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
>
> It's not a deal-breaker for this patch series, but I'm just wondering:
> is there some "native" thing, provided by Linux, that could give us the
> size here, like sizeof(some_type)? If we're trying to use the native
> stuff in the native files, then for consistency it would be nice to
> avoid relying on our own definition of the sizeof pauth.
There's struct user_pac_mask in <asm/ptrace.h> so we could do
sizeof (user_pac_mask), but to allow using older system headers that would
require a configure test as done in patch 6 of this series, and add our
own definition of the struct in case the system headers don't have it.
I can do that as a separate patch if you think it's better.
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
2026-03-04 4:04 ` Thiago Jung Bauermann
@ 2026-03-10 14:18 ` Luis
0 siblings, 0 replies; 25+ messages in thread
From: Luis @ 2026-03-10 14:18 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: Simon Marchi, gdb-patches, Chris Packham, Tom Tromey, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 2075 bytes --]
Thanks.
Unless Simon wants the points he made fixed...
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
On Wed, Mar 4, 2026, 01:04 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Simon Marchi <simark@simark.ca> writes:
>
> >> diff --git a/gdbserver/linux-aarch64-low.cc
> b/gdbserver/linux-aarch64-low.cc
> >> index b19e605f55d6..07ddfb324466 100644
> >> --- a/gdbserver/linux-aarch64-low.cc
> >> +++ b/gdbserver/linux-aarch64-low.cc
> >> @@ -22,6 +22,7 @@
> >> #include "linux-low.h"
> >> #include "nat/aarch64-linux.h"
> >> #include "nat/aarch64-linux-hw-point.h"
> >> +#include "nat/aarch64-pauth-linux.h"
> >> #include "arch/aarch64-insn.h"
> >> #include "linux-aarch32-low.h"
> >> #include "elf/common.h"
> >> @@ -41,6 +42,7 @@
> >> #include "arch/aarch64.h"
> >> #include "arch/aarch64-gcs-linux.h"
> >> #include "arch/aarch64-mte-linux.h"
> >> +#include "arch/aarch64-pauth-linux.h"
> >> #include "arch/aarch64-scalable-linux.h"
> >> #include "linux-aarch32-tdesc.h"
> >> #include "linux-aarch64-tdesc.h"
> >> @@ -952,7 +954,7 @@ aarch64_adjust_register_sets (const struct
> aarch64_features &features)
> >> break;
> >> case NT_ARM_PAC_MASK:
> >> if (features.pauth)
> >> - regset->size = AARCH64_PAUTH_REGS_SIZE;
> >> + regset->size = AARCH64_LINUX_SIZEOF_PAUTH;
> >
> > It's not a deal-breaker for this patch series, but I'm just wondering:
> > is there some "native" thing, provided by Linux, that could give us the
> > size here, like sizeof(some_type)? If we're trying to use the native
> > stuff in the native files, then for consistency it would be nice to
> > avoid relying on our own definition of the sizeof pauth.
>
> There's struct user_pac_mask in <asm/ptrace.h> so we could do
> sizeof (user_pac_mask), but to allow using older system headers that would
> require a configure test as done in patch 6 of this series, and add our
> own definition of the struct in case the system headers don't have it.
>
> I can do that as a separate patch if you think it's better.
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 3116 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 5:06 ` [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/ Thiago Jung Bauermann
2026-03-03 15:51 ` Simon Marchi
@ 2026-03-04 3:59 ` Thiago Jung Bauermann
1 sibling, 0 replies; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 3:59 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> diff --git a/gdb/nat/aarch64-pauth-linux.h b/gdb/nat/aarch64-pauth-linux.h
> new file mode 100644
> index 000000000000..5ce85fb296c4
> --- /dev/null
> +++ b/gdb/nat/aarch64-pauth-linux.h
> @@ -0,0 +1,26 @@
> +/* Common Linux native definitions for AArch64 PAuth.
> +
> + Copyright (C) 2019-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_NAT_AARCH64_PAUTH_LINUX_H
> +#define GDB_NAT_AARCH64_PAUTH_LINUX_H
> +
> +/* Feature check for Pointer Authentication Code Extension. */
> +#define HWCAP_PACA (1 << 30)
> +
> +#endif /* GDB_NAT_AARCH64_PAUTH_LINUX_H */
As I mentioned in another message, I amended this commit locally with
these changes:
diff --git a/gdb/nat/aarch64-pauth-linux.h b/gdb/nat/aarch64-pauth-linux.h
index 5ce85fb296c4..5005d0038cbb 100644
--- a/gdb/nat/aarch64-pauth-linux.h
+++ b/gdb/nat/aarch64-pauth-linux.h
@@ -20,7 +20,11 @@
#ifndef GDB_NAT_AARCH64_PAUTH_LINUX_H
#define GDB_NAT_AARCH64_PAUTH_LINUX_H
+#include <asm/hwcap.h>
+
/* Feature check for Pointer Authentication Code Extension. */
+#ifndef HWCAP_PACA
#define HWCAP_PACA (1 << 30)
+#endif
#endif /* GDB_NAT_AARCH64_PAUTH_LINUX_H */
The #include of <asm/hwcap.h> is because the #ifndef implies that the
header should have been included, so do it explicitly.
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/ Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-04 4:14 ` Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions Thiago Jung Bauermann
` (4 subsequent siblings)
6 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
not the best place for it since it's a Linux-specific definition.
Add new Linux- and feature-specific headers to contain it, one for
target-dependent code and the other for native code.
The target-dependant code should use AARCH64_HWCAP2_FPRM in
gdb/arch/aarch64-pauth-linux.h while native code should use HWCAP2_FPRM,
which will hopefully be defined by the system headers but with a backup
definition in gdb/nat/aarch64-pauth-linux.h if it isn't.
Suggested-by: Luis <luis.machado.foss@gmail.com>
Suggested-by: Simon Marchi <simark@simark.ca>
---
Changes since v3:
- Also create gdb/nat/aarch64-fpmr-linux.h header.
- Add AARCH64_HWCAP2_FPMR and use it in gdb/aarch64-linux-tdep.c.
gdb/Makefile.in | 2 ++
gdb/aarch64-linux-nat.c | 1 +
gdb/aarch64-linux-tdep.c | 3 ++-
gdb/arch/aarch64-fpmr-linux.h | 26 ++++++++++++++++++++++++++
gdb/arch/aarch64.h | 5 -----
gdb/nat/aarch64-fpmr-linux.h | 28 ++++++++++++++++++++++++++++
gdbserver/linux-aarch64-low.cc | 1 +
7 files changed, 60 insertions(+), 6 deletions(-)
create mode 100644 gdb/arch/aarch64-fpmr-linux.h
create mode 100644 gdb/nat/aarch64-fpmr-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a412f3b3c592..3d9bc86a97fd 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1301,6 +1301,7 @@ HFILES_NO_SRCDIR = \
amdgpu-tdep.h \
annotate.h \
arch/aarch32.h \
+ arch/aarch64-fpmr-linux.h \
arch/aarch64-gcs-linux.h \
arch/aarch64.h \
arch/aarch64-insn.h \
@@ -1546,6 +1547,7 @@ HFILES_NO_SRCDIR = \
mn10300-tdep.h \
moxie-tdep.h \
namespace.h \
+ nat/aarch64-fpmr-linux.h \
nat/aarch64-hw-point.h \
nat/aarch64-linux.h \
nat/aarch64-linux-hw-point.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index f64cc0a97d88..81a46ee1f0d0 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -32,6 +32,7 @@
#include "aarch32-linux-nat.h"
#include "aarch32-tdep.h"
#include "arch/arm.h"
+#include "nat/aarch64-fpmr-linux.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
#include "nat/aarch64-pauth-linux.h"
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index d3d4c9e1de38..504e4126f1bc 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -51,6 +51,7 @@
#include "record-full.h"
#include "linux-record.h"
+#include "arch/aarch64-fpmr-linux.h"
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
@@ -1764,7 +1765,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
features.pauth = hwcap & AARCH64_HWCAP_PACA;
features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
- features.fpmr = hwcap2 & HWCAP2_FPMR;
+ features.fpmr = hwcap2 & AARCH64_HWCAP2_FPMR;
/* Handle the TLS section. */
asection *tls = bfd_get_section_by_name (abfd, ".reg-aarch-tls");
diff --git a/gdb/arch/aarch64-fpmr-linux.h b/gdb/arch/aarch64-fpmr-linux.h
new file mode 100644
index 000000000000..5495cf8c0018
--- /dev/null
+++ b/gdb/arch/aarch64-fpmr-linux.h
@@ -0,0 +1,26 @@
+/* Common Linux target-dependent definitions for AArch64 FPMR.
+
+ Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_ARCH_AARCH64_FPMR_LINUX_H
+#define GDB_ARCH_AARCH64_FPMR_LINUX_H
+
+/* Feature check for Floating Point Mode Register. */
+#define AARCH64_HWCAP2_FPMR (1ULL << 48)
+
+#endif /* GDB_ARCH_AARCH64_FPMR_LINUX_H */
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 7856d95a93b1..c9a89ac40986 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -243,9 +243,4 @@ enum aarch64_regnum
/* Size of the SME2 ZT0 register in bytes. */
#define AARCH64_SME2_ZT0_SIZE 64
-/* Feature check for Floating Point Mode Register. */
-#ifndef HWCAP2_FPMR
-#define HWCAP2_FPMR (1ULL << 48)
-#endif /* HWCAP2_FPMR */
-
#endif /* GDB_ARCH_AARCH64_H */
diff --git a/gdb/nat/aarch64-fpmr-linux.h b/gdb/nat/aarch64-fpmr-linux.h
new file mode 100644
index 000000000000..bb0243a89396
--- /dev/null
+++ b/gdb/nat/aarch64-fpmr-linux.h
@@ -0,0 +1,28 @@
+/* Common Linux native definitions for AArch64 FPMR.
+
+ Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_NAT_AARCH64_FPMR_LINUX_H
+#define GDB_NAT_AARCH64_FPMR_LINUX_H
+
+/* Feature check for Floating Point Mode Register. */
+#ifndef HWCAP2_FPMR
+#define HWCAP2_FPMR (1ULL << 48)
+#endif /* HWCAP2_FPMR */
+
+#endif /* GDB_NAT_AARCH64_FPMR_LINUX_H */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 07ddfb324466..a6439943e855 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -46,6 +46,7 @@
#include "arch/aarch64-scalable-linux.h"
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
+#include "nat/aarch64-fpmr-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "tdesc.h"
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h to gdb/arch/ and gdb/nat/
2026-03-03 5:06 ` [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h " Thiago Jung Bauermann
@ 2026-03-04 4:14 ` Thiago Jung Bauermann
2026-03-10 14:14 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 4:14 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
> not the best place for it since it's a Linux-specific definition.
>
> Add new Linux- and feature-specific headers to contain it, one for
> target-dependent code and the other for native code.
>
> The target-dependant code should use AARCH64_HWCAP2_FPRM in
> gdb/arch/aarch64-pauth-linux.h while native code should use HWCAP2_FPRM,
> which will hopefully be defined by the system headers but with a backup
> definition in gdb/nat/aarch64-pauth-linux.h if it isn't.
>
> Suggested-by: Luis <luis.machado.foss@gmail.com>
> Suggested-by: Simon Marchi <simark@simark.ca>
Fixed locally these typos and pastos pointed out by Simon in the commit
message:
- s/HWCAP2_FPRM/HWCAP2_FPMR/g
- aarch64-pauth-linux.h → aarch64-fpmr-linux.h
> diff --git a/gdb/nat/aarch64-fpmr-linux.h b/gdb/nat/aarch64-fpmr-linux.h
> new file mode 100644
> index 000000000000..bb0243a89396
> --- /dev/null
> +++ b/gdb/nat/aarch64-fpmr-linux.h
> @@ -0,0 +1,28 @@
> +/* Common Linux native definitions for AArch64 FPMR.
> +
> + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_NAT_AARCH64_FPMR_LINUX_H
> +#define GDB_NAT_AARCH64_FPMR_LINUX_H
> +
> +/* Feature check for Floating Point Mode Register. */
> +#ifndef HWCAP2_FPMR
> +#define HWCAP2_FPMR (1ULL << 48)
> +#endif /* HWCAP2_FPMR */
> +
> +#endif /* GDB_NAT_AARCH64_FPMR_LINUX_H */
As with the previous patch, I locally amended this one to also include
<asm/hwcap.h>:
diff --git a/gdb/nat/aarch64-fpmr-linux.h b/gdb/nat/aarch64-fpmr-linux.h
index bb0243a89396..9ed651d95059 100644
--- a/gdb/nat/aarch64-fpmr-linux.h
+++ b/gdb/nat/aarch64-fpmr-linux.h
@@ -20,6 +20,8 @@
#ifndef GDB_NAT_AARCH64_FPMR_LINUX_H
#define GDB_NAT_AARCH64_FPMR_LINUX_H
+#include <asm/hwcap.h>
+
/* Feature check for Floating Point Mode Register. */
#ifndef HWCAP2_FPMR
#define HWCAP2_FPMR (1ULL << 48)
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h to gdb/arch/ and gdb/nat/
2026-03-04 4:14 ` Thiago Jung Bauermann
@ 2026-03-10 14:14 ` Luis
0 siblings, 0 replies; 25+ messages in thread
From: Luis @ 2026-03-10 14:14 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: gdb-patches, Chris Packham, Tom Tromey, Simon Marchi, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 3095 bytes --]
Thanks.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
On Wed, Mar 4, 2026, 01:14 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
>
> > GDB conditionally defines HWCAP2_FPMR in gdb/arch/aarch64.h, but that's
> > not the best place for it since it's a Linux-specific definition.
> >
> > Add new Linux- and feature-specific headers to contain it, one for
> > target-dependent code and the other for native code.
> >
> > The target-dependant code should use AARCH64_HWCAP2_FPRM in
> > gdb/arch/aarch64-pauth-linux.h while native code should use HWCAP2_FPRM,
> > which will hopefully be defined by the system headers but with a backup
> > definition in gdb/nat/aarch64-pauth-linux.h if it isn't.
> >
> > Suggested-by: Luis <luis.machado.foss@gmail.com>
> > Suggested-by: Simon Marchi <simark@simark.ca>
>
> Fixed locally these typos and pastos pointed out by Simon in the commit
> message:
>
> - s/HWCAP2_FPRM/HWCAP2_FPMR/g
> - aarch64-pauth-linux.h → aarch64-fpmr-linux.h
>
> > diff --git a/gdb/nat/aarch64-fpmr-linux.h b/gdb/nat/aarch64-fpmr-linux.h
> > new file mode 100644
> > index 000000000000..bb0243a89396
> > --- /dev/null
> > +++ b/gdb/nat/aarch64-fpmr-linux.h
> > @@ -0,0 +1,28 @@
> > +/* Common Linux native definitions for AArch64 FPMR.
> > +
> > + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> > +
> > + This file is part of GDB.
> > +
> > + This program is free software; you can redistribute it and/or modify
> > + it under the terms of the GNU General Public License as published by
> > + the Free Software Foundation; either version 3 of the License, or
> > + (at your option) any later version.
> > +
> > + This program is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + GNU General Public License for more details.
> > +
> > + You should have received a copy of the GNU General Public License
> > + along with this program. If not, see <http://www.gnu.org/licenses/>.
> */
> > +
> > +#ifndef GDB_NAT_AARCH64_FPMR_LINUX_H
> > +#define GDB_NAT_AARCH64_FPMR_LINUX_H
> > +
> > +/* Feature check for Floating Point Mode Register. */
> > +#ifndef HWCAP2_FPMR
> > +#define HWCAP2_FPMR (1ULL << 48)
> > +#endif /* HWCAP2_FPMR */
> > +
> > +#endif /* GDB_NAT_AARCH64_FPMR_LINUX_H */
>
> As with the previous patch, I locally amended this one to also include
> <asm/hwcap.h>:
>
> diff --git a/gdb/nat/aarch64-fpmr-linux.h b/gdb/nat/aarch64-fpmr-linux.h
> index bb0243a89396..9ed651d95059 100644
> --- a/gdb/nat/aarch64-fpmr-linux.h
> +++ b/gdb/nat/aarch64-fpmr-linux.h
> @@ -20,6 +20,8 @@
> #ifndef GDB_NAT_AARCH64_FPMR_LINUX_H
> #define GDB_NAT_AARCH64_FPMR_LINUX_H
>
> +#include <asm/hwcap.h>
> +
> /* Feature check for Floating Point Mode Register. */
> #ifndef HWCAP2_FPMR
> #define HWCAP2_FPMR (1ULL << 48)
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 4192 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/ Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 2/6] GDB: Add aarch64-fpmr-linux.h " Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-04 4:17 ` Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions Thiago Jung Bauermann
` (3 subsequent siblings)
6 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
GDB conditionally defines HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h, but
that's not the best place for it since it's a definition that should be
used only in native code so move it to gdb/nat/aarch64-mte-linux-ptrace.h.
Introduce an AARCH64_HWCAP2_MTE in gdb/arch/aarch64-mte-linux.h to be used
by target-dependant code.
Similarly, add AARCH64_ prefix to the SEGV_MTEAERR and SEGV_MTESERR
definitions in gdb/arch/aarch64-mte-linux.h.
I noticed that enum class aarch64_memtag_type is only used in native code,
so move its definition to gdb/nat/aarch64-mte-linux-ptrace.h as well.
I also noticed that gdb/aarch64-linux-tdep.h defines
AARCH64_LINUX_SIZEOF_MTE_REGSET which is redundant with
AARCH64_LINUX_SIZEOF_MTE, already defined in gdb/arch/aarch64-mte-linux.h
so consolidate both definitions.
Finally, the include of arch/aarch64-mte-linux.h isn't used in
gdb/aarch64-linux-nat.c nor in gdb/nat/aarch64-mte-linux-ptrace.c so
remove it from them.
Suggested-by: Luis <luis.machado.foss@gmail.com>
Suggested-by: Simon Marchi <simark@simark.ca>
---
gdb/aarch64-linux-nat.c | 4 +---
gdb/aarch64-linux-tdep.c | 6 +++---
gdb/aarch64-linux-tdep.h | 3 ---
gdb/arch/aarch64-mte-linux.h | 23 ++++-------------------
gdb/nat/aarch64-mte-linux-ptrace.c | 1 -
gdb/nat/aarch64-mte-linux-ptrace.h | 14 ++++++++++++++
gdbserver/linux-aarch64-low.cc | 2 +-
7 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 81a46ee1f0d0..d12e2ddcfb28 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -35,6 +35,7 @@
#include "nat/aarch64-fpmr-linux.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
+#include "nat/aarch64-mte-linux-ptrace.h"
#include "nat/aarch64-pauth-linux.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
@@ -54,9 +55,6 @@
#include "arch-utils.h"
#include "arch/aarch64-gcs-linux.h"
-#include "arch/aarch64-mte-linux.h"
-
-#include "nat/aarch64-mte-linux-ptrace.h"
#include "arch/aarch64-scalable-linux.h"
#include <string.h>
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 504e4126f1bc..4ca05fba771d 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1764,7 +1764,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
features.pauth = hwcap & AARCH64_HWCAP_PACA;
features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
- features.mte = hwcap2 & HWCAP2_MTE;
+ features.mte = hwcap2 & AARCH64_HWCAP2_MTE;
features.fpmr = hwcap2 & AARCH64_HWCAP2_FPMR;
/* Handle the TLS section. */
@@ -2698,7 +2698,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
const char *meaning;
- if (si_code == SEGV_MTEAERR || si_code == SEGV_MTESERR)
+ if (si_code == AARCH64_SEGV_MTEAERR || si_code == AARCH64_SEGV_MTESERR)
meaning = _("Memory tag violation");
else if (si_code == SEGV_CPERR && si_errno == 0)
meaning = _("Guarded Control Stack error");
@@ -2710,7 +2710,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
uiout->field_string ("sigcode-meaning", meaning);
/* For synchronous faults, show additional information. */
- if (si_code == SEGV_MTESERR)
+ if (si_code == AARCH64_SEGV_MTESERR)
{
uiout->text (_(" while accessing address "));
uiout->field_core_addr ("fault-addr", gdbarch, fault_addr);
diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h
index b99fe91f36bd..385b03cc1be7 100644
--- a/gdb/aarch64-linux-tdep.h
+++ b/gdb/aarch64-linux-tdep.h
@@ -33,9 +33,6 @@
alignment. */
#define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
-/* The MTE regset consists of a 64-bit register. */
-#define AARCH64_LINUX_SIZEOF_MTE_REGSET (8)
-
extern const struct regset aarch64_linux_gregset;
extern const struct regset aarch64_linux_fpregset;
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 5c7e78c71eaf..bc31ae52b916 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -20,29 +20,14 @@
#ifndef GDB_ARCH_AARCH64_MTE_LINUX_H
#define GDB_ARCH_AARCH64_MTE_LINUX_H
-
-/* Feature check for Memory Tagging Extension. */
-#ifndef HWCAP2_MTE
-#define HWCAP2_MTE (1 << 18)
-#endif
+#define AARCH64_HWCAP2_MTE (1 << 18)
/* The MTE regset consists of a single 64-bit register. */
-#define AARCH64_LINUX_SIZEOF_MTE 8
+#define AARCH64_LINUX_SIZEOF_MTE_REGSET 8
/* Memory tagging definitions. */
-#ifndef SEGV_MTEAERR
-# define SEGV_MTEAERR 8
-# define SEGV_MTESERR 9
-#endif
-
-/* Memory tag types for AArch64. */
-enum class aarch64_memtag_type
-{
- /* MTE logical tag contained in pointers. */
- mte_logical = 0,
- /* MTE allocation tag stored in memory tag granules. */
- mte_allocation
-};
+#define AARCH64_SEGV_MTEAERR 8
+#define AARCH64_SEGV_MTESERR 9
/* Given a TAGS vector containing 1 MTE tag per byte, pack the data as
2 tags per byte and resize the vector. */
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.c b/gdb/nat/aarch64-mte-linux-ptrace.c
index 903e11841201..c88b1d4fcd23 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.c
+++ b/gdb/nat/aarch64-mte-linux-ptrace.c
@@ -23,7 +23,6 @@
#include "arch/aarch64.h"
#include "arch/aarch64-mte.h"
-#include "arch/aarch64-mte-linux.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index d31fa9f3c071..653de33108c8 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -20,6 +20,11 @@
#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+/* Feature check for Memory Tagging Extension. */
+#ifndef HWCAP2_MTE
+#define HWCAP2_MTE (1 << 18)
+#endif
+
/* MTE allocation tag access */
#ifndef PTRACE_PEEKMTETAGS
@@ -33,6 +38,15 @@
/* Maximum number of tags to pass at once to the kernel. */
#define AARCH64_MTE_TAGS_MAX_SIZE 4096
+/* Memory tag types for AArch64. */
+enum class aarch64_memtag_type
+{
+ /* MTE logical tag contained in pointers. */
+ mte_logical = 0,
+ /* MTE allocation tag stored in memory tag granules. */
+ mte_allocation
+};
+
/* Read the allocation tags from memory range [ADDRESS, ADDRESS + LEN)
into TAGS.
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index a6439943e855..a00ee1556c80 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -959,7 +959,7 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
break;
case NT_ARM_TAGGED_ADDR_CTRL:
if (features.mte)
- regset->size = AARCH64_LINUX_SIZEOF_MTE;
+ regset->size = AARCH64_LINUX_SIZEOF_MTE_REGSET;
break;
case NT_ARM_TLS:
if (features.tls > 0)
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions
2026-03-03 5:06 ` [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions Thiago Jung Bauermann
@ 2026-03-04 4:17 ` Thiago Jung Bauermann
2026-03-10 14:12 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 4:17 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
> index d31fa9f3c071..653de33108c8 100644
> --- a/gdb/nat/aarch64-mte-linux-ptrace.h
> +++ b/gdb/nat/aarch64-mte-linux-ptrace.h
> @@ -20,6 +20,11 @@
> #ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
> #define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
>
> +/* Feature check for Memory Tagging Extension. */
> +#ifndef HWCAP2_MTE
> +#define HWCAP2_MTE (1 << 18)
> +#endif
> +
> /* MTE allocation tag access */
>
> #ifndef PTRACE_PEEKMTETAGS
As with the previous patches, I locally amended this one to also include
<asm/hwcap.h>. And since this header also defines some ptrace constants,
also include <asm/ptrace.h>:
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h b/gdb/nat/aarch64-mte-linux-ptrace.h
index 653de33108c8..7d1e7c1960d1 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.h
+++ b/gdb/nat/aarch64-mte-linux-ptrace.h
@@ -20,6 +20,9 @@
#ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
#define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
+#include <asm/hwcap.h>
+#include <asm/ptrace.h>
+
/* Feature check for Memory Tagging Extension. */
#ifndef HWCAP2_MTE
#define HWCAP2_MTE (1 << 18)
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions
2026-03-04 4:17 ` Thiago Jung Bauermann
@ 2026-03-10 14:12 ` Luis
0 siblings, 0 replies; 25+ messages in thread
From: Luis @ 2026-03-10 14:12 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: gdb-patches, Chris Packham, Tom Tromey, Simon Marchi, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]
Thanks.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
On Wed, Mar 4, 2026, 01:17 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
>
> > diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h
> b/gdb/nat/aarch64-mte-linux-ptrace.h
> > index d31fa9f3c071..653de33108c8 100644
> > --- a/gdb/nat/aarch64-mte-linux-ptrace.h
> > +++ b/gdb/nat/aarch64-mte-linux-ptrace.h
> > @@ -20,6 +20,11 @@
> > #ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
> > #define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
> >
> > +/* Feature check for Memory Tagging Extension. */
> > +#ifndef HWCAP2_MTE
> > +#define HWCAP2_MTE (1 << 18)
> > +#endif
> > +
> > /* MTE allocation tag access */
> >
> > #ifndef PTRACE_PEEKMTETAGS
>
> As with the previous patches, I locally amended this one to also include
> <asm/hwcap.h>. And since this header also defines some ptrace constants,
> also include <asm/ptrace.h>:
>
> diff --git a/gdb/nat/aarch64-mte-linux-ptrace.h
> b/gdb/nat/aarch64-mte-linux-ptrace.h
> index 653de33108c8..7d1e7c1960d1 100644
> --- a/gdb/nat/aarch64-mte-linux-ptrace.h
> +++ b/gdb/nat/aarch64-mte-linux-ptrace.h
> @@ -20,6 +20,9 @@
> #ifndef GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
> #define GDB_NAT_AARCH64_MTE_LINUX_PTRACE_H
>
> +#include <asm/hwcap.h>
> +#include <asm/ptrace.h>
> +
> /* Feature check for Memory Tagging Extension. */
> #ifndef HWCAP2_MTE
> #define HWCAP2_MTE (1 << 18)
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 2174 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
` (2 preceding siblings ...)
2026-03-03 5:06 ` [PATCH v4 3/6] GDB: aarch64-linux: Reorganize MTE-related definitions Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-04 4:21 ` Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions Thiago Jung Bauermann
` (2 subsequent siblings)
6 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
The HWCAP2_SME, HWCAP2_SME2 and HWCAP2_SME2P1 definitions should be in a
file under gdb/nat/, so move them to aarch64-scalable-linux-ptrace.h.
Also, I noticed that gdb/aarch64-linux-nat.c and
gdbserver/linux-aarch64-low.cc don't need anything from the
arch/aarch64-scalable-linux.h header, so make them not include it.
---
gdb/aarch64-linux-nat.c | 1 -
gdb/arch/aarch64-scalable-linux.h | 11 -----------
gdb/nat/aarch64-scalable-linux-ptrace.h | 11 +++++++++++
gdbserver/linux-aarch64-low.cc | 1 -
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index d12e2ddcfb28..4b86ae9ebe16 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -55,7 +55,6 @@
#include "arch-utils.h"
#include "arch/aarch64-gcs-linux.h"
-#include "arch/aarch64-scalable-linux.h"
#include <string.h>
diff --git a/gdb/arch/aarch64-scalable-linux.h b/gdb/arch/aarch64-scalable-linux.h
index 813d06562055..e20d094e79d7 100644
--- a/gdb/arch/aarch64-scalable-linux.h
+++ b/gdb/arch/aarch64-scalable-linux.h
@@ -23,17 +23,6 @@
#include "gdbsupport/common-regcache.h"
-/* Feature check for Scalable Matrix Extension. */
-#ifndef HWCAP2_SME
-#define HWCAP2_SME (1 << 23)
-#endif
-
-/* Feature check for Scalable Matrix Extension 2. */
-#ifndef HWCAP2_SME2
-#define HWCAP2_SME2 (1UL << 37)
-#define HWCAP2_SME2P1 (1UL << 38)
-#endif
-
/* Streaming mode enabled/disabled bit. */
#define SVCR_SM_BIT (1 << 0)
/* ZA enabled/disabled bit. */
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index 453f19dfe8d9..f3424baf7092 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -34,6 +34,17 @@
#include <stdarg.h>
#include "aarch64-scalable-linux-sigcontext.h"
+/* Feature check for Scalable Matrix Extension. */
+#ifndef HWCAP2_SME
+#define HWCAP2_SME (1 << 23)
+#endif
+
+/* Feature check for Scalable Matrix Extension 2. */
+#ifndef HWCAP2_SME2
+#define HWCAP2_SME2 (1UL << 37)
+#define HWCAP2_SME2P1 (1UL << 38)
+#endif
+
/* Indicates whether a SVE ptrace header is followed by SVE registers or a
fpsimd structure. */
#define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE)
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index a00ee1556c80..c44f75167141 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -43,7 +43,6 @@
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-pauth-linux.h"
-#include "arch/aarch64-scalable-linux.h"
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
#include "nat/aarch64-fpmr-linux.h"
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions
2026-03-03 5:06 ` [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions Thiago Jung Bauermann
@ 2026-03-04 4:21 ` Thiago Jung Bauermann
2026-03-10 14:07 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 4:21 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
> index 453f19dfe8d9..f3424baf7092 100644
> --- a/gdb/nat/aarch64-scalable-linux-ptrace.h
> +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
> @@ -34,6 +34,17 @@
> #include <stdarg.h>
> #include "aarch64-scalable-linux-sigcontext.h"
>
> +/* Feature check for Scalable Matrix Extension. */
> +#ifndef HWCAP2_SME
> +#define HWCAP2_SME (1 << 23)
> +#endif
> +
> +/* Feature check for Scalable Matrix Extension 2. */
> +#ifndef HWCAP2_SME2
> +#define HWCAP2_SME2 (1UL << 37)
> +#define HWCAP2_SME2P1 (1UL << 38)
> +#endif
> +
> /* Indicates whether a SVE ptrace header is followed by SVE registers or a
> fpsimd structure. */
> #define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE)
As with the other patches, I amended this one locally with:
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h b/gdb/nat/aarch64-scalable-linux-ptrace.h
index f3424baf7092..357154751508 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.h
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
@@ -30,6 +30,7 @@
these very same symbols. When that's the case, build errors will
result when <asm/ptrace.h> is included before <sys/ptrace.h>. */
#include <sys/ptrace.h>
+#include <asm/hwcap.h>
#include <asm/ptrace.h>
#include <stdarg.h>
#include "aarch64-scalable-linux-sigcontext.h"
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions
2026-03-04 4:21 ` Thiago Jung Bauermann
@ 2026-03-10 14:07 ` Luis
0 siblings, 0 replies; 25+ messages in thread
From: Luis @ 2026-03-10 14:07 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: gdb-patches, Chris Packham, Tom Tromey, Simon Marchi, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 1700 bytes --]
Thanks.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
On Wed, Mar 4, 2026, 01:21 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
>
> > diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h
> b/gdb/nat/aarch64-scalable-linux-ptrace.h
> > index 453f19dfe8d9..f3424baf7092 100644
> > --- a/gdb/nat/aarch64-scalable-linux-ptrace.h
> > +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
> > @@ -34,6 +34,17 @@
> > #include <stdarg.h>
> > #include "aarch64-scalable-linux-sigcontext.h"
> >
> > +/* Feature check for Scalable Matrix Extension. */
> > +#ifndef HWCAP2_SME
> > +#define HWCAP2_SME (1 << 23)
> > +#endif
> > +
> > +/* Feature check for Scalable Matrix Extension 2. */
> > +#ifndef HWCAP2_SME2
> > +#define HWCAP2_SME2 (1UL << 37)
> > +#define HWCAP2_SME2P1 (1UL << 38)
> > +#endif
> > +
> > /* Indicates whether a SVE ptrace header is followed by SVE registers
> or a
> > fpsimd structure. */
> > #define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE)
>
> As with the other patches, I amended this one locally with:
>
> diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.h
> b/gdb/nat/aarch64-scalable-linux-ptrace.h
> index f3424baf7092..357154751508 100644
> --- a/gdb/nat/aarch64-scalable-linux-ptrace.h
> +++ b/gdb/nat/aarch64-scalable-linux-ptrace.h
> @@ -30,6 +30,7 @@
> these very same symbols. When that's the case, build errors will
> result when <asm/ptrace.h> is included before <sys/ptrace.h>. */
> #include <sys/ptrace.h>
> +#include <asm/hwcap.h>
> #include <asm/ptrace.h>
> #include <stdarg.h>
> #include "aarch64-scalable-linux-sigcontext.h"
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 2481 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
` (3 preceding siblings ...)
2026-03-03 5:06 ` [PATCH v4 4/6] GDB: aarch64-linux: Reorganize SME-related definitions Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-04 4:27 ` Thiago Jung Bauermann
2026-03-03 5:06 ` [PATCH v4 6/6] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
2026-03-03 16:14 ` [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Simon Marchi
6 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Only native code should use struct user_gcs, so its definition should be
in a native-specific file and not in a file under gdb/arch/.
To fix this problem, create gdb/nat/aarch64-gcs-linux-ptrace.h and move
the struct user_gcs definition to it, as suggested by Luis.
To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
and use it in aarch64-linux-tdep.c, as is done for other regsets and
following a suggestion from Simon Marchi.
Also, move the HWCAP_GCS definition to
gdb/nat/aarch64-gcs-linux-ptrace.h and create an AARCH64_HWCAP_GCS
definition in gdb/arch/aarch64-gcs-linux.h for use by target-dependent
code.
Similarly, move the SEGV_CPERR and PR_SHADOW_STACK_{ENABLE,WRITE,PUSH}
definitions, which were added by the GCS patches and are only used by
aarch64-linux target-dependent code, to gdb/arch/aarch64-gcs-linux.h
with an AARCH64_ prefix and adjust users.
Finally, I noticed that gdb/aarch64-linux-nat.c and
gdbserver/linux-aarch64-low.cc don't need anything from the
arch/aarch64-gcs-linux.h header, so make them not include it.
Suggested-by: Luis <luis.machado.foss@gmail.com>
Suggested-by: Simon Marchi <simark@simark.ca>
---
Changes since v3:
- Move HWCAP_GCS definition to gdb/nat/aarch64-gcs-linux-ptrace.h.
- Add AARCH64_HWCAP_GCS and use it in gdb/aarch64-linux-tdep.c.
- Move the SEGV_CPERR and PR_SHADOW_STACK_{ENABLE,WRITE,PUSH} definitions
to gdb/arch/aarch64-gcs-linux.h with an AARCH64_ prefix.
- Remove inclusion of arch/aarch64-gcs-linux.h from gdb/aarch64-linux-nat.c
and gdbserver/linux-aarch64-low.cc.
Changes since v2:
- Don't rename gdb/arch/aarch64-gcs-linux.h to gdb/arch/aarch64-linux.h,
as suggested by Luis.
- Create gdb/nat/aarch64-gcs-linux-ptrace.h to contain definition of
struct user_gcs, as suggested by Luis.
- Don't rename HWCAP_GCS to AARCH64_HWCAP_GCS, as suggested by Luis.
- Move definition of AARCH64_LINUX_SIZEOF_GCS_REGSET from
gdb/aarch64-linux-tdep.h to gdb/arch/aarch64-gcs-linux.h, as suggested
by Luis.
- Move changes to HWCAP_PACA to separate patch.
gdb/Makefile.in | 1 +
gdb/aarch64-linux-nat.c | 3 +--
gdb/aarch64-linux-tdep.c | 13 +++++-----
gdb/arch/aarch64-gcs-linux.h | 24 ++++++------------
gdb/linux-tdep.h | 11 ---------
gdb/nat/aarch64-gcs-linux.h | 45 ++++++++++++++++++++++++++++++++++
gdbserver/linux-aarch64-low.cc | 2 +-
7 files changed, 63 insertions(+), 36 deletions(-)
create mode 100644 gdb/nat/aarch64-gcs-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3d9bc86a97fd..4a68189b4340 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1548,6 +1548,7 @@ HFILES_NO_SRCDIR = \
moxie-tdep.h \
namespace.h \
nat/aarch64-fpmr-linux.h \
+ nat/aarch64-gcs-linux.h \
nat/aarch64-hw-point.h \
nat/aarch64-linux.h \
nat/aarch64-linux-hw-point.h \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 4b86ae9ebe16..52ace4aab411 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -33,6 +33,7 @@
#include "aarch32-tdep.h"
#include "arch/arm.h"
#include "nat/aarch64-fpmr-linux.h"
+#include "nat/aarch64-gcs-linux.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-linux-hw-point.h"
#include "nat/aarch64-mte-linux-ptrace.h"
@@ -54,8 +55,6 @@
#include "gdb_proc_service.h"
#include "arch-utils.h"
-#include "arch/aarch64-gcs-linux.h"
-
#include <string.h>
#ifndef TRAP_HWBKPT
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 4ca05fba771d..d136b0f2145e 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -1736,8 +1736,9 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
gcs_regmap, regcache_supply_regset, regcache_collect_regset
};
- cb (".reg-aarch-gcs", sizeof (user_gcs), sizeof (user_gcs),
- &aarch64_linux_gcs_regset, "GCS registers", cb_data);
+ cb (".reg-aarch-gcs", AARCH64_LINUX_SIZEOF_GCS_REGSET,
+ AARCH64_LINUX_SIZEOF_GCS_REGSET, &aarch64_linux_gcs_regset,
+ "GCS registers", cb_data);
}
}
@@ -1763,7 +1764,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
length. */
features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
features.pauth = hwcap & AARCH64_HWCAP_PACA;
- features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
+ features.gcs = features.gcs_linux = hwcap & AARCH64_HWCAP_GCS;
features.mte = hwcap2 & AARCH64_HWCAP2_MTE;
features.fpmr = hwcap2 & AARCH64_HWCAP2_FPMR;
@@ -2612,7 +2613,7 @@ aarch64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache *regcache,
if (status != REG_VALID)
error (_("Can't read $gcspr."));
- shadow_stack_enabled = features_enabled & PR_SHADOW_STACK_ENABLE;
+ shadow_stack_enabled = features_enabled & AARCH64_PR_SHADOW_STACK_ENABLE;
return gcspr;
}
@@ -2700,7 +2701,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
if (si_code == AARCH64_SEGV_MTEAERR || si_code == AARCH64_SEGV_MTESERR)
meaning = _("Memory tag violation");
- else if (si_code == SEGV_CPERR && si_errno == 0)
+ else if (si_code == AARCH64_SEGV_CPERR && si_errno == 0)
meaning = _("Guarded Control Stack error");
else
return;
@@ -2733,7 +2734,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
uiout->field_string ("logical-tag", hex_string (ltag));
}
}
- else if (si_code != SEGV_CPERR)
+ else if (si_code != AARCH64_SEGV_CPERR)
{
uiout->text ("\n");
uiout->text (_("Fault address unavailable"));
diff --git a/gdb/arch/aarch64-gcs-linux.h b/gdb/arch/aarch64-gcs-linux.h
index b31fc32daa03..4aa0cbd4def8 100644
--- a/gdb/arch/aarch64-gcs-linux.h
+++ b/gdb/arch/aarch64-gcs-linux.h
@@ -20,25 +20,17 @@
#ifndef GDB_ARCH_AARCH64_GCS_LINUX_H
#define GDB_ARCH_AARCH64_GCS_LINUX_H
-#include <stdint.h>
-
/* Feature check for Guarded Control Stack. */
-#ifndef HWCAP_GCS
-#define HWCAP_GCS (1ULL << 32)
-#endif
-
-/* Make sure we only define these if the kernel header doesn't. */
-#ifndef GCS_MAGIC
+#define AARCH64_HWCAP_GCS (1ULL << 32)
-/* GCS state (NT_ARM_GCS). */
+#define AARCH64_SEGV_CPERR 10 /* Control protection error. */
-struct user_gcs
-{
- uint64_t features_enabled;
- uint64_t features_locked;
- uint64_t gcspr_el0;
-};
+/* Flag which enables shadow stack in PR_SET_SHADOW_STACK_STATUS prctl. */
+#define AARCH64_PR_SHADOW_STACK_ENABLE (1UL << 0)
+#define AARCH64_PR_SHADOW_STACK_WRITE (1UL << 1)
+#define AARCH64_PR_SHADOW_STACK_PUSH (1UL << 2)
-#endif /* GCS_MAGIC */
+/* The GCS regset consists of 3 64-bit registers. */
+#define AARCH64_LINUX_SIZEOF_GCS_REGSET (3 * 8)
#endif /* GDB_ARCH_AARCH64_GCS_LINUX_H */
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 73d4832069f4..aee52eae0f4a 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -27,17 +27,6 @@
struct inferior;
struct regcache;
-#ifndef SEGV_CPERR
-#define SEGV_CPERR 10 /* Control protection error. */
-#endif
-
-/* Flag which enables shadow stack in PR_SET_SHADOW_STACK_STATUS prctl. */
-#ifndef PR_SHADOW_STACK_ENABLE
-#define PR_SHADOW_STACK_ENABLE (1UL << 0)
-#define PR_SHADOW_STACK_WRITE (1UL << 1)
-#define PR_SHADOW_STACK_PUSH (1UL << 2)
-#endif
-
/* Enum used to define the extra fields of the siginfo type used by an
architecture. */
enum linux_siginfo_extra_field_values
diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
new file mode 100644
index 000000000000..ddf8342a4284
--- /dev/null
+++ b/gdb/nat/aarch64-gcs-linux.h
@@ -0,0 +1,45 @@
+/* Common native Linux definitions for AArch64 Guarded Control Stack.
+
+ Copyright (C) 2025-2026 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef GDB_NAT_AARCH64_GCS_LINUX_H
+#define GDB_NAT_AARCH64_GCS_LINUX_H
+
+#include <stdint.h>
+#include <asm/ptrace.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+/* Make sure we only define these if the kernel header doesn't. */
+#ifndef GCS_MAGIC
+
+/* GCS state (NT_ARM_GCS). */
+
+struct user_gcs
+{
+ uint64_t features_enabled;
+ uint64_t features_locked;
+ uint64_t gcspr_el0;
+};
+
+#endif /* GCS_MAGIC */
+
+#endif /* GDB_NAT_AARCH64_GCS_LINUX_H */
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index c44f75167141..a2588a6e2a9c 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -40,12 +40,12 @@
#include "gdb_proc_service.h"
#include "arch/aarch64.h"
-#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-pauth-linux.h"
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
#include "nat/aarch64-fpmr-linux.h"
+#include "nat/aarch64-gcs-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "tdesc.h"
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions
2026-03-03 5:06 ` [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions Thiago Jung Bauermann
@ 2026-03-04 4:27 ` Thiago Jung Bauermann
2026-03-10 14:05 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 4:27 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
> Only native code should use struct user_gcs, so its definition should be
> in a native-specific file and not in a file under gdb/arch/.
>
> To fix this problem, create gdb/nat/aarch64-gcs-linux-ptrace.h and move
> the struct user_gcs definition to it, as suggested by Luis.
>
> To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
> macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
> and use it in aarch64-linux-tdep.c, as is done for other regsets and
> following a suggestion from Simon Marchi.
>
> Also, move the HWCAP_GCS definition to
> gdb/nat/aarch64-gcs-linux-ptrace.h and create an AARCH64_HWCAP_GCS
> definition in gdb/arch/aarch64-gcs-linux.h for use by target-dependent
> code.
>
> Similarly, move the SEGV_CPERR and PR_SHADOW_STACK_{ENABLE,WRITE,PUSH}
> definitions, which were added by the GCS patches and are only used by
> aarch64-linux target-dependent code, to gdb/arch/aarch64-gcs-linux.h
> with an AARCH64_ prefix and adjust users.
>
> Finally, I noticed that gdb/aarch64-linux-nat.c and
> gdbserver/linux-aarch64-low.cc don't need anything from the
> arch/aarch64-gcs-linux.h header, so make them not include it.
>
> Suggested-by: Luis <luis.machado.foss@gmail.com>
> Suggested-by: Simon Marchi <simark@simark.ca>
As Simon mentioned in his review, this commit message wrongly references
gdb/nat/aarch64-gcs-linux-ptrace.h. I forgot to adjust the text after I
decided to rename the file to gdb/nat/aarch64-gcs-linux.h. Fixed locally.
> diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
> new file mode 100644
> index 000000000000..ddf8342a4284
> --- /dev/null
> +++ b/gdb/nat/aarch64-gcs-linux.h
> @@ -0,0 +1,45 @@
> +/* Common native Linux definitions for AArch64 Guarded Control Stack.
> +
> + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +#ifndef GDB_NAT_AARCH64_GCS_LINUX_H
> +#define GDB_NAT_AARCH64_GCS_LINUX_H
> +
> +#include <stdint.h>
> +#include <asm/ptrace.h>
> +
> +/* Feature check for Guarded Control Stack. */
> +#ifndef HWCAP_GCS
> +#define HWCAP_GCS (1ULL << 32)
> +#endif
> +
> +/* Make sure we only define these if the kernel header doesn't. */
> +#ifndef GCS_MAGIC
> +
> +/* GCS state (NT_ARM_GCS). */
> +
> +struct user_gcs
> +{
> + uint64_t features_enabled;
> + uint64_t features_locked;
> + uint64_t gcspr_el0;
> +};
> +
> +#endif /* GCS_MAGIC */
> +
> +#endif /* GDB_NAT_AARCH64_GCS_LINUX_H */
As with previous patches, I amended this one locally with:
diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
index ddf8342a4284..79e6dcaaaf18 100644
--- a/gdb/nat/aarch64-gcs-linux.h
+++ b/gdb/nat/aarch64-gcs-linux.h
@@ -21,6 +21,7 @@
#define GDB_NAT_AARCH64_GCS_LINUX_H
#include <stdint.h>
+#include <asm/hwcap.h>
#include <asm/ptrace.h>
/* Feature check for Guarded Control Stack. */
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions
2026-03-04 4:27 ` Thiago Jung Bauermann
@ 2026-03-10 14:05 ` Luis
0 siblings, 0 replies; 25+ messages in thread
From: Luis @ 2026-03-10 14:05 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: gdb-patches, Chris Packham, Tom Tromey, Simon Marchi, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 3997 bytes --]
Thanks.
Approved-By: Luis Machado <luis.machado.foss@gmail.com>
On Wed, Mar 4, 2026, 01:27 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Thiago Jung Bauermann <thiago.bauermann@linaro.org> writes:
>
> > Only native code should use struct user_gcs, so its definition should be
> > in a native-specific file and not in a file under gdb/arch/.
> >
> > To fix this problem, create gdb/nat/aarch64-gcs-linux-ptrace.h and move
> > the struct user_gcs definition to it, as suggested by Luis.
> >
> > To fix the use of struct user_gcs in gdb/aarch64-linuxt-dep.c, define a
> > macro with the size of the GCS regset in gdb/arch/aarch64-gcs-linux.h
> > and use it in aarch64-linux-tdep.c, as is done for other regsets and
> > following a suggestion from Simon Marchi.
> >
> > Also, move the HWCAP_GCS definition to
> > gdb/nat/aarch64-gcs-linux-ptrace.h and create an AARCH64_HWCAP_GCS
> > definition in gdb/arch/aarch64-gcs-linux.h for use by target-dependent
> > code.
> >
> > Similarly, move the SEGV_CPERR and PR_SHADOW_STACK_{ENABLE,WRITE,PUSH}
> > definitions, which were added by the GCS patches and are only used by
> > aarch64-linux target-dependent code, to gdb/arch/aarch64-gcs-linux.h
> > with an AARCH64_ prefix and adjust users.
> >
> > Finally, I noticed that gdb/aarch64-linux-nat.c and
> > gdbserver/linux-aarch64-low.cc don't need anything from the
> > arch/aarch64-gcs-linux.h header, so make them not include it.
> >
> > Suggested-by: Luis <luis.machado.foss@gmail.com>
> > Suggested-by: Simon Marchi <simark@simark.ca>
>
> As Simon mentioned in his review, this commit message wrongly references
> gdb/nat/aarch64-gcs-linux-ptrace.h. I forgot to adjust the text after I
> decided to rename the file to gdb/nat/aarch64-gcs-linux.h. Fixed locally.
>
>
> > diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
> > new file mode 100644
> > index 000000000000..ddf8342a4284
> > --- /dev/null
> > +++ b/gdb/nat/aarch64-gcs-linux.h
> > @@ -0,0 +1,45 @@
> > +/* Common native Linux definitions for AArch64 Guarded Control Stack.
> > +
> > + Copyright (C) 2025-2026 Free Software Foundation, Inc.
> > +
> > + This file is part of GDB.
> > +
> > + This program is free software; you can redistribute it and/or modify
> > + it under the terms of the GNU General Public License as published by
> > + the Free Software Foundation; either version 3 of the License, or
> > + (at your option) any later version.
> > +
> > + This program is distributed in the hope that it will be useful,
> > + but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + GNU General Public License for more details.
> > +
> > + You should have received a copy of the GNU General Public License
> > + along with this program. If not, see <http://www.gnu.org/licenses/>.
> */
> > +
> > +#ifndef GDB_NAT_AARCH64_GCS_LINUX_H
> > +#define GDB_NAT_AARCH64_GCS_LINUX_H
> > +
> > +#include <stdint.h>
> > +#include <asm/ptrace.h>
> > +
> > +/* Feature check for Guarded Control Stack. */
> > +#ifndef HWCAP_GCS
> > +#define HWCAP_GCS (1ULL << 32)
> > +#endif
> > +
> > +/* Make sure we only define these if the kernel header doesn't. */
> > +#ifndef GCS_MAGIC
> > +
> > +/* GCS state (NT_ARM_GCS). */
> > +
> > +struct user_gcs
> > +{
> > + uint64_t features_enabled;
> > + uint64_t features_locked;
> > + uint64_t gcspr_el0;
> > +};
> > +
> > +#endif /* GCS_MAGIC */
> > +
> > +#endif /* GDB_NAT_AARCH64_GCS_LINUX_H */
>
> As with previous patches, I amended this one locally with:
>
> diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
> index ddf8342a4284..79e6dcaaaf18 100644
> --- a/gdb/nat/aarch64-gcs-linux.h
> +++ b/gdb/nat/aarch64-gcs-linux.h
> @@ -21,6 +21,7 @@
> #define GDB_NAT_AARCH64_GCS_LINUX_H
>
> #include <stdint.h>
> +#include <asm/hwcap.h>
> #include <asm/ptrace.h>
>
> /* Feature check for Guarded Control Stack. */
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 5371 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v4 6/6] GDB: aarch64-linux: Fix build failure on musl systems
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
` (4 preceding siblings ...)
2026-03-03 5:06 ` [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions Thiago Jung Bauermann
@ 2026-03-03 5:06 ` Thiago Jung Bauermann
2026-03-03 16:14 ` [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Simon Marchi
6 siblings, 0 replies; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-03 5:06 UTC (permalink / raw)
To: gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, Simon Marchi, sunilkumar.dora
When building against musl (e.g. on Alpine Linux), the following error
happens:
CXX linux-aarch64-low.o
In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:48:
/home/bauermann/src/binutils-gdb/gdbserver/../gdb/nat/aarch64-gcs-linux.h:36:8: error: redefinition of 'struct user_gcs'
36 | struct user_gcs
| ^~~~~~~~
In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:36:
/usr/include/asm/ptrace.h:329:8: note: previous definition of 'struct user_gcs'
329 | struct user_gcs {
| ^~~~~~~~
make[2]: *** [Makefile:565: linux-aarch64-low.o] Error 1
aarch64-linux-tdep.c fails to build in the same way. This happens because
aarch64-gcs-linux-ptrace.h uses GCS_MAGIC to see whether the system headers
have GCS-related definitions. The problem is that GCS_MAGIC is defined in
<asm/sigcontext.h> while struct gcs_user is defined in <asm/ptrace.h>.
It's fine on glibc systems because in the set of system headers that
linux-aarch64-low.cc and aarch64-linux-tdep.c include, <asm/sigcontext.h>
ends up being included implicitly as well. This doesn't happen when using
musl's headers though.
There isn't a macro in <asm/ptrace.h> whose presence is correlated with
the presence of the struct user_gcs definition, so a configure check is
needed to detect it and conditionally define the struct.
Note that there's another build issue with musl, described in
PR gdb/33747 affecting compilation of gdb/ser-unix.c. In order to be
able to test this patch, I applied the patch in comment 11 there.
Tested with a native build on an Alpine Linux aarch64 system, and also
verified that all gdb.arch/aarch64-gcs*.exp tests pass on it.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33926
Co-authored-by: Chris Packham <judge.packham@gmail.com>
---
As I mentioned in the cover letter, if the series is approved I will
propose a version of this patch for the GDB 17 branch which doesn't depend
on the previous patches.
Changes since v3:
- Renamed gdb/nat/aarch64-gcs-linux-ptrace.h to gdb/nat/aarch64-gcs-linux.h.
Changes since v2:
- It's the same patch except that the header changed is
gdb/nat/aarch64-gcs-linux-ptrace.h rather than gdb/nat/aarch64-linux.h,
which doesn't exist in this version of the patch series.
gdb/nat/aarch64-gcs-linux.h | 5 ++---
gdbsupport/config.in | 3 +++
gdbsupport/configure | 36 ++++++++++++++++++++++++++++++++++++
gdbsupport/configure.ac | 19 +++++++++++++++++++
4 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h
index ddf8342a4284..3ce7b6486785 100644
--- a/gdb/nat/aarch64-gcs-linux.h
+++ b/gdb/nat/aarch64-gcs-linux.h
@@ -28,8 +28,7 @@
#define HWCAP_GCS (1ULL << 32)
#endif
-/* Make sure we only define these if the kernel header doesn't. */
-#ifndef GCS_MAGIC
+#ifndef HAVE_STRUCT_USER_GCS
/* GCS state (NT_ARM_GCS). */
@@ -40,6 +39,6 @@ struct user_gcs
uint64_t gcspr_el0;
};
-#endif /* GCS_MAGIC */
+#endif /* HAVE_STRUCT_USER_GCS */
#endif /* GDB_NAT_AARCH64_GCS_LINUX_H */
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index 0beacf22c057..2957ee0f0301 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -271,6 +271,9 @@
/* Define to 1 if `st_blocks' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
+/* Define to 1 if your system has struct user_gcs. */
+#undef HAVE_STRUCT_USER_GCS
+
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 05ad00f48c4f..584a80ef8255 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -14307,6 +14307,42 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Check for `struct user_gcs`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct user_gcs" >&5
+$as_echo_n "checking for struct user_gcs... " >&6; }
+if ${gdb_cv_struct_user_gcs+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/ptrace.h>
+ #include <asm/ptrace.h>
+int
+main ()
+{
+struct user_gcs u;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ gdb_cv_struct_user_gcs=yes
+else
+ gdb_cv_struct_user_gcs=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_user_gcs" >&5
+$as_echo "$gdb_cv_struct_user_gcs" >&6; }
+if test "$gdb_cv_struct_user_gcs" = yes; then
+
+$as_echo "#define HAVE_STRUCT_USER_GCS 1" >>confdefs.h
+
+fi
+
# Set the 'development' global.
. $srcdir/../bfd/development.sh
diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac
index 5491b8f3f10a..6c06832f0913 100644
--- a/gdbsupport/configure.ac
+++ b/gdbsupport/configure.ac
@@ -68,6 +68,25 @@ GDB_AC_PTRACE
AM_GDB_COMPILER_TYPE
AM_GDB_WARNINGS
+# Check for `struct user_gcs`
+AC_CACHE_CHECK(
+ [for struct user_gcs],
+ [gdb_cv_struct_user_gcs],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#include <sys/ptrace.h>
+ #include <asm/ptrace.h>],
+ [struct user_gcs u;]
+ )],
+ [gdb_cv_struct_user_gcs=yes],
+ [gdb_cv_struct_user_gcs=no]
+ )]
+)
+if test "$gdb_cv_struct_user_gcs" = yes; then
+ AC_DEFINE(HAVE_STRUCT_USER_GCS, 1,
+ [Define to 1 if your system has struct user_gcs.])
+fi
+
# Set the 'development' global.
. $srcdir/../bfd/development.sh
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-03 5:06 [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
` (5 preceding siblings ...)
2026-03-03 5:06 ` [PATCH v4 6/6] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
@ 2026-03-03 16:14 ` Simon Marchi
2026-03-04 3:52 ` Thiago Jung Bauermann
6 siblings, 1 reply; 25+ messages in thread
From: Simon Marchi @ 2026-03-03 16:14 UTC (permalink / raw)
To: Thiago Jung Bauermann, gdb-patches
Cc: Chris Packham, Luis, Tom Tromey, sunilkumar.dora
On 2026-03-03 00:06, Thiago Jung Bauermann wrote:
> v4 adds two new patches, reorganizing MTE and SME definitions.
>
> With this series, I think the AArch64 definitions are correctly organized
> between the headers in gdb/arch/ and gdb/nat/.
>
> if the series is approved I will propose a version of the last patch for
> the GDB 17 branch which doesn't depend on the previous patches, so that the
> build failure on aarch64-linux-musl can be fixed with minimal changes.
>
> I didn't include Luis' Approved-by to patches, since they have some changes
> in them.
>
> I also build-tested this version on aarch64-freebsd14.3 in addition to
> aarch64-linux-gnu and aarch64-linux-musl.
>
> Previous versions of the patches:
>
> v1: https://inbox.sourceware.org/gdb-patches/20260211045853.1436881-1-thiago.bauermann@linaro.org/
> v2: https://inbox.sourceware.org/gdb-patches/20260214045504.361392-1-thiago.bauermann@linaro.org/
> v3: https://inbox.sourceware.org/gdb-patches/20260217060106.1906312-1-thiago.bauermann@linaro.org/
I skimmed the code and read the commit messages, it looks good to me,
but I will leave Luis give the approval. Thanks for the cleanup, I
think things are organized in a systematic and predictable way now.
Here are some things that copilot had to say, I checked and they seemed
true:
- gdb/nat/aarch64-pauth-linux.h: HWCAP_PACA is defined unconditionally,
unlike every other HWCAP fallback in the series (HWCAP2_MTE,
HWCAP2_FPMR, HWCAP2_SME, HWCAP_GCS) which all use #ifndef guards. On
any modern aarch64 Linux system HWCAP_PACA is already defined by
<asm/hwcap.h>, so including this header after any header that pulls
it in will cause a redefinition error. Wrap it in #ifndef HWCAP_PACA
/ #endif.
(Simon: not sure it will necessarily be a error, I think it's possible to
redefine macros if they have exactly the same value, but still it
would be good to add the #ifndef.)
- FPMR: the commit message appears to be a copy-paste of the pauth one
that wasn't updated — it references AARCH64_HWCAP2_FPRM, HWCAP2_FPRM,
and gdb/arch/aarch64-pauth-linux.h / gdb/nat/aarch64-pauth-linux.h,
when all four should refer to the FPMR variants.
(Simon: notice the FPRM -> FPMR typos in there)
- GCS: the commit message says "create
gdb/nat/aarch64-gcs-linux-ptrace.h" but the file actually created is
gdb/nat/aarch64-gcs-linux.h.
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-03 16:14 ` [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes Simon Marchi
@ 2026-03-04 3:52 ` Thiago Jung Bauermann
2026-03-10 14:19 ` Luis
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-04 3:52 UTC (permalink / raw)
To: Simon Marchi
Cc: gdb-patches, Chris Packham, Luis, Tom Tromey, sunilkumar.dora
Hello Simon,
Simon Marchi <simark@simark.ca> writes:
> On 2026-03-03 00:06, Thiago Jung Bauermann wrote:
>> v4 adds two new patches, reorganizing MTE and SME definitions.
>>
>> With this series, I think the AArch64 definitions are correctly organized
>> between the headers in gdb/arch/ and gdb/nat/.
>>
>> if the series is approved I will propose a version of the last patch for
>> the GDB 17 branch which doesn't depend on the previous patches, so that the
>> build failure on aarch64-linux-musl can be fixed with minimal changes.
>>
>> I didn't include Luis' Approved-by to patches, since they have some changes
>> in them.
>>
>> I also build-tested this version on aarch64-freebsd14.3 in addition to
>> aarch64-linux-gnu and aarch64-linux-musl.
>>
>> Previous versions of the patches:
>>
>> v1: https://inbox.sourceware.org/gdb-patches/20260211045853.1436881-1-thiago.bauermann@linaro.org/
>> v2: https://inbox.sourceware.org/gdb-patches/20260214045504.361392-1-thiago.bauermann@linaro.org/
>> v3: https://inbox.sourceware.org/gdb-patches/20260217060106.1906312-1-thiago.bauermann@linaro.org/
>
> I skimmed the code and read the commit messages, it looks good to me,
> but I will leave Luis give the approval. Thanks for the cleanup, I
> think things are organized in a systematic and predictable way now.
Thanks! and thank you for the prompt review.
> Here are some things that copilot had to say, I checked and they seemed
> true:
They are true indeed.
> - gdb/nat/aarch64-pauth-linux.h: HWCAP_PACA is defined unconditionally,
> unlike every other HWCAP fallback in the series (HWCAP2_MTE,
> HWCAP2_FPMR, HWCAP2_SME, HWCAP_GCS) which all use #ifndef guards. On
> any modern aarch64 Linux system HWCAP_PACA is already defined by
> <asm/hwcap.h>, so including this header after any header that pulls
> it in will cause a redefinition error. Wrap it in #ifndef HWCAP_PACA
> / #endif.
Ah, I missed that. Fixed locally.
> (Simon: not sure it will necessarily be a error, I think it's possible to
> redefine macros if they have exactly the same value, but still it
> would be good to add the #ifndef.)
I tested and you are correct. There's a build error only if the
definitions differ.
In the process of testing this, I noticed that the #ifndef implies that
<asm/hwcap.h> is included, so I amended the nat/*.h files that define
HWCAP macros to also include it explicitly. And also <asm/ptrace.h> in
the case of one header which defines a couple of ptrace constants. I'll
detail it in the respective patches.
> - FPMR: the commit message appears to be a copy-paste of the pauth one
> that wasn't updated — it references AARCH64_HWCAP2_FPRM, HWCAP2_FPRM,
> and gdb/arch/aarch64-pauth-linux.h / gdb/nat/aarch64-pauth-linux.h,
> when all four should refer to the FPMR variants.
Argh. Fixed.
> (Simon: notice the FPRM -> FPMR typos in there)
Argh again. Fixed again.
> - GCS: the commit message says "create
> gdb/nat/aarch64-gcs-linux-ptrace.h" but the file actually created is
> gdb/nat/aarch64-gcs-linux.h.
Yes, I originally called the file ...-ptrace.h but then I changed my
mind and forgot to adjust the commit message. Fixed.
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-04 3:52 ` Thiago Jung Bauermann
@ 2026-03-10 14:19 ` Luis
2026-03-17 2:29 ` Thiago Jung Bauermann
0 siblings, 1 reply; 25+ messages in thread
From: Luis @ 2026-03-10 14:19 UTC (permalink / raw)
To: Thiago Jung Bauermann
Cc: Simon Marchi, gdb-patches, Chris Packham, Tom Tromey, sunilkumar.dora
[-- Attachment #1: Type: text/plain, Size: 3574 bytes --]
Thanks. I think v4 is good.
On Wed, Mar 4, 2026, 00:52 Thiago Jung Bauermann <
thiago.bauermann@linaro.org> wrote:
> Hello Simon,
>
> Simon Marchi <simark@simark.ca> writes:
>
> > On 2026-03-03 00:06, Thiago Jung Bauermann wrote:
> >> v4 adds two new patches, reorganizing MTE and SME definitions.
> >>
> >> With this series, I think the AArch64 definitions are correctly
> organized
> >> between the headers in gdb/arch/ and gdb/nat/.
> >>
> >> if the series is approved I will propose a version of the last patch for
> >> the GDB 17 branch which doesn't depend on the previous patches, so that
> the
> >> build failure on aarch64-linux-musl can be fixed with minimal changes.
> >>
> >> I didn't include Luis' Approved-by to patches, since they have some
> changes
> >> in them.
> >>
> >> I also build-tested this version on aarch64-freebsd14.3 in addition to
> >> aarch64-linux-gnu and aarch64-linux-musl.
> >>
> >> Previous versions of the patches:
> >>
> >> v1:
> https://inbox.sourceware.org/gdb-patches/20260211045853.1436881-1-thiago.bauermann@linaro.org/
> >> v2:
> https://inbox.sourceware.org/gdb-patches/20260214045504.361392-1-thiago.bauermann@linaro.org/
> >> v3:
> https://inbox.sourceware.org/gdb-patches/20260217060106.1906312-1-thiago.bauermann@linaro.org/
> >
> > I skimmed the code and read the commit messages, it looks good to me,
> > but I will leave Luis give the approval. Thanks for the cleanup, I
> > think things are organized in a systematic and predictable way now.
>
> Thanks! and thank you for the prompt review.
>
> > Here are some things that copilot had to say, I checked and they seemed
> > true:
>
> They are true indeed.
>
> > - gdb/nat/aarch64-pauth-linux.h: HWCAP_PACA is defined unconditionally,
> > unlike every other HWCAP fallback in the series (HWCAP2_MTE,
> > HWCAP2_FPMR, HWCAP2_SME, HWCAP_GCS) which all use #ifndef guards. On
> > any modern aarch64 Linux system HWCAP_PACA is already defined by
> > <asm/hwcap.h>, so including this header after any header that pulls
> > it in will cause a redefinition error. Wrap it in #ifndef HWCAP_PACA
> > / #endif.
>
> Ah, I missed that. Fixed locally.
>
> > (Simon: not sure it will necessarily be a error, I think it's
> possible to
> > redefine macros if they have exactly the same value, but still it
> > would be good to add the #ifndef.)
>
> I tested and you are correct. There's a build error only if the
> definitions differ.
>
> In the process of testing this, I noticed that the #ifndef implies that
> <asm/hwcap.h> is included, so I amended the nat/*.h files that define
> HWCAP macros to also include it explicitly. And also <asm/ptrace.h> in
> the case of one header which defines a couple of ptrace constants. I'll
> detail it in the respective patches.
>
> > - FPMR: the commit message appears to be a copy-paste of the pauth one
> > that wasn't updated — it references AARCH64_HWCAP2_FPRM, HWCAP2_FPRM,
> > and gdb/arch/aarch64-pauth-linux.h / gdb/nat/aarch64-pauth-linux.h,
> > when all four should refer to the FPMR variants.
>
> Argh. Fixed.
>
> > (Simon: notice the FPRM -> FPMR typos in there)
>
> Argh again. Fixed again.
>
> > - GCS: the commit message says "create
> > gdb/nat/aarch64-gcs-linux-ptrace.h" but the file actually created is
> > gdb/nat/aarch64-gcs-linux.h.
>
> Yes, I originally called the file ...-ptrace.h but then I changed my
> mind and forgot to adjust the commit message. Fixed.
>
> --
> Thiago
>
[-- Attachment #2: Type: text/html, Size: 4842 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-10 14:19 ` Luis
@ 2026-03-17 2:29 ` Thiago Jung Bauermann
2026-03-17 2:49 ` Simon Marchi
0 siblings, 1 reply; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-17 2:29 UTC (permalink / raw)
To: Luis
Cc: Simon Marchi, gdb-patches, Chris Packham, Tom Tromey, sunilkumar.dora
Hello,
Luis <luis.machado.foss@gmail.com> writes:
> Thanks. I think v4 is good.
Thank you! I waited a bit to see if Simon wanted to chime in again on
the discussion about using struct user_pac_mask in patch 1. I'll create
an RFC patch implementing that idea and post it separately.
I just pushed the series, with the last commit being 02090062127d.
While doing it I noticed that I had forgotten to add your Approved-By to
the last patch, which you had given in v3. Since that patch was
identical in v4, I added it to the commit message.
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-17 2:29 ` Thiago Jung Bauermann
@ 2026-03-17 2:49 ` Simon Marchi
2026-03-17 23:43 ` Thiago Jung Bauermann
0 siblings, 1 reply; 25+ messages in thread
From: Simon Marchi @ 2026-03-17 2:49 UTC (permalink / raw)
To: Thiago Jung Bauermann, Luis
Cc: gdb-patches, Chris Packham, Tom Tromey, sunilkumar.dora
On 2026-03-16 22:29, Thiago Jung Bauermann wrote:
> Hello,
>
> Luis <luis.machado.foss@gmail.com> writes:
>
>> Thanks. I think v4 is good.
>
> Thank you! I waited a bit to see if Simon wanted to chime in again on
> the discussion about using struct user_pac_mask in patch 1. I'll create
> an RFC patch implementing that idea and post it separately.
It's just an idea, do it if you think it makes sense and it's not too
complicated. I thought it could help show that the magic size doesn't
come from nowhere. But there is not advantage beyond that.
Simon
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v4 0/6] GDB: aarch64-linux: Some header fixes
2026-03-17 2:49 ` Simon Marchi
@ 2026-03-17 23:43 ` Thiago Jung Bauermann
0 siblings, 0 replies; 25+ messages in thread
From: Thiago Jung Bauermann @ 2026-03-17 23:43 UTC (permalink / raw)
To: Simon Marchi
Cc: Luis, gdb-patches, Chris Packham, Tom Tromey, sunilkumar.dora
Simon Marchi <simark@simark.ca> writes:
> On 2026-03-16 22:29, Thiago Jung Bauermann wrote:
>> Hello,
>>
>> Luis <luis.machado.foss@gmail.com> writes:
>>
>>> Thanks. I think v4 is good.
>>
>> Thank you! I waited a bit to see if Simon wanted to chime in again on
>> the discussion about using struct user_pac_mask in patch 1. I'll create
>> an RFC patch implementing that idea and post it separately.
>
> It's just an idea, do it if you think it makes sense and it's not too
> complicated. I thought it could help show that the magic size doesn't
> come from nowhere. But there is not advantage beyond that.
Thank you. I experimented with it but im my view it's not worth the
extra configure boilerplate.
Unlike the GCS code which actually uses the struct user_gcs definition,
the PAuth register fetching/writing code uses a two-element array of
uint64_t and would benefit little from a rewrite to use members of
struct user_pac_mask instead.
--
Thiago
^ permalink raw reply [flat|nested] 25+ messages in thread