Commit Graph

82 Commits

Author SHA1 Message Date
Eugene Syromiatnikov
2cb3604727 find-provides.ksyms, find-requires.ksyms: rewrite section data matching
Currently, it just matches the 2nd to 5th fields with awk, which leads
to occasional capturing of some garbage at the end of the section data
and minor issues when supplying it to the symbol extracting awk script:

    awk: cmd. line:1: (FILENAME=- FNR=19) fatal: argument index with `$' must be > 0
    awk: warning: escape sequence `\.' treated as plain `.'
    awk: cmd. line:1: (FILENAME=- FNR=9) fatal: not enough arguments to satisfy format string
    	`78b624dbc125415351be965ex.$..%ASQ..^'
    	                              ^ ran out for this one

While at it, also eliminate grep and sed calls (with the pair of awk and
sed being the most offending).

* find-provides.ksyms: Generate part of the awk script that performs
the byte reversal based on the endianness in the readelf -h output,
inject it into the awk script;  use substr for matching parts
of the section data instead of fields.
* find-requires.ksyms (all_provides): Likewise.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:39 +02:00
Eugene Syromiatnikov
5910d31329 find-provides.ksyms: factor out the output sorting
To bring it more in line with the implementation in find-requires.ksyms.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:39 +02:00
Eugene Syromiatnikov
0f60c336b4 find-requires.ksyms: set LC_ALL=C globally
To bring it more in line with the way it is implemented
in find-provides.ksyms and avoid the inconsistencies prodiced by missing
the environment setting.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:39 +02:00
Eugene Syromiatnikov
30b19c9d63 find-provides.ksyms, find-requires.ksyms: use "read -r"
To avoid all kinds of fun that might stem from interpreting the user-supplied
input.

* find-provides.ksyms: Supply -r option to the read call.
* find-requires.ksyms (all_provides): Likewise.

Fixes: cd7e9e8a2f "find-provides.ksyms, find-requires.ksyms: rewrite indirect CRC parsing"
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:39 +02:00
Eugene Syromiatnikov
459cc0478d find-requires.ksyms: call readelf -R on the sectname and not hard-coded .rodata
* find-requires.ksyms (all_provides): Pass $sectname to the readelf -R call.

Fixes: cd7e9e8a2f "find-provides.ksyms, find-requires.ksyms: rewrite indirect CRC parsing"
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:39 +02:00
Eugene Syromiatnikov
0a8324122a find-provides.ksyms, find-requires.ksyms: match only the section being processed
Instead of ignoring the section name in the objdump -t output, section
name has to be checked in the awk script to produce only the meaningful
output;  hit when both __kcrctab and __kcrctab_gpl are present.

* find-requires.ksyms (all_provides): Pass $sectname to the awk script,
check that the relevant field of the input matches it.
* find-provides.ksyms: Likewise.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-24 16:09:36 +02:00
Eugene Syromiatnikov
027d626014 find-provides.ksyms, find-requires.ksyms: filter local __crc_* symbols as well
Apparently, these are local in the recent kernels.

* find-provides.ksyms (all_provides): Filter local __crc_* symbols
in additional to global in the objdump -t call output.
* find-requires.ksyms: Likewise.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-05-16 09:27:51 +02:00
Eugene Syromiatnikov
96aa636698 kabi: handle symvers.xz
Check for symvers.xz support in addition to symvers.gz,
due to unnanounced unilateral change[1][2] in the kernel packaging.

[1] 2644665657
[2] 2db77a072a

* kabi.attr: Add xz extension to the file matching pattern
* kabi.sh: Add xz extension to the matching pattern;  determine catenation
program based on extension.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
References: https://bugzilla.redhat.com/show_bug.cgi?id=2192895
2023-05-16 09:27:51 +02:00
Denys Vlasenko
9008a32c7d README.md: update docs, add some questions
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-12 15:48:56 +02:00
Denys Vlasenko
efa36b601a tests: adjust internal patch to apply cleanly
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-08 11:28:24 +02:00
Denys Vlasenko
f46d3e8522 modalias.prov: rename "class" and "tag" variables to "prev" and "next"
The old names are misleading.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-08 11:12:45 +02:00
Denys Vlasenko
5683c50270 modalias.prov: use standard "match any char not in set" glob pattern, and sed -E option
[^set] is not correct in glob (it's regexp construct). [!set] is.

sed: -n is not necessary. -e too. manpage recommends using -E instead of -r.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:56:30 +02:00
Denys Vlasenko
35e1f2fc73 modalias.prov: speed up, explain and make more correct combining code
The time to run on tests/* data decreased from 34.517s to 30.201s.

Do not allow combining of any glob meta characters, either in first
or second line.

The code is still buggy, it may attempt to combine
    modalias(abc[def]123)
    modalias(abc[dXf]123)
into
    modalias(abc[d[eX]f]123)
(presumably there won't be any such cases in real modules, but still).

Eliminate "| head -n1" - do it with bash string ops.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:49:24 +02:00
Denys Vlasenko
c39c0162a0 tests: add tests for modalias.prov
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:36:00 +02:00
Denys Vlasenko
7cd7d838cf modalias.prov: group modalias lines by length
On my machine, out of 2604 modules, this reduces number of
"provides" items by ~800 (to 12689 items).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-07 17:29:18 +02:00
Denys Vlasenko
c2b1f3e458 modalias.prov: avoid a subshell (fork) in position check
This creates a subshell: ... && ( [ -z "$pos" ] || [ $n = $pos ] )

For example, processing ath9k.ko needed ~80 forks here.
Rather expensive.

This should do the same: ... && [ -z "$pos" -o "$n" = "$pos" ]

While at it, explain algorithm in comments.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 18:17:29 +02:00
Denys Vlasenko
653ec7d086 modalias.prov: use "local" builtin rather than "declare"
While (in this case) their effect is the same,
many more people know that "local" makes variables function-local,
than that "declare" in bash does the same. I didn't know.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:40:03 +02:00
Denys Vlasenko
510e0c8261 modalias.prov: make sort locale-independent with LC_ALL=C
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:35:42 +02:00
Denys Vlasenko
6a6920aed2 modalias.prov: use "command" rather than "which" to check existence of commands
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-05 17:34:05 +02:00
Denys Vlasenko
0c336570df kmod.attr: cosmetic fixes: %{1} to %1, indentation fix
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-04 12:55:15 +02:00
Denys Vlasenko
e9cc0440fd kmod.attr: fix string.gsub patterns and return values
basename(): return one value, not two (principle of least confusion).
strip_compress_sfx(): ditto

strip_compress_sfx(): fix it, it had several problems:
    (a) incorrect escaping of . (period) ... masked by incorrect use of backslash
    (b) lua has no | "or" pattern

Use simpler gsub patterns / replacements, presumably faster (did not measure).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-04 12:51:15 +02:00
Denys Vlasenko
5df3d6d58b kmod.attr: optimization: do not call strip_compress_sfx() twice
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-04 12:43:01 +02:00
Denys Vlasenko
491a3411df kmod.attr: fix "%g+.ko" pattern (erroneously matches "anythingko") to "%g+%.ko"
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-04 12:37:36 +02:00
Denys Vlasenko
9d75b962fc modalias.prov: fix spurious exitcode of 1 on reaching EOF
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-05-03 11:30:18 +02:00
Denys Vlasenko
0c32043719 README.md: add notes to understand what is done by which file
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-04-28 15:56:49 +02:00
Denys Vlasenko
05ce41491c test commit
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2023-04-26 09:33:20 +02:00
Eugene Syromiatnikov
9e9dc09cda find-provides.ksyms, find-requires.ksyms: avoid awaking debuginfod
Starting with RHEL 9.2 and Fedora 35, debuginfod is enabled by default,
which leads to significant startup times of various tools
from the elfutils package (namely, readelf and objdump).
Unset DEBUGINFOD_URLS to avoid it.

* find-provides.ksyms (DEBUGINFOD_URLS): Unset.
* find-requires.ksyms (DEBUGINFOD_URLS): Ditto.
* kernel-srpm-macros.spec (Release): Bump to 18.
(%changelog): Add a record.

Suggested-by: Panu Matilainen <pmatilai@redhat.com>
Co-Authored-by: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-04-25 12:40:16 +02:00
Eugene Syromiatnikov
891b09a028 kernel-srpm-macros.spec: bump RPM release
* kernel-srpm-macros.spec (Release): Bump to 17.
(%changelog): Add a record.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-04-25 12:20:18 +02:00
Eugene Syromiatnikov
90757faf53 kernel-srpm-macros.spec: update Requires: for binaries used in scripts
Add "Requies:" tags for binearies used in various scripts, namely
brp-kmod-compress, brp-kmod-set-exec-bit, find-provides.ksyms,
find-requires.ksyms, and kmodtool.

* kernel-srpm-macros.spec (%package -n kernel-rpm-macros) <Requires>:
Add %{_bindir}/xz, %{_bindir}/find, %{_bindir}/sed, %{_bindir}/awk,
%{_bindir}/grep, %{_bindir}/nm, %{_bindir}/objdump, %{_bindir}/readelf,
%{_sbindir}/modinfo, %{_sbindir}/modprobe.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Resolves: #2135047
2023-03-07 14:57:02 +01:00
Eugene Syromiatnikov
cd7e9e8a2f find-provides.ksyms, find-requires.ksyms: rewrite indirect CRC parsing
Linux commit v5.19-rc1~139^2~2 ("kbuild: link symbol CRCs at final link,
removing CONFIG_MODULE_REL_CRCS") has broken the assumption aobut
the placement of non-absolute CRC symbols in .rodata (and also affects
the architectures that used to have these symbols as absolute);  rewrite
the parsing by utilising "objdump -t" output to figure out
the section(s) where the __crc_* symbols are stored and process
it instead of the hard-coded ".rodata" section.  The change also speeds
up the processing a bit, around 33% on synthetic tests:

    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.ppc64le -name "*.ko.xz" | find-provides.ksyms.old > /dev/null 2> /dev/null'
    sh -c   10.36s user 5.58s system 137% cpu 11.613 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.ppc64le -name "*.ko.xz" | find-provides.ksyms.new > /dev/null 2> /dev/null'
    sh -c   7.82s user 4.59s system 142% cpu 8.686 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.ppc64le -name "*.ko.xz" -exec sh -c "echo {} | find-provides.ksyms.old" \; > /dev/null 2> /dev/null'
    sh -c   11.85s user 6.76s system 129% cpu 14.318 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.ppc64le -name "*.ko.xz" -exec sh -c "echo {} | find-provides.ksyms.new" \; > /dev/null 2> /dev/null'
    sh -c   8.91s user 5.51s system 135% cpu 10.647 total

* find-provides.ksyms: Process "objdump -t" output to get the list
of sections where __crc_* symbol contents are placed;  retrieve
each one with "readelf -R" and supply it to an awk script that cuts
the required part of it for each __crc_* symbol in that section.
* find-requires.ksyms (all_provides): Likewise.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Resolves: #2135047
2023-03-07 14:56:55 +01:00
Eugene Syromiatnikov
297a5b711f find-provides.ksyms, find-requires.ksyms: work around printed __crc_* type change
Commit binutils-2_33~1385[1] has changed (and binutils-2_35~1768[2]
has not reverted) the calculated type for symbols in read-write .rodata section
from 'R' to 'D' on architectures where CONFIG_MODULE_REL_CRCS is enabled
(namely, ppc64* and s390*), since, apparently, many kernel modules have it indeed
read-write.  Work around it by matching both D and R as possible __crc_* symbol
type.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=a288c270991d
[2] https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=49d9fd42acef

* find-provides.ksyms: Match D as possible __crc_* symbol type in
addition to R.
* find-requires.ksyms: Likewise.
* kernel-srpm-macros.spec (Release): Bump to 11%{?dist}.
(%changelog): Mention the change.

Resolves: #2055464
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2023-03-07 14:56:48 +01:00
Eugene Syromiatnikov
4eeb063077 find-provides.ksyms, find-requires.ksyms: rewrite absolute CRC parsing
Avoid running sed on the whole "nm" output and also avoid "sed | awk"
pipe in favor of a single awk call.  Overall, this gives around 20%
speedup on some quick synthetic tests:

    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.x86_64 -name "*.ko.xz" | find-provides.ksyms.old > /dev/null 2> /dev/null'
    sh -c   14.20s user 8.93s system 144% cpu 16.014 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.x86_64 -name "*.ko.xz" | find-provides.ksyms.new > /dev/null 2> /dev/null'
    sh -c   12.01s user 7.46s system 143% cpu 13.567 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.x86_64 -name "*.ko.xz" -exec sh -c "echo {} | find-provides.ksyms.old" \; > /dev/null 2> /dev/null'
    sh -c   16.31s user 10.77s system 134% cpu 20.092 total
    $ time sh -c 'find ./lib/modules/5.14.0-258.el9.x86_64 -name "*.ko.xz" -exec sh -c "echo {} | find-provides.ksyms.new" \; > /dev/null 2> /dev/null'
    sh -c   13.95s user 8.92s system 135% cpu 16.836 total

* find-provides.ksyms: Check presence of absolute __crc_* symbols with
"grep -q" exit code and not presence of sed output;  rewrite awk script to match
the __crc_* symbols instead of preprocessing the nm output with sed.
* find-requires.ksyms: Likewise.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Resolves: #2135047
2023-03-07 14:52:22 +01:00
Eugene Syromiatnikov
7945a35005 find-provides.ksyms: set LC_ALL=C globally
This makes the sort order a bit more predictable across various
environments and also speeds up grep/sed/sort a bit as they no longer
need to deal with non-trivial collations and multibyte sequences
that may appear when some garbage is being parsed accidentally.

* find-provides.ksyms: Add "export LC_ALL=C", remove "LC_ALL=C" from the
specific calls.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Resolves: #2135047
2023-03-07 14:52:16 +01:00
Fedora Release Engineering
c8c9d28cff Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-19 14:22:32 +00:00
Fedora Release Engineering
d3674971b2 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-21 15:52:52 +00:00
Fedora Release Engineering
5964ba5c17 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-20 14:26:11 +00:00
Miro Hrončok
29c8ac1bcc Bump kernel-rpm-macros to 205 to provide clear upgrade path 2021-11-18 20:27:22 +01:00
Miro Hrončok
e9f4351c7f Move Perl scripts back to kernel-rpm-macros to avoid Perl in the default buildroot 2021-11-18 20:14:57 +01:00
Miro Hrončok
94d61f4448 Correct conflicts to redhat-rpm-macros < 205 2021-11-18 20:13:26 +01:00
Eugene Syromiatnikov
e7874d56d5 kernel-srpm-macros.spec: bump revision 2021-11-18 17:58:15 +01:00
Eugene Syromiatnikov
a844ef825b macros.kmp: remove kernel-abi-stablelists from the dependency list 2021-11-18 17:55:06 +01:00
Eugene Syromiatnikov
fbb2188fca find-requires.ksyms: perform kABI check only on RHEL
It does not make sense to check for kABI in Fedora.

* find-requires.ksyms (os_id): New variable.
[os_id != "rhel"]: Do not call check_kabi.
2021-11-18 17:52:07 +01:00
Eugene Syromiatnikov
5785e58c40 kernel-srpm-macros.spec: add conflicts on kernel-rpm-macros < 185-9
Add conflicts of kernel-srpm-macros with kernel-rpm-macros < 185-9
as macros.kmp, kmodtool, and rpmsort were moved from the latter
to the former.

* kernel-srpm-macros.spec (Conflicts): Add kernel-rpm-macros < 185-9.
(%changelog): New entry.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
06b9df7abc kernel-srpm-macros.spec: bump the release
* kernel-srpm-macros.spec (Release): Change to 9.
(%package -n kernel-rpm-macros) <Release>: Fix the release.
(%changelog): New record.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
87a94493b5 rpmsort: update the FSF address
* rpmsort: Chnge the FSF address from "59 Temple Place, Suite 330,
Boston, MA  02111-1307  USA" to "51 Franklin Street, Fifth Floor,
Boston, MA  02110-1301 USA".

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
f218d75450 modalias.prov: stricter module aliase/version mangling
* modalias.prov: Replace everyithing that is not "0-9a-zA-Z.:"
in a kernel module version with underscores;  replace everything
that is not "][0-9a-zA-Z.:*_?/-" in a kernel module alias with
underscores.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
52ba5a74f2 modalias.prov: change interpreter to /bin/bash -efu
* modalias.prov: Chnge interpreter from "/bin/sh" to "/bin/bash" because
it uses bashisms;  add "-efu" flags to keep things in check; initialise
is_kernel_package variable; check for presence of /sbin/modinfo, sed,
and sort.
(combine_modaliases): Initialise the "variants" and "pos" variables.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
1208dd48a6 Add zstd kmod compression support
* brp-kmod-restore-perms: Add chech for "$RPM_BUILD_ROOT/$path.zst".
* find-provides.ksyms: Add "\.zst" to the kernel module path matching
regular expression; process kernel module with zstd if its file name
ends with "zst".
* find-requires.ksyms: Likewise.
* firmware.prov: Add "\.zst" to the kernel module path matching
regular expression.
* kmodtool (%post, %preun): Likewise.
* modalias.prov: Likewise.
* modalias.attr (%__modalias_path): Add "ko\.zst" to the kernel module
path matching regular expression.
* provided_ksyms.attr (%__provided_ksyms_path): Likewise.
* required_ksyms.attr (%__required_ksyms_path): Likewise.
* kmod.attr (%__kmod_path): Add ".*\.ko\.zst" to the kernel module path
matching regular expression.
(strip_compress_sfx): Strip "\.zst" suffix, if present.

Resolves: #1942537
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
39342dd4d2 Improve Provides: kernel() generation for built-in modules
After split of the kmods into a separate packages (like kernel-modules
and kernel-modules-extra), kernel() provides for the inbox kmods are generated
for incorrect package, as they were handled by kabi.sh that uses symvers
as a basis for the dependency list.  Stop using it for kmod dependencies
(but continue using it for the symbols provided by vmlinux itself) and
employ find-provides.sh for that purpose.

* kabi.sh: Filter only those symbols that are exported by vmlinux.
* find-provides.ksyms: Generate tags with the "kernel" prefix for kernel
modules inside /lib/modules/[1-9][^/]*/kernel.

Resolves: #1942563
Resolves: #1975927
Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00
Eugene Syromiatnikov
75651f97bb kernel-srpm-macros.spec: move macros for SRPM generation to kernel-srpm-macros
redhat-rpm-macros has broken kmod SRPM generation when stopped providing
in the base buildroot by moving macros.kmp to kernel-rpm-macros
and not depending on the latter due to superficial reasons.  Since
it depends on kernel-srpm-macros now, we can fix that breakage.

Resolves: #2002887
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2021-11-18 16:44:20 +01:00