From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nhaKEGj8sWo1jTAAWB0awg (envelope-from ) for ; Mon, 21 Sep 2026 23:56:24 -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=BN4i49IX; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 331991E051; Mon, 21 Sep 2026 23:56:24 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 6617A1E033 for ; Mon, 21 Sep 2026 23:56:23 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A86C4BAE7CC for ; Tue, 22 Sep 2026 03:56:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A86C4BAE7CC 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=BN4i49IX Received: from mail-vs2-x10.google.com (mail-vs2-x10.google.com [IPv6:2a00:1450:4864:3a::10]) by sourceware.org (Postfix) with ESMTPS id 949854BA9035 for ; Tue, 22 Sep 2026 03:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 949854BA9035 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 949854BA9035 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:3a::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790049357; cv=none; b=tO3RpGlZtI9zLCoxRAIKlFcIUfir4rYrIWQDHor6Qfg+1eoT3tBJow5Uw+JC/Aqq4a1Dw3+rLh1dn5zOuesGwkxeYSQrcgyfiimncL5ZnobzlsXyV7fAbYS+bTMgak7J5DF8d1LKN83IvSVReIJX0aK7DMKbsak9Ypu1xaPT+UI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790049357; c=relaxed/simple; bh=CBhmdi/faBIDFPu99/a/Tr0e0Dx85HYAFE5jWRsZUF0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rNRRXSH4PTG1sGbF1s9MiOs3kM9UA8VYN+SzpEAj4fh2Scg7yw13mgJP+4pQOvEmCcMrFa0XQGlWK4ucr9Y3qvsMRRn20V41LliYm6c/eef6fIeA87G3I3zDY6cL3RTvTTw+eHEPo33SoEo4hjRPO7dudU4XQzrV3FEFDysPmcQ= 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=BN4i49IX DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 949854BA9035 Received: by mail-vs2-x10.google.com with SMTP id 71dfb90a1353d-5c67e5059faso1276293e0c.0 for ; Mon, 21 Sep 2026 20:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1790049357; x=1790654157; darn=sourceware.org; h=content-transfer-encoding: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=/XcvZdBHqT/p3xOIOL95Kdu9+YfcMqWcMxIFdriilhY=; b=BN4i49IXLJGRHPB3XH2lwSb0nDYOEPmXbl9+E9hCMEzoeqPjDWV9kP+6vjf39f65tK pK5EvOR9h6/Bt51Ql159hG7Hw9hhKqUxjofGMajNjWDG+5GX5Jyy6nD2hMH7jzuSsPrv QLrYKOqXIcslyg3jtkYynJH2qZ/BJ3oe+9KRHYXA4M2rVRyqmEGym9UTxuX4p5onkINF euDGFt9Sy1GuU9yBWtEth6FbdxYn3JrgzrvnmYPPELPyiAIvps49s8QUag9GT938sVDt 5tDquFOXU4H9GIZ3w+8Lr/oFK8J+Nlm9KON4AEmnhuEjsF4EWphha6mtX2AfgJa6EzFQ hzgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790049357; x=1790654157; h=content-transfer-encoding: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=/XcvZdBHqT/p3xOIOL95Kdu9+YfcMqWcMxIFdriilhY=; b=iIm8m/6khwtGOD00tGne+a2bLrtB+Er60rw2bvhKtjTuqMdvCXxeDAT9YnmLpLmPRN QAmWLxc4Uqy4WxNyWa+6y/lgXDzohM/WVE/1xoGDJC2ISKHzPZtYnG2f6TdpUhFrpyd7 tOikeoK2kcUHnluDp3gg2d0OAb8VMvOyxX3IhRaxZb6L56Cp8mOvHki56oL/HHVPACYd TycotkPULepdStjwspAqj88WdGTgzqkdGRU+PoWaP0I2JfSgGKpdwdHFcfrCcPrBEnf/ FsDyZGGyFXWCcKRc9g4f6cNaaxMJNixeuuUscpkdao9iqZYWaQSaGVHpebxXPzn0unEr MirA== X-Gm-Message-State: AFuF++nSMtNyo812HQanGFtJuPGco15bQGEtZ/HdL99pnaKzsLVnTmS2 MA3fA8N2mljSr+WvC8zthkUy7mUd97DVKTecNBg6NWa079Mxb9VAe7a618/Lx5sCrRI= X-Gm-Gg: AYBFou0hh4QZQFHtZGZVIotupmkvCHm6D3lO8i1zRU7p2T12q89fW4GyRIFvCzigtRG 4HdBhlO3h42JSQqV3CGGl98J6PdnOhXeRC6P9XObYqiZR3hVbYrNgRqCBQms9MGU3UtrR3YMtoq msVAaql05QnGhkABuOaLfIHsOdAQ2HP2xGqed87W6UJ+7RqrN0KFIzHi54ztYtroR7t1CV1Scqn WkMDHYEO/5SaTaCYZUsA0K8AEdIWy0oGB2qKH3OcnyrJ65wS6AyqRDEMmaNb+HBmvU/0rceTxht v+N575Jo3xHJehCCpit6wu6vw/WTl/KzCQX7w1N6Cajh4b4FxDnn3KI7LFUTE2yb5rqK3oIxRHo a3u71yj6R/4jIJ3BFiB311AzNWK490oMjeK+uAplQF01yebrjgXVqmpIpU4fYWuOtq9tXCAYhLY IPW1y+E3Dz2g+NqLq0fv2Ldc+IlbUDLMhrMCmFaz+bXTvTwI2xEKAdm1LnqocB7bEuvHi8JuOVB COVKIo3 X-Received: by 2002:a05:6122:d14:b0:5c8:2dc9:f8d2 with SMTP id 71dfb90a1353d-5c9b872d199mr8603564e0c.0.1790049356969; Mon, 21 Sep 2026 20:55:56 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c9e7d5309asm507479e0c.14.2026.09.21.20.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 20:55:56 -0700 (PDT) From: Thiago Jung Bauermann To: "Joos, Christina" Cc: "gdb-patches@sourceware.org" , "tom@tromey.com" Subject: Re: [PATCH v4 02/13] aarch64: Implement gdbarch function top_addr_empty_shadow_stack. In-Reply-To: References: <20260708143639.2214689-1-christina.schimpe@intel.com> <20260708143639.2214689-3-christina.schimpe@intel.com> <87h5jvqa6f.fsf@linaro.org> User-Agent: mu4e 1.14.3; emacs 31.1 Date: Tue, 22 Sep 2026 03:55:54 +0000 Message-ID: <8733v2548l.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 "Joos, Christina" writes: >> -----Original Message----- >> From: Thiago Jung Bauermann >> Sent: Samstag, 12. September 2026 08:03 >> To: Joos, Christina >> Cc: gdb-patches@sourceware.org; tom@tromey.com >> Subject: Re: [PATCH v4 02/13] aarch64: Implement gdbarch function >> top_addr_empty_shadow_stack. >>=20 >> Christina Schimpe writes: >>=20 >> > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index >> > 848cee3043c..d789b8569d2 100644 >> > --- a/gdb/aarch64-tdep.c >> > +++ b/gdb/aarch64-tdep.c >> > @@ -1908,6 +1908,26 @@ aarch64_pop_gcs_entry (regcache *regs) >> > regcache_cooked_write_unsigned (regs, tdep->gcs_reg_base, gcs_addr >> > + 8); } >> > >> > +/* Implement the "top_addr_empty_shadow_stack" gdbarch method. */ >> > + >> > +static bool >> > +aarch64_top_addr_empty_shadow_stack >> > + (const CORE_ADDR addr, >> > + const std::pair range) { >> > + gdb_assert (addr >=3D range.first); >> > + >> > + /* For AArch64, addr must be strictly less than the upper address i= n the >> > + range, but other architectures allow it to be equal to the upper >> > + address when the stack is empty so GDB core works with those add= resses >> > + and can send them our way. */ >> > + gdb_assert (addr <=3D range.second); >> > + >> > + /* The GCS grows down, and the oldest entry isn't an address. >> > + Just the value '0'. */ >> > + return addr >=3D range.second - 8; >> > +} >> > + >> > /* Implement the "push_dummy_call" gdbarch method. */ >> > >> > static CORE_ADDR >> > @@ -4783,9 +4803,13 @@ aarch64_gdbarch_init (struct gdbarch_info info,= struct gdbarch_list *arches) >> > /* Register a hook for converting a memory tag to a string. */ >> > set_gdbarch_memtag_to_string (gdbarch, aarch64_memtag_to_string); >> > >> > - /* AArch64's shadow stack pointer is the GCSPR. */ >> > if (tdep->has_gcs ()) >> > - set_gdbarch_ssp_regnum (gdbarch, tdep->gcs_reg_base); >> > + { >> > + /* AArch64's shadow stack pointer is the GCSPR. */ >> > + set_gdbarch_ssp_regnum (gdbarch, tdep->gcs_reg_base); >> > + set_gdbarch_top_addr_empty_shadow_stack >> > + (gdbarch, aarch64_top_addr_empty_shadow_stack); >> > + } >>=20 >> On the other hand, since this is new code added by this patch, could you >> please change this to the following? >>=20 >> if (tdep->has_gcs ()) >> /* AArch64's shadow stack pointer is the GCSPR. */ >> set_gdbarch_ssp_regnum (gdbarch, tdep->gcs_reg_base); >> set_gdbarch_top_addr_empty_shadow_stack (gdbarch, >>=20 >> aarch64_top_addr_empty_shadow_stack); > > Yes, of course. > One nit: I think the GDB Coding Standards still require some braces here. Ah, right. Because of the comment. > So, my overall changes for this patch will look as follows (Luis requeste= d some > comment changes, too). > > ~~~ > $ git diff > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index d789b8569d2..94893dd4bcf 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -1923,8 +1923,8 @@ aarch64_top_addr_empty_shadow_stack > and can send them our way. */ > gdb_assert (addr <=3D range.second); > > - /* The GCS grows down, and the oldest entry isn't an address. > - Just the value '0'. */ > + /* The GCS grows down, and the oldest entry is the value '0', not an > + address. */ > return addr >=3D range.second - 8; > } > > @@ -4807,10 +4807,13 @@ aarch64_gdbarch_init (struct gdbarch_info info, s= truct gdbarch_list *arches) > { > /* AArch64's shadow stack pointer is the GCSPR. */ > set_gdbarch_ssp_regnum (gdbarch, tdep->gcs_reg_base); > - set_gdbarch_top_addr_empty_shadow_stack > - (gdbarch, aarch64_top_addr_empty_shadow_stack); > } > > + /* Implementing this hook is required to allow the unwinding of > + the shadow stack pointer in shadow-stack.c:dwarf2_prev_ssp. */ > + set_gdbarch_top_addr_empty_shadow_stack > + (gdbarch, aarch64_top_addr_empty_shadow_stack); > + > ~~~ > > I hope this is ok from your side, if not please let me know. =F0=9F=98=8A Yes, it looks great. Thanks! --=20 Thiago (he/him)