From patchwork Wed Jun 18 05:54:45 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: 897545 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f54:0:b0:3a4:ee3f:8f15 with SMTP id cm20csp137191wrb; Tue, 17 Jun 2025 23:02:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYSf0G1BZVRtI8bVsV5AHS3boj0wxpsiwSBVd9NU83UnN9SXAkcJNTQqAZ5ab4bOLiSkxwIQ==@linaro.org X-Google-Smtp-Source: AGHT+IGRgsx2APTOiKpe5R1wYs3COL9/MWOIAF4pcQk11NTjk56ebKZvPh96QBX4m7k7uFO7ndbv X-Received: by 2002:a05:620a:2983:b0:7d3:8cc5:8a45 with SMTP id af79cd13be357-7d3c6cfef18mr2344742085a.53.1750226577167; Tue, 17 Jun 2025 23:02:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1750226577; cv=pass; d=google.com; s=arc-20240605; b=dmZI8UUe54yZ2kTMlhBdb/Ig9qnd6A+K1xGG0ofkjrcOCYiM4tKKR+ihxrVhEK1WKh XLOP1za6BuIU/xsnfcZREopl67htOtZWmMRscKkYgbVszJcCB1C4VLnpW03GAAgzI9Vw /GcFiLOteC7qiaQJyhwO4O6w3QbBDUmoLLmkQ8zMT0jvf4Q5VrkOR0or695KDlolLmcq COTrGL+xtFI2zxn4EnP3ro3aHokOV/szgKTquBZqjNcNX1x/t8hftuPqUKFZHOQBP7m/ nnanV1YxYKFAu0kvsFTX+n66z4ADPqrtvuguVbyciBVRk/3Ucm6DKpdj5I2LBCpe7dXY 2cKw== 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=9Ou6zKEWxaGKcDekUYW1XQ50CLlsTLyBSQ42IYqbBRA=; fh=v0Swrqm/HGzmFfs2Lyn4KGEK39u4NVWMm4qGXeDZh/s=; b=J6sgBC3ClW+Z7m9AsYsVRJDm1qEQg9tRI19tPoeHQJpB2MXn9/QVZgwio+dfH+Iv8B EBL2zOC4NhV6soh6QzLtOv6wYkP46CwejbTRpCweHFwRjcHlk0on6NjD2l2uZK41zPJL 67rjo//hWACZ1HsNpS/cCGbMCIUSLMoaUZXuskIZNNv0HEjy6Scwoh10k2PwF5rXzNjT BBJd9qdz71gLHNsc0euxnGjD8zhnkNRzfdDSh1FuaDnIKx92pmh+m3RY9dlkt0T654bR mJaFtI4EqQ4FSS5d25tupZgMsdOygg8Zm66vgKIZ4OYDTGheIXLvpBBJ0/sfjs3EjxUW PO1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RbDj2Ozn; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id af79cd13be357-7d3b8dc7745si1428118685a.21.2025.06.17.23.02.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 23:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RbDj2Ozn; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 B867838110BC for ; Wed, 18 Jun 2025 06:02:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B867838110BC 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=RbDj2Ozn X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id CBC13382893C for ; Wed, 18 Jun 2025 05:55:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBC13382893C 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 CBC13382893C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750226117; cv=none; b=QcAfAZNnPTKVrfNswoTGilSdEK3bch8T60NSm21VXasE7aWF/yJw0kLfkmLklqtyETc8C7FTJpkmiU1RfoOhaB/pdKXDdUFpG3E0uBtZ5dc5NdD03j1QE9v6u0nEzH+zUGF4/OwhPIL6jWAoS19g/Bf63DMmmkaFMcUWJhbpnHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750226117; c=relaxed/simple; bh=7p6P/50MfMkAaeRRDibaZt8eiptXcPEl1Kr1kkiK334=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pp8wwLkGMCN6F8f0stBM6ebmWiYIqWW6HbSa+KzNPuMulz6vWa+N9XTPT5fe/YE8ItZTZwRZQrJc5Ro3beQCwjxu6g8fkiUpJjZdz1DAwtWSiUziO4JF2FkXYC9Uc3DwsdjCSRYs/8vyfOJemgTef5e3Fa1M40HwiXOdMRz0IyQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBC13382893C Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-235ef62066eso99308585ad.3 for ; Tue, 17 Jun 2025 22:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1750226116; x=1750830916; 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=9Ou6zKEWxaGKcDekUYW1XQ50CLlsTLyBSQ42IYqbBRA=; b=RbDj2OznlbSv1NMeP2E6kSPcVNe8k+wj9KKOrpMMfBbhhiv7JeKAj+151Rv34LcuiC 2m3YfMIdbVGBAqB2MXuaH9po79PnqCWfH9/4qqQsqZEcamoacUeXKLXY1CM2HxDnF7Pn J8DebkOCyHfk3HgtMApYogn2qgSZwiiVMBrNT7ATgCqb+EwX9NBpxzO7ocJU2pUp5u0W N7sm0R8t6MyyVA1hZ2557WsVgnkWZOG5ZFVUSB4H+WYSKYbNtMQbfiVITH1SsA1kQ+Kv gwUlMXo76ed72F9c7ywb6IN/8OiHk5GeW/epllVWkfob2VZxdsRAVO55nOmzyq60kCA+ GWUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750226116; x=1750830916; 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=9Ou6zKEWxaGKcDekUYW1XQ50CLlsTLyBSQ42IYqbBRA=; b=Gh9Zuk+kfJXtkt678kZ8g7lB8qXGXBiaFnjmACljvdCuOakAwepp8oXBuIza/PBtjM liwR1ju/BhTcxEfcyAZVXngjNILEpRXAOKpr1lMfkRPRXnVH4ZIAtXPmCvaspcPVCzHu MMS8wxWFSifOmqgGeSyt+x2+wHCLX6aq2KSw4cPSH/hA9OkukZM8i/Xsfqat0asnLANR x4DGTg3ljjce/WEK9NBXlAZJtjcUnne7ZhvJ6jI6LTYJ4N2kmZXLOi4xk43B9XoOawqu KsBOYmbsoawj9xFHP0KNPnX5sDc5trMYB3x9yUYdUukyljaMBkKfSrOL11qXEwlNsDyG kyYg== X-Gm-Message-State: AOJu0Yx+WeSvtW02fLIWEfNbMELZ0xUwZiIIxjfUtFX71jvbCCqUc0rL Jboyxbxgvjz/fWtXp0hyzRm/6A83YKLoaCmdIB+jy1UeP4dbMKHEUcKa6J84DuSty39KpulgqQ3 J/8Mt X-Gm-Gg: ASbGnctRRoLiQFr40PPCLos0cdbpwvjWTdnrCtpSr/FkiLLbWUPMo27fZxO0UnpHWjL m/pA5Q8WkACoeBC8JmXH8A0fCFhD889h9wbeMg7XfUjiUpzZqLAtZf4C+PvelsKPbRo4O73ARKb IBNc40kGbu6urY+DOehodxvlRR1oUmd4MIojwc+M3PJ7gnDP9zqpjHkQM5qtuILbytJzIoyKKIV 5h7wkyB3DzWJ4/8Bzl9M5ZkThIJPI3IArR9QYItCe0BJ6u7YZn5x6k8MCAxILbmvpSXB6v2f4Ww GG7BzWs5ZOgY6giATfmClUOF51W72x5aM19N3dlHKXZUJqdiFsoYCq1/jN0yFsrOBHGK X-Received: by 2002:a17:902:c404:b0:235:c9ef:c9e1 with SMTP id d9443c01a7336-2366b337dfbmr246061965ad.5.1750226115826; Tue, 17 Jun 2025 22:55:15 -0700 (PDT) Received: from localhost ([2804:14d:7e39:88d6:ae12:97ab:a9:43c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-237c57c63efsm2800805ad.172.2025.06.17.22.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 22:55:15 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Eli Zaretskii , "Schimpe, Christina" , Luis Machado Subject: [PATCH v2 9/9] GDB: doc: Document Linux AArch64 support for Guarded Control Stacks Date: Wed, 18 Jun 2025 02:54:45 -0300 Message-ID: <20250618055445.709416-10-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250618055445.709416-1-thiago.bauermann@linaro.org> References: <20250618055445.709416-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 --- gdb/NEWS | 3 ++ gdb/doc/gdb.texinfo | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) I didn't include Eli's Reviewed-by in this version because there were a few additions to the manual since v1. 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". 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..2bf20ad06230 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 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 GDB 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