Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2751549pxb; Mon, 31 Jan 2022 03:36:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJycg20VuVBqlNOOBSSSwZBewN/eapps8xlRhJB8uAHvHStb4ofmj4fHUpry5pEtSGq+Dcq9 X-Received: by 2002:a63:5255:: with SMTP id s21mr16213685pgl.131.1643628969597; Mon, 31 Jan 2022 03:36:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643628969; cv=none; d=google.com; s=arc-20160816; b=KT8QJ1QZRMkoPtFzpoBRzjQWvZENCocBhDibmckuD28Loq7cuKo01TVmnxVszX6k5U D9JXu6oHM/uuN2jRal6Xsnu85vlHYAFhH60vVf+DDfwIAJZ7LSuVLxEDl65YvR4YxiAV IEAsYKnw7jSpWKB+l/RLQ+Xon2r7KUHZJjRLcx93jZTg26zUrxQuxKhau/UBMAh0FCEr VVmFBhZH+k49B6OEyh29tvCzit71bS2e27a+IJMDHzwD46HnsfyrgB9R3tKvD+0sG7cB Qfv41tW5tMH3h96ZR165hOoRO7SVsWQmqwqpoi/FiL0qoT9IWep4yfwu4ic3XUfcMr19 5IuA== 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=CKFHu1mwRyMCd3tE6xfYJyy3RgbH1D0nAbWrHT5RWOU=; b=bre5QYth+AoF7O5Qk+g5HPtkfETN2ZlCGOKVIWWSH7Ct6zIWhq+Ei03wLiOrXzYrTw XDbBzGbV3ye5kaGaL1GVpT0OSbybdfx+BZ93ohSm4sRmqg4T2Qmxz39NjNyTOHRabctF 87Z4VyZao096vHEcQgcOkWy2BXd2icg0VsyA/onM7ma1BNEMqGDFKflOstdSDBiZReb3 oyoHVz2gaAp3elWqU9y3oY33ofD4GB9cqTmZLSyHWXXWHyzDj8R77HZaAvM+CF7VmtF2 GjiHJeMZtPlr5FUmz5Y2gM/FTT4UTbETTcZzhcgNTKO+yQu8AHl0mSm9KTCRQWE461P5 o+xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=axA3pjk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n8si16249017plh.598.2022.01.31.03.35.58; Mon, 31 Jan 2022 03:36:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=axA3pjk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344430AbiA1Ujt (ORCPT + 99 others); Fri, 28 Jan 2022 15:39:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44818 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240697AbiA1Ujl (ORCPT ); Fri, 28 Jan 2022 15:39:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643402380; 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=CKFHu1mwRyMCd3tE6xfYJyy3RgbH1D0nAbWrHT5RWOU=; b=axA3pjk7c5NpMwtJo8aKHvM/cPPmhcXBvEA3OyO6+J1HGQZhZiWK8KZvtuvaviah30jj4s W42/zSaWqgONc6zS2RkEV3QMyBbn81ZOEmGPe9863hdC+HD5rQUULl1ihu23lQaYI187ZP d32Iu2QAVSKq48IOrFzF+X4OscM8HZQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-3RsQddSqPaWRSOnz9qJSAQ-1; Fri, 28 Jan 2022 15:39:39 -0500 X-MC-Unique: 3RsQddSqPaWRSOnz9qJSAQ-1 Received: by mail-wm1-f72.google.com with SMTP id bg16-20020a05600c3c9000b0034bea12c043so6423136wmb.7 for ; Fri, 28 Jan 2022 12:39:39 -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=CKFHu1mwRyMCd3tE6xfYJyy3RgbH1D0nAbWrHT5RWOU=; b=csPpjodm7vAlq3zrU1DrX+I8cqI7xJzuvWXvyk01MQ9lrpR9aFgpxk0WS06nJYQGuK Rvhm+TOEolim9dpD2SbQ9tR7glHoFA+E5Yw6Rr4ft57E4hQ/+/uLz/1dBW431ceOKBi2 dLIBODgq3tHRNZ+NDIKLlt/aAAc8VnCAjto7s1hHOSp4AEjFzQ29XZcKZy+LBzZdetqK yS0+0LravmP+hnp50xd4uzIAtk20C/aj9hLCah+1vdq83aUwG2U3ArtApII2Cefgb30g SGSppX6hy+Bq6jK1kLanryouVKDdrcPnabR0jtMNz1kSP2Hj8VTA9C4fczewZhqezzDK ckCg== X-Gm-Message-State: AOAM532RhsEt/PhKLM82ASnKdeMft19mPeQ9npE6FQQU9UgRKpPGPd9G nTPInZOdbiDu5GFAGZLEESS3zOdHZQGDiazUNL5Th+NB2PWNP/2MyZTbFRwknDNPtsDFiQZpNSg v2K3rSglObS3ykAtTEcZPGYI= X-Received: by 2002:a05:600c:1ca0:: with SMTP id k32mr7305026wms.62.1643402378589; Fri, 28 Jan 2022 12:39:38 -0800 (PST) X-Received: by 2002:a05:600c:1ca0:: with SMTP id k32mr7305003wms.62.1643402378384; Fri, 28 Jan 2022 12:39:38 -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 f13sm6960199wry.77.2022.01.28.12.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 12:39:37 -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 Subject: [RFC PATCH v3 02/13] module: Simple refactor in preparation for split Date: Fri, 28 Jan 2022 20:39:23 +0000 Message-Id: <20220128203934.600247-3-atomlin@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128203934.600247-1-atomlin@redhat.com> References: <20220128203934.600247-1-atomlin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 8c381c99062f..e3c593f8767f 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 d8c6269af6cf..fee64c4957f3 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) @@ -4555,9 +4539,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