Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp595055rwe; Thu, 25 Aug 2022 06:07:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6lSXp7SBoPYFhnXphRctDlIfXQqthM+qaiVPRfYdKYg2dN+If30AamZ7RyrW1blanbmqs8 X-Received: by 2002:aa7:c7da:0:b0:440:d482:36b5 with SMTP id o26-20020aa7c7da000000b00440d48236b5mr3159452eds.21.1661432837917; Thu, 25 Aug 2022 06:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661432837; cv=none; d=google.com; s=arc-20160816; b=TPYG/wti00puaPo1Y1O343dl+XXENvzzL/cYe6dvducKmuOR7OJzGuZXtS9fKgxVHq 5XeIOriZbYi9AGjjjp+uBL2Aqt4whL1g/v5WrFf+2P8ziwuU6Sv5rNKbyzB8JvStx6// 00k/MqA7496wHiHPRhh7gPdTJUZGVz0+EXb4NRaH+g74VxNmSzjSqcLCtKf1PFhFuaQC RUbm1ZNs97S5+/jLvTLwHoy66fpXJqL7/iPesa2dqHM/0l9oh4gzFWGoSSmBkaXq/a+V L+a5jL1zPsJcWdObxx9CYra+kwBJQAxRDZcu9Qe15vHboYX1Tq9DYr7EHAvAsFKs2rh5 aRJQ== 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=lgr5goy4GqQ5onc3dqjbrXz1GDxfyFhFPyptN1tPjRU=; b=AMZk/ejs0xJ2cWef+FHeRa9ow8Q8CIXhID9sQNlpMkMwsV+y6czj5K5e6QpqDPLvFI V3RmP7xOPnvRaE65UdGmYbx3o+cdAycdJ+2+oY5bhlpG2bRmVFzC31thJkkkxrJvJ8eV eJQcdNpVavD2zMOUw+IH0hSxAep0S+tlnU1S+pZy1S9XSCk4JSEY7O+4WQeIvTGbx3l9 GgSTLCadKJ5NGpKOIBQUAy4tGS1EhoIxrOOn4nCYw//SyvgKNq9GzNbZttRl+e0ojZrO Eg+t4j6vpiXMiv/XCOddAfYQRaCs9IJPxHDp+ait4z4ZX3j9B4+zPFXIxXJbESXOl3gc fIPw== 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 y25-20020a170906471900b00730f3cb968fsi3144584ejq.990.2022.08.25.06.06.42; Thu, 25 Aug 2022 06:07: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 S242278AbiHYNDS (ORCPT + 99 others); Thu, 25 Aug 2022 09:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242190AbiHYNC6 (ORCPT ); Thu, 25 Aug 2022 09:02:58 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A7B39E8A5; Thu, 25 Aug 2022 06:02:45 -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 27PCwEnu008838; Thu, 25 Aug 2022 07:58:14 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 27PCwDAs008837; Thu, 25 Aug 2022 07:58:13 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 25 Aug 2022 07:58:13 -0500 From: Segher Boessenkool To: Peter Zijlstra Cc: Borislav Petkov , X86 ML , Michael Matz , linux-toolchains@vger.kernel.org, LKML , Josh Poimboeuf Subject: Re: [PATCH] x86/sev: Mark snp_abort() noreturn Message-ID: <20220825125813.GE25951@gate.crashing.org> References: <20220824152420.20547-1-bp@alien8.de> <20220824172929.GA25951@gate.crashing.org> <20220824224144.GC25951@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Aug 25, 2022 at 08:41:19AM +0200, Peter Zijlstra wrote: > On Wed, Aug 24, 2022 at 05:41:44PM -0500, Segher Boessenkool wrote: > > > It is! A noreturn function (that doesn't warn like "warning: 'noreturn' > > function does return") does not have whatever your architecture uses for > > function returns in it. Just like most non-noreturn functions that do > > not return btw: the attribute affects code generation of the *caller* of > > such functions. > > Yeah, but objtool can't tell if the compiler just spazzed out and > stopped generating code or if it was intentional. I don't understand what you mean. If the compiler malfunctioned, all bets are off. If not, then the compiler correctly decided the function does not return in a normal way, and it generated machine code accordingly. Or you mean something else by "stopped generating code"? > > What fundamental problem does objtool have in dealing with any normal > > compiled code itself? Does it try to understand the semantics of the > > machine code (not very tractable), does it expect some magic markup to > > be generated together with the machine code, does it want to have > > compilers hamstrung wrt what kind of code they can generate? > > > > There is some serious disconnect here, and I'm not even completely sure > > what it is :-( > > Objtool follows control flow. As you said above, noreturn functions > behave differently and code-gen after a call to a noreturn function > stops. The noreturn attribute only informs the compiler that this function is one that does not return. There are other functions that do the same. Most (or hopefully all!) functions flagged by -Wmissing-noreturn for example. You cannot require all functions that do not return have the attribute. > Typically objtool expects a call instruction to return and continue on > the next instruction; if all of a sudden there's nothing there, it gets > suspicious and says the compiler messed up. That is a shortcoming in objtool then. The fundamental problem is that you cannot really parse machine code as much as you apparently want to. And limiting yourself to "machine code a compiler would generate" breaks down if a) the compiler changes, or b) your assumptions of what compilers do or do not generate are faulty. Segher