Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3359030pxp; Tue, 8 Mar 2022 12:39:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZHNhe98RjHMIJpGEkDy/fV9KnA9QnUPm6NNhb49JB2pihvxKqZd5CexErTqrri1RPOWbE X-Received: by 2002:a25:ae12:0:b0:628:b787:b0c2 with SMTP id a18-20020a25ae12000000b00628b787b0c2mr13680617ybj.382.1646771945001; Tue, 08 Mar 2022 12:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646771944; cv=none; d=google.com; s=arc-20160816; b=eAxBuqimkf4iel86I5knvxH6Nta0LB3BArsQMVqiHh4DZ0MFJCdeOVqV0KK0iFhofu HgZk4b0QsqSsYizGVNXqUdMhFSbRLdajzW3dv0sLLoP+qIfJaGicjqQJNxR3z97mEXZF fj1E6/uTE78XFvj2dskHS6Iky6Z88qUWjLLN0GvjY7T/lEp3jKpFEEU59hM/EXKlI89M CBBXWm5C3CGBhrYZZmuBLoXGwD3JAiTLA8fSMDvUh/BnJPgCHDrqgntKZWwtE0GnqUwc fS49wDvQpRLgp21N8BJ5Arb5VKLe3zS48zvhL60s8MNLD//Yqp5zXN3SkvXxtuPm2Gkp jYRw== 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=Zln+MaotO9F3OZWBQkZ8RRcCDDlcbIVRMz8zB5PgPNY=; b=IA4/IK12c/inPYuBmKf/4zYWtxk4nlgh4dv1TvHs38ufNMy5Ur492zSOcRxLJDLrLa Vrn1ELnJGhQer8G4FRH2rDlvYgH3J1ErERr7nvvTL5JXmCzWI8ZJexJ/Co64Mqpb8zl2 bbeyYlOtmN7ZS5nF91WsQGCMuYW34UqvKLnGM2G18I2jVvFVtBrmeb0qhX2Fn3t/tutX zA9les+i8W78p8wvixGwCtg9Avzi+JT67dl36TRLbeVfk5yP1n5GwvdawZShAo//ewjU Gs3ziG71GZQ3G0fL4b4zUP3pmqmYTcbtbEs4lrH4OxjTh30IVK+26Bu38dmnv9k1FH67 GRHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i1Psm0wI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a5b088a000000b0062897cefef3si10393723ybq.421.2022.03.08.12.38.49; Tue, 08 Mar 2022 12:39:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i1Psm0wI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240287AbiCGRqW (ORCPT + 99 others); Mon, 7 Mar 2022 12:46:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240024AbiCGRqM (ORCPT ); Mon, 7 Mar 2022 12:46:12 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E80571EE3 for ; Mon, 7 Mar 2022 09:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646675117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zln+MaotO9F3OZWBQkZ8RRcCDDlcbIVRMz8zB5PgPNY=; b=i1Psm0wIoaGxjcx0KJV2v/hhvhePk1TgM0KGeIJny9tW606yUcOaD8J10lGZpy6+3dq1Lv YjvkalI7oDJO0ChBRVTEiKRC8y/ka3Iv7nsB5GRpcdnvFegUW1CZyNYyG5T5C6XQur1IDi sgoE2g85Gjdypq20xRfPJ/vrr/BE2IE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-8egaDb-cMgihWEjUSekSwg-1; Mon, 07 Mar 2022 12:45:16 -0500 X-MC-Unique: 8egaDb-cMgihWEjUSekSwg-1 Received: by mail-wr1-f72.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so4805152wrp.10 for ; Mon, 07 Mar 2022 09:45:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zln+MaotO9F3OZWBQkZ8RRcCDDlcbIVRMz8zB5PgPNY=; b=4GT2MRWkheHTkkvFF/YRYIPrMPl+B2PRpu93qsst2FtnS9gb/9OCD1pIzgg5OwajeJ 5cNV+tSIfYLgo9Uwo42ZXIYfWDsx12Eo1HdPJPEJ9QRyNJtRieiTFhDPvGF/SBiE5fHz Ey/vF12aIHnzlV71dRPh43EIf+tosx4cdWZz8lZByjVEhLXKwn1OiyX50EYX0+S2Wb8e 01rrUy3/pRD3oCLB6XuyM8XwvATCdHz4f7Mom+DasPNcHJp9d/gHJtDhNAC61O3ycI+R YWYPHNBkw0bSC7YYbIXGhXmXILTHZVbTvH8w6m0BP9ZUIILGg73rJ+uXxoyeV6Z1xfe3 1new== X-Gm-Message-State: AOAM532Zwkcal6mFo9myVUHIZD7GLNHUsdW7ii37ePpb4AS583s1dNHp SgB0Q6CkvJ4/Krkl6bk/7OuP3DY4/cm2eaRsrrIBZJXebkCBFwBWn6g4Dx+EBc9cZcsH6/cp8D+ 7MyvIW4IeeYFzT3yPZVWt6vY= X-Received: by 2002:a1c:3b8a:0:b0:380:e40a:289 with SMTP id i132-20020a1c3b8a000000b00380e40a0289mr34308wma.17.1646675114811; Mon, 07 Mar 2022 09:45:14 -0800 (PST) X-Received: by 2002:a1c:3b8a:0:b0:380:e40a:289 with SMTP id i132-20020a1c3b8a000000b00380e40a0289mr34275wma.17.1646675114602; Mon, 07 Mar 2022 09:45:14 -0800 (PST) Received: from localhost (cpc111743-lutn13-2-0-cust979.9-3.cable.virginm.net. [82.17.115.212]) by smtp.gmail.com with ESMTPSA id g11-20020a5d554b000000b001f0326a23ddsm12153963wrw.70.2022.03.07.09.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 09:45:14 -0800 (PST) From: Aaron Tomlin To: mcgrof@kernel.org, christophe.leroy@csgroup.eu Cc: cl@linux.com, mbenes@suse.cz, akpm@linux-foundation.org, jeyu@kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, void@manifault.com, atomlin@atomlin.com, allen.lkml@gmail.com, joe@perches.com, msuchanek@suse.de, oleksandr@natalenko.name, jason.wessel@windriver.com, daniel.thompson@linaro.org, hch@infradead.org, pmladek@suse.com Subject: [PATCH v10 02/14] module: Simple refactor in preparation for split Date: Mon, 7 Mar 2022 17:44:57 +0000 Message-Id: <20220307174509.2887714-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220307174509.2887714-1-atomlin@redhat.com> References: <20220307174509.2887714-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 No functional change. This patch makes it possible to move non-essential code out of core module code. Reviewed-by: Christophe Leroy Signed-off-by: Aaron Tomlin --- kernel/module/internal.h | 21 +++++++++++++++++++++ kernel/module/main.c | 22 ++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 8c381c99062f..ea8c4c02614c 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -7,6 +7,27 @@ #include #include +#include + +#ifndef ARCH_SHF_SMALL +#define ARCH_SHF_SMALL 0 +#endif + +/* If this is set, the section belongs in the init part of the module */ +#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG - 1)) +/* Maximum number of characters written by module_flags() */ +#define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) + +extern struct mutex module_mutex; +extern struct list_head modules; + +/* Provided by the linker */ +extern const struct kernel_symbol __start___ksymtab[]; +extern const struct kernel_symbol __stop___ksymtab[]; +extern const struct kernel_symbol __start___ksymtab_gpl[]; +extern const struct kernel_symbol __stop___ksymtab_gpl[]; +extern const s32 __start___kcrctab[]; +extern const s32 __start___kcrctab_gpl[]; struct load_info { const char *name; diff --git a/kernel/module/main.c b/kernel/module/main.c index 34a2b0cf3c3e..5f5e21f972dd 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -63,10 +63,6 @@ #define CREATE_TRACE_POINTS #include -#ifndef ARCH_SHF_SMALL -#define ARCH_SHF_SMALL 0 -#endif - /* * Modules' sections will be aligned on page boundaries * to ensure complete separation of code and data, but @@ -78,9 +74,6 @@ # define debug_align(X) (X) #endif -/* If this is set, the section belongs in the init part of the module */ -#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) - /* * Mutex protects: * 1) List of modules (also safely readable with preempt_disable), @@ -88,8 +81,8 @@ * 3) module_addr_min/module_addr_max. * (delete and add uses RCU list operations). */ -static DEFINE_MUTEX(module_mutex); -static LIST_HEAD(modules); +DEFINE_MUTEX(module_mutex); +LIST_HEAD(modules); /* Work queue for freeing init sections in success case */ static void do_free_init(struct work_struct *w); @@ -408,14 +401,6 @@ static __maybe_unused void *any_section_objs(const struct load_info *info, return (void *)info->sechdrs[sec].sh_addr; } -/* Provided by the linker */ -extern const struct kernel_symbol __start___ksymtab[]; -extern const struct kernel_symbol __stop___ksymtab[]; -extern const struct kernel_symbol __start___ksymtab_gpl[]; -extern const struct kernel_symbol __stop___ksymtab_gpl[]; -extern const s32 __start___kcrctab[]; -extern const s32 __start___kcrctab_gpl[]; - #ifndef CONFIG_MODVERSIONS #define symversion(base, idx) NULL #else @@ -4542,9 +4527,6 @@ static void cfi_cleanup(struct module *mod) #endif } -/* Maximum number of characters written by module_flags() */ -#define MODULE_FLAGS_BUF_SIZE (TAINT_FLAGS_COUNT + 4) - /* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */ static char *module_flags(struct module *mod, char *buf) { -- 2.34.1