Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp403379lqp; Thu, 21 Mar 2024 05:08:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAquQaQ2QnaOW/UsJ+KKBaa3z5fSJ7fZX8TegPW8VzzGxcwZykA9BFZve/HlP9RtOUgdL90+rcnI8SiVRNCE1L83Afv5Ce3B5rQpronA== X-Google-Smtp-Source: AGHT+IG0Gn0BU8pblKonLGjj67CPCfDwhcV4bIekzZyEBuG2aQOEt8svYxTOgfkVF3XDoH1ch4fg X-Received: by 2002:a05:6214:1803:b0:696:315d:c549 with SMTP id o3-20020a056214180300b00696315dc549mr4713586qvw.41.1711022931234; Thu, 21 Mar 2024 05:08:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711022931; cv=pass; d=google.com; s=arc-20160816; b=xAMHug6NBkO5GTxL9q2WMYJRjnWk5jU2CiuPU1kPNZOaepgHSuIHAxzJvzbSfq/s+C /8aZIS+pWVFTBRpd03pv88Dpn6Dg+zlpcYANsZdXsoEXW4PwPoXionO90bxvSz3uKsML xTzsPAtthP9/dbyL4AoRQs4MVk4SRG45OTFBlQZso8qM9RURsutCVKeZ7X6sZnvsNUjf tuyUm3PCOOmf3ql4NkUITlkxM8mOvasWTzL+f/DwT2HMmtbWy/CYU1PUWZZ5oYRwO+o3 Q/JtTuCu7b/aU97S3CqNApa/hgNQkkcFmnUBLnEHbtKjg8HcCvDhI81OY2aOLH1/Tk5c HI5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=GqyvfRUi6RfErn9zYplQfeZe7bnkSZoOo+d9kCUvcWM=; fh=8qweV8c4aaEm7jHXmxAsmR7VxsJrfd98+oZOD+1u2TE=; b=Od3RQP09JWJab0C4oW4TuSCWMyBHlJ94gcIEwM4T3dCsrTrE8/CS9gSOY6XIR5KBoP L+YZQk34YtSvAsoiiM6eC4nbuXWSy5yaXg2LlWyu8pxrLLfYPo0fftL5RJfqsjC0Hdho WrFhvbrHxTSIbw4vNcg12iToOoVx+bczSuJF+iAdwlCN80AEIO+4LepIsb7PduPzdN4T peoK0sqpd96SaipnOz1bdubykIlVb5i1gizFQhw6vL5ttPdID/F3d9dOzsnW404qxlOM //AeJ1IMq+xXjLJdZcFjp/G3Bw6li8SeYlb5Y6CRHGQFxiaCi0rM0m5qyCSYduHCGqhL o3TA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-110009-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fn1-20020ad45d61000000b00690b9abcd95si15332914qvb.364.2024.03.21.05.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 05:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110009-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; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-110009-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 EC2C71C21A27 for ; Thu, 21 Mar 2024 12:08:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61CAC762E6; Thu, 21 Mar 2024 12:08:32 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (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 12F967604D for ; Thu, 21 Mar 2024 12:08:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.86.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711022911; cv=none; b=uxt23jcQqKDDlrCpHkj65Sr+Esu4b2XsE5B3shbAyvjBcE2zFzI/VW4hi70Jk2nrJl8J6/sUKa5jDbJMaGsVDKjn5wE01Ege/36DcjxTsaQ1dcfLP7ybj23VFX9goEySu3OJkc/gu92KBL0c44DtnkIhHq8t+hlxA+lGHxE2q28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711022911; c=relaxed/simple; bh=GqyvfRUi6RfErn9zYplQfeZe7bnkSZoOo+d9kCUvcWM=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=Z+hVxErj1A1utKbGclUXe7saf3PJa5EcOuh96itCjKzogjPY4zpfkIs6QmTuR90qrOW080gTFqnTtip9mG2TOpeslc0Q7UYgA9luPZWhZczbkA2SZ1LfO36fTNJluvrDOXgWqlyr4ZiLxOb2/mfEx9kJctd4xOBfQgbxYSB2SNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.86.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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)