From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bH0sBmfoTWqx7CsAWB0awg (envelope-from ) for ; Wed, 08 Jul 2026 02:04:23 -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=mp0QQ08/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 089F81E098; Wed, 08 Jul 2026 02:04:23 -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 E38061E070 for ; Wed, 08 Jul 2026 02:04:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA35D4BA2E22 for ; Wed, 8 Jul 2026 06:04:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA35D4BA2E22 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=mp0QQ08/ Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 900974BA2E15 for ; Wed, 8 Jul 2026 06:03:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 900974BA2E15 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 900974BA2E15 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783490615; cv=none; b=kKprDDQpBfFJwn2wMiO9JqiYEXCdAJphvkGtWGBolZ90yC3O1Kuw4Vxs+XLZFgqUyBlBhr+h46cxyyjT2TG0HC8vADqwtF3t74KsI+Wn6LeJTbZ6fJl7ssgHMLu7GIRvIkAHutG/gJl9wzQ3jh1+ZfJU1uBb0XLsHm03iif1hk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783490615; c=relaxed/simple; bh=IzDdL/2I1Fw1IxiTYQKqrTlYxGBjyjKpBnVRIvAMPGk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YoJ1aG0Jvz1ZSVBBL5TWfDowWdTy4J/L55HL8Jq0KOupFjdxjaMadJXcsqfZHGcWMTU1NKKWMlAuwmLmsewwBsaDqw/b+7wtkvn0HzQ5BW+4Mr0S67Rngb/QQWS5oRpwavupTlKYahpwzZL9Yjen+UXYOvKuIayKPAgnFsonUSo= 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=mp0QQ08/ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 900974BA2E15 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-383b4a3755fso317818a91.3 for ; Tue, 07 Jul 2026 23:03:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783490614; x=1784095414; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=vXOVPyQ3ivPramBW37Ps+c3nqna25vUcr7+RewaHpV4=; b=mp0QQ08/gKL8iNcX5JtRqTKSN5WKnx3mxoGT70FjlCeg0SPzZkWtpRGsIZZZ3am4KP tH8C4a3O26McsaujTgXUtWajtDkVXlPe6POZragPD95el2cchyX9C7A3tP+PCj9e19B1 BBO3riox3TPMfoeyR/Znp6yXEooAvFYV4QCWyc4LBhZGBL74b3fERZgcJooMuAJuWJpJ qqEbtcVSC1TM58QNgMNMgC1xUZWcKhCac+z6uhFcaW+aEC8TMkBcukOCnjBN2fqD80Od J27jRdhaAh6VCwwcddr4eIh317mitGVUvGN+m7HZiaj0xpvkNV4yKf5h1ny867Xnr9RY x87Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783490614; x=1784095414; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vXOVPyQ3ivPramBW37Ps+c3nqna25vUcr7+RewaHpV4=; b=fGmiyv7FCdrJRQbzEeqzEpPuKSmf6D/BYhS74/ayy4yMuq3QeT2OP1jZVgAY1ZESW+ qXE+LmNf7g0a3u77cfH71yeR08t0O63Deu7endVimxxetnd/61LDsZ7y6yQBNdA29gKH yLxpbgBapy/h3aVpM30sCWpaCRWh1bCxVzv2NG+n2YYyRM+3j/Wp1DfX4nV95pVkqK/l fbMk48ONfrUJkIoTIg9bNONni7aa/uQRubxbyjR9ja21b5QooOzGX/YWUIe4ZND7Kjgy BYddx6dx+H3Rn9YMuzrc0lTndnBl6XQM/dawk0XxsxXu7K/QMeZtHEAuV/lSB5eR3oQL /O8A== X-Gm-Message-State: AOJu0Yx982pEoeYuq3p3ENiCyB5dFouCHHBmqAc+YKc5RUvebrN6II8C ZX/qUAVn5e+iVN+h+PPnbkW0vUqAYreiZmAKqtLka6mOThzwInj8bnWPM4AOdUZoAjmvzWEoa+/ Asj8FjLM= X-Gm-Gg: AfdE7cnwJMOpblwDmWkew+zdMJrndpMY7SjcFPuWsNRFNYAGewyscWs/GCgbOzV36Ja +JOAj3xHrtALDu8mdjcVQqs2YDfBVXtkzRn1jzyGAyV6d2Yyj8Y+zZPOQ1qko1aBVtUkmeOU84/ y1Z6agkG7yaqGam3vBSVswMiNOxfTNAcs+16svZYWKj407zwxsm2YbWk2D7T81XkCIryPncdMR9 KdOfXweTHVKfjUfXkBd0QWxwmJLFYlo6TNkiCVYgkPp6M4fjwAAOuHqc1N1daNRwyL1+gc72G8F TIvnsjD7VaWGhBu4iUiNpMvT6w8wHrp3xfWSKy9Wgx+4K3m5uxIVb6HrGzyA8phXCZhdC187f6q 0jUPEimAXaWczx0TtbpVHDwvr1HkesX4+qkeYXxztQ9yGBANWagRvVAspJ2gV8ZeL5Q/3IqzW1X U6OOK9Nev13l3erMsmfhV6w2c= X-Received: by 2002:a17:90b:184d:b0:37f:a94e:10b0 with SMTP id 98e67ed59e1d1-38941cc599emr1190208a91.24.1783490614436; Tue, 07 Jul 2026 23:03:34 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-311935fd091sm1527663eec.24.2026.07.07.23.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 23:03:33 -0700 (PDT) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Luis Subject: [PATCH] GDB: aarch64: Fix inferior function call if GCS is present but disabled Date: Wed, 8 Jul 2026 03:03:31 -0300 Message-ID: <20260708060331.347616-1-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.55.0 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 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? 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. */