Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1303428pxp; Thu, 10 Mar 2022 02:53:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDgwq044jX9/7yL5JN9a1zZhlEooHJsCRHBnXAd8D73VlCKO+Iw2+sBJ/+zuPOs186oMrS X-Received: by 2002:a05:6402:1941:b0:413:2b7e:676e with SMTP id f1-20020a056402194100b004132b7e676emr3771567edz.114.1646909590957; Thu, 10 Mar 2022 02:53:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646909590; cv=none; d=google.com; s=arc-20160816; b=OiqTNMOwt2AoF42GHs22OIkIOfCOvKmmUt/7MwUaVpMneuxkXGoqgfUOCt1OL2c04B 7iGni/vTHiiITaG8DOqR9bIcg9X/aSDq6umOpaM5XEcoUWL/eb1WzJGIC4q4/wrgJsmH 6wYsZyKJhaRcJlJwSMGxefxSsoZPxLvresq/tSvbehiKQuEE3Q+mg8q+Djg0+M63JkHH EejGwg4Pok39Ie3sh5cQ3AQZ9i+gMstFIBO0zSAsKdDtUrMGnVm+Bu/n7GOtKRjIn58B W7NYhoGN1861wOEA9Dlu1+d4KTZplrqUIcQ6nP5aV++zGGaJ6hw2ijCopYa+CvNolaib 9fxg== 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=p3OSYJtUKwRSW/eBSbv3qny1UiHxTzeAAcbBOZRnylE64KFbuZ2KSgZcVNmOQX5Hs+ s7c7OhD18qi4iCBqtlBoC6xs5F8VpF8AT7ajVyu89j7mSb/v14VxN3xsZuCSRtqLUIKP LWFbF6bvYgA2Mdz/Mdkr/maLmV8VIPiycxfuSiLujLzFQwcm5/R3gUK5aX8OKczQ5Sxj rt+r+5RKTjbHSGIGrUS1sVpVRN+YvTG+GhbIjBeJET6LDJhrzef3BgRGGdPFkkM+SfWR 7dCptffZN47yUFDQOQroS45tVDzIeQKQZ6QNo1iKXIq6hlfx2kptDmXMKtCw94Xw7suL VICA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iwIbBldS; 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 pv28-20020a170907209c00b006ceead162a2si2871591ejb.835.2022.03.10.02.52.46; Thu, 10 Mar 2022 02:53:10 -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=iwIbBldS; 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 S241236AbiCJKZk (ORCPT + 99 others); Thu, 10 Mar 2022 05:25:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241194AbiCJKZY (ORCPT ); Thu, 10 Mar 2022 05:25:24 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B466F70D7 for ; Thu, 10 Mar 2022 02:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646907862; 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=iwIbBldS/uzkG+HxBmwSrc5sMLiUtkl6va6tpMmHvLodSJarGmqDcqKsee1qrp3teGRbfL dS4EZlY5FeyLTLlowNjqkjzMdkl2gZNHJZB1nvd4zwX7zXSPmVVd6VRa2acDy8SKZ+1yCT Jup/wL9suNprX3ELNEBF6CmF6TXfRqI= 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-100-05gwJ4yPMB6sXTaFt395pg-1; Thu, 10 Mar 2022 05:24:21 -0500 X-MC-Unique: 05gwJ4yPMB6sXTaFt395pg-1 Received: by mail-wr1-f72.google.com with SMTP id f9-20020a5d58e9000000b001f0247e5e96so1522748wrd.15 for ; Thu, 10 Mar 2022 02:24:21 -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=UbSx9X5PNfFgOJg9vrEmCNuDDfJmDhkDctwgZz1BghGV7QSA56wIOUuLElUVkJpKc9 KY0ACvOLGhPVDCdeWCzg3hlqWX/9QZED6A2LEjZUJ7ZWb7TCcoSKpTBffTl+x4WSzfI6 0dPzIQEXJdy34YiMQkktC6iDZzuZcD0phVQnyvbiV7DaKj9MRqKP7ec8PZuC/bBGuWXK n+0RFJtL2UGxRZGgc0qEQJB+8dy2DO+Uf7nQb+Wqj/XUcZB3b+Jfpno2Nd/9SYPn4mGn qFArpN40JQRt105+I3UqyxibiGb2N8CHBUueEsoH53zzkQsLWCdZRIHKSTUKHv7EvLt5 39FQ== X-Gm-Message-State: AOAM532PKV4WbHz/xCmCOtCNYYuFBzkVNZis6DC6NaedzfExOE2+d52+ KuZXt/Rf3d29mDgoypZsOwk0vswOhiGibOVvzDPJZv2k9Vs8jmcXZRTD9znM+9NVs/ZEbgpj4M2 /NdMUbBjOGeXEF9PhF2QDWHY= X-Received: by 2002:adf:8b9d:0:b0:1f1:deb6:5607 with SMTP id o29-20020adf8b9d000000b001f1deb65607mr2898700wra.125.1646907860151; Thu, 10 Mar 2022 02:24:20 -0800 (PST) X-Received: by 2002:adf:8b9d:0:b0:1f1:deb6:5607 with SMTP id o29-20020adf8b9d000000b001f1deb65607mr2898680wra.125.1646907859922; Thu, 10 Mar 2022 02:24:19 -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 c12-20020a05600c0a4c00b00381141f4967sm5509758wmq.35.2022.03.10.02.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 02:24:19 -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, pmladek@suse.com, daniel.thompson@linaro.org, hch@infradead.org Subject: [PATCH v11 02/14] module: Simple refactor in preparation for split Date: Thu, 10 Mar 2022 10:24:01 +0000 Message-Id: <20220310102413.3438665-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220310102413.3438665-1-atomlin@redhat.com> References: <20220310102413.3438665-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