Skip to content

Commit cd66a5d

Browse files
committed
Merge: Update kernel-module support to v6.8
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4061 # Merge Request Required Information ## Summary of Changes RHIVOS is running into early mm init performance issues, and a long-term set of solutions is to improve the kernel linear map when kernel security is set to a max-level, a RHIVOS FuSa requirement, where all of memory is -not- read/writeable via the linear map (all of memory mapping from PAGE_OFFSET), but has strict execute-only, rodata, rw-data and no-execute pages. Although RHEL9 and upstream can support the latter functionally, it is a significant performance issue as page-level mapping of the kernel linear map has to be employed from the default huge-page mappings that the various arch's support. The boot kernel itself is relatively easy to know how to map for optimal page-mappings and protection, because it is the first to load and ELF sections can be scanned for needed info; the same can't be said for all the loadable kernel modules, which is the impetus for page-splitting of the linear map (on x86) and the per-page-mapping on ARM64, where page-splitting of the linear map is not supported, but is the long-term optimal solution. In order to make a step in this long-term effort, this patch series attempts to take the existing RHEL9 kernel module load support, which is barely 12 patches past the initial v5.14 base, and bring it up to a current, v6.8 version. Of course, such an update brings a lot of other needed backports to apply cleanly, if the goal is to get close to upstream, maintain RHEL kmod support, and not regress. Thus, this series results with major updates to dynamic-debug (since it involves modifying kernel module sections), kbuild, modpost, genksyms, and sprinkle an odd livepatch, fpatch, and BPF patch, although the latter were trimmed or dropped wherever possible. The split is approximately 150 kernel-module, 30 dyndbg, 80 modpost, 15 kbuild, 3 livepatch, 3 ftrace, 2 bpf (one being a fix for earlier kernel commit). Note: modpost and related kbuild updates moved it to approximately v6.4. A full update to 6.8 wasn't deemed necessary, and was an additional 30+ commits, and more kbuild modifications. This effort was deemed sufficiently large and complete for the intended goal of making RHEL9 amenable to future updates to the kernel-module subsystem for posted patches on review now in linux-mm by Mike Rapaport. Those patches and expected follow-ons, will be backported to RHEL-9 when upstream settles on final updates in this area; these updates will make the kernel-load subsystem more common, and less arch-specific. One patch from v6.9-rc1 was taken, modules: wait do_free_init correctly, to repair a race seen in the module-load path on a RHIVOS platform, which needed to sit on top of this series for ease of backporting. v6: Evidently the rebase to -457 kept a merge conflict, which was a duplicate patch already taken in. Latest series is now 299 patches vs 300. No functional changes! v5: rebased to latest kernel (-457) since gitlab punted due to claimed merge conflict; only conflict was relative source, due to other MRs pulled into cs9/9.5 ahead of this MR; no code changes, and (tkdiff+)diff-ing v4 patches to v5, showed no diffs to the author's naked eye. v4: Just updated 3rd patch's revert to put Upstream status *after* Subject, so it shows correctly in a git-format output. No code changes from v3. (although CKI running a-muck after push'd update w/only a commit-log change). v3: Rebase to -455 kernel since v2 was 8300 commits behind and had merge conflicts with JoeL's objtool update MR. v2: Pulling out of Draft. : (Hopefully) fixed numerous nits (Jira: -> JIRA:; proper link so no more 404's, etc.) : add new/latest Fixes, some id'd by reviewers, some new to v6.9 : Cleaned up/out bad merges that had introduced RHEL-only hunks : Significantly re-ordered the series to make it more bisectable; still breaks where the upstream maintainer tore code out of modpost.c and into a sed script, and then put the functionality back into modpost.c, and removed the sed script, which this series didn't backport since it was already large enough. : identified a failure with systemtap, that Will Cohen is repairing; thus, this MR has to wait for a systemtap update before it will pass its check in the (brew? cki?) builds. v1: Draft! This series has gone through some simple, preliminary testing, but it needs deep review by ftrace, BPF, livepatch, and rh-kabi support to ensure no regressions in these few, but corner kernel-modifying code paths. rh-kabi tooling is a bit unknown, as it isn't in the kernel, but there are RHEL-only patches in the kernel for it. A patchreview run against the series was exed'd, and needed Fixes were added/included. The list of self-documented omissions is listed below. If new ones have popped in v6.9-rc<n>, please forward them for addition. Bisectability: The series is has known bisectability (patch-ordering) issues at the moment, but plan to re-shuffle the patches in v2 to improve if not make it completely bisectable. Expected feedback will be incorporated in v2, and planned upgrade to full-MR/drop-Draft status. Shout-out to Joe Lawrence who aided in debugging and providing fixes for well-hidden noarch build failures around Documentation generation, as well as warning cleanups for EXPORT'd init-tagged functions, which the update checks for now. Joe was instrumental in finding key chunks of the modpost update that appears to have closed gaps in my original backport efforts. Intentionally Omitted Fix: 0aa24a7 kbuild: do not try to parse *.cmd files for objects provided by compiler -- for parisc & sky arch's, not needed in RHEL9 Intentionally Omitted Fix: f5983da modpost: define more R_ARM_* for old distributions For old releases not having R_ARM_* in arch/arm/include/asm/elf.h, which RHEL9 has Intentionally Omitted Fix: 08700ec linux/export: fix reference to exported functions for parisc64 -- no parisc64 support in RHEL9 Intentionally Omitted Fix: 86495af media: dvb: symbol fixup for dvb_attach() -- not included in this backport due to partner request not to include until RHEL-10 Intentionally Omitted Fix: d81f0d7 Subject: kunit: add KUNIT_INIT_TABLE to init link -- will let KUNIT update bring in and enable as needed ## Approved Development Ticket JIRA: https://issues.redhat.com/browse/RHEL-28063 Signed-off-by: Donald Dutile <ddutile@redhat.com> Approved-by: Chris von Recklinghausen <crecklin@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Approved-by: Eric Chanudet <echanude@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents dc79087 + aaaa438 commit cd66a5d

