Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp197803rdg; Tue, 10 Oct 2023 07:57:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOzaNivfwDYrl6boaFUetHbc+bkSwgEfaPPy5fFVNJNCOlCPHz2zVcDzb+B+rkwGjaAJcQ X-Received: by 2002:a17:902:d2c3:b0:1c4:4efc:90a6 with SMTP id n3-20020a170902d2c300b001c44efc90a6mr25159156plc.38.1696949823343; Tue, 10 Oct 2023 07:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696949823; cv=none; d=google.com; s=arc-20160816; b=h717O6L+EXk3BHriRLhLvlX+gb8Nqd2NMUXEMCjZX0VuqhevASHvAyfwegXe72w6Ud usFSIQUfYgPKkicnIh/IFmC8rU4L/GW5LCFYgq4Vmm43vScbpSUjxn02KbxKVhtSNprA SVLxLPmqPx/PRhQBKn9yYDhFnexBlkJ9lZKVb+LeV/BVD5dPLKcX89/NC5vR6vTHbgCQ JKALoMYziIvgJVFsPb8oQelHsHTehQkHVQhcAU/IRxDP/EIp0ssv3R05Ji7W/+0iUbtJ E+b+6nsJflUuQ1s0VthowBIE/qbNhTXcgN8HDZ+h8RSKWkHiKPTwP+DAXpEZudQIn9v7 ecuw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2iYfz+2SfHgQ2iuztaA0vsSkKn3LIllWMFPKJv+Tu6w=; fh=bmB7PkFeXW/+E7ht2bCvpkWs9MLcFAwtqp/Vvd/+wbo=; b=es3xNtbLI8uMrBihJuZKuVicqzQztsfJAzcWWm97wSlkKOZGDdLVM/+4KjgGIeFTSU MQZdvkdnbgYBCWF82Brau5XILLHx1Che2mNb2kqntHCoRJ8WRbXZXedCndc8SYptLzV3 zJIbz5e+pZgsBRvnN8BL85GjEgqdAj6i1TVzwb/4p0Ce8/VFflR78klsN8Am0tnLNq7N woOFo2NXHhDusncFYUxS2GLJFX9nVmdgrpbgHAEV42UZul9qL9joAvdoOI2hlDbHi9xP lunD2G2Whf1PAZkYSaaRelpwBVgcCJpq1MfaynA9CPop3EjgJwi6qE+dnGVJLOKLeZPo gGYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=cj0pTKB1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u16-20020a170902e5d000b001b8a3e851d2si12853600plf.342.2023.10.10.07.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=cj0pTKB1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 7DD4580C0DC7; Tue, 10 Oct 2023 07:57:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233232AbjJJO4j (ORCPT + 99 others); Tue, 10 Oct 2023 10:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232586AbjJJO4h (ORCPT ); Tue, 10 Oct 2023 10:56:37 -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 DCD43A7; Tue, 10 Oct 2023 07:56:34 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=2iYfz+2SfHgQ2iuztaA0vsSkKn3LIllWMFPKJv+Tu6w=; b=cj0pTKB1jcrNlXMRFKu/NgthTF YJ/ikOEA7by54fpgW8KGAIt4+n7aBQ7UAMUa3q5HmG9PlYO5m3l0Jl7wRQswgrLKE4ZgUrmE9rr2I PADmeUwPjWEugeXW7DYMr7UwtjrdhGxlBE1aoIXO4lTxct6rSrU9+7tXHd2z01zsqwQ4dceHcVwNh Q6v99QnsZxSW8O2eJU8Mp+KdrRAIDlptrWOnr385jiMfTiZJWE+MJfKc2BdBNPkRy+0WCBLIu1KwO vqAltO+2Iy8J9dkr4N3u4/Oey3xFyplUUXtpVVCEc97oc0Jgt5yYWmM1rYcvGIH255aKIYwPhrW7D 8BdyZy6Q==; 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 1qqE9Q-00Gvi2-14; Tue, 10 Oct 2023 14:56:01 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7175E3002E1; Tue, 10 Oct 2023 16:56:01 +0200 (CEST) Date: Tue, 10 Oct 2023 16:56:01 +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: <20231010145601.GP377@noisy.programming.kicks-ass.net> References: <20231009224347.2076221-1-mmaurer@google.com> <20231010081220.GD377@noisy.programming.kicks-ass.net> <20231010142448.GN377@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:57:00 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 07:34:45AM -0700, Matthew Maurer wrote: > On Tue, Oct 10, 2023 at 7:24 AM Peter Zijlstra wrote: > > > > 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). > > > That's fine - Rust does have stack/scope unwinds with the > `panic=unwind` strategy. In the kernel, we use `panic=abort` and are > unlikely to ever change this approach. There are a host of other > complications that come from unwinding without NOTRACK getting > involved :) > > In case you find `catch_unwind` - this function only has an effect > with `panic=unwind`. When `panic=abort`, there's nothing analogous to > catch/throw anymore, and `catch_unwind` becomes a no-op. > > Are there other features you expect might trigger NOTRACK? I'm not sure -- if they happen, objtool should warn about them. So I suppose we'll take it from there. Acked-by: Peter Zijlstra (Intel)