Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1806171pxb; Fri, 18 Feb 2022 16:16:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3WC3dWBhc6Jm1HavaAg4iMoL1W/srAkPe3ChTHh/vlymqA7m3lLSziKHy5sDRM9CTkfR1 X-Received: by 2002:a17:907:3115:b0:6b5:6ebd:d785 with SMTP id wl21-20020a170907311500b006b56ebdd785mr8389955ejb.592.1645229766305; Fri, 18 Feb 2022 16:16:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645229766; cv=none; d=google.com; s=arc-20160816; b=x/lTvmpwCEYCSOEZAVv2imaT+ap95kZshGTos1Pk0HrnOPwciXL/udmh77C2j+QRDF V8Q1yBzm8oXdGeoHFICw3Me9gWjctRlES+w6Ork+B4/UZU5PNXxSy3yYCzDqFvRkciEK OGCVvgAPU6Ng62d/rq9nH+mqyAMlWmUHV8eTuRDs3obLJVEombXbHXjICTxEwmRnD7sC x91JPCTXPW1NtLz1a8GROjx8NQOzNTwfOBg+yYHgejf7c1KYBYmzz2VhTAWp0Lo64bxy 2C/SonVa/2TPTfYinLsfQwKDDia7FUoV04gU8CGYvofCzut9UzUVpyGc5zOA/SUsAcYr FPOQ== 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=7zVpwYHDHIaBW4/Qu1I++XmAGaqsqPN3XBi8gcs7g9U=; b=fNWP/etLidCw9Z89/423vGRoxJcxXKPEYClPFLWfxkR70puPhr9kcIyTvoYFtPCibN 5TBLbKgkZsIqNZFute7EjoT2UTLBTkl6FZAqMf+3NqvOaOqT3LcMXQJLGKY9AqwUePwG h0axK1rLdw+YqzugjWLxR07vd1t5LNGCWYSC/p67gEb4mNWUKoOvmKMJ6PO8TW/nha0r QMXwitTHdlHnH7PwetuC7t3F+kHOSV4Y6cI1ezqYmsQWTHIRorGr02u1OJiyI4X/wEte vZ2iT55wPLz3VgojTyAr91ATj3x8M3nMAmB4qXXbOTZFMxag3kOTsn4vdDBuEJX2RvkL Da9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eUFKMP2A; 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 p6si2155919ejf.585.2022.02.18.16.15.32; Fri, 18 Feb 2022 16:16:06 -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=eUFKMP2A; 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 S239785AbiBRV0A (ORCPT + 99 others); Fri, 18 Feb 2022 16:26:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239782AbiBRVZj (ORCPT ); Fri, 18 Feb 2022 16:25:39 -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 91E7223F0BD for ; Fri, 18 Feb 2022 13:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645219520; 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=7zVpwYHDHIaBW4/Qu1I++XmAGaqsqPN3XBi8gcs7g9U=; b=eUFKMP2Aq8/tSfMD+zC9YbJvR6SSGS3iepDp+HLrlIMYbruCnVSDSdd7lzVsXRU8jr5+8y d49GUSR/mUJW23BmqOBl8pDWmI0Ru1/sKsQ2xd82uBaouJe6lWICsCU5itFKdqm96UFy4p GkziOpP5Kp682z1no0zGzEe/FoCTOo0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-ZvYzVDTTMbKdFf4cTV8fMg-1; Fri, 18 Feb 2022 16:25:17 -0500 X-MC-Unique: ZvYzVDTTMbKdFf4cTV8fMg-1 Received: by mail-wm1-f70.google.com with SMTP id b17-20020a05600c4e1100b0037cc0d56524so6481744wmq.2 for ; Fri, 18 Feb 2022 13:25:16 -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=7zVpwYHDHIaBW4/Qu1I++XmAGaqsqPN3XBi8gcs7g9U=; b=cG5uZJ7dfM6ULYiKAXFaES/Cf5p70l1nCWCULUEVE7NZP078zBdOYiTISgTRo+D878 8gKR+CnYE7NUG2TLFtJfIovBF4MQi3pWWUrcNXwDgFRU2o2D3GNQ/IsYvMZnj/+FPFUM p/Xxqmw3yF2z351cGh1oZk9d3Db6K8BB6V8hidFPvMPnFWNFmd9rxwi0rlhRXZwd2Y4r fnwFDrXLYUUC8BpTUG27KBvrqlwurEF9KSLp94DObfh6bx3fVcfiByWcfU3uTsql38lR 1ZGV+IacAyQalOiE6AmOlyHWrw9q6/TOy8txi45laeuuS9dmqKhi0FKq9ghNw9F5thDS 9UIw== X-Gm-Message-State: AOAM530gpEa8seT0dlAjuaNN11yMW1aPRdo7c9eH0Ax8WIyARwi/G1+6 zOz3EE7Wt76t/ThicjJGqeD1w22WWGrKKQy4r3cqddSIAkc3i+Tg2TPm3NM2nKzrEngdkXjBCrP 3aHcc05qEU1u5+8s98LydxMw= X-Received: by 2002:a7b:c4ce:0:b0:37c:49b:403d with SMTP id g14-20020a7bc4ce000000b0037c049b403dmr8781035wmk.90.1645219515888; Fri, 18 Feb 2022 13:25:15 -0800 (PST) X-Received: by 2002:a7b:c4ce:0:b0:37c:49b:403d with SMTP id g14-20020a7bc4ce000000b0037c049b403dmr8781004wmk.90.1645219515600; Fri, 18 Feb 2022 13:25:15 -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 b15sm41534566wri.96.2022.02.18.13.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 13:25:15 -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, joe@perches.com, christophe.leroy@csgroup.eu, msuchanek@suse.de, oleksandr@natalenko.name Subject: [PATCH v6 02/13] module: Simple refactor in preparation for split Date: Fri, 18 Feb 2022 21:25:00 +0000 Message-Id: <20220218212511.887059-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218212511.887059-1-atomlin@redhat.com> References: <20220218212511.887059-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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. 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