Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp178554rdg; Tue, 10 Oct 2023 07:26:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvbWTSWLeN28qE7j1GfSMDYhnyB75YaSOk1QufXH8FKaLyBfZiWUdkGZnCi8hj5bQlf7oy X-Received: by 2002:a05:6a20:431a:b0:159:f884:4d6e with SMTP id h26-20020a056a20431a00b00159f8844d6emr20628111pzk.40.1696947992654; Tue, 10 Oct 2023 07:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696947992; cv=none; d=google.com; s=arc-20160816; b=czjH3ESdMgMRcjnKGuCjq3hHFpNknjm6/YatTR2LWwf+uRY/o9l3eIMuuyp+mZL1fx m/JVJzPbb0mXEwGE4z3oUxRTu/JKCAIjDVH49D1jDqt/31P8MkPtMQPlhDEi8QmIsHzt T5ytNAUHx4BxsltP7InvzsWRxw8kXYYsXky/isLCVKXVmBbAeUzruTh4gwoK1HoCky0b 0sDA9Nifd373l49OeRVPnHvIpAtA8FFW+tQCZ8lx7jZznnn96MqtJqC/lCEdHtBfuBXA WQPfw9lU0SdOXuxBiS4kBR/uYExxjKRlFuZmHt3FCWUyMe8PxOamkWk9lPLj5EqlWz42 qZ6g== 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=6Nr/KkwCGn5Ob2JlgP9dTNdp/ZUel4tqnxZisHtdBY8=; fh=bmB7PkFeXW/+E7ht2bCvpkWs9MLcFAwtqp/Vvd/+wbo=; b=s5gDJS2mcXlqpUN3SHtXl0JluDGqGg5+MYmIeBhLdRPp/Zkyp1tw9oUVEUWmL/leBI 8NL70h9Y/mW0/4XzAQ8W2FBG6Vq4He2cdjeSsH+InIvDQyu7V+VdrJPH97CHUBAZ9KDK eHSYhLc4YCU2wHnwXXg5s/PHqYtydLCGUJWcnaqMod8osBh727bpyVagi0Y1OiaMtsEM fsl/puGfvcq67/eOZXUeP3CtP3KuuIW9MBwJtUr2vy5Hurf5OfDj3WpDqYTxqXG6d8WY gfuXPAN+pydCUxn83XMFH8lqqR86/vHqck2AUnQRdKOujKKREXuJ/Xk2w4wmpdAU64rr Akfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=jFy25iGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id kh7-20020a170903064700b001c57c952622si11227668plb.446.2023.10.10.07.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=jFy25iGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 96C98801CCDE; Tue, 10 Oct 2023 07:25:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjJJOZa (ORCPT + 99 others); Tue, 10 Oct 2023 10:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbjJJOZ2 (ORCPT ); Tue, 10 Oct 2023 10:25:28 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24DBBC4; Tue, 10 Oct 2023 07:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=6Nr/KkwCGn5Ob2JlgP9dTNdp/ZUel4tqnxZisHtdBY8=; b=jFy25iGwS0sUAyZWA/Iq77sqbD vaDE+eqrvqmxZhuavEE6oeqorEjpXEvh2VBYLoxOdQUuh/qIhev8rs9Nc14EHf8iGoTaJUzV8QWNS jfHc0SkqaCeo3yXFWAh9r8cSkCEub0amR2x/KNR2O7xCYoAoCRyADSD9Np4ErQr6gTRPP9W3A46zT lUg49GPjEXPZIHyD0vL2iXcJ6CfGXWj0WG/QmzkHoTx5jdDC+8PWsnJ1Dc1IJ3jX3IYFUuSsH2ws7 WAWNXx2qASFWB/gmpGV62Io2BjGaSGnpQ4U1OHy+a1xN5MRUyJssyQVcxIE1s0v6zynn1v+am65dG Atg0BYsQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qqDfD-00Gu0i-1m; Tue, 10 Oct 2023 14:24:49 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A6EF0300392; Tue, 10 Oct 2023 16:24:48 +0200 (CEST) Date: Tue, 10 Oct 2023 16:24:48 +0200 From: Peter Zijlstra To: Matthew Maurer Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , "H. Peter Anvin" , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, "H.J. Lu" , Nick Desaulniers Subject: Re: [PATCH] x86: Enable IBT in Rust if enabled in C Message-ID: <20231010142448.GN377@noisy.programming.kicks-ass.net> References: <20231009224347.2076221-1-mmaurer@google.com> <20231010081220.GD377@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:25:41 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 07:06:32AM -0700, Matthew Maurer wrote: > > > +KBUILD_RUSTFLAGS += -Zcf-protection=branch -Zno-jump-tables > > > > One question, -Zcf-protection=branch, will that ever emit NOTRACK > > prefix? The kernel very explicitly does not support (enable) NOTRACK. > rustc does this via LLVM, so its code generation works very similarly to clang. > It does not create its own explicit NOTRACKs, but LLVM will by default > with just -Zcf-protection-branch. > I've linked a godbolt showing that at least for the basic case, your > no-jump-tables approach from clang ports over. > https://godbolt.org/z/bc4n6sq5q > Whether rust generates NOTRACK should end up being roughly equivalent > to whether clang generates it, and if LLVM gains a code generation > flag for NOTRACK being disallowed some day, we can pass that through > as well. IIRC C++ will also emit NOTRACK for things like catch/throw and other stack/scope unwinds. Obviously C doesn't have that, but does Rust? (as might be obvious, I *really* don't know the language). ISTR HJL had a GCC patch to force-disable NOTRACK, but I've no idea what happened to that.