File tree

110 files changed

+8071
-4980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+8071
-4980
lines changed

Documentation/admin-guide/dynamic-debug-howto.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ The flags are::
229229

230230
p enables the pr_debug() callsite.
231231
f Include the function name in the printed message
232+
s Include the source file name in the printed message
232233
l Include line number in the printed message
233234
m Include module name in the printed message
234235
t Include thread ID in messages not generated from interrupt context
@@ -240,17 +241,16 @@ have meaning, other flags ignored.
240241
For display, the flags are preceded by ``=``
241242
(mnemonic: what the flags are currently equal to).
242243

243-
Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification.
244-
To clear all flags at once, use ``=_`` or ``-flmpt``.
244+
Note the regexp ``^[-+=][fslmpt_]+$`` matches a flags specification.
245+
To clear all flags at once, use ``=_`` or ``-fslmpt``.
245246

246247

247248
Debug messages during Boot Process
248249
==================================
249250

250251
To activate debug messages for core code and built-in modules during
251252
the boot process, even before userspace and debugfs exists, use
252-
``dyndbg="QUERY"``, ``module.dyndbg="QUERY"``, or ``ddebug_query="QUERY"``
253-
(``ddebug_query`` is obsoleted by ``dyndbg``, and deprecated). QUERY follows
253+
``dyndbg="QUERY"`` or ``module.dyndbg="QUERY"``. QUERY follows
254254
the syntax described above, but must not exceed 1023 characters. Your
255255
bootloader may impose lower limits.
256256

@@ -270,8 +270,7 @@ this boot parameter for debugging purposes.
270270

271271
If ``foo`` module is not built-in, ``foo.dyndbg`` will still be processed at
272272
boot time, without effect, but will be reprocessed when module is
273-
loaded later. ``ddebug_query=`` and bare ``dyndbg=`` are only processed at
274-
boot.
273+
loaded later. Bare ``dyndbg=`` is only processed at boot.
275274

276275

277276
Debug Messages at Module Initialization Time
@@ -358,7 +357,7 @@ Examples
358357
// boot-args example, with newlines and comments for readability
359358
Kernel command line: ...
360359
// see what's going on in dyndbg=value processing
361-
dynamic_debug.verbose=1
360+
dynamic_debug.verbose=3
362361
// enable pr_debugs in 2 builtins, #cmt is stripped
363362
dyndbg="module params +p #cmt ; module sys +p"
364363
// enable pr_debugs in 2 functions in a module loaded later

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -918,11 +918,6 @@
918918
Format: <port#>,<type>
919919
See also Documentation/input/devices/joystick-parport.rst
920920

921-
ddebug_query= [KNL,DYNAMIC_DEBUG] Enable debug messages at early boot
922-
time. See
923-
Documentation/admin-guide/dynamic-debug-howto.rst for
924-
details. Deprecated, see dyndbg.
925-
926921
debug [KNL] Enable kernel debugging (events log level).
927922

928923
debug_boot_weak_hash
@@ -1190,8 +1185,12 @@
11901185
nopku [X86] Disable Memory Protection Keys CPU feature found
11911186
in some Intel CPUs.
11921187

