From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A73E6C54E68 for ; Thu, 21 Mar 2024 13:08:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25F486B0082; Thu, 21 Mar 2024 09:08:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 20F0F6B0083; Thu, 21 Mar 2024 09:08:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0889A6B0087; Thu, 21 Mar 2024 09:08:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E8EC56B0082 for ; Thu, 21 Mar 2024 09:08:44 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 78F3B41601 for ; Thu, 21 Mar 2024 13:08:44 +0000 (UTC) X-FDA: 81921075768.06.25AE3E0 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) by imf28.hostedemail.com (Postfix) with ESMTP id 4A18FC0015 for ; Thu, 21 Mar 2024 13:08:41 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=armlinux.org.uk header.s=pandora-2019 header.b=bq3le8SH; dmarc=pass (policy=none) header.from=armlinux.org.uk; spf=none (imf28.hostedemail.com: domain of "linux+linux-mm=kvack.org@armlinux.org.uk" has no SPF policy when checking 78.32.30.218) smtp.mailfrom="linux+linux-mm=kvack.org@armlinux.org.uk" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711026521; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PeWMjzv2TCP5O1EIfymN2AlFHQvzJcY+97La6mMNs54=; b=KgPOts7osy3npFQEl3QdiewIFPrMMA2judjt+AH0FIXnqOMwwIffVsEAFJFbhbhwp7VSKg T4zw9SnpLjHUXm1arBzHFJtMEo1FF8kq5k2Ya+pUwsqdGQ3F0gf3VlW4Ohj02qmfw0w7I3 ADSg3BdfHcWg9MtpEwoOgxurQHh1LhM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=armlinux.org.uk header.s=pandora-2019 header.b=bq3le8SH; dmarc=pass (policy=none) header.from=armlinux.org.uk; spf=none (imf28.hostedemail.com: domain of "linux+linux-mm=kvack.org@armlinux.org.uk" has no SPF policy when checking 78.32.30.218) smtp.mailfrom="linux+linux-mm=kvack.org@armlinux.org.uk" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711026521; a=rsa-sha256; cv=none; b=SSHtAjjzHisn16chn7ChbGCCdF7DGLnSohmv6roJK9dyHSh3GL3Ci3uy2RdBUJtfsD1UBH KVyLqPDj3oDEM1gf0MJU1HDFMNaVV9zMm+s8UE3jmYHqHcDxyl/GRZOOHI7sYVZnF4GKSy GCOGDWaIYZm0ep96lEUwPGU8Q3kyELU= 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0fd55e156195440bb1d815dd8300894b@AcuMS.aculab.com> X-Rspamd-Queue-Id: 4A18FC0015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xwm7w7rmjo337qoz4ay51cmkh18ina5w X-HE-Tag: 1711026521-99816 X-HE-Meta: U2FsdGVkX19UhPjVhwChpIx19om+lBiZPNCr6v5UPTElotA60J+6j7hOBsEInNwPVhJIj3wiqDMODVug2V91n1+/CmHri+CZCZPh6GOZ1GiyK/5dLisJuIpdTclTJPaSBK7ej+N/xmCEzeacojO/QznpQfwUi4SY0R9iGYmjMPClTPeULxV2X9ewW7RamBYiZK/j0Wb+pEQfLupiyQRMrb+Jpu20n+DTc8yOKNMjAWML4LHpqoKhCSDBG5lvaEGKY+q1XWPHPKGhpH8qBhxEvlJ/Gc9SeWF33PBLyiigFC+BSDL6RFBNbOSV8zZOoaW4xuA8Z8PoNDWuWkqqiZiBWt5hWmfCD4LOG7LobuzRtQHnKoz6MtQT4HuELwjHhDY14zh7LauLVT9FT2rwUiKRqLNEJvbKv5rS5fgo7+v9pcOfHv0oZmUKkfCLZYYi5QlD8JFQ9WcTjrUayL/3AJJq7lrsqJc10Drv7gQdwjLISSOz9Kn7zq6kXqomhZlQLPEiGcLCkVaRoRLzRiXD59GB2qK3JsVLAlm//jBPi+aPYJZnBlhEU6x82WrVEPwS/GS13KJXKOZf36OvJvxaFgrxEd2K4E8apESzZpnNzSxHXBqpzCVL3kTMK24kEagetOkmX96Z96YYeR7XQodLNswCg0XE/oGKFPP3fTyzrFBJ63AG8J3U4p4Yd++pSnjEK0fcwj2J5DjxeDNIcsU7cMd3VKtFmGGGDIPAM0LpRHmxqg2zP03iciPpwa3KPo4kVPAxbumFm6y1OZPc/m4tTaiFywsGfkvKWABPyZLkyKsnAKsameaIb9sMVl2WRYsXf64HuwOVF/ZCBMyEJfJs/ga2i9uhyBMUH6Isu8L67//cz69gZiVSZDoVCxrSs1dkEzsyT9h3e0UbPQFAXsu19RZyW6xe3h/p/ii8Ru1/rqAUUdNkOqie70MckyUJcYC0igkdatX8XfHNOdT13J+w6YT C/fk9P2b xYwr7W9eK/62eiBeRh/7nS+iUh/ZPZcnzZ/cJ1t1AZUjZHQTBTvqkf5+9dCWxslJulZrmZukr6LhcQ3PvakCif33eKAAL760VeDCarILqLcpK534= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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!