From patchwork Sun Jun 22 01:18:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 899057 Delivered-To: patch@linaro.org Received: by 2002:adf:e506:0:b0:3a6:d909:26ce with SMTP id j6csp362983wrm; Sat, 21 Jun 2025 20:29:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfPp6uG7yVtsZK+5Nb4M51uhIvZE8OGKA0OO56WRprnYp1pOkYiFKTY1TLMu/4V8YWeGVVhg==@linaro.org X-Google-Smtp-Source: AGHT+IGwykwg9SrycCtwZhEQ4xQWszfxq3WANCgELy5jyKc6z1dwlAC+dkK8TAkgzYE1EXgkKWQK X-Received: by 2002:a05:6214:4885:b0:6fa:9f9b:8df0 with SMTP id 6a1803df08f44-6fd0a534772mr141484336d6.20.1750562947896; Sat, 21 Jun 2025 20:29:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1750562947; cv=pass; d=google.com; s=arc-20240605; b=VroWy4tnbSh3nLHk5Z5wCpOohJIXe22VTaDGEBMbxvLNqBhmQJ9uEA/UNSYllypg12 VCzLaISRC7ZXZdsSbkmwwO94/On3cTsFslS3MhvAeG/+yhKT4OGOfvsuV6+mGIL2ki0n xhmavJwlo6OjRLJtlXLPWejA5EfTCAhoXAySjGiitG6NaNJmvErj3ExKCAPDmiDJHDO4 Z2ucH2f9iSnuvf6DSTmlzeiEcW7Wsy+CXvhXnmwcNl9xDnmDv1ivWmJH6sCay3GgVJNM pivTOCSo4FkTa65fln86widEsu8wFZFowO7NwijRb9fVwczX/blHLTGg+8/vlG0yXTx6 kTUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=8UCsPheKAJ/miZ0v+BEcLPL0Ag4YuAbL6rwTxmNRspw=; fh=v0Swrqm/HGzmFfs2Lyn4KGEK39u4NVWMm4qGXeDZh/s=; b=eWZtMRqfLt1ZwHmGgzRUqHP5Cv5sQ19xuSH7kzzKxQJRmzTipA9y/0/r5Z/SoD7LXr 5MTlYiBsixsblukX4PdofCmjWuYBojJO8Uxw3DY1KLii5jji/ldKtUpQvCfbGF+Aizpq iLfNPnoXjHmsLzRl5tX4MWQMhPrM8LOSG0ETYnZmQBVxCBEetnoRSz07Zq/kK0IBlTm0 0kRkkJbKQAcTb+opk2/W1qUONpRftojjRL8p+TjRQXmyemOCJAgzAFXVLIgoNJ5fJC7/ e00MWnbKB5qeZNtbaXV8SwtHt+srf00tCaksdaUiltNgfN9f1VrPmORUaBeW9p/B7lOu bc3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VhgXfqsG; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6fd093e15d0si55918246d6.92.2025.06.21.20.29.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jun 2025 20:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VhgXfqsG; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gdb-patches-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E0B039DD8A2 for ; Sun, 22 Jun 2025 02:48:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E0B039DD8A2 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=VhgXfqsG X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 8B0D138EA03E for ; Sun, 22 Jun 2025 01:18:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B0D138EA03E 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 8B0D138EA03E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750555122; cv=none; b=Fp6p4N+d8ik+B95eoKGB9UTvBdXiTYQBj7veR6GIJNoDqSMti/s81Kx1MftMUlMma5f0L2sAORR60zcj6pOJrtmwytI1QvorklMn15xNT6B/QAHVd9jKTB8kT9gEtU54YBDugpHNAPubylPepb3UEN9vtV7o6ZF1bTSGxsx9dPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750555122; c=relaxed/simple; bh=R64MVqzAkM1oQBeETipOqiwfkFciHmBi6ZNqArujTyA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Migy+QvdOUe2y6pE3/4+hotY8t9BOfQqbrrv8enla7En1dQiEFOl5oYBd59PeXCtJpkkQp+p+dWY/Sodw9kvL4dFlJLdzIKzkWmaj6hKHh+WeO1rp5WdqHqyV9VMTU1rRCsu1NiAr/Jpo0sT6nhFhThMfo6+JIIo7wPAG5XZL8k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B0D138EA03E Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-747fc7506d4so2296768b3a.0 for ; Sat, 21 Jun 2025 18:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1750555121; x=1751159921; 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=8UCsPheKAJ/miZ0v+BEcLPL0Ag4YuAbL6rwTxmNRspw=; b=VhgXfqsGvYA+pht3ZLm/mFdwTkR1lsQyHKhCHPzcyXTPV/kDKOe+eASziYFgtQBhaZ 7cqvtadcCHpapd7ZDxe8mP18uuCjwFsKML36SfKIDJW096dZ5v+E2DwTyg0J/Hz8zCQi 1/rLs8CV1m1gi2GSFAsjer6GfmI+s0BfX8bv3ymWAqejjSamPsSOsTKURK1FgrhgBKqR wDNuMAhGfJCDU9myNqS/IWrvI7p5RN1cVMZkxz97pz18h/WqeLHuj7OMsxWpGByqTk+z BFllzZaL6Q/93YkNbkf2snnk3yzNBg2LKqNyOu4KCjPT1nA/gJFNKewbCRJijwLLTnRN Y88g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750555121; x=1751159921; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8UCsPheKAJ/miZ0v+BEcLPL0Ag4YuAbL6rwTxmNRspw=; b=E48u1dEuEJrRm0oMYwtxL3zHLmIW1Ukw/BFf7BkAMbnJwCl3c98iiKFB70kN4iq5sq qxxbBMCoofLapCjZ+paoVVVJ0D7HqHLTgxSBHQcznbhHSsGYXD9jadQiKWjNOQnKpS48 PBEZQasiweM+I/SAHWc/vy5a+q9yZXu3Q66aLS1P6OiGofouhvtLbfP4Alb/+aSUpRYo LqXw3knpvO9MLDWr/f2SVh5fF5V2vNLB5U0Eb7iyV+pxuvA+vd46IwuFW0qS5SCkHs2v 9HEthF88Hw0eA9U0UYkrihNHzV7kvIXR6O6ZjlOR5x/CoWyX+/qC5vZwycHIoMX2CUYw rKmw== X-Gm-Message-State: AOJu0YxFzd3ScjlSDC3qmp032WvhxwGlzCUtxbm53NZiiPruxb+NV+xc //J5aWaXlxVB68v6ukaMU/zSp+BAJWpohn+W3bBq+1/LPwjm742sY0aU7ZvuDjKwAy9vMqJDLHa MDdxS X-Gm-Gg: ASbGnctS6eML0kBrICeglwan6bqwH+ZMh0F1/i0eXh9jNG8q3lFGGbmUVoDirlnbPu3 +jIEdmd19yIuKZWtZPhBUbvDOaSR8KwVJDAon4hqYe0ngJWJbbP9WIuQ1b7tmUB4mOOmuicUtqf SIBzrT3daQ2Bxn6EEqPUHr9LXC9Qbmwzcpfq7XgM6rJfs3T500eLIcAvh7AXZ30CeATLmoslFFy jCQlq+1NkriSi+VDaOoN08fM1vyHaQG9KUOU1rpPnk1SLf6NyUs1BM9esDwJ3V1+oqnWRkL33/q kkMyHKiaVWc4JonA3EO5FxPgjhuI4gqRxsvt6VdLHIWy2YEmxzCJNcLQ7jh2nq/wfxTKi0QVQJL L0tfGXbU= X-Received: by 2002:a05:6a21:78d:b0:215:e818:9fda with SMTP id adf61e73a8af0-22026f66715mr11145479637.27.1750555121537; Sat, 21 Jun 2025 18:18:41 -0700 (PDT) Received: from localhost ([2804:14d:7e39:88d6:79ae:7a30:10f3:dfed]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7490a64b2aasm5070707b3a.116.2025.06.21.18.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jun 2025 18:18:41 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Eli Zaretskii , "Schimpe, Christina" , Luis Machado Subject: [PATCH v3 9/9] GDB: doc: Document Linux AArch64 support for Guarded Control Stacks Date: Sat, 21 Jun 2025 22:18:11 -0300 Message-ID: <20250622011811.371949-10-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250622011811.371949-1-thiago.bauermann@linaro.org> References: <20250622011811.371949-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 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~patch=linaro.org@sourceware.org Add NEWS entry and new sections to the "Configuration-Specific Information" and "Standard Target Features" parts of the manual. Reviewed-By: Eli Zaretskii Reviewed-By: Eli Zaretskii --- Changes since v2: - Added missing @code{EL0} and @value{GDBN} tags (suggested by Eli). Changes since v1: - Reword 1st paragraph of GCS configuration-specific section to make it clear that the special registers are only available on the Linux kernel (suggested by Luis). - Describe flags in the custom flags type used for the GCSPR in the GCS feature section (suggested by Luis). - Fix NEWS wording from "are now supported" to "is now supported". gdb/NEWS | 3 ++ gdb/doc/gdb.texinfo | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 4dcc344b0727..54a61f0e87b3 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -48,6 +48,9 @@ * Add record full support for rv64gc architectures +* Debugging Linux programs that use AArch64 Guarded Control Stacks is now + supported. + * New commands maintenance check psymtabs diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c41aa89a3c48..7afe96035ba8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26992,6 +26992,32 @@ information automatically from the core file, and will show one of the above messages depending on whether the synchronous or asynchronous mode is selected. @xref{Memory Tagging}. @xref{Memory}. +@subsubsection AArch64 Guarded Control Stack +@cindex Guarded Control Stack, AArch64 +@cindex GCS, AArch64 + +When @value{GDBN} is debugging the AArch64 architecture, the program is +using the feature Guarded Control Stack (GCS), the operating system kernel +is Linux and it supports GCS, @value{GDBN} will make a couple of special +registers --- @code{gcs_features_enabled} and @code{gcs_features_locked} +--- available through the @code{org.gnu.gdb.aarch64.gcs.linux} feature. +These registers expose some options that can be controlled at runtime and +emulate the @code{prctl} option @code{PR_SET_SHADOW_STACK_STATUS}. For +further information, see the +@uref{https://www.kernel.org/doc/html/latest/arch/arm64/gcs.html,ignored, +documentation} in the Linux kernel. + +Naturally the Guarded Control Stack pointer at @code{EL0} is also +available, as the @code{gcspr} register. + +To aid debugging, @value{GDBN} will note when SIGSEGV signals are generated +as a result of a Guarded Control Stack error: + +@smallexample +Program received signal SIGSEGV, Segmentation fault +Guarded Control Stack error. +@end smallexample + @node x86 @subsection x86 @@ -49505,6 +49531,63 @@ of bytes. Extra registers are allowed in this feature, but they will not affect @value{GDBN}. +@subsubsection AArch64 GCS registers feature + +The @samp{org.gnu.gdb.aarch64.gcs} feature is optional. If present, it +means the target supports Guarded Control Stacks and must contain the +following register: + +@itemize @minus + +@item +@code{gcspr}, which points to the thread's Guarded Control Stack. It is 64 +bits in size and has a type of @samp{data_ptr}. + +@end itemize + +The @samp{org.gnu.gdb.aarch64.gcs.linux} feature is optional. If present, +then the @samp{org.gnu.gdb.aarch64.gcs} feature must also be present. The +@samp{org.gnu.gdb.aarch64.gcs.linux} feature represents facilities provided +by the Linux kernel for GCS support and should contain the following: + +@itemize @minus + +@item +@code{gcs_features_enabled} shows the features currently enabled via the +prctl or ptrace system calls. It is represented as if it were a 64-bit +register with a custom flags type. + +@item +@code{gcs_features_locked} shows the features currently locked via the +prctl or ptrace system calls. It is represented as if it were a 64-bit +register with a custom flags type. + +@end itemize + +The custom flags type allows @value{GDBN} to print a human-friendly +representation of the contents of @code{gcs_features_enabled} and +@code{gcs_features_locked} and should contain: + +@itemize @minus + +@item +@code{PR_SHADOW_STACK_ENABLE} + +@item +@code{PR_SHADOW_STACK_WRITE} + +@item +@code{PR_SHADOW_STACK_PUSH} + +@end itemize + +For further information, see the +@uref{https://www.kernel.org/doc/html/latest/arch/arm64/gcs.html,ignored, +documentation} in the Linux kernel. + +Extra registers are allowed in these features, but they will not affect +@value{GDBN}. + @node ARC Features @subsection ARC Features @cindex target descriptions, ARC Features