1193-
<module>.async_probe [KNL]
1194-
Enable asynchronous probe on this module.
1188+
<module>.async_probe[=<bool>] [KNL]
1189+
If no <bool> value is specified or if the value
1190+
specified is not a valid <bool>, enable asynchronous
1191+
probe on this module. Otherwise, enable/disable
1192+
asynchronous probe on this module as indicated by the
1193+
<bool> value. See also: module.async_probe
11951194

11961195
early_ioremap_debug [KNL]
11971196
Enable debug messages in early_ioremap support. This
@@ -3433,6 +3432,21 @@
34333432
For details see:
34343433
Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst
34353434

3435+
module.async_probe=<bool>
3436+
[KNL] When set to true, modules will use async probing
3437+
by default. To enable/disable async probing for a
3438+
specific module, use the module specific control that
3439+
is documented under <module>.async_probe. When both
3440+
module.async_probe and <module>.async_probe are
3441+
specified, <module>.async_probe takes precedence for
3442+
the specific module.
3443+
3444+
module.enable_dups_trace
3445+
[KNL] When CONFIG_MODULE_DEBUG_AUTOLOAD_DUPS is set,
3446+
this means that duplicate request_module() calls will
3447+
trigger a WARN_ON() instead of a pr_warn(). Note that
3448+
if MODULE_DEBUG_AUTOLOAD_DUPS_TRACE is set, WARN_ON()s
3449+
will always be issued and this option does nothing.
34363450
module.sig_enforce
34373451
[KNL] When CONFIG_MODULE_SIG is set, this means that
34383452
modules without (valid) signatures will fail to load.

Documentation/core-api/kernel-api.rst

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,30 @@ relay interface
216216
Module Support
217217
==============
218218

219-
Module Loading
220-
--------------
219+
Kernel module auto-loading
220+
--------------------------
221221

222-
.. kernel-doc:: kernel/kmod.c
222+
.. kernel-doc:: kernel/module/kmod.c
223223
:export:
224224

225+
Module debugging
226+
----------------
227+
228+
.. kernel-doc:: kernel/module/stats.c
229+
:doc: module debugging statistics overview
230+
231+
dup_failed_modules - tracks duplicate failed modules
232+
****************************************************
233+
234+
.. kernel-doc:: kernel/module/stats.c
235+
:doc: dup_failed_modules - tracks duplicate failed modules
236+
237+
module statistics debugfs counters
238+
**********************************
239+
240+
.. kernel-doc:: kernel/module/stats.c
241+
:doc: module statistics debugfs counters
242+
225243
Inter Module support
226244
--------------------
227245

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10725,6 +10725,7 @@ F: drivers/tty/serial/kgdboc.c
1072510725
F: include/linux/kdb.h
1072610726
F: include/linux/kgdb.h
1072710727
F: kernel/debug/
10728+
F: kernel/module/kdb.c
1072810729

1072910730
KHADAS MCU MFD DRIVER
1073010731
M: Neil Armstrong <narmstrong@baylibre.com>
@@ -11182,6 +11183,7 @@ F: arch/s390/include/asm/livepatch.h
1118211183
F: arch/x86/include/asm/livepatch.h
1118311184
F: include/linux/livepatch.h
1118411185
F: kernel/livepatch/
11186+
F: kernel/module/livepatch.c
1118511187
F: lib/livepatch/
1118611188
F: samples/livepatch/
1118711189
F: tools/testing/selftests/livepatch/
@@ -13050,7 +13052,7 @@ M: Jessica Yu <jeyu@kernel.org>
1305013052
S: Maintained
1305113053
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux.git modules-next
1305213054
F: include/linux/module.h
13053-
F: kernel/module.c
13055+
F: kernel/module/
1305413056

1305513057
MONOLITHIC POWER SYSTEM PMIC DRIVER
1305613058
M: Saravanan Sekar <sravanhome@gmail.com>

arch/Kconfig

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -791,16 +791,6 @@ config CFI_CLANG
791791

792792
https://clang.llvm.org/docs/ControlFlowIntegrity.html
793793

794-
config CFI_CLANG_SHADOW
795-
bool "Use CFI shadow to speed up cross-module checks"
796-
default y
797-
depends on CFI_CLANG && MODULES
798-
help
799-
If you select this option, the kernel builds a fast look-up table of
800-
CFI check functions in loaded modules to reduce performance overhead.
801-
802-
If unsure, say Y.
803-
804794
config CFI_PERMISSIVE
805795
bool "Use CFI in permissive mode"
806796
depends on CFI_CLANG
@@ -946,6 +936,12 @@ config MODULES_USE_ELF_REL
946936
Modules only use ELF REL relocations. Modules with ELF RELA
947937
relocations will give an error.
948938

