Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1644789pxp; Thu, 17 Mar 2022 13:28:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy88rn0yDUxvaCSBLF6Gusf6Bn/U4Ta1yAs9JhSmP6CHBMXrwIybbeq4h1eQWuAk5VM+zL5 X-Received: by 2002:a63:a1a:0:b0:34d:a4a9:a8b9 with SMTP id 26-20020a630a1a000000b0034da4a9a8b9mr5157263pgk.176.1647548929083; Thu, 17 Mar 2022 13:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647548929; cv=none; d=google.com; s=arc-20160816; b=usiKylyxeySIQqO12QV27Nnc+G2LAmhcI8f2qlGOrhHtW8mP0eVuasKxfxamon0ouM GwNUzPynTGUfD7YQTIyMHgGsAb4ghVaVSp2LyNDp1W3lk1e1s6YcUCTgqhgDEsaQ0bRQ WSVBvnPFvIeKio1LWx/7ks1sjNPCE0MzK7TcQBEOyyN0Qtre2b85n8E3ofBISZZPDL81 UpnWTpIxYSPJGYunUhRDUhbqhlwOFTq5bo3irLGQh5yN7B8y+kP+eCARFi4XhxR+QH2m Nik7LZQQLXKDR4cSw3akyPFqkRZ0sD3yzQFcNL53Gx6IiIovIe89y7HVnQ38C4RuQEzd Y2iw== 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=ayQBtVLxvJA/kIvvHxecPygkDGr2Vd+nYXk4WmssNsM=; b=0l8NsTfh4JqCUUDpzGVgtZRsdmeiK9VNDVGRYO5TNfY+q8B/tP1b7xrv+pWN0O00jX WwQN/NJUQhPU/AnszIfgEese6i8FozDAHfjzO/WHoMYOoHLDrQbY4uFI/H/GSFzjMON/ c+QqfFHdfBoQarkZafH5N1dKT7U4NvXbR72m2c1y/CKuvTQwJRFecEEOIaMPB9XlyuQm C5sIIsSzEtWYYAtY6GyqNahnyRkgP102tk7Y5jXZ4A10UiqHXTNEJpaGBqs9aHvSOIEf hawyzDbxsQwnUtBi1hDWwIzobIclnoZ/ehE0zlKgvkhF8zqjwuPSvOwUYQRBICZTS7bn Elaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K+Eu65cs; 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 y10-20020a1709029b8a00b00153b2d165e8si80913plp.496.2022.03.17.13.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:28:49 -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=K+Eu65cs; 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 2A6532C276C; Thu, 17 Mar 2022 13:04:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237358AbiCQSOD (ORCPT + 99 others); Thu, 17 Mar 2022 14:14:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237309AbiCQSOB (ORCPT ); Thu, 17 Mar 2022 14:14:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4783A21F76A; Thu, 17 Mar 2022 11:12:09 -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 C63C26167E; Thu, 17 Mar 2022 18:12:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C614C340E9; Thu, 17 Mar 2022 18:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647540728; bh=bUhkeyVMEpUF8zm+Yp0Qgcuxbk2GMC5TY1d7kJdRmus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+Eu65csOPVvAQHxp+d2RmeYqZM3l2T65SXH6C1f7xMfD3Nqy7gq8ZkPtq+xn8cvy wFLp3pGeHuDdD4MfdwhL6221bpghlMuW7WJ/pzwJAUn0yw/mF6hPT0mVKmQDCzY0pP rW3cLCJV2Dk55tQDNrEE3l7KgUZSmFxSPqRB1iJhvYu3e80ctqrlW9iaAkCBiejQST hHVjWwGjMoJfMkyBJrYLHI3nKsi6GNRUOxHj3TcWayNEWCMWJdqYR9FBppgSM2pdvA zOX4HVKc+yOz6Sjwij/M2lrx70AYq2lW8jxAW8xw0gyiJzFW5Oqe3MuTuPPAH0Iy6H YNAQiFkLAVcFA== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Subject: [PATCH v5 11/20] rust: export generated symbols Date: Thu, 17 Mar 2022 19:09:59 +0100 Message-Id: <20220317181032.15436-12-ojeda@kernel.org> In-Reply-To: <20220317181032.15436-1-ojeda@kernel.org> References: <20220317181032.15436-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 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.1