Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp321637rwe; Thu, 25 Aug 2022 00:24:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR5sFZAE5vuUu2VRlRfmtyZbOAw27q/b6sMN7zPo9E/3aKbfcr1GZjN1mVnXKXYVTK5RVNOR X-Received: by 2002:a17:90a:a097:b0:1fb:5bc:7778 with SMTP id r23-20020a17090aa09700b001fb05bc7778mr3164699pjp.209.1661412298911; Thu, 25 Aug 2022 00:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661412298; cv=none; d=google.com; s=arc-20160816; b=qj7uWdWFmYw2nsj+6IGkw8Uk/iiJpBIMWbC3MRn0+UlYOJqVvfCMpbumSZj66TbEXr IzWJUDiHRcKSyP8Lt6WsR6LGaOzVwXaAXdaCjFNXAp3Sb/Yixv9wpqQbO0JXzF5nxeSf MHKahB2/cyksHmBY7Nm9eXU07p1DSdHZzjLLKljD2uDy+CnvdbYlgvjPQJCxcHdqgjbc Ut1dpn4P1ZanTOb3tu8s8fdTbTn8V9gWu2yF+YwcE+lrmWrvB4s3mK5pgJrqCXt7mWLe j8ggNOtSxeaHGxnW8wwuJY9HyVG5dyJK4UAN8GGE9CpvkZ85O9Y3uJCs2xEdLgHGL099 LrbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=suL/EYVy2FnBYbtDax1tUpPi5wWYo1uJguDKeceNIkI=; b=06Sy97EHZy3/OHbUEUQfh4dgN5Vfb1+oMr1qjNkDrKzynwSjJXux2Er7mtqZioVLY4 WfIFNkc/qziurIOwFNjX5YCF7eBfR0PLcEVaDq0CbnVw++fGmmzaAEzCOtrcR/IGhW1s gCGmszJXVho3ZQJtUV6HXuHJ5dd+TdZNfH9CYxCwpxJqDoxLx6oRIOxnzK9idyQodfXT lC192Wdy9+iubiA6eCjPFhuBGIvAUMUswsPyzfs73riPkAtbUR1W538DErmoo/G3tmr6 5zQ9rpW/qzwOjrnZ5CX/c8s3T+DOkA3HOcjwbt1IvYbO5BcekVS+xuhO5InipEClkAbm gY8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Do25rY1c; 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 e17-20020a170903241100b0016d69207784si19386451plo.162.2022.08.25.00.24.47; Thu, 25 Aug 2022 00:24:58 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Do25rY1c; 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 S232089AbiHYGlo (ORCPT + 99 others); Thu, 25 Aug 2022 02:41:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232550AbiHYGlk (ORCPT ); Thu, 25 Aug 2022 02:41:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5135552E54; Wed, 24 Aug 2022 23:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=suL/EYVy2FnBYbtDax1tUpPi5wWYo1uJguDKeceNIkI=; b=Do25rY1cPxB2i+yQK6ONRRBmBp NOdrCYrhyKVKzzBz5n1OM0mt7qMi8/bPt45EujAcTMtRlSwIjkd/G6Cb/CxUlmMrJPbbf5s6dKOMx W6Uk3Af3AjKdUMlz5wHT5R2JCsG4aD3EknEg1H02i4HdiEZnz+aV7gVJ5c+zEy0vlSMVQ9Qy9E+pN E3Ji9Srhs1zDVHN0+cWFuyzV+O7RL3twB0Tkopebu+Nl/La/HrVq/nUvpXpn8nbcBh+DFaVyvQwgf 9KBF7xSj6zRXgxyDn9trsQ/OqVOYhJeNK5hFyrUSOM9oUSYd4IEqky63ntt01QGCrTjX1zPTj9EgO vVkj6oCQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oR6YM-00H216-Gr; Thu, 25 Aug 2022 06:41:22 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 1ECD798012A; Thu, 25 Aug 2022 08:41:20 +0200 (CEST) Date: Thu, 25 Aug 2022 08:41:19 +0200 From: Peter Zijlstra To: Segher Boessenkool 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: 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: <20220824224144.GC25951@gate.crashing.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, 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. > > STT_FUNC_NORETURN would do I suppose, except then all > > the tools will need to be taught how to deal with that, which is also > > very painful. > > What is that? Even Google has no idea. Hrm. Something I just made up :-) A new symbol type for noreturn functions would be very useful. > 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. 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. (FWIW, we've found a fair number of actual compiler bugs with this) Now, as mentioned we have heuristics that try and detect if a function is noreturn or not; but all those fail horribly if the function is in another translation unit for example.