From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9848ECD8C8F for ; Tue, 10 Oct 2023 14:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232618AbjJJOZc (ORCPT ); Tue, 10 Oct 2023 10:25:32 -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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.