Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1194140pxb; Fri, 21 Jan 2022 11:58:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzO4FHTqwkQEpgZivM9WPopP4ozShZ2EWWAt9cYwdJ4avT1Mz6bYghL+QzcuWF01eY8DxNB X-Received: by 2002:a17:90a:5e0d:: with SMTP id w13mr2190839pjf.235.1642795136055; Fri, 21 Jan 2022 11:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795136; cv=none; d=google.com; s=arc-20160816; b=HorF7B1GQMp3u1k4vEMkFpJeL2fBNMXTNFFWz6kfsTgQyqMU9V9a7e9Z2N4xPSoIN2 foBnhoLWE2aptWL9bvSgzgqP4Bw9Xq7/iAkRcyuqDEaz0tkiAznEIRm2Vey0mH4qo2zL 06gOeRSyKnLkZtpxPHMdNtNDARM64J8B+yjKLO9YGJ4YoGOuk83YTZ+Vnl8aOnuE6LZ6 FdLTUwyXke20kW0gclW4mERsbz9UzyJ4TR4DCeWCF9scMalUonkp3dL+/E9BPkrIWv5N OLE/g8WeE6oURz3n6dPQYLU1vsoq+GODm/QNKnlynQQZI3/WranfPt4Ng8lHxkRTi7bX Zc4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=DWOJ/x2qrYLClfcPkF95pUctzsp1LecGRHAyU49C+UA=; b=uN5ixGBEA4rv+qsLc4W+eLQ+o9JBbGRlBXl/obfUh84tfoOQ5hKkb0X18UEv2GrfYj HEYJ72NANf2uCb0rCHhIpR8D++px1OUD0CxM2d//BvvyRBaBfl5nwv6v5Jgf4FqdVBlm J8BizpiUAt0J5aBXlY8A1VvdjqItHa2xZi8oUPJGxHWhtFAB5Beosewpo+hU4vAV+3qQ ilb1qBvsaErqAkc1prV1tz7FtRYt3PjbWG8/9B6L1ytio7Y/rTI6Nqi9Uqlve4voWo8C K3mb0y9JWjA4iRzxzsmcZdt6V61ZQzhsAmEVO81WXL5AZFngLF6n3A04C8wsFfAaTdIP 4jXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=YK6o8hD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bj23si1050156pgb.127.2022.01.21.11.58.43; Fri, 21 Jan 2022 11:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=YK6o8hD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356970AbiASTFT (ORCPT + 99 others); Wed, 19 Jan 2022 14:05:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356952AbiASTFR (ORCPT ); Wed, 19 Jan 2022 14:05:17 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F68C06161C for ; Wed, 19 Jan 2022 11:05:16 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id l35-20020a05600c1d2300b0034d477271c1so7616388wms.3 for ; Wed, 19 Jan 2022 11:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DWOJ/x2qrYLClfcPkF95pUctzsp1LecGRHAyU49C+UA=; b=YK6o8hD5gFGRAp8tp4YVQydGmIMHSwCHo+EwL5lNkcog2WDKT/73n765xQdnecSYKf ydcDvZZpXdBNdRB7+pOXnWXKLQlEpPpd0H1TA+eR74v5jFUQGhWVRhaf5m/pzUflgLjq NVlH3Eea3+IZPtdPK/jGlMcE+c5LYQsjPOE0KrjIoUJc+r0i6d+dvsxQvgnTgbDsJnqs r5Yz47O5inARvd25H8B6EXPIOogkmFNtHCIFbUZwNf/xJoV1oinP8YZx7oKSspS0J3aW eFzytT/xM+nL7lUP2B3Rgsu7Iq/bc65yywCyb6xstCsG+TxXro4RZumdwsJpgEHgeN8q 0+Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=DWOJ/x2qrYLClfcPkF95pUctzsp1LecGRHAyU49C+UA=; b=vfwC2O8NNAFdRHnzQ87Xnso+lskEjm+GV8KMaTSH/mQNO5cfeG5XlvG3cXtmMCPbJG ozmiPJdnJTcIQacg1z8mNj3Er7q/zZjaBnHviO3jpaQoN0FYkV5aRE8d53hOJg47S9nj qc1PmU4iyrclcnbMkUmNzBUSNppLcHvMY8dhlSyRQYFuPb38z1OsrfY7wK9FH5qGL405 8xzm8hYLVSV573uSnwhfhe9AoMGM+DACA5xZM5BMH/xRZAGtqinbWQio+YJ0mtjb7veU RFEquN9FHFczgAZl581syagVuUDIg7D+AL3fcl5/nGoZYJAtCQi8kH76FVziphJSOV0v 8B2Q== X-Gm-Message-State: AOAM533VQXXAqWSb/0UvCoQbApWSDGTUVLiFFKV+RdotL4S/0weJ8cU5 rp7A8Bwel9QZZ17jqPxTuZn0Tw== X-Received: by 2002:a05:600c:4f8c:: with SMTP id n12mr4976974wmq.108.1642619114821; Wed, 19 Jan 2022 11:05:14 -0800 (PST) Received: from smtpclient.apple (global-5-142.nat-2.net.cam.ac.uk. [131.111.5.142]) by smtp.gmail.com with ESMTPSA id p4sm856793wrr.4.2022.01.19.11.05.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jan 2022 11:05:14 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [PATCH] riscv: eliminate unreliable __builtin_frame_address(1) From: Jessica Clarke In-Reply-To: <87v8yg6lhf.fsf@igel.home> Date: Wed, 19 Jan 2022 19:05:13 +0000 Cc: Changbin Du , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220117154433.3124-1-changbin.du@gmail.com> <87v8yg6lhf.fsf@igel.home> To: Andreas Schwab X-Mailer: Apple Mail (2.3693.40.0.1.81) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19 Jan 2022, at 10:58, Andreas Schwab wrote: >=20 > On Jan 17 2022, Jessica Clarke wrote: >=20 >> Yes, this is a bug, that is always wrong. LLVM gets this right. >=20 > Is that an ABI requirement? In case of a leaf function, gcc saves the > caller's frame pointer in the first slot, not the second (it doesn't > save the return address). Leaf functions by definition don=E2=80=99t have callees that are trying = to read their frame pointer so aren=E2=80=99t relevant here. The stack frame = layout isn=E2=80=99t specified by the ABI, only that the in-memory outgoing = arguments be at the bottom when calling other functions. However, GCC knows what layout it uses, so it should be consistent and follow that layout for walking back up frames. Especially for __builtin_frame_address(1), that just pertains to the current function=E2=80=99s frame, which it clearly = knows without a doubt, so there=E2=80=99s no reason to get that wrong. = Accessing 0(s0) is just straight up wrong, that=E2=80=99s accessing past the top = of the stack frame, which is never going to make any sense. Jess