From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uRtaNmAlsGkjuCEAWB0awg (envelope-from ) for ; Tue, 10 Mar 2026 10:06:24 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TBoH6mFQ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D6A541E0DD; Tue, 10 Mar 2026 10:06:24 -0400 (EDT) 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,FREEMAIL_FROM,HTML_MESSAGE, 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 8823F1E08D for ; Tue, 10 Mar 2026 10:06:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 3A0904B9DB5D for ; Tue, 10 Mar 2026 14:06:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A0904B9DB5D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TBoH6mFQ Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 93DF94BA2E08 for ; Tue, 10 Mar 2026 14:05:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93DF94BA2E08 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 93DF94BA2E08 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2607:f8b0:4864:20::332 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1773151554; cv=pass; b=e/JTK/IMNlvb+Ecs3rdFSJcvijGZjGflQGt3iFxaIvjW+GIeulSU/MKukeMmDwvCqAKNWmOmuqP5mliAVjaMLdfjRCwaoWbXnQKXIp+e78dray7LrhR2LHOD3J7F//63SszDYhK8ihVpiKrMPwwGyhUScvxO9lh2l1YE5qG4D50= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1773151554; c=relaxed/simple; bh=HqJAJvB3Awwtx5GVxC61/MLqvn+vNwvJWScqX3QG+f8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=gByNwoq521dkezEwqZ2kR86Z4tGk7bSqxRZL+yYwAgazvpkYSWywpE0drzPfv+oebIYj3JXVlIQQbwlkXUwc6HXjhkq9qTLHQ4b1cg+RN9Knq6svQYC1DPdTfcteZIXOD20kOVWC2LvAwTGFpBhtDpteNTIFKIjLU9NaFpiCcuQ= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93DF94BA2E08 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-7d744d9abdaso2116232a34.0 for ; Tue, 10 Mar 2026 07:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773151554; cv=none; d=google.com; s=arc-20240605; b=b3B5z3l2dYnhdH/QgRM9yuB7PDAh/VtRbViQBcVaEBGDCpiP+qVPq6b8KMAMgjaKtR YMZ/Uz9hp+RU6FcWYtkYhsbxbW2+yxJs7dEjjebfx+89ZMEp2O/dbhR5c9cZnb7Db6z9 S6TStdjsUCC+M+K8Du8rkrwwA4tKRLNkx6iDa6VRkEzqQbGOaWI72g4hzfjG09k/G0vu 3dZfuspwKgjTxhoAvqCpGom3WFDygd/XugAhx5Q1Q6Ti8R0xhbKy4udZivk6/6OVHtGG mgVTmiWJWfXumdiOv2SmC/TyuUcS/Svc0kQRIbUgrwidxRSl9vfk41cQ34qOcNgD+U6e M5qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=CIR8wgXdWhEHyTM8v0+MEo5hFHOe8Q5fOtGVksQzF60=; fh=fjfPYQfMhWEU5kxyRFb+iB2y8yPz633xsUnVQoxbtAE=; b=Yxj+fScuSdu6vi59YtO/Wd0Olg2Cr/W+tmAeK0zAQn/MNYE+uftcUYkc9znICNpELG UOILEWie4hE31kEEeqky6e+tzVCV6emztp3TjSz0ZMEY7cphGCwwlULCfheG1VR/rY4D 0a5bSVheZDoOIPka8MI8ZOITIMd4h/9xACeJerc12Hni/iUGCqweUy9wT9bBfsvsmf7S 0uVZXygilm1HpTJqsZXfr1zx0mYNhY3ReblScCmYNWQuMuPs2LAukrlbxuO+krwedJ8Q eCYqBkf6tkpI3q6CHg9Fy6B416pSGt7Ur//BkeQNrbAuvuk4/3prYTEBR4vK2/1URBOW ZOzw==; darn=sourceware.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773151554; x=1773756354; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CIR8wgXdWhEHyTM8v0+MEo5hFHOe8Q5fOtGVksQzF60=; b=TBoH6mFQY1LJkRF7apcvqwySen7zuQrQqfo/0c0HM/v+GniCAb08mhxZUy1QdcOa1E WoIFkpgY2zLg2liVZq9AkrnyCJbD4yX8iQRZtNoMEVEFnx5mfY5aAJLYilllHaZzsjFf 24AJvSkOYfFvYdId96He42ct7OP99Pp/anVksqVG/8rzcCIum5TXosmcD/eZdJxj1F5u VbqKLccDP9SVP7OHNI2HXa0Q1chzD335Qlxtd5e/NfWdOYR/jVKVDWljC3dq8Sz5hW4H JHqAQAgM8rRtwFaaSyM6ymQqhjMeF0y5fsBi+/zXTzVe0zbtd1/pH66nB2Rf1ICYgsSg Ca4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773151554; x=1773756354; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CIR8wgXdWhEHyTM8v0+MEo5hFHOe8Q5fOtGVksQzF60=; b=WxXKJ1X+7ZpvLtkVSj8F0+qFfzlUcjuy4aaaU3XNCnejp/BkqmKPeaSF9ieYGZO8FM iF2av+jtS9zfXONb2yapJrp2+cOY3DkL8DlrUSMjZmioMfRhwzqUx4RgIsoR/4TtlXp5 YgxuchTr0U8QDKiWZAxRhfMdySzKrqkQK1KNreXfcGV167kn8VpphsIW+/1BUS0CRcDv 6iXww2/BNs0QH6I14+Zd74nyc+yTCmUQT5RH8mgl0TmTFRDq5742pllu2/0t62hmpVpn 8V41KBOYs86BMqpHycpYU1bDk4KVy1oOJTchEH0oxQgADeHD30Cu/6wzSgX4fifdOGFK 5ewQ== X-Gm-Message-State: AOJu0YzfeoYNmAqtaJQkgXbJ0qb2fJt1lD59Z6OIkV3ggnm+4VQOJgmD Ytth7vy81XF4ZmH2ojya8Mfdu1ybkrC5lHDIUntpPufkNY2Gpz3H8wGDNem0mFPh1+ewc0Qr6eg 3Be7y5tkgUNEcjRv6nmg2iEs2uoYLqi7p8A== X-Gm-Gg: ATEYQzx34H9xHTKlLTErwyFKNPDO7h7xRgHFI5VOH2eXLKXA07Od26QJfiVN/Px23Ch wCmb+Qb1DDwhwERklglyn4S5FUON6SCvndDAEwJ3YNfeXYu4Brh4AmJItpMNkGqDmMYslQ58AjG EcATq/JiNR5PNkN5Yh2TiovR8yjJipyNRHdwQgkXMRkcPgejgf269wwEkzv1i6bRs/Gw5FkR+xd IWM4RzWbV64XuLvEu3herzjBoct2H71fo/dTZUOGLl5b/dJsqxSuORUr7P+gCrpQCU9yM74xPWS WIGXp+xR2XP9/6x5j1UPWoER+sXBWU3m6M+CklY= X-Received: by 2002:a05:6830:698a:b0:7d4:bb79:65cc with SMTP id 46e09a7af769-7d726f80364mr9976741a34.20.1773151553388; Tue, 10 Mar 2026 07:05:53 -0700 (PDT) MIME-Version: 1.0 References: <20260303050641.198127-1-thiago.bauermann@linaro.org> <20260303050641.198127-6-thiago.bauermann@linaro.org> <87seagb4nd.fsf@linaro.org> In-Reply-To: <87seagb4nd.fsf@linaro.org> From: Luis Date: Tue, 10 Mar 2026 11:05:41 -0300 X-Gm-Features: AaiRm51MULdvGyJ8QKXfe1j_5PsMtaS3s98mD8LmZltdMAcrliQxF0PLCMS79vU Message-ID: Subject: Re: [PATCH v4 5/6] GDB: aarch64-linux: Reorganize GCS-related definitions To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org, Chris Packham , Tom Tromey , Simon Marchi , sunilkumar.dora@windriver.com Content-Type: multipart/alternative; boundary="0000000000007905f0064cac04e4" 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 --0000000000007905f0064cac04e4 Content-Type: text/plain; charset="UTF-8" Thanks. Approved-By: Luis Machado On Wed, Mar 4, 2026, 01:27 Thiago Jung Bauermann < thiago.bauermann@linaro.org> wrote: > Thiago Jung Bauermann 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 > > Suggested-by: Simon Marchi > > 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 . > */ > > + > > +#ifndef GDB_NAT_AARCH64_GCS_LINUX_H > > +#define GDB_NAT_AARCH64_GCS_LINUX_H > > + > > +#include > > +#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 */ > > + > > +#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 > +#include > #include > > /* Feature check for Guarded Control Stack. */ > > -- > Thiago > --0000000000007905f0064cac04e4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks.

