Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1010814lqp; Fri, 22 Mar 2024 02:53:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaPL5+c3oR8QoXvi8f2wrcX+oH9pi+3bxFdpbUxQ/R7A0yBd3kzfvxSfQvjH98R4hZugiokctESUCukzNBLHNGYnqi4oj7lyGqSpY2wA== X-Google-Smtp-Source: AGHT+IHOEe3eNjxfnqUnRPssc7YIkEl/chLkbIQijYtDuE1I8UCV12h4H9FKE1b60UgkzaWKO8rv X-Received: by 2002:a17:906:2853:b0:a46:cbf3:a674 with SMTP id s19-20020a170906285300b00a46cbf3a674mr1262364ejc.21.1711101179858; Fri, 22 Mar 2024 02:52:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711101179; cv=pass; d=google.com; s=arc-20160816; b=AaAE5jDy64/ewaiQmWhAxrJgwNvpseU6wJiFN/zmUlq2B5mkjUJA8PK14aLrXnwwBp DKi5EfNWK0aQXf9Q5lMPj77JxhNeNPEnQERTFuO7/+xNQ1JCx2jmmO4i9QRpWGr6iUo8 5MsgBHdapiRIAciAWu+cO3GUl0DqcDRDkvuhlRMDop1N4TCMabgBEMUAS3msyWYnD952 O7TQCD6S8eVBN0VV5yONf43+asl0oml8f+RB4OhxRvmDHzUmClyytZndM/lrHqYP7mEA 1t1KStbLNCZOkqaJTBRFikcyT7skFyI1etoGuzJEFcLjnrY2Gy6xDT3i31pDxlW6RyZu sETw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=uY3ErBRSm13BWg/PRQDPTz4nkc8UUIhrKSwSU3A1w7U=; fh=ca4aNwbjdigo63UpNinY57GX2zbyTCSgUC//QO7t+Gg=; b=sH3zSbNdeTYXgq2uZfxyxaQTOe0icavJwrZItwNJ0YkcTKluAffqKQZUcOIK61PLiK cRhnwao3QNg4Kq95pysu2+TNew58gjjdoplUOyj/mwQ0G0ZdMOHaG+jetwoBGI8F+9fP UuMAeheUgyNHFlN2T1LfPKaaAhY6KwhoAKW/Av8DHpe42O8RRMFuvKSwJG12ZBOReB0P ImOyEdb+E/Ijm+UFwEIGeZa9IyADhfvLISK69oY7gL8cqRQMRSS/uyr+TAtsNGYpxPLt KUUp/uzmF7ky+eZ1kA7cvFEOsiovQiATz3ewrybNAWYyKvnKL5L6fECr2NkEb2YUknne MLMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Y384k+jz; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-111251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dx24-20020a170906a85800b00a46cc4daef2si754169ejb.3.2024.03.22.02.52.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 02:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111251-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; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Y384k+jz; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-111251-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk 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 6B2C41F2665E for ; Fri, 22 Mar 2024 09:52:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 343B7224D8; Fri, 22 Mar 2024 09:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Y384k+jz" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 7EED717575; Fri, 22 Mar 2024 09:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711101172; cv=none; b=DcF8KeEtOn99TKewVAlxdlNGpeRcfngtAVfRZXOKTslIqAvARVyDbqCl6tZsRHt3F3DiPYdtHtbXcdsbX/58WGNppXeGeY2sl73OohynR8nr4ePDQOOMWcYfcUX7z6+mApLjXENyhqa5fPyQ/PTVTB5Dj+ss9jHxp3BQH778zU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711101172; c=relaxed/simple; bh=bOhLcsYDVZmhBgEUm4A+AenfvHCVdl7QYceTR0y7L2I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f60irZwXF1ONF2rI1tL7iaer3o9vpfyJpjCINhtDjk93c6JO0bSwCgQdg1JaBr4Dpo1eJ+pFqqb0iXAduoZnw8Iqal7ZLllwrnyiRnWwBQ922eMBESFQ6ry/NplQPrm9c0728UfiZbGi5vQsj/GvaUB46/+tHwOUvdHzY172Nv4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=Y384k+jz; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk 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=uY3ErBRSm13BWg/PRQDPTz4nkc8UUIhrKSwSU3A1w7U=; b=Y384k+jzKaq1zpLti0tPPj9ga5 MNe50rOqiaFr4DqqJtrpa5NP1INK5UeoY34zpnnSteBYYYUajBQLdyy1U9zWiG+/kgjgaffsnzQ0J 1keQ8qPvs8MHWpN9QXTeEvBiMg37vNC0qwPQC6JVGIqKs563vXAJ37YbSJ/xvT1xWHIYRjFp09otU OYbqxq5EXKWY+ARCABdGy8Xr+tcpLKRNzl9CkkLqGLgIuRiYdgvSwbhg5xAHUwuUWE8ENBgmH0jfX 0NETo0ksPxJpcda3ZrZALDQO0wDdwRAhbd5TkOsT9YkqP+rFlBporRUq1fni/+o8sTOcKBTxNe/N3 jgcRP+Wg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54618) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rnbZT-0000BM-0N; Fri, 22 Mar 2024 09:52:19 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rnbZL-0004bs-DT; Fri, 22 Mar 2024 09:52:11 +0000 Date: Fri, 22 Mar 2024 09:52:11 +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: <1710906278-23851-1-git-send-email-xiaojiangfeng@huawei.com> <84a57ca8-8963-ca24-8bd1-ddc5c33bf4da@huawei.com> <2b2993fb215c4a5abd7d77ff1c984113@AcuMS.aculab.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b2993fb215c4a5abd7d77ff1c984113@AcuMS.aculab.com> Sender: Russell King (Oracle) On Fri, Mar 22, 2024 at 09:24:20AM +0000, David Laight wrote: > From: Russell King > > Sent: 22 March 2024 00:09 > > > > On Thu, Mar 21, 2024 at 11:43:41PM +0100, Ard Biesheuvel wrote: > > > Given that this particular issue would just disappear if the compiler > > > would just insert a BRK after the BL, I'd prefer to explore first > > > whether we can get this fixed on the compiler side. > > > > Arm32 doesn't have a BRK instruction. What would be appropriate after > > the no-return BL would be OS specific. > > It would need to depend on what was being compiled. Yes, but as for the rest... > For the kernel it could be much the same as BUG(). > (Probably without any extra data.) > I suspect that arm32 could use 'swi' in kernel space, > but you wouldn't want to use that in userspace. > > Looks like armv5 has a bkpt instruction - could that be used? > Or does the kernel need to support armv4? > > The last arm I wrote anything for was a strongarm. Thank you David, but remember - I have programmed 32-bit Arm since 1992, and wrote the majority of the 32-bit Arm kernel support. I think I know what I'm walking about by now. The compiler can't do the same as BUG() - that is a kernel specific construct and not an architecture one. It is an undefined instruction specifically chosen to be undefined on both 32-bit and 16-bit Arm ISAs. As for your idea of using "swi" in kernel space, no that's never going to happen - to shoe-horn that into the SWI exception path for the sake of the compiler would be totally idiotic - it would cause userspace performance regressions for something that never happens. Moreover, with EABI the "comment" field in the "swi" instruction is ignored so all SWIs under EABI are treated the same. So no, that's not going to work without causing inefficiencies - again - for a case that will likely never happen. Whereas we already provide an abort() function because iirc the compiler used to emit branches to that due to noreturn functions. If correct, there's previous convention for doing this - and abort() is still exists in the kernel and in userspace since it's part of ANSI C. This would be a more reliable and portable solution, but probably not for embedded platforms - and that's probably why it got removed. There isn't going to be a single solution to this which satisfies everyone, and I don't blame the compiler people for deciding to basically give up with putting any instruction after a call to a no-return function - because there isn't an instruction defined in the architecture that _could_ be put there that would work everywhere. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!