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 806F3C54E68 for ; Thu, 21 Mar 2024 12:23:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7C996B0089; Thu, 21 Mar 2024 08:23:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E2D4C6B008A; Thu, 21 Mar 2024 08:23:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF5746B008C; Thu, 21 Mar 2024 08:23:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BD3A76B0089 for ; Thu, 21 Mar 2024 08:23:35 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4067516052D for ; Thu, 21 Mar 2024 12:23:35 +0000 (UTC) X-FDA: 81920961990.01.05E8926 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) by imf19.hostedemail.com (Postfix) with ESMTP id 8378E1A000D for ; Thu, 21 Mar 2024 12:23:32 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=armlinux.org.uk header.s=pandora-2019 header.b=Lkj3c18Y; spf=none (imf19.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"; dmarc=pass (policy=none) header.from=armlinux.org.uk ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711023812; a=rsa-sha256; cv=none; b=ZIc2DERYHpwFPvOq77+wtBEFAUY+dpkJCxJUAIL9nx5KAIrSW0FS2UdlCtOlB64jlOZlhk gK4NRyaNx+3gceUSXmIjyKXytT//GXhD9+rFKdJveEX24ihbw5yxsbf/s/4aH+rEcib03j zS8RPjaO3VBnMlKXQcEM3WF6lvSxCGU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=armlinux.org.uk header.s=pandora-2019 header.b=Lkj3c18Y; spf=none (imf19.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"; dmarc=pass (policy=none) header.from=armlinux.org.uk ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711023812; 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=bv5iaIHPCtllbUdTBibdobMZ0uFxV6D8XvDh1qKAPRc=; b=1vC+gNhCueBI2NAZT/SRIecVBDhXve9JmgHPcA6v9/1qgruEYP9vC3VD+rC4AfXDbsfJ/8 zv9GocXMcHnqvd8HEX7EtWB43ELH5Z8FA3C4EnTyl0fWSqHVZfKwuTUNAkVlNQLxuJjN2K DXJqC33MFXGbYzZyRQ3Qp2rHKhvfjdY= 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=bv5iaIHPCtllbUdTBibdobMZ0uFxV6D8XvDh1qKAPRc=; b=Lkj3c18YRRBepAzzJc64myDSZ6 vTbXteiIViBqHGeU6E9lDwpYqA0nDPgbUdpNDKiKND3D3T7kC05v3NOAPvITBZ8sQH/gZ/oYjHuR0 Jr9QRYKBkKGYOSs1J56y0aTRsIsA7gFEzzc4ioVpgPvb96lA+eVHPF27AqqLR96jTwaTeYsmli5DK 6lHemPYIN4ZXJrAQ8ki1duGAs00GxSlSMT5x5tqU7qxB7/sU9bKdNQuB3hXCxVSDzBg5CdCm9aXGM t7xvvUgoUj6DAWZuSdv/CrgjYFfm8lenv+szEn2gueWVKhEgXbVFPfutWDZd7VNTtqWD43wt/75rk 5W9R5S2w==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55568) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rnHRo-0007XB-0R; Thu, 21 Mar 2024 12:23:04 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rnHRi-0003dh-TB; Thu, 21 Mar 2024 12:22:58 +0000 Date: Thu, 21 Mar 2024 12:22:58 +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: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8378E1A000D X-Stat-Signature: 99iet119sx8wryzwq6ft1mpwxoqys7ox X-Rspam-User: X-HE-Tag: 1711023812-303920 X-HE-Meta: U2FsdGVkX1/GoMETGw+lVIsTap3EUWJzG4Wd9RycKQJ53kFN/xd0J+9sNswqiTjxpHMQi0U8ShqgHY/XyGhixEKNrSwkSN4odEN37Y9xh7oSdRX1RySYYNP5a2fx2bMh+qBHZcWnm04wcRu9dbvdJhnFRtmYcwoWP31Zosd4iE8BlZjTZjySgqrXZtSYR/lfhoIxmOM/CbWOCRdq3X20auPY+OKxZx20CtXZLfmPGe/i5a8mlGase7oDgce577nSxri8ocir/tQl5zl5pZWUza4ewgn5w7gc9Bm6O7IyO8Kvk9sjIbREKavNtJXwY1Srwqt8ekvnnLNmedxR0T8hoFc0hvjVd9olTfnSkVBChCDz8wWD0LYTANLfcOuiww4EMdgAeBZQ+Z2xFI1BcdR3FeMDYk8HgnZN7JraBpwLIrbPif689u2Fq4GMvER7BkPcDgwnDipwaGMtpMScUEqWoslvplN128XwoHZ4gf2ATW06yFxbs3iaJGfYWf9tLHI0Cg68cNiBO9WS+TBNxIA8QVVfH+CeCDHVcQrRzzQLKxjo24jFIAhsquvXDvydacPzjjEfqvAW7aB0RV5loTXrcFP1z/GZgoMm9Xsxq9ByCVZP4uAD8UL/xWnQw8z7GnmRBSGZ3axMHjhctkeILN2ayNjYyvvB0FKI1SQHYjz+1och+5Lf/4RR/QG4ETG0taVHOhFiI4YXWzYCq3pmRPMwICBfILalwsdz0vh004SOUvnJPagqQQsRrl888N/WYFt1t2+IakRgga/OCWyfePVsTuhVK2s7XIzxL9dEiSZXvp1srnkG3xtb0Fwb0cCXoPAzl6cMT0CMPe+xfKlCaB4qYrDTCQ4keQfKWXs70p3eZLMr6e93JOgZ5E/2Xcv4OXA5WE4S9mddMatqe8B6FVwXZGpbAi+p0aBrjV2dWwB6e8F3I9aWqnpvu8CXgza3KBLYlCUylapvNLfg+sfi5tv ye2xumrb 08qd074YoX1NoS7TOOYc9CJb+mcMdOAU98Js6eDkRweaJ+++06yJV8pdzLvzb9M8yKRCEEbR+3aImvd4HC4lOVIt0e/GK1ydn9Z4g82VDWs7MALsNOFzJw//+ndq51j4hszz7cU895TurKqYzqecJeF+DXv9u2QdVMkQk4gG0GQ0ZEUoBT/FiiBBVrjEaYeLQrQe40Pwi2Y6EJ9vnxyes+z+WBSSFy2ROyqRllypX2u3ez+Am93K5Wq44j2akA4rVCBoIlxlFt13IXkFjfRphfFPf+JzPL/LSM2uPbvOltB/ccjZIsylDQPbvCRqe5EY7gyaDk18mVgMAmmuWSxWiuEzI2kepQ772p4LvbiFqC+9fZvgkr7mfOUSN/PI90uA//iG73CrjXGs650iFLUEAHNXGQ4Qiu2H6Gce6Zth0O4Py8JDuS3/lj+J6Jzp6f2yv2jEjrcdW7VEj4UzZfNTZjmS1Zg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000026, 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:07:51PM +0000, David Laight wrote: > From: Russell King > > Sent: 21 March 2024 11:24 > > > > On Thu, Mar 21, 2024 at 10:22:30AM +0000, David Laight wrote: > > > How aggressively does the compiler optimise 'noreturn' functions? > > > > 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. .. which is why we pass -mno-sched-prolog to GCC. > 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. > > 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 = next-instruction. You are missing the fact that the PC can be the saved LR, and thus can very well be the next instruction. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!