Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7852884rwn; Wed, 14 Sep 2022 05:36:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6M4KlZqPGuDXU5CcD9QFXTrRuhRrXKIwm+hjAU1cxza8J8S97Hj/0/3rb56k/S83M28XeV X-Received: by 2002:a63:ed18:0:b0:439:4176:3ea6 with SMTP id d24-20020a63ed18000000b0043941763ea6mr6841351pgi.363.1663158977660; Wed, 14 Sep 2022 05:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663158977; cv=none; d=google.com; s=arc-20160816; b=MvlkKtPwUiej0iK6ui0XhGILWJu6s/mnGnBysZj5AQGFPdA8PvulLOv3S4TCxHjoZX pHBAaA6J8RMXih+AUk5sVXCe7hewYhVVvt6IC+XXUWwWXK2JROcUPtbu+AuViQIANUCK 94vhN1xOYbwhj8Bx0qDm8SDJWoWR1FcBXqVPegWXh0dMGXtKfr/iheJ7Q+8VAVOC8zHy jpod1trm+2IalTYeg6ChV26qpCmvNtEplsCZsjLFwFv8DB9TMsNHS4IHsdjEvPBM83Aw SnE/17iXSg6noaMlyrvzF0ZmRwtiNXqxIsnrBXwyKxKYlROS/gU/WyBDmI9BlxFYvV/v Tohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=x8uUa76/vYqHHpYV6xz30WHtBbv2SBVtOfOunr1hErA=; b=pr2qeq8HQPZm+o077vjRQYeX2H+aZGfoqFF7tBfqJcCraOXlIMrs+51LJtc+tMu3jh jT+Oss1bMt3I6A+Bv8liXgiEby1/Hl8dhALlbJfUS2uo/tdvi7I2FIjT+N9ICoVcx2EC vXqsvJhgTKecgV59XxAAs5G5mMnX1L+Tt3byDC2PzpftQcajZE2Z5Tca8sfzQNMGaepP 6j7/AZ2MJ/JywKgCNdCr8H9ihB0QQI1IlgnwcJWAqRCg1Ao2NIgEzH00h4m6ZcYhlCrM UPBGKBHmtdf5etdH0HTle+pC4iDe6TO2w8COJXLRgsFogk3twsy0JS9dTMhXTcqiml/l ePlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h27-20020a63531b000000b0041d35692c4csi14720681pgb.281.2022.09.14.05.36.05; Wed, 14 Sep 2022 05:36:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbiINM20 (ORCPT + 99 others); Wed, 14 Sep 2022 08:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiINM2Y (ORCPT ); Wed, 14 Sep 2022 08:28:24 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF95C2E6A4; Wed, 14 Sep 2022 05:28:21 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 28ECGMjO020934; Wed, 14 Sep 2022 07:16:22 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 28ECGLVD020933; Wed, 14 Sep 2022 07:16:21 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 14 Sep 2022 07:16:20 -0500 From: Segher Boessenkool To: Josh Poimboeuf Cc: Mark Rutland , Peter Zijlstra , linuxppc-dev@lists.ozlabs.org, Chen Zhongjin , x86@kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, Mark Brown , Sathvika Vasireddy , linux-toolchains@vger.kernel.org, Indu Bhagat , live-patching@vger.kernel.org, Miroslav Benes , Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, "Jose E. Marchesi" , Michael Matz Subject: Re: [RFC] Objtool toolchain proposal: -fannotate-{jump-table,noreturn} Message-ID: <20220914121620.GY25951@gate.crashing.org> References: <20220909180704.jwwed4zhwvin7uyi@treble> <20220912113114.GV25951@gate.crashing.org> <20220914102100.thl5ad35plvazark@treble> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220914102100.thl5ad35plvazark@treble> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 14, 2022 at 11:21:00AM +0100, Josh Poimboeuf wrote: > On Mon, Sep 12, 2022 at 06:31:14AM -0500, Segher Boessenkool wrote: > > On Fri, Sep 09, 2022 at 11:07:04AM -0700, Josh Poimboeuf wrote: > > > 2) Noreturn functions: > > > > > > There's no reliable way to determine which functions are designated > > > by the compiler to be noreturn (either explictly via function > > > attribute, or implicitly via a static function which is a wrapper > > > around a noreturn function.) > > > > Or just a function that does not return for any other reason. > > > > The compiler makes no difference between functions that have the > > attribute and functions that do not. There are good reasons to not > > have the attribute on functions that do in fact not return. The > > not-returningness of the function may be just an implementation > > accident, something you do not want part of the API, so it *should* not > > have that attribute; or you may want the callers to a function to not be > > optimised according to this knowledge (you cannot *prevent* that, the > > compiler can figure it out it other ways, but still) for any other > > reason. > > Yes, many static functions that are wrappers around noreturn functions > have this "implicit noreturn" property. I meant functions that are noreturn intrinsically. The trivial example: void f(void) { for (;;) ; } > I agree we would need to know > about those functions (or, as Michael suggested, their call sites) as > well. Many "potentially does not return" functions (there are very many such functions!) turn into "never returns" functions, for some inputs (or something in the environment). If the compiler specialises a code path that does not return, you'll not see that marked up any way. Of course such a path should not be taken in the kernel, normally :-) > > > This information is needed because the > > > code after the call to such a function is optimized out as > > > unreachable and objtool has no way of knowing that. > > > > Since June we (GCC) have -funreachable-traps. This creates a trap insn > > wherever control flow would otherwise go into limbo. > > Ah, that's interesting, though I'm not sure if we'd be able to > distinguish between "call doesn't return" traps and other traps or > reasons for UD2. The trap handler can see where the trap came from. And then look up that address in some tables or such. Just like __bug_table? Segher