MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4307
JIRA: https://issues.redhat.com/browse/RHEL-30902
Tested: manual testing and preliminary LNST run show improvement in some
tests and no regressions.
The fields that the rx and tx paths use were placed all over the core
networking structs. Reorganize these structs so the fields of each
struct that are read/written in rx/tx paths are placed close to each
other to reduce the number of cache lines used.
Signed-off-by: Felix Maurer <fmaurer@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: Sabrina Dubroca <sdubroca@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>
Merged-by: Lucas Zampieri <lzampier@redhat.com>
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4476
JIRA: https://issues.redhat.com/browse/RHEL-39439
Depends: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4224
v3: Added a stackleak plugin fix for bug introduced due to 0f7f7b63f5
v2:
Patch 1/5 fixes a crash with cpu hotplug. 2/5 and 3/5 and 4/5 do not introduce any functional changes - 3/5 and 4/5 are for SME and SEV respectively but are tied up since they use common machinery for running kernels with C-bit-encrypted. They help apply the following patch cleanly. 5/5 fixes a bug with SEV guests' behavior with accessing ROM regions. Although, it's unlikely we will hit it on top of KVM/QEMU, it is a bug fix and prevents a crash on top of non-efi hypervisors.
v1:
Patch 1/4 fixes a crash with cpu hotplug. 2/4 and 3/4 do not introduce any functional changes but 3/4 helps applying 4/4 cleanly. 4/4 fixes a bug with SEV guests' behavior with accessing ROM regions. Although, it's unlikely we will hit it on top of KVM/QEMU, it is a bug fix and prevents a crash on top of non-efi hypervisors.
Signed-off-by: Bandan Das <bsd@redhat.com>
Approved-by: Waiman Long <longman@redhat.com>
Approved-by: Donald Dutile <ddutile@redhat.com>
Approved-by: David Arcari <darcari@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>
Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Merged-by: Scott Weaver <scweaver@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-31230
Conflicts:
1) The net/netfilter/Makefile hunk is dropped due to missing
nft_ct_fast.c file first intruduced by commit d9e789147605
("netfilter: nf_tables: avoid retpoline overhead for some ct
expression calls").
2) A merge conflict in the tools/objtool/check.c hunk due to missing
upstream commit 9bb2ec608a20 ("objtool: Update Retpoline validation").
3) First hunk of net/netfilter/nf_tables_core.c is dropped and a merge
conflict in the second hunk due to missing upstream commit
d8d760627855 ("netfilter: nf_tables: add static key to skip retpoline
workarounds").
4) The net/netfilter/nft_ct.c hunks are dropped due to missing upstream
commit d9e789147605 ("netfilter: nf_tables: avoid retpoline overhead
for some ct expression calls").
commit aefb2f2e619b6c334bcb31de830aa00ba0b11129
Author: Breno Leitao <leitao@debian.org>
Date: Tue, 21 Nov 2023 08:07:32 -0800
x86/bugs: Rename CONFIG_RETPOLINE => CONFIG_MITIGATION_RETPOLINE
Step 5/10 of the namespace unification of CPU mitigations related Kconfig options.
[ mingo: Converted a few more uses in comments/messages as well. ]
Suggested-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Ariel Miculas <amiculas@cisco.com>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20231121160740.1249350-6-leitao@debian.org
Signed-off-by: Waiman Long <longman@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-31230
Conflicts:
1) A merge conflict in scripts/Makefile.lib due to the presence of the
following later upstream commits:
- 0c0a6d8934e2 ("objtool: Add --hacks=skylake")
- 931ab63664f0 ("x86/ibt: Implement FineIBT")
- b341b20d648b ("x86: Add prefix symbols for function padding")
2) A merge conflict in scripts/Makefile.vmlinux_o due to the
presence of a later upstream commit eeb9f34df065 ("x86/srso: Fix
unret validation dependencies").
commit 9ec6ab6ee5ca72afdf8f60c330ad997825c0819b
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Wed, 7 Sep 2022 03:49:35 +0900
kbuild: use objtool-args-y to clean up objtool arguments
Based on Linus' patch. Refactor scripts/Makefile.vmlinux_o as well.
Link: https://lore.kernel.org/lkml/CAHk-=wgjTMQgiKzBZTmb=uWGDEQxDdyF1+qxBkODYciuNsmwnw@mail.gmail.com/
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Waiman Long <longman@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-31230
Conflicts:
1) There are two merge conflicts in scripts/Makefile.build. The first
hunk is dropped as it is overwritten by RHEL backport of upstream
commit b42d23065024 ("kbuild: factor out the common objtool
arguments") earlier. The second conflict is due to the presence
of a later upstream commit c6031b1dbbbf ("kbuild: make *.mod rule
robust against too long argument error").
2) A merge conflict in scripts/Makefile.lib due to the presence of
a later upstream commit b42d23065024 ("kbuild: factor out the common
objtool arguments").
3) A merge conflict in scripts/mod/modpost.c and the hunk is dropped
as the relevant code had already been deleted by RHEL backport
of upstream commit 090feaafca ("modpost: simplify mod->name
allocation").
commit c25e1c55822f9b3b53ccbf88b85644317a525752
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Fri, 27 May 2022 19:01:49 +0900
kbuild: do not create *.prelink.o for Clang LTO or IBT
When CONFIG_LTO_CLANG=y, additional intermediate *.prelink.o is created
for each module. Also, objtool is postponed until LLVM IR is converted
to ELF.
CONFIG_X86_KERNEL_IBT works in a similar way to postpone objtool until
objects are merged together.
This commit stops generating *.prelink.o, so the build flow will look
similar with/without LTO.
The following figures show how the LTO build currently works, and
how this commit is changing it.
Current build flow
==================
[1] single-object module
$(LD)
$(CC) +objtool $(LD)
foo.c --------------------> foo.o -----> foo.prelink.o -----> foo.ko
(LLVM IR) (ELF) | (ELF)
|
foo.mod.o --/
(LLVM IR)
[2] multi-object module
$(LD)
$(CC) $(AR) +objtool $(LD)
foo1.c -----> foo1.o -----> foo.o -----> foo.prelink.o -----> foo.ko
| (archive) (ELF) | (ELF)
foo2.c -----> foo2.o --/ |
(LLVM IR) foo.mod.o --/
(LLVM IR)
One confusion is that foo.o in multi-object module is an archive
despite of its suffix.
New build flow
==============
[1] single-object module
Since there is only one object, there is no need to keep the LLVM IR.
Use $(CC)+$(LD) to generate an ELF object in one build rule. When LTO
is disabled, $(LD) is unneeded because $(CC) produces an ELF object.
$(CC)+$(LD)+objtool $(LD)
foo.c ----------------------------> foo.o ---------> foo.ko
(ELF) | (ELF)
|
foo.mod.o --/
(LLVM IR)
[2] multi-object module
Previously, $(AR) was used to combine LLVM IR files into an archive,
but there was no technical reason to do so. Use $(LD) to merge them
into a single ELF object.
$(LD)
$(CC) +objtool $(LD)
foo1.c ---------> foo1.o ---------> foo.o ---------> foo.ko
| (ELF) | (ELF)
foo2.c ---------> foo2.o ----/ |
(LLVM IR) foo.mod.o --/
(LLVM IR)
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Waiman Long <longman@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-31230
Conflicts: The first scripts/Makefile.build hunk is replaced by the
renaming of linked-object in scripts/Makefile.lib to
delay-objtool which was introduced by RHEL backport of
upstream commit b42d23065024 ("kbuild: factor out the common
objtool arguments") earlier.
commit 0cfd90060d714e3d1e0d1b30cfd1c46b71f4e721
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Fri, 27 May 2022 19:01:48 +0900
kbuild: replace $(linked-object) with CONFIG options
*.prelink.o is created when CONFIG_LTO_CLANG or CONFIG_X86_KERNEL_IBT
is enabled.
Replace $(linked-object) with $(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT)
so you will get a quick idea of when the --link option is passed.
No functional change is intended.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14
Signed-off-by: Waiman Long <longman@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-39439
commit e7d24c0aa8e678f41457d1304e2091cac6fd1a2e
Author: Ard Biesheuvel <ardb@kernel.org>
Date: Thu Mar 28 07:42:57 2024 +0100
gcc-plugins/stackleak: Avoid .head.text section
The .head.text section carries the startup code that runs with the MMU
off or with a translation of memory that deviates from the ordinary one.
So avoid instrumentation with the stackleak plugin, which already avoids
.init.text and .noinstr.text entirely.
Fixes: 48204aba801f1b51 ("x86/sme: Move early SME kernel encryption handling into .head.text")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202403221630.2692c998-oliver.sang@intel.com
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240328064256.2358634-2-ardb+git@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Bandan Das <bsd@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-30902
commit aeb9ce058d7c6193dc41e06b3a5b29d22c446b14
Author: Coco Li <lixiaoyan@google.com>
Date: Wed Nov 29 07:27:53 2023 +0000
cache: enforce cache groups
Set up build time warnings to safeguard against future header changes of
organized structs.
Warning includes:
1) whether all variables are still in the same cache group
2) whether all the cache groups have the sum of the members size (in the
maximum condition, including all members defined in configs)
The __cache_group* variables are ignored in kernel-doc check in the
various header files they appear in to enforce the cache groups.
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Coco Li <lixiaoyan@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Felix Maurer <fmaurer@redhat.com>
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4435
JIRA: https://issues.redhat.com/browse/RHEL-40250
Tested: Just built
Omitted-fix: 62776e4378ae9 ("mips: boot/compressed: use __NO_FORTIFY")
- No need to include this as MIPS arch is not supported in RHEL
Commits:
```
54d9469bc515 ("fortify: Add run-time WARN for cross-field memcpy()")
311fb40aa056 ("fortify: Use SIZE_MAX instead of (size_t)-1")
fa35198f3957 ("fortify: Explicitly check bounds are compile-time constants")
9f7d69c5cd23 ("fortify: Convert to struct vs member helpers")
03699f271de1 ("string: Rewrite and add more kern-doc for the str*() functions")
62e1cbfc5d79 ("fortify: Short-circuit known-safe calls to strscpy()")
439a1bcac648 ("fortify: Use __builtin_dynamic_object_size() when available")
26dd68d293fd ("overflow: add DEFINE_FLEX() for on-stack allocs")
21a2c74b0a2a ("fortify: Use const variables for __member_size tracking")
ead62aa370a8 ("fortify: strscpy: Fix flipped q and p docstring typo")
f0a6b5831cfb ("uml: Replace strlcpy with strscpy")
b229baa374db ("kernel.h: split out COUNT_ARGS() and CONCATENATE() to args.h")
e6584c3964f2 ("string: Allow 2-argument strscpy()")
f478898e0aa7 ("string: Redefine strscpy_pad() as a macro")
8366d124ec93 ("string: Allow 2-argument strscpy_pad()")
0d043351e5ba ("ext4: fix fortify warning in fs/ext4/fast_commit.c:1551")
b2ba00c2a517 ("rxrpc: replace zero-lenth array with DECLARE_FLEX_ARRAY() helper")
```
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Approved-by: Petr Oros <poros@redhat.com>
Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>
Merged-by: Lucas Zampieri <lzampier@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-23644
commit e37243b65d528a8a9f8b9a57a43885f8e8dfc15c
Author: Gianmarco Lusvardi <glusvardi@posteo.net>
Date: Tue Feb 13 23:05:46 2024 +0000
bpf, scripts: Correct GPL license name
The bpf_doc script refers to the GPL as the "GNU Privacy License".
I strongly suspect that the author wanted to refer to the GNU General
Public License, under which the Linux kernel is released, as, to the
best of my knowledge, there is no license named "GNU Privacy License".
This patch corrects the license name in the script accordingly.
Fixes: 56a092c895 ("bpf: add script and prepare bpf.h for new helpers documentation")
Signed-off-by: Gianmarco Lusvardi <glusvardi@posteo.net>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20240213230544.930018-3-glusvardi@posteo.net
Signed-off-by: Viktor Malik <vmalik@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 1102f9f85bf66b1a7bd6a40afb40efbbe05dfc05
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Sat Mar 23 20:45:11 2024 +0900
modpost: do not make find_tosym() return NULL
As mentioned in commit 397586506c3d ("modpost: Add '.ltext' and
'.ltext.*' to TEXT_SECTIONS"), modpost can result in a segmentation
fault due to a NULL pointer dereference in default_mismatch_handler().
find_tosym() can return the original symbol pointer instead of NULL
if a better one is not found.
This fixes the reported segmentation fault.
Fixes: a23e7584ecf3 ("modpost: unify 'sym' and 'to' in default_mismatch_handler()")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
Conflicts: Slight source diff due to omitted commits from upstream.
commit 4074532758c5c367d3fcb8d124150824a254659d
Author: Jack Brennen <jbrennen@google.com>
Date: Tue Sep 26 08:40:44 2023 -0400
modpost: Optimize symbol search from linear to binary search
Modify modpost to use binary search for converting addresses back
into symbol references. Previously it used linear search.
This change saves a few seconds of wall time for defconfig builds,
but can save several minutes on allyesconfigs.
Before:
$ make LLVM=1 -j128 allyesconfig vmlinux -s KCFLAGS="-Wno-error"
$ time scripts/mod/modpost -M -m -a -N -o vmlinux.symvers vmlinux.o
198.38user 1.27system 3:19.71elapsed
After:
$ make LLVM=1 -j128 allyesconfig vmlinux -s KCFLAGS="-Wno-error"
$ time scripts/mod/modpost -M -m -a -N -o vmlinux.symvers vmlinux.o
11.91user 0.85system 0:12.78elapsed
Signed-off-by: Jack Brennen <jbrennen@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit c05780ef3c190c2dafbf0be8e65d4f01103ad577
Author: Palmer Dabbelt <palmer@rivosinc.com>
Date: Fri Jul 7 09:00:51 2023 -0700
module: Ignore RISC-V mapping symbols too
RISC-V has an extended form of mapping symbols that we use to encode
the ISA when it changes in the middle of an ELF. This trips up modpost
as a build failure, I haven't yet verified it yet but I believe the
kallsyms difference should result in stacks looking sane again.
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Closes: https://lore.kernel.org/all/9d9e2902-5489-4bf0-d9cb-556c8e5d71c2@infradead.org/
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
Conflicts:
- Only backport the scripts/mod/modpost.c portion as cs-9 never
backported the aborted check_local_export approach.
commit 6d62b1c46b1e6e1686a0cf6617c96c80d4ab5cd5
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon Jun 12 00:50:54 2023 +0900
modpost: check static EXPORT_SYMBOL* by modpost again
Commit 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script
instead of modpost") moved the static EXPORT_SYMBOL* check from the
mostpost to a shell script because I thought it must be checked per
compilation unit to avoid false negatives.
I came up with an idea to do this in modpost, against combined ELF
files. The relocation entries in ELF will find the correct exported
symbol even if there exist symbols with the same name in different
compilation units.
Again, the same sample code.
Makefile:
obj-y += foo1.o foo2.o
foo1.c:
#include <linux/export.h>
static void foo(void) {}
EXPORT_SYMBOL(foo);
foo2.c:
void foo(void) {}
Then, modpost can catch it correctly.
MODPOST Module.symvers
ERROR: modpost: vmlinux: local symbol 'foo' was exported
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
Conflicts:
(1) Dropped patches for check-local-export; that script was temporarily
replacing modpost, but abanadoned and modpost resumed with simpler
addition and-or bug fixes, so skip it here.
(2) Drop ia64 patches since RHEL doesn't support ia64, and didn't apply cleanly.
(3) Made cmd_gensymversions genksyms exec same as cmd_gensymtypes;
cmd_gensymversions appears to be a rhel-ism, and it has no callers/users
under script hierarchy.
commit ddb5cdbafaaad6b99d7007ae1740403124502d03
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon Jun 12 00:50:52 2023 +0900
kbuild: generate KSYMTAB entries by modpost
Commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing
CONFIG_MODULE_REL_CRCS") made modpost output CRCs in the same way
whether the EXPORT_SYMBOL() is placed in *.c or *.S.
For further cleanups, this commit applies a similar approach to the
entire data structure of EXPORT_SYMBOL().
The EXPORT_SYMBOL() compilation is split into two stages.
When a source file is compiled, EXPORT_SYMBOL() will be converted into
a dummy symbol in the .export_symbol section.
For example,
EXPORT_SYMBOL(foo);
EXPORT_SYMBOL_NS_GPL(bar, BAR_NAMESPACE);
will be encoded into the following assembly code:
.section ".export_symbol","a"
__export_symbol_foo:
.asciz "" /* license */
.asciz "" /* name space */
.balign 8
.quad foo /* symbol reference */
.previous
.section ".export_symbol","a"
__export_symbol_bar:
.asciz "GPL" /* license */
.asciz "BAR_NAMESPACE" /* name space */
.balign 8
.quad bar /* symbol reference */
.previous
They are mere markers to tell modpost the name, license, and namespace
of the symbols. They will be dropped from the final vmlinux and modules
because the *(.export_symbol) will go into /DISCARD/ in the linker script.
Then, modpost extracts all the information about EXPORT_SYMBOL() from the
.export_symbol section, and generates the final C code:
KSYMTAB_FUNC(foo, "", "");
KSYMTAB_FUNC(bar, "_gpl", "BAR_NAMESPACE");
KSYMTAB_FUNC() (or KSYMTAB_DATA() if it is data) is expanded to struct
kernel_symbol that will be linked to the vmlinux or a module.
With this change, EXPORT_SYMBOL() works in the same way for *.c and *.S
files, providing the following benefits.
[1] Deprecate EXPORT_DATA_SYMBOL()
In the old days, EXPORT_SYMBOL() was only available in C files. To export
a symbol in *.S, EXPORT_SYMBOL() was placed in a separate *.c file.
arch/arm/kernel/armksyms.c is one example written in the classic manner.
Commit 22823ab419 ("EXPORT_SYMBOL() for asm") removed this limitation.
Since then, EXPORT_SYMBOL() can be placed close to the symbol definition
in *.S files. It was a nice improvement.
However, as that commit mentioned, you need to use EXPORT_DATA_SYMBOL()
for data objects on some architectures.
In the new approach, modpost checks symbol's type (STT_FUNC or not),
and outputs KSYMTAB_FUNC() or KSYMTAB_DATA() accordingly.
There are only two users of EXPORT_DATA_SYMBOL:
EXPORT_DATA_SYMBOL_GPL(empty_zero_page) (arch/ia64/kernel/head.S)
EXPORT_DATA_SYMBOL(ia64_ivt) (arch/ia64/kernel/ivt.S)
They are transformed as follows and output into .vmlinux.export.c
KSYMTAB_DATA(empty_zero_page, "_gpl", "");
KSYMTAB_DATA(ia64_ivt, "", "");
The other EXPORT_SYMBOL users in ia64 assembly are output as
KSYMTAB_FUNC().
EXPORT_DATA_SYMBOL() is now deprecated.
[2] merge <linux/export.h> and <asm-generic/export.h>
There are two similar header implementations:
include/linux/export.h for .c files
include/asm-generic/export.h for .S files
Ideally, the functionality should be consistent between them, but they
tend to diverge.
Commit 8651ec01da ("module: add support for symbol namespaces.") did
not support the namespace for *.S files.
This commit shifts the essential implementation part to C, which supports
EXPORT_SYMBOL_NS() for *.S files.
<asm/export.h> and <asm-generic/export.h> will remain as a wrapper of
<linux/export.h> for a while.
They will be removed after #include <asm/export.h> directives are all
replaced with #include <linux/export.h>.
[3] Implement CONFIG_TRIM_UNUSED_KSYMS in one-pass algorithm (by a later commit)
When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses
the directory tree to determine which EXPORT_SYMBOL to trim. If an
EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the
second traverse, where some source files are recompiled with their
EXPORT_SYMBOL() tuned into a no-op.
We can do this better now; modpost can selectively emit KSYMTAB entries
that are really used by modules.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 94d6cb68124b7a63f24fcc345795ba5f9a27e694
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon Jun 12 00:50:51 2023 +0900
modpost: pass struct module pointer to check_section_mismatch()
The next commit will use it.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 3a3f1e573a105328a2cca45a7cfbebabbf5e3192
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date: Thu Jun 8 11:23:40 2023 +0300
modpost: fix off by one in is_executable_section()
The > comparison should be >= to prevent an out of bounds array
access.
Fixes: 52dc0595d5 ("modpost: handle relocations mismatch in __ex_table.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
Conflicts: Source diff since upstream commit 1e688dd2a3d6759d
"powerpc/bug: Provide better flexibility to WARN_ON/__.."
not backported to RHEL9.
commit 19331e84c3873256537d446afec1f6c507f8c4ef
Author: Nathan Chancellor <nathan@kernel.org>
Date: Tue Dec 13 11:35:29 2022 -0700
modpost: Include '.text.*' in TEXT_SECTIONS
Commit 6c730bfc89 ("modpost: handle -ffunction-sections") added
".text.*" to the OTHER_TEXT_SECTIONS macro to fix certain section
mismatch warnings. Unfortunately, this makes it impossible for modpost
to warn about section mismatches with LTO, which implies
'-ffunction-sections', as all functions are put in their own
'.text.<func_name>' sections, which may still reference functions in
sections they are not supposed to, such as __init.
Fix this by moving ".text.*" into TEXT_SECTIONS, so that configurations
with '-ffunction-sections' will see warnings about mismatched sections.
Link: https://lore.kernel.org/Y39kI3MOtVI5BAnV@google.com/
Reported-by: Vincent Donnefort <vdonnefort@google.com>
Reviewed-and-tested-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 2cb749466d179e3ccfe83eb8a52dc002d07b08af
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:10:01 2023 +0900
modpost: detect section mismatch for R_ARM_REL32
For ARM, modpost fails to detect some types of section mismatches.
[test code]
.section .init.data,"aw"
bar:
.long 0
.section .data,"aw"
.globl foo
foo:
.long bar - .
It is apparently a bad reference, but modpost does not report anything.
The test code above produces the following relocations.
Relocation section '.rel.data' at offset 0xe8 contains 1 entry:
Offset Info Type Sym.Value Sym. Name
00000000 00000403 R_ARM_REL32 00000000 .init.data
Currently, R_ARM_REL32 is just skipped.
Handle it like R_ARM_ABS32.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 3310bae805250aec227eb056e8e61a246678f28a
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:10:00 2023 +0900
modpost: fix section_mismatch message for R_ARM_THM_{CALL,JUMP24,JUMP19}
addend_arm_rel() processes R_ARM_THM_CALL, R_ARM_THM_JUMP24,
R_ARM_THM_JUMP19 in a wrong way.
Here, test code.
[test code for R_ARM_THM_JUMP24]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
b bar
[test code for R_ARM_THM_CALL]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
push {lr}
bl bar
pop {pc}
If you compile it with CONFIG_THUMB2_KERNEL=y, modpost will show the
symbol name, (unknown).
WARNING: modpost: vmlinux.o: section mismatch in reference: foo (section: .text) -> (unknown) (section: .init.text)
(You need to use GNU linker instead of LLD to reproduce it.)
Fix the code to make modpost show the correct symbol name. I checked
arch/arm/kernel/module.c to learn the encoding of R_ARM_THM_CALL and
R_ARM_THM_JUMP24. The module does not support R_ARM_THM_JUMP19, but
I checked its encoding in ARM ARM.
The '+4' is the compensation for pc-relative instruction. It is
documented in "ELF for the Arm Architecture" [1].
"If the relocation is pc-relative then compensation for the PC bias
(the PC value is 8 bytes ahead of the executing instruction in Arm
state and 4 bytes in Thumb state) must be encoded in the relocation
by the object producer."
[1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
Fixes: c9698e5cd6 ("ARM: 7964/1: Detect section mismatches in thumb relocations")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit cd1824fb7a377882497e8b87a6f3a9ec19be3623
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:09:59 2023 +0900
modpost: detect section mismatch for R_ARM_THM_{MOVW_ABS_NC,MOVT_ABS}
When CONFIG_THUMB2_KERNEL is enabled, modpost fails to detect some
types of section mismatches.
[test code]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
It is apparently a bad reference, but modpost does not report anything.
The test code above produces the following relocations.
Relocation section '.rel.text' at offset 0x1e8 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
00000000 0000052f R_ARM_THM_MOVW_AB 00000000 .LANCHOR0
00000004 00000530 R_ARM_THM_MOVT_AB 00000000 .LANCHOR0
Currently, R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS are just skipped.
Add code to handle them. I checked arch/arm/kernel/module.c to learn
how the offset is encoded in the instruction.
One more thing to note for Thumb instructions - the st_value is an odd
value, so you need to mask the bit 0 to get the offset. Otherwise, you
will get an off-by-one error in the nearest symbol look-up.
It is documented in "ELF for the ARM Architecture" [1]:
In addition to the normal rules for symbol values the following rules
shall also apply to symbols of type STT_FUNC:
* If the symbol addresses an Arm instruction, its value is the
address of the instruction (in a relocatable object, the offset
of the instruction from the start of the section containing it).
* If the symbol addresses a Thumb instruction, its value is the
address of the instruction with bit zero set (in a relocatable
object, the section offset with bit zero set).
* For the purposes of relocation the value used shall be the address
of the instruction (st_value & ~1).
[1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit b1a9651d48b42f3eddf095123c09f93e4df23060
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:09:58 2023 +0900
modpost: refactor find_fromsym() and find_tosym()
find_fromsym() and find_tosym() are similar - both of them iterate
in the .symtab section and return the nearest symbol.
The difference between them is that find_tosym() allows a negative
distance, but the distance must be less than 20.
Factor out the common part into find_nearest_sym().
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 12ca2c67d742d390c0aa1f8c1cfc49469df55ddf
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:09:57 2023 +0900
modpost: detect section mismatch for R_ARM_{MOVW_ABS_NC,MOVT_ABS}
For ARM defconfig (i.e. multi_v7_defconfig), modpost fails to detect
some types of section mismatches.
[test code]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
It is apparently a bad reference, but modpost does not report anything.
The test code above produces the following relocations.
Relocation section '.rel.text' at offset 0x200 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
00000000 0000062b R_ARM_MOVW_ABS_NC 00000000 .LANCHOR0
00000004 0000062c R_ARM_MOVT_ABS 00000000 .LANCHOR0
Currently, R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS are just skipped.
Add code to handle them. I checked arch/arm/kernel/module.c to learn
how the offset is encoded in the instruction.
The referenced symbol in relocation might be a local anchor.
If is_valid_name() returns false, let's search for a better symbol name.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 56a24b8ce6a7f9c4a21b2276a8644f6f3d8fc14d
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:09:56 2023 +0900
modpost: fix section mismatch message for R_ARM_{PC24,CALL,JUMP24}
addend_arm_rel() processes R_ARM_PC24, R_ARM_CALL, R_ARM_JUMP24 in a
wrong way.
Here, test code.
[test code for R_ARM_JUMP24]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
b bar
[test code for R_ARM_CALL]
.section .init.text,"ax"
bar:
bx lr
.section .text,"ax"
.globl foo
foo:
push {lr}
bl bar
pop {pc}
If you compile it with ARM multi_v7_defconfig, modpost will show the
symbol name, (unknown).
WARNING: modpost: vmlinux.o: section mismatch in reference: foo (section: .text) -> (unknown) (section: .init.text)
(You need to use GNU linker instead of LLD to reproduce it.)
Fix the code to make modpost show the correct symbol name.
I imported (with adjustment) sign_extend32() from include/linux/bitops.h.
The '+8' is the compensation for pc-relative instruction. It is
documented in "ELF for the Arm Architecture" [1].
"If the relocation is pc-relative then compensation for the PC bias
(the PC value is 8 bytes ahead of the executing instruction in Arm
state and 4 bytes in Thumb state) must be encoded in the relocation
by the object producer."
[1]: https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
Fixes: 56a974fa2d ("kbuild: make better section mismatch reports on arm")
Fixes: 6e2e340b59 ("ARM: 7324/1: modpost: Fix section warnings for ARM for many compilers")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit b7c63520f6703a25eebb4f8138fed764fcae1c6f
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu Jun 1 21:09:55 2023 +0900
modpost: fix section mismatch message for R_ARM_ABS32
addend_arm_rel() processes R_ARM_ABS32 in a wrong way.
Here, test code.
[test code 1]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
If you compile it with ARM versatile_defconfig, modpost will show the
symbol name, (unknown).
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> (unknown) (section: .init.data)
(You need to use GNU linker instead of LLD to reproduce it.)
If you compile it for other architectures, modpost will show the correct
symbol name.
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
For R_ARM_ABS32, addend_arm_rel() sets r->r_addend to a wrong value.
I just mimicked the code in arch/arm/kernel/module.c.
However, there is more difficulty for ARM.
Here, test code.
[test code 2]
#include <linux/init.h>
int __initdata foo;
int get_foo(void) { return foo; }
int __initdata bar;
int get_bar(void) { return bar; }
With this commit applied, modpost will show the following messages
for ARM versatile_defconfig:
WARNING: modpost: vmlinux.o: section mismatch in reference: get_foo (section: .text) -> foo (section: .init.data)
WARNING: modpost: vmlinux.o: section mismatch in reference: get_bar (section: .text) -> foo (section: .init.data)
The reference from 'get_bar' to 'foo' seems wrong.
I have no solution for this because it is true in assembly level.
In the following output, relocation at 0x1c is no longer associated
with 'bar'. The two relocation entries point to the same symbol, and
the offset to 'bar' is encoded in the instruction 'r0, [r3, #4]'.
Disassembly of section .text:
00000000 <get_foo>:
0: e59f3004 ldr r3, [pc, #4] @ c <get_foo+0xc>
4: e5930000 ldr r0, [r3]
8: e12fff1e bx lr
c: 00000000 .word 0x00000000
00000010 <get_bar>:
10: e59f3004 ldr r3, [pc, #4] @ 1c <get_bar+0xc>
14: e5930004 ldr r0, [r3, #4]
18: e12fff1e bx lr
1c: 00000000 .word 0x00000000
Relocation section '.rel.text' at offset 0x244 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
0000000c 00000c02 R_ARM_ABS32 00000000 .init.data
0000001c 00000c02 R_ARM_ABS32 00000000 .init.data
When find_elf_symbol() gets into a situation where relsym->st_name is
zero, there is no guarantee to get the symbol name as written in C.
I am keeping the current logic because it is useful in many architectures,
but the symbol name is not always correct depending on the optimization.
I left some comments in find_tosym().
Fixes: 56a974fa2d ("kbuild: make better section mismatch reports on arm")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit abc23979ac90396c5a5dff03dcea198b5bd0c50d
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:22 2023 +0900
modpost: merge bad_tosec=ALL_EXIT_SECTIONS entries in sectioncheck table
There is no distinction between TEXT_TO_ANY_EXIT and DATA_TO_ANY_EXIT.
Just merge them.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
Conflicts: Minor source diffs but source changes the same.
commit a9bb3e5d57293773d7f925dd07e45f6e13e94947
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:13 2023 +0900
modpost: remove is_shndx_special() check from section_rel(a)
This check is unneeded. Without it, sec_name() will returns the null
string "", then section_mismatch() will return immediately.
Anyway, special section indices rarely appear in these loops.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 04ed3b476306c1b4c6e544e40d10f477c8193435
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:12 2023 +0900
modpost: replace r->r_offset, r->r_addend with faddr, taddr
r_offset/r_addend holds the offset address from/to which a symbol is
referenced. It is unclear unless you are familiar with ELF.
Rename them to faddr, taddr, respectively. The prefix 'f' means 'from',
't' means 'to'.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit a23e7584ecf33df2b27ac176185c7b030ab0736f
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:11 2023 +0900
modpost: unify 'sym' and 'to' in default_mismatch_handler()
find_tosym() takes 'sym' and stores the return value to another
variable 'to'. You can use the same variable because we want to
replace the original one when appropriate.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 05bb0704672dec59cbdc6b901130098ecfe7a846
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:09 2023 +0900
modpost: remove unused argument from secref_whitelist()
secref_whitelist() does not use the argument 'mismatch'.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 17b53f10aba7c17e92bcf713179bc577cba059b7
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 22 01:04:06 2023 +0900
Revert "modpost: skip ELF local symbols during section mismatch check"
This reverts commit a4d26f1a09.
The variable 'fromsym' never starts with ".L" since commit 87e5b1e8f257
("module: Sync code of is_arm_mapping_symbol()").
In other words, Pattern 6 is now dead code.
Previously, the .LANCHOR1 hid the symbols listed in Pattern 2.
87e5b1e8f257 provided a better solution.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit ac263349b91bf34b7c8419f5645c84b4f88de846
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:28 2023 +0900
modpost: rename find_elf_symbol() and find_elf_symbol2()
find_elf_symbol() and find_elf_symbol2() are not good names.
Rename them to find_tosym(), find_fromsym(), respectively.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 9990ca35870b7c57d39f8b325d676dfd028035b4
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:27 2023 +0900
modpost: pass section index to find_elf_symbol2()
find_elf_symbol2() converts the section index to the section name,
then compares the two strings in each iteration. This is slow.
It is faster to compare the section indices (i.e. integers) directly.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit dbf7cc2e4e78dfecad02ff17ff5c9971b42da462
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:26 2023 +0900
modpost: pass 'tosec' down to default_mismatch_handler()
default_mismatch_handler() does not need to compute 'tosec' because
it is calculated by the caller.
Pass it down to default_mismatch_handler() instead of calling
sec_name() twice.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 856567d5599e7df75d7cad1fef1311d7c1854200
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:25 2023 +0900
modpost: squash extable_mismatch_handler() into default_mismatch_handler()
Merging these two reduces several lines of code. The extable section
mismatch is already distinguished by EXTABLE_TO_NON_TEXT.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit f4c35484e7f11458c1834b88ee55b746cdabbb09
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:24 2023 +0900
modpost: clean up is_executable_section()
SHF_EXECINSTR is a bit flag (#define SHF_EXECINSTR 0x4).
Compare the masked flag to '!= 0'.
There is no good reason to stop modpost immediately even if a special
section index is given. You will get a section mismatch error anyway.
Also, change the return type to bool.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit fc5fa862c49a4d9e23617fbda7d249d2c1b72e56
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:23 2023 +0900
modpost: squash report_sec_mismatch() into default_mismatch_handler()
report_sec_mismatch() and default_mismatch_handler() are small enough
to be merged together.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit faee9defd8fc376864efb39b87d59f667deeb488
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:22 2023 +0900
modpost: squash report_extable_warnings() into extable_mismatch_handler()
Collect relevant code into one place to clarify all the cases are
covered by 'if () ... else if ... else ...'.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 6691e6f5fc3e9fa76c9a50970fa851829df7d9f2
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:21 2023 +0900
modpost: remove get_prettyname()
This is the last user of get_pretty_name() - it is just used to
distinguish whether the symbol is a function or not. It is not
valuable information.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit 6c90d36be3e5140c93d3af360d012fa26966304a
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:20 2023 +0900
modpost: remove fromsym info in __ex_table section mismatch warning
report_extable_warnings() prints "from" in a pretty form, but we know
it is always located in the __ex_table section, i.e. a collection of
struct exception_table_entry.
It is very likely to fail to get the symbol name and ends up with
meaningless message:
... in reference from the (unknown reference) (unknown) to ...
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>
JIRA: https://issues.redhat.com/browse/RHEL-28063
commit d0acc76a49aa917c1a455d11d32d34a01e8b2835
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Mon May 15 00:27:19 2023 +0900
modpost: remove broken calculation of exception_table_entry size
find_extable_entry_size() is completely broken. It has awesome comments
about how to calculate sizeof(struct exception_table_entry).
It was based on these assumptions:
- struct exception_table_entry has two fields
- both of the fields have the same size
Then, we came up with this equation:
(offset of the second field) * 2 == (size of struct)
It was true for all architectures when commit 52dc0595d5 ("modpost:
handle relocations mismatch in __ex_table.") was applied.
Our mathematics broke when commit 548acf1923 ("x86/mm: Expand the
exception table logic to allow new handling options") introduced the
third field.
Now, the definition of exception_table_entry is highly arch-dependent.
For x86, sizeof(struct exception_table_entry) is apparently 12, but
find_extable_entry_size() sets extable_entry_size to 8.
I could fix it, but I do not see much value in this code.
extable_entry_size is used just for selecting a slightly different
error message.
If the first field ("insn") references to a non-executable section,
The relocation at %s+0x%lx references
section "%s" which is not executable, IOW
it is not possible for the kernel to fault
at that address. Something is seriously wrong
and should be fixed.
If the second field ("fixup") references to a non-executable section,
The relocation at %s+0x%lx references
section "%s" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
Merge the two error messages rather than adding even more complexity.
Change fatal() to error() to make it continue running and catch more
possible errors.
Fixes: 548acf1923 ("x86/mm: Expand the exception table logic to allow new handling options")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Donald Dutile <ddutile@redhat.com>