From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lOemOXCoTmq5uSwAWB0awg (envelope-from ) for ; Wed, 08 Jul 2026 15:43:44 -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=blybleXo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D87501E098; Wed, 08 Jul 2026 15:43:44 -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 EC9DC1E04F for ; Wed, 08 Jul 2026 15:43:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3094C4BA2E20 for ; Wed, 8 Jul 2026 19:43:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3094C4BA2E20 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=blybleXo Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 808614BA2E10 for ; Wed, 8 Jul 2026 19:43:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 808614BA2E10 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 808614BA2E10 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783539798; cv=none; b=lT57gNIeB36+VajBTcaHumN5GV2D5R1K3Wx0+Bcg/m+hZmTuMgUSxKzVOMBiaDG+H6WU0CGd2Bf1kggddAOm/2ZE/4eqvQVHe5EB6zzKePMUJqy90ylMG2pP62RLbnX3BwhNGtwXJgPRQpSHfrw4/3lklmOXs5fIhCguJifL/YU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783539798; c=relaxed/simple; bh=XCJV5prznbZvH5VEsbDPwuEl0YSlnqQJFSV/kp5TSjE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nu54AzteZugF+KP1GiuUfBjV8CPiMN1QaKRCkqhQ4XV9GGF5BAI6d2Rkpf2a8zHkrl1J76t/XfwhFYLd1cPqS269i0TmeqyXqwO836AgQcGaFXs0H8PMMJfOmiuehT4fNGrj9+9LPNanFNs83h8aELQUmVEiK+yIU3tsUKmVxVw= 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=blybleXo DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 808614BA2E10 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-c9e7391839cso904416a12.0 for ; Wed, 08 Jul 2026 12:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1783539797; x=1784144597; 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=70VEC3LO4rdltjF/uDimIuBTzPCIMNdRl2J2wW9cPck=; b=blybleXoqH4c5RZ94nQT6Vh8afdfGbOnULuCcf+cRwP7RVZbH+lDp08K49ve7LGXEu 6hF2IHmElBTr/+rikndy0t79hpmZ4B8WF3ub2rgvDkVcTf8rxNcfUmeGpaKpzL86ox1t x5VgZjWgiezpKLUUTpIjLaMr0buw/NkzGAMYs3++qZ/mgkiLikcHlVCmNTtyatgyD8eq UtHDiSOh5eWAEn2afJroyKvRQApepJA3xNaJfW/ZAyIA30zZvV4fMjaneBwFw2lTzA1R 5wmj/9/tU+kno/aU8GD/fumoQKzsX9dyn4kjKJgFRMyswYMEqp6o+evl9rSibM1PM7Ty dTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783539797; x=1784144597; 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=70VEC3LO4rdltjF/uDimIuBTzPCIMNdRl2J2wW9cPck=; b=UAiulm97VmMkRHBqphjOjp0whPu+2D6Mx87UvpXhy/6XNKScUHMwJSg2VaucL/TZJk or08owjLyuJi9Ub+0cS+F6Y6OZKYTV+DOmQlFKdKXrCllX30Za95BaOLaI0eeXmDqBjP WKtPe4YqvzzYdIaR9QVFagcUD0E4ZZapwAfAeh8/5pja4vIb26uq2EHClEp2AE3SQNmZ a7NOL/RcZLZ78fk7wUeRkEk5XYOgeylF0OoTV4JyZJApPb9P+8vhyK+L1bP2jgQYLj29 bAduO8nLl2jGFAONODJ5aSgvQrZPNCN+EFWFYZVYUSWbnX9iGIee9k8miJtB8UhOXPIb vd2w== X-Gm-Message-State: AOJu0YwE7YU62S3dmy4ThBr2LhO1+0seTF/T3Avibi16ykMAlHw/TO2j MMvF1jeixmXDbREJZcI+7cqIDEhEUvv7tSl6tB6lojq221MeE/DDUTpV2AnyrkmeFkg= X-Gm-Gg: AfdE7ckyXOcVQ++QgHnAG9fPd9dyUCEufcKeTFTOKvOuwZXZ82VIpDOTX6LwJ/7n2zz 6g30p5ufIk76EY39yzVPuu4dkIJ4NNp3iJpj3Og42qNtQ4xmg/6+qddMTI9WJMaoSHJIM6fi+8C mVig8YZMgfehK4TtwAyNjby6JtWEpNS53o8Vw6tpp3FLuUJ9cw//nRxlX4/WFI8W557ELWLloWh i46NWGuHrR0YGVvPvThAi7ivEbIHuhyWKtQaM5zsuH2SnwHjW/JfGju0qEfqop8uIBMQgrJwVPW q/r2mld0A7fQaAQ9Z95mz/yuD3OwoW8IJ4VHJerZumo2qWbStR1y9QDJyGKJXXg283yFN+CKVGo uVhsPIj0zlpeLfISkjJll+EV+kb9/xUaXQKXm0jDxpnYOcjqp7kOJaJw8oOZcQSN1q7tIQ8BX/L kLWqhdRBc3s/7F9NsmLrrTIFc= X-Received: by 2002:a05:6a21:3382:b0:3b4:8bc6:138 with SMTP id adf61e73a8af0-3c0bcfea3f8mr5340383637.23.1783539797445; Wed, 08 Jul 2026 12:43:17 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b6593c76dsm23240607c88.3.2026.07.08.12.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 12:43:17 -0700 (PDT) From: Thiago Jung Bauermann To: "Aktemur, Baris" Cc: "gdb-patches@sourceware.org" , Luis Subject: Re: [PATCH] GDB: aarch64: Fix inferior function call if GCS is present but disabled In-Reply-To: (Baris Aktemur's message of "Wed, 8 Jul 2026 07:50:08 +0000") References: <20260708060331.347616-1-thiago.bauermann@linaro.org> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Wed, 08 Jul 2026 19:43:14 +0000 Message-ID: <87y0fl5ktp.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 Baris, Thank you for your review! "Aktemur, Baris" writes: >> 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); > > Some analyzer tools may flag this because the return value is not being used. > Maybe put a `(void)` in front to indicate the return value is being ignored > deliberately. Makes sense. I made this change locally: diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index b4437dcccc8a..5b38ff74260c 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1936,7 +1936,7 @@ aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr, { bool gcs_is_enabled; - gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled); + (void) gdbarch_get_shadow_stack_pointer (gdbarch, regcache, gcs_is_enabled); if (gcs_is_enabled) aarch64_push_gcs_entry (regcache, new_addr); } -- Thiago (he/him)