From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: gdb-patches@sourceware.org
Cc: Chris Packham <judge.packham@gmail.com>,
Luis <luis.machado.foss@gmail.com>, Tom Tromey <tom@tromey.com>,
Simon Marchi <simark@simark.ca>
Subject: [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h
Date: Tue, 17 Feb 2026 03:00:59 -0300 [thread overview]
Message-ID: <20260217060106.1906312-2-thiago.bauermann@linaro.org> (raw)
In-Reply-To: <20260217060106.1906312-1-thiago.bauermann@linaro.org>
The code supporting Pointer Authentication duplicates the definition of
AARCH64_HWCAP_PACA and of AARCH64_LINUX_SIZEOF_PAUTH between GDB and
gdbserver, so add new header to host those definitions.
Also, rename AARCH64_HWCAP_PACA to HWCAP_PACA and only define it if it
isn't already defined by the system headers, as is done for other HWCAP
constants.
Suggested-by: Luis <luis.machado.foss@gmail.com>
---
gdb/Makefile.in | 1 +
gdb/aarch64-linux-nat.c | 3 ++-
gdb/aarch64-linux-tdep.c | 3 ++-
gdb/aarch64-linux-tdep.h | 6 ------
gdb/arch/aarch64-pauth-linux.h | 31 +++++++++++++++++++++++++++++++
gdb/arch/aarch64.h | 3 ---
gdbserver/linux-aarch64-low.cc | 8 +++-----
7 files changed, 39 insertions(+), 16 deletions(-)
create mode 100644 gdb/arch/aarch64-pauth-linux.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 2aa95be968ac..8f8a95beccc3 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 \
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 028de981588b..d310d3e814b2 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -53,6 +53,7 @@
#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
+#include "arch/aarch64-pauth-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
#include "arch/aarch64-scalable-linux.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..b5af281d8a40 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"
@@ -1760,7 +1761,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
have the correct target description with the correct SVE vector
length. */
features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
- 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.fpmr = hwcap2 & HWCAP2_FPMR;
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..e973c79c8767
--- /dev/null
+++ b/gdb/arch/aarch64-pauth-linux.h
@@ -0,0 +1,31 @@
+/* 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. */
+#ifndef HWCAP_PACA
+#define HWCAP_PACA (1 << 30)
+#endif
+
+/* 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/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index b19e605f55d6..69aaabc1a8f9 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -45,6 +45,7 @@
#include "linux-aarch32-tdesc.h"
#include "linux-aarch64-tdesc.h"
#include "nat/aarch64-mte-linux-ptrace.h"
+#include "arch/aarch64-pauth-linux.h"
#include "nat/aarch64-scalable-linux-ptrace.h"
#include "tdesc.h"
@@ -952,7 +953,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 +985,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 +1003,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);
next prev parent reply other threads:[~2026-02-17 6:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-17 6:00 [PATCH v3 0/4] GDB: aarch64-linux: Some header fixes Thiago Jung Bauermann
2026-02-17 6:00 ` Thiago Jung Bauermann [this message]
2026-02-21 12:14 ` [PATCH v3 1/4] GDB: Add gdb/arch/aarch64-pauth-linux.h Luis
2026-02-21 15:57 ` Simon Marchi
2026-02-22 10:06 ` Luis
2026-02-22 14:22 ` Simon Marchi
2026-02-22 15:15 ` Luis
2026-02-22 15:25 ` Simon Marchi
2026-03-03 5:00 ` Thiago Jung Bauermann
2026-02-17 6:01 ` [PATCH v3 2/4] GDB: Add gdb/arch/aarch64-fpmr-linux.h Thiago Jung Bauermann
2026-02-21 12:15 ` Luis
2026-02-17 6:01 ` [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs Thiago Jung Bauermann
2026-02-21 12:20 ` Luis
2026-02-17 6:01 ` [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems Thiago Jung Bauermann
2026-02-21 12:23 ` Luis
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=20260217060106.1906312-2-thiago.bauermann@linaro.org \
--to=thiago.bauermann@linaro.org \
--cc=gdb-patches@sourceware.org \
--cc=judge.packham@gmail.com \
--cc=luis.machado.foss@gmail.com \
--cc=simark@simark.ca \
--cc=tom@tromey.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