From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wq4kHSwhYWocvCYAWB0awg (envelope-from ) for ; Wed, 22 Jul 2026 15:59:40 -0400 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=wmSJ0uhJ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 459C71E033; Wed, 22 Jul 2026 15:59:40 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 015F71E033 for ; Wed, 22 Jul 2026 15:59:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A5C54BA2E35 for ; Wed, 22 Jul 2026 19:59:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A5C54BA2E35 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=wmSJ0uhJ Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 7BE934BA2E0B for ; Wed, 22 Jul 2026 19:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BE934BA2E0B 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 7BE934BA2E0B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784750352; cv=none; b=H4sJNvI/Yv6fTMBGTzGYNueEAV5fFvfV+ANnJPpEFD+mEnVsgsFgJY+4+PuRPq9FQ8ARVt/WOf7Q2TcWrv42durT5cWL96Ro9ayBskHd1MQEDCWRTEz+3vu29X4i1Y8BlePIn7MJdZbmVDQQy1yb1BFWU2K2x8CjBSjd/56ir0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784750352; c=relaxed/simple; bh=/kC+IcVHQPWlWPKiFfb4hZlCZVa6HYBtXZqyDviVDsI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kdx9tGNIDJ5yAAh/fHApGemB9us48adfPK1sBIvluW7XpCj25pRWxtFlSaovFGcmrEBBlGevXdcktVGubsVZx/1B1lSio+YHzPF03visIRGPlveYI68IsR+EDG7hNXPuBGRqop5LQbhckbiHYySfvfArWJmh4AokzuZvo9Sa+Ys= ARC-Authentication-Results: i=1; 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=wmSJ0uhJ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BE934BA2E0B Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2caed617615so144743855ad.3 for ; Wed, 22 Jul 2026 12:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1784750351; x=1785355151; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=QbYWEDtCv/rTQV3Nq7MhXGeoPbdQF1VI8yxUtol7Amc=; b=wmSJ0uhJsHNbN/Y9zvLrFnLpGTYPOw1O3oZgmZhDHMbeNtuqhDEhyjUlei1aN38ITR 0q1C2yNesQxF1w0JW0nYnFCB8Js1TtLZMHUZKqujBE7npxilpOnGg+kwAh7g83n+8qYQ qQHOWLjorB9fvIsrxJZXCZSY56qKJIquSpMmgyLGz2DmJKEGzm5XssiL7RfTxmGVYf86 2xmtoFPlODOtQEKx3k6YQA/dv4NI0k+wZ0Mc0bER/8zkMHEwxUYXbBNLMDzWzYcXaFRj qs+fpvNSMFAoQEXA4JZfGKlmhOX9yh3JzYhBL2MGK4/be0wlmx+StU+RtO6PTXmuM23l 2x2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784750351; x=1785355151; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=QbYWEDtCv/rTQV3Nq7MhXGeoPbdQF1VI8yxUtol7Amc=; b=cotCib6CcH2TOO5VM+MEA4iMRfYCUh1seOD9/V9cWuATU6i1Gbgl8m7/bDWXZlMY/N Mk/m4eOHkrZhHKjm9btKvBdTQWPIFNkj4Wc2uOz8j+7N9W8d1BsSL2AWLw4xnHH3Pth3 pvlpS90hIwZqMP5t1kvUJQQuFLYHerWMc/YCIN3hQDA+evE/BoKkHBo8uVHoBXJDTYeF 2QRuqVEZus7ZSDcWXkiYg/EPt/FozlH9O5kDZZF+jMmM6GxlUFYG/xNXqgnxQu8E8Ans 3eomNMOvG+zFw8Xs5mlBfva+xXNu7dywPsnkz2FLuTjtKO3fDpatCZDFwPP6lbxqYj9E K1IQ== X-Gm-Message-State: AOJu0YwfPv/OYP2lLESEoqnmVPtdQ0/CftIPCblPWe2eXMh8yri4o4r3 KurL8uwL9b4Y3ByX8tA3k0Dl8w84T3gBn94Tttg1/6IWSKSIq+tRNzMmDlteJAoCJe75+u/bciD mDFWF X-Gm-Gg: AR+sD117guQ2ao9J53Gq5tbbVtKP3wgY7oPmPHpefsmgm++RccWtpSdZM9zcF58VW+m TF4XpdhsuXL7a5Xa9aA300OAOz55le97JL/SfJ7FfxpgfPNJSneDtEHvKrRf9CDlULURr7MAZ9Y NgoMXZmOH9n0c2eH6saSrJlDb2jP/rZSSc7/oJrNPeIwcE/tPtYq5cNWHVMFJqefPP5tI2wiWJk 87T0BBpRR/xsfwKjq+H6k3gnV1I06UX8F5O5ZCJ7Ldh2Gzt01HMCJtmAR+VmZWCKHJsKpJc9bhq R1hLymUsyHweQ/mw/fANZRrlcuhHFuQ2WxnIAQRmjap3ImTBsDGNEwkYs7CBZJhOGHpicwGAUMs bKErnd9mahr+YWJgOZ+vDcj55yVmIsZeDEmYCkU+lp4DdSN5H+j0hgTPKrAtmy8aQVp+sPGV7gC SQwwSv4/ljVj5E X-Received: by 2002:a17:902:e850:b0:2cc:9763:e607 with SMTP id d9443c01a7336-2cfa6c6665emr3153825ad.27.1784750351200; Wed, 22 Jul 2026 12:59:11 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3147e1b6a45sm11379786eec.28.2026.07.22.12.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 12:59:10 -0700 (PDT) From: Thiago Jung Bauermann To: Luis Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] GDB: aarch64: Fix inferior function call if GCS is present but disabled In-Reply-To: (Luis's message of "Sun, 19 Jul 2026 09:57:46 +0100") References: <20260708060331.347616-1-thiago.bauermann@linaro.org> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Wed, 22 Jul 2026 19:59:07 +0000 Message-ID: <875x26x0c4.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain 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 Hello Luis, Thank you for the review! Luis writes: > On 08/07/2026 07:03, Thiago Jung Bauermann wrote: >> On AArch64, even if the Guarded Control Stack feature is present on the >> system the inferior may not have enabled it. >> There's a bug in GDB's GCS support in that if the system supports GCS, >> GDB will always push a GCS entry when doing an inferior function call >> even if the inferior doesn't have it enabled. This causes inferior >> function calls to fail. E.g.: >> (gdb) p foo () >> Can't write to Guarded Control Stack. >> The error message is because the GCSPR doesn't point to a valid memory >> address. >> Fix by checking whether GCS is enabled in the inferior before trying to >> push a GCS entry. >> Regression tested on an aarch64-linux-gnu QEMU VM with GCS present. >> --- >> GCS support first appeared in GDB 17, so if this patch is approved for >> trunk is it ok to also commit it to the branch? > > Sounds good to me. > >> gdb/aarch64-tdep.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c >> index 886e7ce1e7b6..b4437dcccc8a 100644 >> --- a/gdb/aarch64-tdep.c >> +++ b/gdb/aarch64-tdep.c >> @@ -1934,7 +1934,11 @@ static void >> aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr, >> regcache *regcache) >> { >> - aarch64_push_gcs_entry (regcache, new_addr); >> + bool gcs_is_enabled; >> + >> + gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled); >> + if (gcs_is_enabled) >> + aarch64_push_gcs_entry (regcache, new_addr); >> } >> /* Implement the "push_dummy_call" gdbarch method. */ > > LGTM, with Baris' suggestion. > > Approved-By: Luis Machado Pushed as commit 4410648da673, with Baris' suggestion. Also pushed as commit cbdcbf506376 to gdb-17-branch. -- Thiago (he/him)