Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3308800pxm; Mon, 28 Feb 2022 17:04:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOtOqQw96QFUwXNV46834m89U60Eg0hkeFa35/yEzI3KxOxTVAcK4ssdkyMvBuKUPfWNO8 X-Received: by 2002:a17:90a:d3d1:b0:1bb:fdc5:182 with SMTP id d17-20020a17090ad3d100b001bbfdc50182mr19324679pjw.206.1646096691137; Mon, 28 Feb 2022 17:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646096691; cv=none; d=google.com; s=arc-20160816; b=t+xlfP1UYXufs3COguVe7iw/RXJXPeyjRvyRHkNL0B93uMb7s7oik48QXpoTwrNb9p nqxdLWZRDUscCnWcLD9IkR8I9n1HUOlx3c2mU3nybOqFW69mMzM+3u5GLOG1+z5wK8on DXBQ4NVveKuhBteMaprYkBInRPjfyXyWV1oG3YjNMTptXnzO17wYgHYHlAJUDnYNdTfm G+Fp2GAxyMqYyM77uUmaxv5sP35yWeqv2mTsHO56+P31ccg08iGulcZ1VE+7WsHeFLr4 Qwds/4x3sYuC9zcgxjUNzYXZDs/4ySuhBEbn28aftVmFN/HiPC4QLvQ1m/tp8HGGuI96 17fw== 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=d+4srAAMErVw535l0eDKeN/HK5YQVdzz5tEIqEuu1IJuhYBDArONI5X7itxhmaFPoJ U+u2CTBv/o8TK/rjSTRSRNcMtGzaWQebx9S5Sgo/sGVxoSyjrJ3ShYM1gKgdIJBRXvQi A+G27C5z89euxdMYOzCEthUbzZ2ypjlswIyiiGXHQU9JQNQ4Zp6m/xYJg8gvxSbQ+dK5 09od7hQBsZsQ8qG1ri8Xy3JUe29BtQLq7Uov/ezbcqyfxrghFAvI67Yj6GQttt8BTV6j Z0NSM8bLuxziNP4ztcFr84NzhBvwYggQHuLCx1+uct7JHB21kQjt36DBTKy5n3bK5H4K OlEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SMWI1ZNd; 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 p14-20020a170902e74e00b0014f8de1dd35si12304912plf.151.2022.02.28.17.04.29; Mon, 28 Feb 2022 17:04:51 -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=SMWI1ZNd; 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 S230164AbiB1XoV (ORCPT + 99 others); Mon, 28 Feb 2022 18:44:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbiB1XoM (ORCPT ); Mon, 28 Feb 2022 18:44: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 273E6EC5D7 for ; Mon, 28 Feb 2022 15:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646091812; 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=SMWI1ZNd+R0OSiZYEkr7LJK6ppSk48SnrJIKMjToIHqOPUjoKol6V5Ru9BW7Tg9SVpKwZQ N+Lfzq7cplX8Hl+0Zb4iFAnpp7n5YkRsXNZPz8HBHia4ehSLzZGKW96CwrDIj3BMLR1W9Q dmf42HpMeRYM6SuH9RdXa6jS5VR/iHw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-E0vgYevTNOi8M32mbKnVpg-1; Mon, 28 Feb 2022 18:43:30 -0500 X-MC-Unique: E0vgYevTNOi8M32mbKnVpg-1 Received: by mail-wm1-f71.google.com with SMTP id f189-20020a1c38c6000000b0037d1bee4847so310680wma.9 for ; Mon, 28 Feb 2022 15:43:30 -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=ddT/RiPDSj95Ju3OSHukYHSFP+Gx6M1f3HO3puioVjiYS6MLan2e59BuYwpTWJy1yh 3k0yh9xjjlR2OrogdqqaDCt6EWOqMWilm93OJ0mp1ZYs8v82ZRcjdnJ/1EmO///nbBiB D08BNjfN0nHaPgvjyvaFaHacEuhdirudEF9/T/hsfjgDFdVZUFOayRUuM6uBnnN/LrSP CoHua1HIOdg+gDf2ewmba3hQ0Xq0QcT6l4nzItAPLQgj5dVhuQefCcHQZ72vnLo4YAVy JLppWEfGk8BCvkvPOkifL1ZqJQbOONAzq+guNdogn63LVryUMSi4c5jA7KWPBwosebPQ SVug== X-Gm-Message-State: AOAM533zVWAuKCWiOkr0Xdy2bL4l3k4dpvQo1EYutd8rQxn5La1Q9VgW EGlqrKFarpJxCa48V2riAWaU11DHu0erWvMkMdrxgXmjcP5CfbS/zRWhpgv7RvUCw3EOwRS6edf gwSgTQQpnd6hDmc3frWpygm4= X-Received: by 2002:a5d:6545:0:b0:1ef:8273:fca0 with SMTP id z5-20020a5d6545000000b001ef8273fca0mr10451717wrv.337.1646091808944; Mon, 28 Feb 2022 15:43:28 -0800 (PST) X-Received: by 2002:a5d:6545:0:b0:1ef:8273:fca0 with SMTP id z5-20020a5d6545000000b001ef8273fca0mr10451696wrv.337.1646091808719; Mon, 28 Feb 2022 15:43:28 -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 y7-20020adff147000000b001dbd1b9812fsm16698780wro.45.2022.02.28.15.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 15:43:28 -0800 (PST) From: Aaron Tomlin To: mcgrof@kernel.org, christophe.leroy@csgroup.eu, pmladek@suse.com 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 Subject: [PATCH v9 02/14] module: Simple refactor in preparation for split Date: Mon, 28 Feb 2022 23:43:10 +0000 Message-Id: <20220228234322.2073104-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220228234322.2073104-1-atomlin@redhat.com> References: <20220228234322.2073104-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_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 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