Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2126838pxb; Wed, 9 Feb 2022 11:23:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+gMBCdhwVSecriv4RdP3ri9B650lEVCJR8BDWC76MujSNSHETnV1tbV13QArgRrQDK4Ho X-Received: by 2002:a17:902:d512:: with SMTP id b18mr3732258plg.90.1644434635895; Wed, 09 Feb 2022 11:23:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644434635; cv=none; d=google.com; s=arc-20160816; b=Dnnk+a0p6SO8KXaDR98qKLe3PGiKoxQHLe6XUOg9HprbcWLV74SMlVaTlHuU5MM0wB LRPFZoEnWstdi0TLjpo/laFe7LGG5GYmVTLhUrSVRZY/RsWmzNr14I28BbdOui9lyapU tjPhtCSCoGDt8ChK3qqYo1+7i4cMduuc3Oxy0aHqE3a+YljFVkKFtQv1pblFOEtLSbNR Y9DDZgu69x0Zeod0ZEev4kXUHpCbSZhlOtCRiAJ46A80Uy96Gz0zd5En3C/OMI4RIEmB ET3J6dGXYaBt79YC5jaHoCgrvrYW/AJZbMhhAX+6W3Tumh+a8NM4DssSC765xfwQta6R dVdw== 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=f0QYZ+16D5dm+XWg7QULMgCvAEAxCydy3KF5g5Fiobo=; b=0y0sBzxpVF5O6rkJboj06fWuXwE3frmc04Lb6kUWD8PnWJi6x37D0DXY4+7+jfSNYC lRx1+U1iyTj1hBbJ/8vStNKjgBDk3yF6qsqlj0cGZsbj11b/jU3RIxEEiniw/PV+HEYZ i4SSlTaL6/P9VRboYAKNlUqNkNaNTn8EckuK0PxNzGrZXyzRdN7LqfCwcL4ktu/WlTI/ IcBovu47Snr0UxClu93kUTXQiKXfYDFVq6vGWAP8IwksEMz6cj03vsjAdoDpx9Z9OUBz Vkr+fNqSnIrIfc271SkUE5/n1aDoHkBqPC6xR8z/kz1Rgj/UYsiZ9s5eiLYOgqmuHBxK G+oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RTypKIWT; 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=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x185si15829044pgd.359.2022.02.09.11.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:23:55 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=RTypKIWT; 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=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC4F4DF48F3C; Wed, 9 Feb 2022 11:18:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237641AbiBIRET (ORCPT + 99 others); Wed, 9 Feb 2022 12:04:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237774AbiBIREE (ORCPT ); Wed, 9 Feb 2022 12:04:04 -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 8097DC05CB8E for ; Wed, 9 Feb 2022 09:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644426246; 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=f0QYZ+16D5dm+XWg7QULMgCvAEAxCydy3KF5g5Fiobo=; b=RTypKIWTV9Ajf0k49M+QaQrQyv8YqAhl5nSw8NBybfcmsXbuPP73pk82BvPuyqgPeQPwLI BbUYRP5EyRNqCKTaixLcYFUAIzLYRrUplvHQIin2zJqjvPvLqCn+71dO3IbwbcOrNfIbr+ zI5iBUfzVk+ii6bL2Y5dsPdUNNx+Q7k= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-ZFQ7Sz1wPviQPXzbcKQ62g-1; Wed, 09 Feb 2022 12:04:03 -0500 X-MC-Unique: ZFQ7Sz1wPviQPXzbcKQ62g-1 Received: by mail-wr1-f71.google.com with SMTP id q8-20020adfb188000000b001e33a8cdbf4so1332676wra.16 for ; Wed, 09 Feb 2022 09:04:03 -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=f0QYZ+16D5dm+XWg7QULMgCvAEAxCydy3KF5g5Fiobo=; b=2pGhNcs7wLKKtEbN9zImKhxfTkIFQclkwSfRP+yqyDpJKzhdKCq8/gbQNO4Lhwbcd4 vAHjbEhlT2i2gclcQ7EhDEUfihsC6V2o7I24X5ekFCuG/jMUR8BsxRwDxnnSUwnqeGk4 A53PFOHeICC1SZ2DjCmNfq/rJFcJrKrX+MJDkjS5Akc2yux7CDloHtRvL+Qruqh/sBMI KgYZsb82qCu24pV3xJH3UlhVouMlWyWiydldJzZT6qGdhZbW70PmUEywbMeYQPUIgG1R kdiHee6qHlMyy1/zmy13g0W61HIXVVGF1gKH4w4pHJZKsLdeEPwcoAdv/PEbU8ieLik0 vCuA== X-Gm-Message-State: AOAM531BRzho/Jbzf0jsVl9e515TGcKCVc/sXO1vDw6Zf851RXaUlJyg /YzQrTu22/JjtFBGQfzdmu4EX3As6KSpWuz+xQ8VuImJGnYxK5BHVgClanRwP1300jEaV4UxRyx dsuSK8yoZ8Rrdo/mmATTCYpM= X-Received: by 2002:a1c:f312:: with SMTP id q18mr2972997wmq.13.1644426242454; Wed, 09 Feb 2022 09:04:02 -0800 (PST) X-Received: by 2002:a1c:f312:: with SMTP id q18mr2972970wmq.13.1644426242280; Wed, 09 Feb 2022 09:04:02 -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 a9sm730604wrg.53.2022.02.09.09.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 09:04:01 -0800 (PST) From: Aaron Tomlin To: mcgrof@kernel.org Cc: cl@linux.com, pmladek@suse.com, mbenes@suse.cz, akpm@linux-foundation.org, jeyu@kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, live-patching@vger.kernel.org, atomlin@atomlin.com, ghalat@redhat.com, allen.lkml@gmail.com, void@manifault.com, joe@perches.com, christophe.leroy@csgroup.eu, msuchanek@suse.de, oleksandr@natalenko.name Subject: [PATCH v5 02/13] module: Simple refactor in preparation for split Date: Wed, 9 Feb 2022 17:03:47 +0000 Message-Id: <20220209170358.3266629-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209170358.3266629-1-atomlin@redhat.com> References: <20220209170358.3266629-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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. Signed-off-by: Aaron Tomlin --- kernel/module/internal.h | 22 ++++++++++++++++++++++ kernel/module/main.c | 23 ++--------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/kernel/module/internal.h b/kernel/module/internal.h index c49896368f7f..1a4b33ce9f5f 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -7,6 +7,28 @@ #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) +#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 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..750e3ad28679 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 @@ -1490,7 +1475,6 @@ struct module_sect_attrs { struct module_sect_attr attrs[]; }; -#define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4)) static ssize_t module_sect_read(struct file *file, struct kobject *kobj, struct bin_attribute *battr, char *buf, loff_t pos, size_t count) @@ -4542,9 +4526,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