From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IXqHC6ZspmlM0hEAWB0awg (envelope-from ) for ; Tue, 03 Mar 2026 00:07:50 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p87yBHC5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 27CE31E08D; Tue, 03 Mar 2026 00:07:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D04681E08D for ; Tue, 03 Mar 2026 00:07:48 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 5AFA54BA23C6 for ; Tue, 3 Mar 2026 05:07:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5AFA54BA23C6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p87yBHC5 Received: from mail-dl1-x1233.google.com (mail-dl1-x1233.google.com [IPv6:2607:f8b0:4864:20::1233]) by sourceware.org (Postfix) with ESMTPS id 6B34D4BA2E0D for ; Tue, 3 Mar 2026 05:06:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B34D4BA2E0D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B34D4BA2E0D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1233 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514407; cv=none; b=HRE2qJBBMKnDfrJb3B9q/i4T21KCRRpNR/kcVsuxwe9h1eXKf/H+VdtSjcapLvSk4Pc9Y2E7Tyr3yiCmzNUMKWwS7FhpbjeVWCLIMJIvdEC4BSawjCPIH/p8uV1Omz0WyF4A2MQ6ywDJVK7P8b2Qo3kJ7RscrDMwK8y7KvUsCMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514407; c=relaxed/simple; bh=IHckzBu3YLKCwWwxC0cr9g/p0CU3PGx9QuzUK1M4Sps=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iQKKPKjkeiwgb4cf69VOnkYtHfpNinsz8O2Y2gR0V4MVXuLxyOXJwE0xgn/bh7/STm/k5XZuXP62bqqr7CX52SscOFj79+cwjAIlQZtGnNpdH0mgoVs8v4QvPAUlyUHcrFLBaVUp/o9SI6XFcmHl2Iw6Oy3cqU+DFg6VOXOrv6w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B34D4BA2E0D Received: by mail-dl1-x1233.google.com with SMTP id a92af1059eb24-126ea4b77adso6785320c88.1 for ; Mon, 02 Mar 2026 21:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772514406; x=1773119206; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pYRY6BdEHnaH562JV5oSCIZij3L1gdGslvmos3CJcm4=; b=p87yBHC5Q7SiwGEjUFvbCZCGzbANsxntC5/jHf8SzPuZ8giMC72Sc/RwJrevd1Xwf6 iDV4y9kUAUmBFgEq83mZpJKJ/ylnfZqVtdaIBKrIaIH6DE+tRh6CdZi+NojHza8agwbV 5cTt0K3tQBx6F5Cbav4bqxSHMUsNFq1T0g4gJB3PENt/j3UFFCyHldGhcVHY91o4uuvu nMGveaYslFllFatKI42Z28M8yJx0xS7eoteyu1afGUR34p2YkkJ9689BIiBh9ooEDc+d DWUgEfYCxUs343URtff0f3Bmgbkdr0Vl5QjIOajjY3uZA2rzFTr2AISBCyqHcQGzaHjG 5EjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772514406; x=1773119206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pYRY6BdEHnaH562JV5oSCIZij3L1gdGslvmos3CJcm4=; b=RxsVDbSLLJ64JVCrsQvkJ2Qas740YEiryAGlju5T2cebzYnLLgMsxL80NeyjFCLtyh aGw3JbPjTSuWTo+fE6Bk8nKhTFONJu3+WPXQRVKRK9wlEA0QVYx0oCjvIhSV81DwvYub 040PnUuIbN5j+KWDhVjkQVP1ExhtnVO8MYlzuU9iaDSoW5Q0g2KNw7bXgqL3ERC3pK+L 0hUskx9Z31hs8yUZryW08Dj8VoHxYTk4/qhkoI8cpjf/fNRMjgH3YQMo4jq3TG11cCjK MrRYBD4RRYsK6u1WRwx3P7CsLk6Liya2sxUyE81UPgUnuwwphhE9d4TFAUZf2LC0Vmj2 x/LA== X-Gm-Message-State: AOJu0YyGXcBf/gBidC2e0/jJXuNGVrgNvEXOgHwWm8nuoJkIrGpnbYA6 8KXCAkR41oyYqDQr07cyspDmfLEuJvPPI5FdacNaB4ZPI2Y+5eFNYFPLdRBdF9w/EC+K3Pz2bZj REtELPaQ= X-Gm-Gg: ATEYQzy0TKw0cgEaq0L+lWC4nNhQFEKHffUjY5KIKfN2/TU2n4U7szXCDn4w/kPpZDV 4IYUzQxWZq5Qj9iCoXgzclLyguZGhqRNTXbFXP8iAXALRIORVsdU0hMK4MjLy5jmPiYQaH3C7ue +7LJalKZjm0pOOT3NdqWsKERCR7XRWflE71LWLVfSf+tDeyEJhkUriPaTFAS2TwexqQtxu9WomE vRB9rTTEqFm3wpQ4YpWD1izozv8F8Q7ow6YLnY6dgOD7+BCaEie8ayPtMgdhnTXGnJzARn7P58d 1he1e4CY7sPhyzjQb49EZ2nQYePrJLl9ECr5osEPFC8km5TaFLedr9o9OgZtbq+APNWolHTf17s uEsG2q6SJPsF6kXOxPqDvw8aXVS5tMhB4ftaKTlALK6VH8A+iq/FXBTfeTvDzwu4exjXub6zh/i iuW7QyINR3nrwcO7EhQZdCz48UQqqxufrA6A== X-Received: by 2002:a05:7022:6881:b0:11e:65b5:75ce with SMTP id a92af1059eb24-1278fb816d9mr6914927c88.10.1772514406108; Mon, 02 Mar 2026 21:06:46 -0800 (PST) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12789a32dabsm18190982c88.11.2026.03.02.21.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 21:06:45 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Chris Packham , Luis , Tom Tromey , Simon Marchi , sunilkumar.dora@windriver.com Subject: [PATCH v4 1/6] GDB: Add aarch64-pauth-linux.h to gdb/arch/ and gdb/nat/ Date: Tue, 3 Mar 2026 02:06:36 -0300 Message-ID: <20260303050641.198127-2-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303050641.198127-1-thiago.bauermann@linaro.org> References: <20260303050641.198127-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.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 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 Suggested-by: Simon Marchi --- 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 . */ + +#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 . */ + +#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);