Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp351387lqp; Thu, 21 Mar 2024 03:23:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUyGPYUJLZawL0NQtwzlT0t5k26sTCD77VwAlsv4998E4FqtanSbZvq0QTYILCfLBoD/mKFYv9tccy9EDYZkQW8M5JXhgOh/pcWt83gMQ== X-Google-Smtp-Source: AGHT+IGQGUVi7g2BIGmvP3eOkDfODbFK1kFcdEnZVq6bZ7VDkCAfrxA0e7zn4J+QiHDes6t3nIma X-Received: by 2002:ac2:5151:0:b0:513:d339:8b1 with SMTP id q17-20020ac25151000000b00513d33908b1mr1039550lfd.27.1711016593347; Thu, 21 Mar 2024 03:23:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711016593; cv=pass; d=google.com; s=arc-20160816; b=yxJh63Zi+ThvZBNI3Z9fCdYD4KtHyYqUQO71Cjsj5W+OqGLIB2xUh1Q4h4iwKR2WRT d69zaUVrzrdfqH+tSgN2nNRg6Ffsjn913pDClstewpMfHKJs4fvzORSLTmhOuyb1i2WJ QdiPSxsRQkAYtkxnecleBv0uUgHz+xjQbZ6bozBVVoYGv7QBoFjQRM+QRhwGEVANpJVj FiYXX5bBHW3EKstDyxCAdOERCgU8yFCMERJQirxd/hduRzkGEC/fITM6nS3F0kjRbmCh HX981uuQlg9+kFjPPPHgs4e/+MHALD6NtBMnykP0GprHCrYdmgIZ+TzKOBe/Jgmb7NTv Z6Pw== 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=5JPCZ+qBJS79Nz0MHkbWXC6seLKtP4tznYnQqpZf1HQ=; fh=oBwl91D56Ys7LMrhau1EPvOfSwYdscSz/I7ojktH1fM=; b=rulasXwkFIvap2k4ULRz54FAXLCqz/w4+O+jKQnFe+k3SS3f+8GK6n4ts7bo/+KIgN irNqC0c7Xom/Pd5g5YEpy+ME/NNZ//bS+ZB2GGLxfSRWOVWYSFImBbSs6Ljkby8KSLBZ m9dn2/s63sPmpgD3QCf+8SugR0vRzUvfoXoLuZJaQvBAFTTHAnICpuTawQov1cNSqfvo 9X6qnwhdoZdfxP2sDfilA5V7dBv4Hcaq2PHaDzF1ETBYdzXxLNbYI++og9QzYlX1LkLO imNav2JdkI3IG3r0J0+rAwJ5TcaY3tmhKqoq2EQuFgSlhFUN+cJl6XlTxJ5ZKOoF2knX Sbfw==; 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-109888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g1-20020a0564021ec100b005682b6ac21esi7512730edg.54.2024.03.21.03.23.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 03:23:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-109888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109888-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 15D101F2256D for ; Thu, 21 Mar 2024 10:23:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB9A056754; Thu, 21 Mar 2024 10:23:06 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.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 73A7A56448 for ; Thu, 21 Mar 2024 10:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711016586; cv=none; b=NfD2KYcdNRS53IJLCwNlOUA5qRQK3a96gFWqhhWN6kJNWTo1gO7JDuoOe1D5Z5Y1ceaE56hW9zEWPZG6VpXXwNE0nsLD07JPKsm/Bu3yCFnPpsb6Cynmy/YCHxEuhkoQE939suK9ep4p/k5JnZYMosn95l65hTRra0g0iK8KjCs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711016586; c=relaxed/simple; bh=5JPCZ+qBJS79Nz0MHkbWXC6seLKtP4tznYnQqpZf1HQ=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=O8EbWDAcX7/VoDPD3yoXJkTQ7ouE+3TQz2jdKzulknCAELsRISR7YEQBj/sWOYsPDNMkzXBR9gCA8H90fcpa1G8sY7P0YuUNZ+qbnTeMDlln6yEZEv3++aIbqLnoI6X0+SO1ienoWohIdUhFUlmNkGqgYZZTAfKcyQpatKjcDpI= 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.85.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-212-p3JOoYAWPBWRUG8sgCg1aA-1; Thu, 21 Mar 2024 10:22:55 +0000 X-MC-Unique: p3JOoYAWPBWRUG8sgCg1aA-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 10:22:30 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 21 Mar 2024 10:22:30 +0000 From: David Laight To: 'Jiangfeng Xiao' , "Russell King (Oracle)" CC: "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+AaCprEesIWGaAOB7ebFB9uHA Date: Thu, 21 Mar 2024 10:22:30 +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 How aggressively does the compiler optimise 'noreturn' functions? Consider: void f(...) { =09... =09if () { =09=09... =09=09noreturn(...); =09} } Without the noreturn() call it is a leaf function. So the compiler doesn't need to save 'lr' on stack (or the save could be deferred to inside the conditional). Since noreturn() doesn't return it can be jumped to. Additionally 'lr' can be used as a scratch register prior to the noreturn() call. So it is likely that inside noreturn() (and anything it might call) you don't have a valid 'lr' chain at all. No amount of picking between 'pc' and 'pc-1' is going to fix that. The only way you can find a return address is by searching the stack and hoping to find something that works. So you need the compiler to 'not believe' the 'noreturn' attribute. Setup a normal call frame and put a faulting instruction after the call in case it returns. That would give you half a chance of generating a backtrace. Without that I suspect you are playing whack-a-mole. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)