Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4632318iob; Sun, 8 May 2022 19:58:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJRQeIYsJ9XTmbGYuQmWP34uga41MN+GG3mh17ZYtt1jFqQEOk+gqG1d8Fhg23/NK3MrTK X-Received: by 2002:a17:902:edd0:b0:15c:6f65:d06b with SMTP id q16-20020a170902edd000b0015c6f65d06bmr14300522plk.91.1652065095164; Sun, 08 May 2022 19:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652065095; cv=none; d=google.com; s=arc-20160816; b=sG9HqPfcY4/GFhpeHuFMEr8kjC7xquo0SqWUEJnN0GvkJwKbK2Ok8EDg4ZB2wzkhgT 0SaZ/AbQ+ejouN3vmdzBXUZ9qrChKY+AGEpiplczNg6mEQKA6TrPQPGBL78OFL2t/BWv 8/kD2RU5udsu8AS69n7j7IW7LNh0MmrWq9hIVz+xTYws8VkeL6LLCWSjokrP7nXLNUpO vFIjGBuVXqINY5JgGa0WJywMN/CI//qswLFUe/WEtuH/gTmvuLp6Fg4DN5Wo6MFPvx4/ rQkpOQmGFDl+kurYhD+WU8FUgJsDty6b4W4jQBZy7Z1t8zCDGrX0g1YSFxStgL5a0zv6 fERg== 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=vrLJkz+bH3j/XSNSWI1fs0tVOibxCCUm1KcjTPKL1UE=; b=TmPUP+hSz4uQfCbydvo5ekuVcdegSsudgiQ7qNUtOJE9Txkj/jPVhEYlIZKhO5Rv3Y OPSKyis0HejsJUYfHt0LBA93ZpaQQ4BUM3hKqhlqLjhsU4OdtOZYKTG+NjXaig2ExDaA BReOL6upX0CsnMh6t715nCOlgOJOofaTkijnkmMyNIEVvZQVgyKqSioxcRa0FSwaVmFy bgN5SLc5T3qR8q+WT67Cwnm23F//B2sIDKQYX2Xe/nkV9rB3FZ6s0AqUwRCu3P8r5Sw9 288T8Ze6yKzTcGFJkanUy6cVO5KM2lb6KJOHq6aiPNwrhxeAkpAIv7rZ8IneL1uTWLim AKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cHNzQ569; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 29-20020a63125d000000b003ab54545cd9si13264319pgs.56.2022.05.08.19.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 19:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cHNzQ569; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 D052A83025; Sun, 8 May 2022 19:57:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1445609AbiEGFbC (ORCPT + 99 others); Sat, 7 May 2022 01:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445674AbiEGFay (ORCPT ); Sat, 7 May 2022 01:30:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1FDF69CE3; Fri, 6 May 2022 22:26:57 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6E36B60018; Sat, 7 May 2022 05:26:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E7B6C385A9; Sat, 7 May 2022 05:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651901216; bh=ZjbsEZQJBzG3/a4R3vRaYmBIoAGsBlFrywvQgv/c/us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHNzQ569t7yK14qvXJtnYrYC66J/bi8/raTsfdLTF7SzBRPCNoknSVuKoRP7dS90P l+/C76jHPBOST2k00zSZWirCewfB9zH4/f3cskvCBmZhQtwm+k5bVB97jn07geZOD5 kZ7XivLXPGnjwq+/jpYdwyjLuU88/FVFcbVF/LXnp1ep5BTYYowkmiOJsd4wm6BPUR uIVZ9XCcduJ/2RCW2U7ATAXjAWGEGf8gxWjyEemcwQNckzvj170cxU+dV203kHYBI4 RUuNUsj/3vYd1fPu6Gz6lo/jDRynxVfr8iGsu0aSrTsPEmVH4r5GTM9DwZGr45NKj6 AQ4qqmHvwlyxg== 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 v6 13/23] rust: export generated symbols Date: Sat, 7 May 2022 07:24:11 +0200 Message-Id: <20220507052451.12890-14-ojeda@kernel.org> In-Reply-To: <20220507052451.12890-1-ojeda@kernel.org> References: <20220507052451.12890-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.35.3