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 6EE63C54E68 for ; Thu, 21 Mar 2024 12:08:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C509A6B0087; Thu, 21 Mar 2024 08:08:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C02C86B0085; Thu, 21 Mar 2024 08:08:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CB346B0089; Thu, 21 Mar 2024 08:08:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7DAFA6B0083 for ; Thu, 21 Mar 2024 08:08:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4516EA1511 for ; Thu, 21 Mar 2024 12:08:25 +0000 (UTC) X-FDA: 81920923770.18.3615538 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf07.hostedemail.com (Postfix) with ESMTP id 5E52840019 for ; Thu, 21 Mar 2024 12:08:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711022903; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GqyvfRUi6RfErn9zYplQfeZe7bnkSZoOo+d9kCUvcWM=; b=oTJ0Xtz3f/e08BzsZBK5e3QhUCawMp6vqiLNJF7pFN0E+t75hymUpdNckHQ8ncd0X+as68 Z33FfzW5uuNbMD/4ZygRmOjD6TspErQ4B53/PpYVMirSD7D6YI+oteGAIDyec8uNjXCtEe CG8xpP+VszySZvpDNBtPQwyKF/g3HpI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711022903; a=rsa-sha256; cv=none; b=6P0TehgH7tdA2H0RnLwfPsMpUKd7bdyQGmrgzd14+qq6qFwQJ1ppl6YtKzUVCqUqt51uxj Ly9T/y5EIA+n54LNEv2x67h0UGRGfj+sYCi0zZLqjHN3HrT5G3L2m4EpLrI6hhdF6rwIyu 2FWK8lEjnr85cSD+eY8Wh1QK59cCsf8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-71-oIAj6dgUOY2gPCXUAXYLDg-1; Thu, 21 Mar 2024 12:08:17 +0000 X-MC-Unique: oIAj6dgUOY2gPCXUAXYLDg-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 21 Mar 2024 12:07:51 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 21 Mar 2024 12:07:51 +0000 From: David Laight To: 'Russell King' , Ard Biesheuvel CC: '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 Thread-Topic: [PATCH v2] ARM: unwind: improve unwinders for noreturn case Thread-Index: AQHae3ROEuI+AaCprEesIWGaAOB7ebFB9uHAgAAWtoCAAAVW8A== Date: Thu, 21 Mar 2024 12:07:51 +0000 Message-ID: References: <1709516385-7778-1-git-send-email-xiaojiangfeng@huawei.com> <1710906278-23851-1-git-send-email-xiaojiangfeng@huawei.com> <84a57ca8-8963-ca24-8bd1-ddc5c33bf4da@huawei.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 5E52840019 X-Rspam-User: X-Stat-Signature: f3h9whor5uegz56j5rae6iq99h9pdg5e X-Rspamd-Server: rspam03 X-HE-Tag: 1711022901-705373 X-HE-Meta: U2FsdGVkX1/nzhCUanTvkoYi7JLWkaLvqT5mdcK9E1fH5pG/iAvWPoCxEciemCLv2rXQRsnLKenNecpJXcE/iWbiEynNaZ8vbJ2EppIxwBRiLy1Gjr3kOBapnfQStp1ltGugorwqy4I94lSD2APqEFT3Yr2J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FsZcc0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Russell King > Sent: 21 March 2024 11:24 >=20 > On Thu, Mar 21, 2024 at 10:22:30AM +0000, David Laight wrote: > > How aggressively does the compiler optimise 'noreturn' functions? >=20 > I've seen cases where the compiler emits a BL instruction as the very > last thing in the function, and nothing after it. I've also seen the compiler defer generating a stack frame until after an initial conditional. 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.=20 > This is where the problem lies - because the link register value > created by the BL instruction will point to the instruction after the > BL which will _not_ part of the function that invoked the BL. That > will probably cause issues for the ELF unwinder, which means this > issue probably goes beyond _just_ printing the function name. Isn't this already in the unwinder? A BL itself isn't going to fault with PC =3D next-instruction. For pretty much all code isn't *(LR-4) going to be BL? On arm that is probably testable. (It is pretty much impossible to detect a ACLL on x86.) If it is a direct BL then you'd normally expect to the be a call the function containing the current 'PC'. The obvious exception is if there was a tail call, and printing the called address would then be useful. (It might help with leaf functions that don't generate a stack frame.) I remember issues with the solaris sparc backtrace that used to get confused by leaf functions... > I have vague memories that Ard has been involved in the unwinder, > maybe he could comment on this problem? Maybe we need the unwinder > itself to do the correction? I also wonder whether we should only > do the correction if we detect that we're pointing at the first > instruction of a function, and the previous instruction in the > text segment was a BL. It might be enough to depend on whether the address is that of a fault (where the instruction could be retried) or from a call/trap instruction where it will be the following instruction. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)