From patchwork Mon Oct 23 17:44:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 157020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1455474vqx; Mon, 23 Oct 2023 10:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYEP3AdynvdVF4vXJKAq8PhUA2jQYzKnH0JxNAX+HJ/Wh2wdt2pWH7wZWquBVuB3hQ8RYJ X-Received: by 2002:a17:903:110d:b0:1ca:d778:a9ce with SMTP id n13-20020a170903110d00b001cad778a9cemr5545094plh.38.1698083190208; Mon, 23 Oct 2023 10:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698083190; cv=none; d=google.com; s=arc-20160816; b=oM58gpP0e+OGvD24trqJtRVZObkaziwwlj/RJguBN8IGysXTKDqD8I2V71hzouDxYI HvCK6nV0jxPuKFq6zfhIVl/eWYT5xQtdXvRaiOlEaSBMNw10Tn4fJrEaM41jYS6AI6Lf o0zMx1mVSzGBhfb+QYLyH6VFpnsZi5RTH4XoVUC1zqUVtuQMetx9NunhmIPJSsNr8ack GHu7RXLV38br2a9OWFO15/FH373Wt0JUIGlATkwMiVMHo04TQ5ZkHFGdWTxas4yF5MJ/ cYZsSRL1FZsL9opUCohf7y5Ga4a1ItUmj8C673948PgkamX1QUpytJixlo4X1dXHz2tM NEAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dOJY6bO9As4CO3CFtLs/Ci2X9Wcd7xeqIbJnbayxUQM=; fh=jroPNv4S+L0mfk/vaQ2sne4kTYgkQFJ83bRXyGX7kv4=; b=g1rAyhuGGTOZMbYow6V2Bb2nqQNBcRJ/IwvvUM60ucbg/5XRSaZRBzAdtR64+WazBj kRRKZyAn0d+LAo0UAyZjDr3a+sS3miExXiNglJJIYHO2zvxkm2yAtjbq2W7ad5+SjzH9 rH6hy6JDl41fQUAJqw97pt5jK86WG8iCSAe468FWnEKL/EwAxMXSJ4Hr8nQBrpNNIMBK l3gEcAS8MOUp8Qq16f/KffvVliuehETr0Rt3ISZSa2B2BI20AQQFmvVHEmEIfnQ8mNoS hXU+Y04kzvBS56uxcU3dCLx/GvyhquemJ+PTqIP6XRhh9wmfXtsca1rZ7FpbYTH8ODJp HZPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NBorsQHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a14-20020a1709027d8e00b001c61817e049si6593463plm.67.2023.10.23.10.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 10:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NBorsQHM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6A5CE80B1D36; Mon, 23 Oct 2023 10:46:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbjJWRqQ (ORCPT + 27 others); Mon, 23 Oct 2023 13:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233993AbjJWRpd (ORCPT ); Mon, 23 Oct 2023 13:45:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47DA010C3 for ; Mon, 23 Oct 2023 10:45:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62D5AC433C9; Mon, 23 Oct 2023 17:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698083130; bh=OTtEvmCKMm7ojlLCYfNOXX7WV2Av9drz4oNtw+8PMlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NBorsQHMmnAu6kmE5ZXnl/NeCJl1/ssPb1p3rjG7224RgRmP4RRgELONe6e9SKZ3y aEg8OPmzcybUoSAXG5o0vw80EQ0ebbRjPyZpqQw9CzDZib222bjnXMvXNf7j48uY/e 6YmKBSJscijZqMPNdjeDAnR9TFLxbdGYFZOM2XsY4eUNwbdZhB9UHr+K33sDiePSYe IWM/f80LtwdlHNLMMpz9Wnn0QxeVS+78vi64HdOdEvKEgifB7PNOz/n1LGpjgalS5m B0Wxb5Xvb9NNAFf7N7P6izCO4JbGedwTX3467RVNYqwyBOtEWJtAqN13b0s7o9X/HZ QtY8nfCBWF+lA== From: Miguel Ojeda To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Peter Zijlstra , Josh Poimboeuf Cc: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , x86@kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, "H. Peter Anvin" Subject: [RFC PATCH 4/4] x86/rust: support RETHUNK Date: Mon, 23 Oct 2023 19:44:48 +0200 Message-ID: <20231023174449.251550-4-ojeda@kernel.org> In-Reply-To: <20231023174449.251550-1-ojeda@kernel.org> References: <20231023174449.251550-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 10:46:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780569278974782019 X-GMAIL-MSGID: 1780569278974782019 When support for `-Zfunction-return` lands in Rust [1], this patch may be used to enable RETHUNK support on top of the previous patch. Link: https://github.com/rust-lang/rust/pull/116892 [1] Signed-off-by: Miguel Ojeda --- Note that this patch is not meant to be applied now, it is only here to show what will be needed to drop the depends on from the previous patch. arch/x86/Makefile | 5 +++++ init/Kconfig | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.42.0 diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 3df7c7c81918..818fdb1a92c5 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -24,11 +24,15 @@ RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix) ifdef CONFIG_RETHUNK RETHUNK_CFLAGS := -mfunction-return=thunk-extern +RETHUNK_RUSTFLAGS := -Zfunction-return=thunk-extern RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) +RETPOLINE_RUSTFLAGS += $(RETHUNK_RUSTFLAGS) endif export RETHUNK_CFLAGS +export RETHUNK_RUSTFLAGS export RETPOLINE_CFLAGS +export RETPOLINE_RUSTFLAGS export RETPOLINE_VDSO_CFLAGS # For gcc stack alignment is specified with -mpreferred-stack-boundary, @@ -193,6 +197,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables # Avoid indirect branches in kernel to deal with Spectre ifdef CONFIG_RETPOLINE KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) + KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS) # Additionally, avoid generating expensive indirect jumps which # are subject to retpolines for small number of switch cases. # LLVM turns off jump table generation by default when under diff --git a/init/Kconfig b/init/Kconfig index 9452b4102b99..6d35728b94b2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1889,7 +1889,6 @@ config RUST depends on !GCC_PLUGINS depends on !RANDSTRUCT depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE - depends on !RETHUNK select CONSTRUCTORS help Enables Rust support in the kernel.