Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1656709ioo; Sun, 22 May 2022 23:15:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBtbKJCw1Vg7AuJ+BeqiaX/xVcuOLPZole/mbwbcMgoaykADmiEhzCaelTRi5rcL48Ckxm X-Received: by 2002:a17:902:b688:b0:162:3124:cde2 with SMTP id c8-20020a170902b68800b001623124cde2mr798175pls.166.1653286542076; Sun, 22 May 2022 23:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653286542; cv=none; d=google.com; s=arc-20160816; b=K7U1uYMzhHtttsLxZ+J/R1cukVEq2L0JdJq9H/BpmGBSEa11/mzwmYPTxwEhFEOGOO Kzb5i4hDdqI3eZm09y2hGucLc+ZSMWe11Qccbk1fGWn78qRVlOU71OcyfwsKbmhtaojl kPr3plqSgbxJiEOqeOn1lrozRbVOt9SBHHJ8zBiUqdGT42Aa3+xGEQ3t6MONl5YOAIoI kPW1yPSA+StOtfPxbOUaoEcU5YT8Tm9GpCf9et2D/Xx43xbr+XJv4llYhu/LERU86rZP /HKGwd0B730iz7DCwpgPBswzVQSRgRmZ6Mro8CYBWo289eJ+GXGNPxEkSI7BIg1R3FA9 9mwA== 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=WJaAnI/1sZ+GZFHni0OcK9ug1LqT3zKj1RJ0xWa3uqg=; b=j8XWhG7ONOnwFiEkiASZadFYgp2MIN1oNiirE5IxVAUQaB8/yZ2PHomeIf5L2PylZ6 7yJ1+jFJjiIi0IMFAOxoG689h2ixZtYczXl+QQAgHKBqal/Wnm3Da5uwc+FBMYyfPVpT VQHvleuJW/MVdUmKC43PqMpaql82a/z9Id26qPeswfD6wbCCEQlTi2+mAayhgBrshlSi xkAZCbp3neBxjv1oebYHg/U6vgifPJ6ScrKPX37VBfiZO3ewaT2HQRSPb9W8WlHEOKrr LyD6sSxUgpFnVHFpCY9lYUYkjrZZ7AAzUzJj4eNkzL1TEulsCoCdvOb64Ai+HL4Ufbbc YF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tZ/uJwED"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x21-20020a056a000bd500b0051873a68dd2si10712169pfu.252.2022.05.22.23.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:15:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tZ/uJwED"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 40D422A71C; Sun, 22 May 2022 23:02:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352811AbiEWCFK (ORCPT + 99 others); Sun, 22 May 2022 22:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352576AbiEWCEN (ORCPT ); Sun, 22 May 2022 22:04:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA57D39140; Sun, 22 May 2022 19:04:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6AB6AB80EA5; Mon, 23 May 2022 02:03:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55A37C34115; Mon, 23 May 2022 02:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653271438; bh=aK8g7YMuhRZgp2N5KP65riZ4nX/BjeCdLeOjA/xPOVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZ/uJwEDrrrmp7GTqBPiaeJClYMerrbggk8QPGp5Ef39QyFOQ9jomO5+mWpWYWhNj 2PqqP+nsRDLzgi/iXOQ10kLkRgz/bnSXqII+zOHQhd98gQ2hbdmEeiC0rbG6fTZ4DU epoGhV2qzhW/Kqxs2N86+lxhfqPAiq/SOC5ngPpNo0OlyJ401beiKFmEsDasIq206S rmOuDgXD6Ch+lpaaAGpf3HvTAffjke+hVuJIyMuap6BIs0gJB1N64iuFi6etVjOR6V HmGEDqXLDaP4293dBobYW4w+d4qwZchhbg94NMWsEq5JBLD3aydNW0x/Z/7475lzFK RiBzCjaImL0bw== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Subject: [PATCH v7 13/25] rust: export generated symbols Date: Mon, 23 May 2022 04:01:26 +0200 Message-Id: <20220523020209.11810-14-ojeda@kernel.org> In-Reply-To: <20220523020209.11810-1-ojeda@kernel.org> References: <20220523020209.11810-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 All symbols are reexported reusing the `EXPORT_SYMBOL_GPL` macro from C. The lists of symbols are generated on the fly. There are three main sets of symbols to distinguish: - The ones from the `core` and `alloc` crates (from the Rust standard library). The code is licensed as Apache/MIT. - The ones from our abstractions in the `kernel` crate. - The helpers (already exported since they are not generated). We export everything as GPL. This ensures we do not mistakenly expose GPL kernel symbols/features as non-GPL, even indirectly. Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Signed-off-by: Miguel Ojeda --- rust/exports.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rust/exports.c diff --git a/rust/exports.c b/rust/exports.c new file mode 100644 index 000000000000..fe3dcfdd6fbf --- /dev/null +++ b/rust/exports.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * A hack to export Rust symbols for loadable modules without having to redo + * the entire `include/linux/export.h` logic in Rust. + * + * This requires the Rust's new/future `v0` mangling scheme because the default + * one ("legacy") uses invalid characters for C identifiers (thus we cannot use + * the `EXPORT_SYMBOL_*` macros). + * + * All symbols are exported as GPL-only to guarantee no GPL-only feature is + * accidentally exposed. + */ + +#include + +#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym); + +#include "exports_core_generated.h" +#include "exports_alloc_generated.h" +#include "exports_kernel_generated.h" -- 2.36.1