Appr= oved-By: Luis Machado <lu= is.machado.foss@gmail.com>

On Wed, Mar 4,= 2026, 01:27 Thiago Jung Bauermann <thiago.bauermann@linaro.org> wrote:
Thiago Jung Bauermann <thiago.bauermann@lina= ro.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 mov= e
> 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<= br> > 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<= br> > 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.=C2=A0 I forgot to adjust the text after= I
decided to rename the file to gdb/nat/aarch64-gcs-linux.h.=C2=A0 Fixed loca= lly.


> 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.=
> +
> +=C2=A0 =C2=A0Copyright (C) 2025-2026 Free Software Foundation, Inc. > +
> +=C2=A0 =C2=A0This file is part of GDB.
> +
> +=C2=A0 =C2=A0This program is free software; you can redistribute it a= nd/or modify
> +=C2=A0 =C2=A0it under the terms of the GNU General Public License as = published by
> +=C2=A0 =C2=A0the Free Software Foundation; either version 3 of the Li= cense, or
> +=C2=A0 =C2=A0(at your option) any later version.
> +
> +=C2=A0 =C2=A0This program is distributed in the hope that it will be = useful,
> +=C2=A0 =C2=A0but WITHOUT ANY WARRANTY; without even the implied warra= nty of
> +=C2=A0 =C2=A0MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2= =A0 See the
> +=C2=A0 =C2=A0GNU General Public License for more details.
> +
> +=C2=A0 =C2=A0You should have received a copy of the GNU General Publi= c License
> +=C2=A0 =C2=A0along with this program.=C2=A0 If not, see <http://www.gnu.org/licenses/>.=C2=A0 */
> +
> +#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.=C2=A0 */
> +#ifndef HWCAP_GCS
> +#define HWCAP_GCS (1ULL << 32)
> +#endif
> +
> +/* Make sure we only define these if the kernel header doesn't.= =C2=A0 */
> +#ifndef GCS_MAGIC
> +
> +/* GCS state (NT_ARM_GCS).=C2=A0 */
> +
> +struct user_gcs
> +{
> +=C2=A0 uint64_t features_enabled;
> +=C2=A0 uint64_t features_locked;
> +=C2=A0 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 @@
=C2=A0#define GDB_NAT_AARCH64_GCS_LINUX_H

=C2=A0#include <stdint.h>
+#include <asm/hwcap.h>
=C2=A0#include <asm/ptrace.h>

=C2=A0/* Feature check for Guarded Control Stack.=C2=A0 */

--
Thiago
--0000000000007905f0064cac04e4--