From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uSPpF1kElGmOej4AWB0awg (envelope-from ) for ; Tue, 17 Feb 2026 01:02:01 -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=mEo8ygmo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5B8DC1E0BA; Tue, 17 Feb 2026 01:02:01 -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 618741E089 for ; Tue, 17 Feb 2026 01:02:00 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 081C34B9DB5B for ; Tue, 17 Feb 2026 06:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 081C34B9DB5B 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=mEo8ygmo Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by sourceware.org (Postfix) with ESMTPS id BF9BC4BAE7CA for ; Tue, 17 Feb 2026 06:01:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF9BC4BAE7CA 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 BF9BC4BAE7CA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771308083; cv=none; b=KL4PghrQUeIMV7Tw+doS4fsoZNJ27Z8bOjeuOsoAXGyKQhSCwCOQJAKuGQDHS6wiAr7Hl3FUg1oh5U1ReliD2BvqEAn4dOfue4TvVD44vPn850CQqf5K12Szf7CQNDvJvk9b0cB5UYBg0cj2+4k3ov6xh0MjfaGmNj13VQdM1ZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771308083; c=relaxed/simple; bh=dDafSPNy2VP+3EGlMmedlOdEng0cu3XM8V2uDmV6CPU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=elZ7ngMsbY2E5XyAuKp37wdjbaTsWil7buJfdVQRVCnD/hDyJbsQn9IGsKztR1lO9NjmrJVgPfj19dDzExNeO5xalDHeIWJTqsoNNru96Bnf6JWUi2wNr0fARjXZx/wcEeqiDvqCbI4rSIbEWGP75EpFk2ujhp9FNWTm9ZmyKlI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF9BC4BAE7CA Received: by mail-vs1-xe36.google.com with SMTP id ada2fe7eead31-5fa26e497abso2939630137.3 for ; Mon, 16 Feb 2026 22:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1771308083; x=1771912883; 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=/elF/Qup7c1X4gk8K36ann8PUVyHv48bzpVhylCsc04=; b=mEo8ygmo+R0WXB+LcNn8Gi836mTTY9s3GPk+pzUbRDyq8ORrdesoLYi7PS3X6UY13F qPGQIrfAH9kwbMWFn+AzXM6he3S2of07vUSxIq/vTiIzGwO+O7T7OYf81aXfVoCBXONr CAoMGr3MefWCrjzajLJJG7yKqnkbcwS+tZFHX/GNnczKOikyazGx+PvNfnGqz+m1j0sh c+B2iEvLbqO8GFGEaiCNgRaAxfm4Y9LHWC7cbmbMJP5h7PvXKw72RqLF5m5IBW5flZdv NdnM68FeVnHq9SfDbM9lm4jAAU9khiime1C0FHNisBgtvDX0CLCJNwD5fu8KvT8feV+t Z+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771308083; x=1771912883; 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=/elF/Qup7c1X4gk8K36ann8PUVyHv48bzpVhylCsc04=; b=DW2s6ktv4QO8rwvkBWHjA7yIuTe7RiCqpsGMdNy9ipVUCzEnInaVbPcFkJdZMFEWFs 2UsWSifK+3Csk18OGUHmdH5prLmEY2/L96rr7FOiogl1L2ZIFxYVNLS1h9gPA/88GUmE tqA9lDWX0TDOuIIARI4O8KgzB6uzO9wuPZ6qQ1iTTxAHk2/m2ZiMWTY6Gutud/XDNnMy yatNLvkVqt9Pg8WbXcJi3Ulkyre1Mr+Hpx2e6vhc3qrzl3KIzl7okFeVe1DyEjFiQtZW Rc0IyV1IKUZKJpU6KwmZVzNg/muywYe3EOq+N6RLbwiTp81bKtMWt5tv3giAM+EZRWDg 0pHA== X-Gm-Message-State: AOJu0Yy5BhijQxxHivp6802TiuWqKZLiKa2gkXME+NByfF07GCTI5DSH rVhhG2VZlH2B/CfLl8ByD7bLK7Ui7kfd7/eeTPijdTm8FngIGz64iFA0Rzuh3nKi75CC1qejm3L rN15E X-Gm-Gg: AZuq6aLUpPS8l4+5GlIGJyMQx2A41HQOO0whF0W75dt5HXxDugSipBVfHocOAeBIEfT J2F76FOf1cFCyGpqkMJIXq1af26ABry4NMX7Fp6JxwYs5mfpDSgK81G2oxcsZDTMq73wfsPp3F7 i7vSTyto59MSLt9z0m3GxHFZWZ9E1jnVp3stQ2xmnj0UG5u+7qfsFEeDJrd/6elXwdU+95aQSwW OLpmVQybXFdelph2ZZWQm07GRzy89YHN87/CPLrNqp9zChg3odDBlGJyE08TZpOK5q/SjEYANMA t5bDCzZpHeJkcQxifvoW1d0s2SHDIaWxwxZvR9V7f/NBABehO/tnjo7dmgQC5DQLOpEL5m31ZJL 54sI0zWW4l+ULMrCd3WZfnJBlCX36ifMI1Uzthvd38SwNyBFLd/LTrWmz6rJPbkOio+m/wCBbJF ZHsTodQrDdzG/G1h5Yx0Pw3Z7ojwayOtLQ9Q== X-Received: by 2002:a05:6102:4410:b0:5ef:8ad:a3bb with SMTP id ada2fe7eead31-5fe2ad3b0e5mr3465081137.9.1771308083010; Mon, 16 Feb 2026 22:01:23 -0800 (PST) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-94afd14e0b7sm7983470241.3.2026.02.16.22.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Feb 2026 22:01:22 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Chris Packham , Luis , Tom Tromey , Simon Marchi Subject: [PATCH v3 3/4] GDB: aarch64-linux: Move definition of struct user_gcs Date: Tue, 17 Feb 2026 03:01:01 -0300 Message-ID: <20260217060106.1906312-4-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260217060106.1906312-1-thiago.bauermann@linaro.org> References: <20260217060106.1906312-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 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. Suggested-by: Luis Suggested-by: Simon Marchi --- 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 | 1 + gdb/aarch64-linux-tdep.c | 5 ++-- gdb/arch/aarch64-gcs-linux.h | 17 ++----------- gdb/nat/aarch64-gcs-linux-ptrace.h | 40 ++++++++++++++++++++++++++++++ gdbserver/linux-aarch64-low.cc | 1 + 6 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 gdb/nat/aarch64-gcs-linux-ptrace.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index f0f10e3946bf..0ac45bd9d326 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1550,6 +1550,7 @@ HFILES_NO_SRCDIR = \ nat/aarch64-hw-point.h \ nat/aarch64-linux.h \ nat/aarch64-linux-hw-point.h \ + nat/aarch64-gcs-linux-ptrace.h \ nat/aarch64-mte-linux-ptrace.h \ nat/aarch64-scalable-linux-ptrace.h \ nat/aarch64-scalable-linux-sigcontext.h \ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 9f85d96b59ef..a49b82ca43c8 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-gcs-linux-ptrace.h" #include "nat/aarch64-scalable-linux-ptrace.h" #include "elf/external.h" diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index c17ccbc66220..f0935cbd67e8 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); } } diff --git a/gdb/arch/aarch64-gcs-linux.h b/gdb/arch/aarch64-gcs-linux.h index b31fc32daa03..015a49b25976 100644 --- a/gdb/arch/aarch64-gcs-linux.h +++ b/gdb/arch/aarch64-gcs-linux.h @@ -20,25 +20,12 @@ #ifndef GDB_ARCH_AARCH64_GCS_LINUX_H #define GDB_ARCH_AARCH64_GCS_LINUX_H -#include - /* 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 */ +/* 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/nat/aarch64-gcs-linux-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h new file mode 100644 index 000000000000..f45a1059cd0a --- /dev/null +++ b/gdb/nat/aarch64-gcs-linux-ptrace.h @@ -0,0 +1,40 @@ +/* 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 . */ + +#ifndef GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H +#define GDB_NAT_AARCH64_GCS_LINUX_PTRACE_H + +#include +#include + +/* 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_PTRACE_H */ diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index 6b61f6d5a815..55e55b2df0ab 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -45,6 +45,7 @@ #include "arch/aarch64-scalable-linux.h" #include "linux-aarch32-tdesc.h" #include "linux-aarch64-tdesc.h" +#include "nat/aarch64-gcs-linux-ptrace.h" #include "nat/aarch64-mte-linux-ptrace.h" #include "arch/aarch64-pauth-linux.h" #include "nat/aarch64-scalable-linux-ptrace.h"