Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp538571lqp; Thu, 21 Mar 2024 08:21:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVabQlBpWMEiUUBLLWYSPt+dUyrb8q2GSPUOCFlTJhtnsL8HVZphyurPnZCdhRvOrXZ6/SzWtlBpnXK+l3WvUd7ryixdUxwLPSXAUd8mg== X-Google-Smtp-Source: AGHT+IE0b17qNApjRYlbCvE4IafiMF/Qru6TeP6u1LNBTCkNicE+3tpqxWP9QaYoNfCbjgynR6we X-Received: by 2002:a17:906:b78e:b0:a46:deba:68d1 with SMTP id dt14-20020a170906b78e00b00a46deba68d1mr5731246ejb.49.1711034495372; Thu, 21 Mar 2024 08:21:35 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e25-20020a170906045900b00a471d68252bsi25509eja.77.2024.03.21.08.21.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 08:21:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-110210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110210-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 1B0091F23B8B for ; Thu, 21 Mar 2024 15:21:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D03A88624F; Thu, 21 Mar 2024 15:21:28 +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 8E5748595B for ; Thu, 21 Mar 2024 15:21:26 +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=1711034488; cv=none; b=uivq8Q4zpQh3G0GVWfFJL9qoJaneijTyDy5ZGsZINsLyOtN58bSNxGCtNaCgQbBK0uU4uQXXEtZhuPyiX67uyIvow+1SojajFUCrD6ert/c+fBQ29Z0b8ZEMr8dvflhrPRjBFYDaY29/GMS1XEE2n61lyR5EpADR0K3LaDyNiTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711034488; c=relaxed/simple; bh=Tz9YlKhIZctUK372Bg+H0LceqSnjtHniwyH8jxYl8Iw=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=Myrg34ElD/gJnCQushZa0dpJ7qDnb4BiCqI/4I4KWmxkcaPVtl0V0/96WjubwbNcc4Q6HBC9Szs54oN+/NrbGjkBY7cxVaOv6xV4d87Z5jxAjmjQN+WYe115X3YlzOdtq2xKxWclSyZOVd7LwGowwM1STMtiDExRLnzTvVQAuJM= 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-27-Q5suj0RZNn-WJXs-ToOs6A-1; Thu, 21 Mar 2024 15:21:23 +0000 X-MC-Unique: Q5suj0RZNn-WJXs-ToOs6A-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 21 Mar 2024 15:20:57 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 21 Mar 2024 15:20:57 +0000 From: David Laight To: 'Russell King' 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 Thread-Topic: [PATCH v2] ARM: unwind: improve unwinders for noreturn case Thread-Index: AQHae3ROEuI+AaCprEesIWGaAOB7ebFB9uHAgAAWtoCAAAVW8IAACy4AgAADrmCAAAjqAIAAC+nggAASTICAAASwMA== Date: Thu, 21 Mar 2024 15:20:57 +0000 Message-ID: <401453a216644af98d577f51c12d292b@AcuMS.aculab.com> References: <84a57ca8-8963-ca24-8bd1-ddc5c33bf4da@huawei.com> <0fd55e156195440bb1d815dd8300894b@AcuMS.aculab.com> <9d6057b110034c04b6b590522c8c69cc@AcuMS.aculab.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 14:56 >=20 > On Thu, Mar 21, 2024 at 02:37:28PM +0000, David Laight wrote: > > From: Russell King > > > Sent: 21 March 2024 13:08 > > > > > > 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 b= e 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 i= n 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: > > > > =09if (...) { > > > > =09=09push x > > > > =09=09bl func > > > > =09=09add %sp, #8 > > > > =09} > > > > =09code; > > > > 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. > > .. >=20 > Don't show me Arm64 assembly when we're discussing Arm32. Oops - I'd assumed no one did 32bit :-) In any case it is much the same, see https://godbolt.org/z/7dcbKrs76 f4: push {r3, lr} subs r3, r0, #0 ble .L2 mov r2, r3 mov r1, r3 bl f L2: pop {r3, pc} f5: subs r3, r0, #0 ble .L6 push {lr} sub sp, sp, #12 mov r2, r3 mov r1, r3 str r3, [sp] bl f L6: bx lr That is with -mno-sched-prolog but with 5+ args they spill to stack and the %sp change is pulled into the conditional. It does look like %lr is being saved (and for arm64 I think). =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)