Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp439930lqp; Thu, 21 Mar 2024 06:08:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrGaM5/LNXOE/RHGqCeZ1Ga4MKfOgewW8ru4GfzhIhl+CJyZqkL0mL7MyAB1HJ6zYHQMBBB/U1J9lK6hENGPPaRvfotawOS3PzNgeJbQ== X-Google-Smtp-Source: AGHT+IHlOZNQiqtsNpLmB+jq2BO/lOGXFh3xFDa7tJdS7N55dPCLBMYqvsaDXelPEV4cmUmsncmp X-Received: by 2002:a05:6214:d63:b0:690:bb49:5eea with SMTP id 3-20020a0562140d6300b00690bb495eeamr4089524qvs.24.1711026531550; Thu, 21 Mar 2024 06:08:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711026531; cv=pass; d=google.com; s=arc-20160816; b=mLL0punnk5jRVDm3qMG7lwkjjKpPQQbfnmC/d0fbY0Qk4oz583/z3KUqfrVHa3g6+f 46Nai7y6h5zuRuBJRuLDHhO3hHA1wd5L8wkK34JUD9DJ1yLEOkksOEbn6LQNMaejwaMI xW7CO3IAi+hBEbpuSs+QvYfpjom60W007LGSLm4RDlrAy4Mc43/hww6aeiKCmAjqyjYa Y76N0AfW+AVuOby/5G3gaQ1c5hd2IA/DulHUc4ropkvgO3kJpjdbbc+bAfWti4S9ufW6 zvtiHfm3cOE1tTZ4RisHy+mDY0cTwQ2HHVmWBEfyWlLux78vZbbH0QcDAOajiierES6H 7uRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=PeWMjzv2TCP5O1EIfymN2AlFHQvzJcY+97La6mMNs54=; fh=EHPjFJ0r1VGpnFeLr3TS7YO5yiZevYl3nt11l1Z9q8k=; b=JBBOQ/Ca/Dj3Ha1KElCEIsNEs3SvwN3RFwfhV19eCjuiueMB+IwandTpgp/eWcJ1tN 89g0PfbeFWD0Ag2lSg/zekxOqWjX/u3qV4YvFLwKAJiVfWs2ktJmjwTIXdMILpbrBQEo GS0B7rPjff9s9DcWU8YZrH97urx8vSV/MjrIT8C0BITqnQ4h0n7nGWsaG3inwjTOyy1Y yu7/ehrdiP+oWekkwcSb7kDCmb0Sen/g8b0Qam5Vk34NeMftBjABZFCscIl+kdsB+XO2 96SOO1AIJLBkNvT+bobJA20UrPBW7aLbHQiSx32NUgnlyQIkTzFGpU940tG4wPWuv0BU x63w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=bq3le8SH; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-110071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e14-20020a0562140d8e00b0069030971fe3si15377716qve.79.2024.03.21.06.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 06:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=bq3le8SH; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-110071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 47F6E1C21833 for ; Thu, 21 Mar 2024 13:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40D438405B; Thu, 21 Mar 2024 13:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="bq3le8SH" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 096EA83CC9; Thu, 21 Mar 2024 13:08:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711026525; cv=none; b=faiHmwNhIwGJOZ1WfvwMPuSrXITQBSzA2QOpjzVsb0innOmi4BdS3htvZjjaFH4Gszw5otoSC5Ym7hhnCeuFlI3TvrgUCLkbRT9V0nwFaAZCeD55w4lBW0mQ8c3HSJE/u8/GJrSutpobPRBBpUmTwwqcYhb1c8BZTsCREXm98IE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711026525; c=relaxed/simple; bh=cG0asu/1nO7Dp23vefPYOO9+RR4qemdnjGRrIiAl7y8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZiI5W9VHWIiLew2ddf3Rf5lG58pTzCyiUFf8JVBbWV0BX9+GeIEURJT6axuH4xdompipR2QIQZgspaVc8ia9QYnITia7nxg0riF1gj1+L1kA/zkWS2P+yqD3WXs1gnQIx1fSJikT7Q5diOruY9h2TCKLL+XpzZowRE2lVrpcHMk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=bq3le8SH; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PeWMjzv2TCP5O1EIfymN2AlFHQvzJcY+97La6mMNs54=; b=bq3le8SHCA9RGKtRjoQT80Yt+r GAIPSfvVky9RjIb3Jj6jCkxsr54sQBXpDnitSmwOcVhkDXEcZK7iXBPmTzELNxCtRU3Vna8xkgRzH VzC9PZx2c0580S3Ilj4czYH2iklxaE1QrI3ge/k08tld8peE+ZQy1PAa5ggPZ7Rv1NEnUXK9bNxX/ ZpkNxepK5BDc6i0hD5OnbzzCwQn3UMPFIYJR2uNhCtYtNOhPACtZPiKqzywCz5Fp75hED7U6OkODN v3+FJbVe6G2ys8Z01T/dpSdLUaBrzBeQhu33cane2Z8qXzEP/ak8sBIFxtiPwDsTdilrD6PVtwRC9 C1LYOZhg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:42380) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rnI9R-0007a9-10; Thu, 21 Mar 2024 13:08:09 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rnI9K-0003fA-VJ; Thu, 21 Mar 2024 13:08:03 +0000 Date: Thu, 21 Mar 2024 13:08:02 +0000 From: "Russell King (Oracle)" To: David Laight Cc: Ard Biesheuvel , 'Jiangfeng Xiao' , "arnd@arndb.de" , "keescook@chromium.org" , "haibo.li@mediatek.com" , "angelogioacchino.delregno@collabora.com" , "amergnat@baylibre.com" , "akpm@linux-foundation.org" , "dave.hansen@linux.intel.com" , "douzhaolei@huawei.com" , "gustavoars@kernel.org" , "jpoimboe@kernel.org" , "kepler.chenxin@huawei.com" , "kirill.shutemov@linux.intel.com" , "linux-hardening@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-arm-kernel@lists.infradead.org" , "nixiaoming@huawei.com" , "peterz@infradead.org" , "wangbing6@huawei.com" , "wangfangpeng1@huawei.com" , "jannh@google.com" , "willy@infradead.org" Subject: Re: [PATCH v2] ARM: unwind: improve unwinders for noreturn case Message-ID: References: <1710906278-23851-1-git-send-email-xiaojiangfeng@huawei.com> <84a57ca8-8963-ca24-8bd1-ddc5c33bf4da@huawei.com> <0fd55e156195440bb1d815dd8300894b@AcuMS.aculab.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0fd55e156195440bb1d815dd8300894b@AcuMS.aculab.com> Sender: Russell King (Oracle) On Thu, Mar 21, 2024 at 12:57:07PM +0000, David Laight wrote: > From: Russell King > > Sent: 21 March 2024 12:23 > ... > > > That might mean you can get the BL in the middle of a function > > > but where the following instruction is for the 'no stack frame' > > > side of the branch. > > > That is very likely to break any stack offset calculations. > > > > No it can't. At any one point in the function, the stack has to be in > > a well defined state, so that access to local variables can work, and > > also the stack can be correctly unwound. If there exists a point in > > the function body which can be reached where the stack could be in two > > different states, then the stack can't be restored to the parent > > context. > > Actually you can get there with a function that has a lot of args. > So you can have: > if (...) { > push x > bl func > add %sp, #8 > } > code; > which is fine. No you can't.... and that isn't even Arm code. Arm doesn't use %sp. Moreover, that "bl" will stomp over the link register, meaning this function can not return. > But if 'func' is 'noreturn' then the 'add %sp, #8' can be discarded > and then the saved LR is that of 'code' - but the stack offset is wrong. If func is noreturn, then the remainder of that path isn't expected to be executed, so anything that happens after the "bl" is irrelevant. > A PC from LR will always be the next instruction. > It is only the PC from a fault frame that is the current one. That sentence makes no sense to me, as I don't think it's even proper English, so I can't parse it. > The unwinder probably need to be told which one it has. > (Or add 4 the fault frame PC so that the unwinder can subtract > 4 from it.) That's basically what I said. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!