939+
config ARCH_WANTS_MODULES_DATA_IN_VMALLOC
940+
bool
941+
help
942+
For architectures like powerpc/32 which have constraints on module
943+
allocation and need to allocate module data outside of module area.
944+
949945
config HAVE_IRQ_EXIT_ON_IRQ_STACK
950946
bool
951947
help

arch/arc/kernel/unwind.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ void *unwind_add_table(struct module *module, const void *table_start,
374374
unsigned long table_size)
375375
{
376376
struct unwind_table *table;
377+
struct module_memory *core_text;
378+
struct module_memory *init_text;
377379

378380
if (table_size <= 0)
379381
return NULL;
@@ -382,11 +384,11 @@ void *unwind_add_table(struct module *module, const void *table_start,
382384
if (!table)
383385
return NULL;
384386

385-
init_unwind_table(table, module->name,
386-
module->core_layout.base, module->core_layout.size,
387-
module->init_layout.base, module->init_layout.size,
388-
table_start, table_size,
389-
NULL, 0);
387+
core_text = &module->mem[MOD_TEXT];
388+
init_text = &module->mem[MOD_INIT_TEXT];
389+
390+
init_unwind_table(table, module->name, core_text->base, core_text->size,
391+
init_text->base, init_text->size, table_start, table_size, NULL, 0);
390392

391393
init_unwind_hdr(table, unw_hdr_alloc);
392394

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ config ARM
8888
select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
8989
select HAVE_CONTEXT_TRACKING_USER
9090
select HAVE_C_RECORDMCOUNT
91+
select HAVE_BUILDTIME_MCOUNT_SORT
9192
select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL
9293
select HAVE_DMA_CONTIGUOUS if MMU
9394
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU

arch/arm/boot/compressed/decompress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/* Not needed, but used in some headers pulled in by decompressors */
3232
extern char * strstr(const char * s1, const char *s2);
3333
extern size_t strlen(const char *s);
34+
extern int strcmp(const char *cs, const char *ct);
3435
extern int memcmp(const void *cs, const void *ct, size_t count);
3536
extern char * strchrnul(const char *, int);
3637

arch/arm/kernel/module-plts.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ static const u32 fixed_plts[] = {
2828
#endif
2929
};
3030

31-
static bool in_init(const struct module *mod, unsigned long loc)
32-
{
33-
return loc - (u32)mod->init_layout.base < mod->init_layout.size;
34-
}
35-
3631
static void prealloc_fixed(struct mod_plt_sec *pltsec, struct plt_entries *plt)
3732
{
3833
int i;
@@ -50,8 +45,8 @@ static void prealloc_fixed(struct mod_plt_sec *pltsec, struct plt_entries *plt)
5045

5146
u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val)
5247
{
53-
struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core :
54-
&mod->arch.init;
48+
struct mod_plt_sec *pltsec = !within_module_init(loc, mod) ?
49+
&mod->arch.core : &mod->arch.init;
5550
struct plt_entries *plt;
5651
int idx;
5752

arch/arm64/kernel/module-plts.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,12 @@ static bool plt_entries_equal(const struct plt_entry *a,
6666
(q + aarch64_insn_adrp_get_offset(le32_to_cpu(b->adrp)));
6767
}
6868

69-
static bool in_init(const struct module *mod, void *loc)
70-
{
71-
return (u64)loc - (u64)mod->init_layout.base < mod->init_layout.size;
72-
}
73-
7469
u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs,
7570
void *loc, const Elf64_Rela *rela,
7671
Elf64_Sym *sym)
7772
{
78-
struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core :
79-
&mod->arch.init;
73+
struct mod_plt_sec *pltsec = !within_module_init((unsigned long)loc, mod) ?
74+
&mod->arch.core : &mod->arch.init;
8075
struct plt_entry *plt = (struct plt_entry *)sechdrs[pltsec->plt_shndx].sh_addr;
8176
int i = pltsec->plt_num_entries;
8277
int j = i - 1;
@@ -106,8 +101,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs,
106101
u64 module_emit_veneer_for_adrp(struct module *mod, Elf64_Shdr *sechdrs,
107102
void *loc, u64 val)
108103
{
109-
struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core :
110-
&mod->arch.init;
104+
struct mod_plt_sec *pltsec = !within_module_init((unsigned long)loc, mod) ?
105+
&mod->arch.core : &mod->arch.init;
111106
struct plt_entry *plt = (struct plt_entry *)sechdrs[pltsec->plt_shndx].sh_addr;
112107
int i = pltsec->plt_num_entries++;
113108
u32 br;

0 commit comments

Comments
 (0)