Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp185077rdg; Tue, 10 Oct 2023 07:35:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6/Xpdhp7Y3nyU5h31aqwYpJ27qkTzmqKK+3xxAgSh77Y5gjE4UlF/cLsI+U8UiopeSoMI X-Received: by 2002:a17:903:11c6:b0:1c0:ad3c:c723 with SMTP id q6-20020a17090311c600b001c0ad3cc723mr19318622plh.10.1696948558616; Tue, 10 Oct 2023 07:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696948558; cv=none; d=google.com; s=arc-20160816; b=VhPI/zL+WeXcssKfrwA7V04XYyTK+L77vbFoqdk0mApbGlqD4+TdjdDA6rDjuiyifI n2HUFMy8bgiCJ/1dKSQUQHown612hOH8fPnOivwHMhh9L0Mj7RmXa0vF2IP44oz+UI3N BOWlsfFaMw4K1xMjoK3buVuBEbQ5eq4QbPhuzzzW+SMmxgSUf1WY3Y/oLXCiIolyPo66 bH4I0WrYIb4dplCaa0PgwtnOa6WH9IBA3gFdlifw20Z7AU3S+Si2OxmK86u0krS6gq3h 51G+gF9kK5f/smzrlU33KEyhytH57ZBP96EiiYLcERIfip7InmB5PBd+JbuQH1WEXabG sI9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KjmuT6KaUq06+aqXLtqrH5SPglMZ98Jy4h+1+Q+YBNc=; fh=SFDeyc7YUDxb8vaDwhXm97ReLgsSfkWd7hXI+LYUULg=; b=0JQ6l35YpKKWkrk1WWIVTTnzXiDRa1t+N/eBQeoKepAH87lLY4mGBtDbAlEE/fGNtn xRp1efxgM5oyb5NAo4DeThaRoLscg4BiMHl0RZ4l4cXDD/rcNOPVNaHGhSXT5j0IUyGW IchH1Ej2ewcCxwn1LpXoVFXwEXQ6NLLqsIUt5r623+BlHo2omejHX9zK8T57u31Kmx3p XbEoI7JYYsqnsiVvG85Tjq5yDXO5istnO8Io2pcE7AAKUbpwhPlpc0KioJ2zKyDXaLcP QMZPZutiAPpdj8W34r3kJyy4NDwyd1lJnlagot8JfXvpdFs0VFodvMIwCpNwbiK0PLcU ZXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=rwp+jxjw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id y21-20020a170902e19500b001c736266dedsi11421967pla.189.2023.10.10.07.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:35:58 -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=@google.com header.s=20230601 header.b=rwp+jxjw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 93C66807DE2B; Tue, 10 Oct 2023 07:35:11 -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 S233117AbjJJOfC (ORCPT + 99 others); Tue, 10 Oct 2023 10:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233083AbjJJOfB (ORCPT ); Tue, 10 Oct 2023 10:35:01 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0FCCC9 for ; Tue, 10 Oct 2023 07:34:59 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-51e24210395so34913a12.0 for ; Tue, 10 Oct 2023 07:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696948498; x=1697553298; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KjmuT6KaUq06+aqXLtqrH5SPglMZ98Jy4h+1+Q+YBNc=; b=rwp+jxjwezPH6xO+U28gWAQU+uhegxu/Djt8hX9aIUxehewzifrqnG2VAfL8+TmMHZ U5Ge8RDily8shnrmAia4uUBOVK9oz9rSwakB4l2HNBnwe4fsgRIxejQ5CjyEO7YADwpS 2MKjWenZzT6kEY6qgWn08JS7/5rR9t4t+IyJ8OFnNqp/gNIFMGrnFCjQZje86UzmKR6t rwgQWR9F2iKAynUw+6zPQ/ZrmqtNoAM1m32120tf0xvJeA2fvL6lmaCJKsToxGhwHNUR dzMOOzgiDqVItY/qt0CPAt4VVM0DAc9NxUsVt38oq8qDOdsr2IMFtWN1ZmLBtIy0ONqI ZU2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696948498; x=1697553298; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KjmuT6KaUq06+aqXLtqrH5SPglMZ98Jy4h+1+Q+YBNc=; b=JIUWmy1lDKgiYPN4CrGJIy/73eXbygxRtuziekmC7jxfSD6jPsHV6uNmP1FZKgFSSN LNhtkBt2/xLmxLcaLZOFLnUPv90ptbH2uDnsIcmhO3Jmo1TcEbVeeccTQJ0x1kVBLDwI mXzj4ugTyBoCE2hhEFSoicjSUVmFBKLs2ffrbzAPSkW3PeZaLBbPMVZ2bwky1ssD5afp 8tO7OkIJ1ofCXYrHsB6xpVFTo3pD8TcUV0n//LKams1u8NkTNP50I8GQkBl7oPCcLmvb bIqNoe0zYY4dTgRhANV0QAlLkGGUJcu8n6ZdcUKgpwjNSw2vSu3GkqSY4FKdX5G+V6Uf tGCg== X-Gm-Message-State: AOJu0Yzgt+U2X0aHUFmCo2qtGfkbf1YrAdwEfGMRiDMjnu374AOXj4Cd dbKkGdoCTkF7edMLc0Fwy4jCmr7ZC+AD8J89TkEohA== X-Received: by 2002:a50:8756:0:b0:52f:5697:8dec with SMTP id 22-20020a508756000000b0052f56978decmr579701edv.4.1696948497945; Tue, 10 Oct 2023 07:34:57 -0700 (PDT) MIME-Version: 1.0 References: <20231009224347.2076221-1-mmaurer@google.com> <20231010081220.GD377@noisy.programming.kicks-ass.net> <20231010142448.GN377@noisy.programming.kicks-ass.net> In-Reply-To: <20231010142448.GN377@noisy.programming.kicks-ass.net> From: Matthew Maurer Date: Tue, 10 Oct 2023 07:34:45 -0700 Message-ID: Subject: Re: [PATCH] x86: Enable IBT in Rust if enabled in C To: Peter Zijlstra 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 , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, "H.J. Lu" , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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:35:11 -0700 (PDT) On Tue, Oct 10, 2023 at 7:24=E2=80=AFAM Peter Zijlstra wrote: > > On Tue, Oct 10, 2023 at 07:06:32AM -0700, Matthew Maurer wrote: > > > > > +KBUILD_RUSTFLAGS +=3D -Zcf-protection=3Dbranch -Zno-jump-tables > > > > > > One question, -Zcf-protection=3Dbranch, 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 t= o 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=3Dunwind` strategy. In the kernel, we use `panic=3Dabort` 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=3Dunwind`. When `panic=3Dabort`, there's nothing analogous to catch/throw anymore, and `catch_unwind` becomes a no-op. Are there other features you expect might trigger NOTRACK? > ISTR HJL had a GCC patch to force-disable NOTRACK, but I've no idea what > happened to that. >