From 547476297ba5e874ff485263d90b794a6b67fb7a Mon Sep 17 00:00:00 2001 From: Petr Pavlu Date: Fri, 12 Jun 2026 15:31:37 +0200 Subject: kbuild: Use --force-group-allocation when linking modules Specific code, such as outlined KASAN checks, may be placed in COMDAT-deduplicated sections. When linking modules as relocatable files, the linker by default preserves such groups, potentially leaving multiple copies in the resulting modules and unnecessary group metadata. Use --force-group-allocation to have the linker resolve the COMDAT groups and place their members as regular sections. The option is available from ld.bfd 2.29 and ld.lld 19.1.0. Remove the workaround in arch/arm64/include/asm/module.lds.h that was added for the same problem but limited to CONFIG_KASAN_SW_TAGS and .text.hot. Note that this code currently has no effect anyway because all .text.hot sections are placed in the .text output section by scripts/module.lds.S, since commit 1ba9f8979426 ("vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros"). Signed-off-by: Petr Pavlu Reviewed-by: Peter Collingbourne Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260612133139.1919042-1-petr.pavlu@suse.com [nsc: Updated patch context in arch/arm64/include/asm/module.lds.h] Signed-off-by: Nicolas Schier --- Makefile | 6 ++++++ arch/arm64/include/asm/module.lds.h | 13 ------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index b9c5792c79e0..1080fb9511c6 100644 --- a/Makefile +++ b/Makefile @@ -1222,6 +1222,12 @@ KBUILD_RUSTFLAGS += $(KRUSTFLAGS) KBUILD_LDFLAGS_MODULE += --build-id=sha1 LDFLAGS_vmlinux += --build-id=sha1 +# Specific code, such as outlined KASAN checks, may be placed in +# COMDAT-deduplicated sections. Use --force-group-allocation to resolve these +# groups when linking modules. The option is available from ld.bfd 2.29 and +# ld.lld 19.1.0. +KBUILD_LDFLAGS_MODULE += $(call ld-option,--force-group-allocation) + KBUILD_LDFLAGS += -z noexecstack ifeq ($(CONFIG_LD_IS_BFD),y) KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) diff --git a/arch/arm64/include/asm/module.lds.h b/arch/arm64/include/asm/module.lds.h index 0b3aacd22c59..603f92a8a73e 100644 --- a/arch/arm64/include/asm/module.lds.h +++ b/arch/arm64/include/asm/module.lds.h @@ -4,19 +4,6 @@ SECTIONS { .text.ftrace_trampoline 0 : { BYTE(0) } .init.text.ftrace_trampoline 0 : { BYTE(0) } -#ifdef CONFIG_KASAN_SW_TAGS - /* - * Outlined checks go into comdat-deduplicated sections named .text.hot. - * Because they are in comdats they are not combined by the linker and - * we otherwise end up with multiple sections with the same .text.hot - * name in the .ko file. The kernel module loader warns if it sees - * multiple sections with the same name so we use this sections - * directive to force them into a single section and silence the - * warning. - */ - .text.hot 0 : { *(.text.hot) } -#endif - #ifdef CONFIG_UNWIND_TABLES /* * Currently, we only use unwind info at module load time, so we can -- cgit v1.2.3 From fba1a1acb42c0bb4fd0da01faf7bbdb7cd3c979c Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Mon, 22 Jun 2026 14:26:53 +0100 Subject: kbuild: remove srctree path from CHECK output The build does not put the full kernel path in when building outputs, so do the same when the check is run to make the output more consistent. turn the following: CC arch/riscv/lib/delay.o CHECK /home/ben/linux/arch/riscv/lib/delay.c into: CC arch/riscv/lib/delay.o CHECK arch/riscv/lib/delay.c Signed-off-by: Ben Dooks Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260622132653.446868-1-ben.dooks@codethink.co.uk [nsc: Fixed typo in subject line] Signed-off-by: Nicolas Schier --- scripts/Makefile.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 911745743246..d432693e5367 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -159,10 +159,10 @@ targets += $(targets-for-builtin) $(targets-for-modules) # Linus' kernel sanity checking tool ifeq ($(KBUILD_CHECKSRC),1) - quiet_cmd_checksrc = CHECK $< + quiet_cmd_checksrc = CHECK $(patsubst $(srctree)/%,%,$<) cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< else ifeq ($(KBUILD_CHECKSRC),2) - quiet_cmd_force_checksrc = CHECK $< + quiet_cmd_force_checksrc = CHECK $(patsubst $(srctree)/%,%,$<) cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< endif -- cgit v1.2.3 From 8d905d34daa8c8512c98ba7976df080b5dd377e6 Mon Sep 17 00:00:00 2001 From: Gustavo Luiz Duarte Date: Fri, 10 Jul 2026 07:03:33 -0700 Subject: scripts: kconfig: merge_config.sh: keep temp file in the output dir merge_config.sh currently creates a temporary file in the current directory. Create it under $OUTPUT instead, which allows running the script against a read-only source tree. The default behavior is unchanged: $OUTPUT is "." so the file stays in the cwd. Reviewed-by: Breno Leitao Signed-off-by: Gustavo Luiz Duarte Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260710-merge_config_output-v2-1-8be3de601612@gmail.com Signed-off-by: Nicolas Schier --- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index f08e0863b712..ec242e03f509 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -122,7 +122,7 @@ fi MERGE_LIST=$* -TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) +TMP_FILE=$(mktemp --tmpdir="$OUTPUT" .tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base" -- cgit v1.2.3 From 9ed48de2d9c4c71c0f560e13bc71fb2c7c8defd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Tue, 30 Jun 2026 23:15:00 +0200 Subject: scripts: headers_install.sh: Normalize __ASSEMBLER__ to __ASSEMBLY__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is an ongoing effort to replace the usage of __ASSEMBLY__ with __ASSEMBLER__ throughout the kernel tree, see for example commit 287d163322b7 ("arm64: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers"). The latter is automatically provided by all compilers and preprocessors supported by the kernel, so the explicit definitions of __ASSEMBLY__ can be removed. However the UAPI headers might be used with non-GCC-compatible compilers, which do not define __ASSEMBLER__ automatically. So this migration may break users. Also during the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly and inconsistent. For now make sure that the exported UAPI headers consistently use __ASSEMBLY__ as before. Link: https://lore.kernel.org/lkml/164baf81-2824-4943-bbc1-4ae8a160c0cc@t-8ch.de/ Signed-off-by: Thomas Weißschuh Acked-by: Nick Huang Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Link: https://patch.msgid.link/20260630-uapi-assembly-v2-1-8e7bee2fe816@weissschuh.net Signed-off-by: Nicolas Schier --- scripts/headers_install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 9c15e748761c..83e447596878 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -36,6 +36,7 @@ sed -E -e ' s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @ + s/__ASSEMBLER__/__ASSEMBLY__/g ' $INFILE > $TMPFILE || exit 1 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE -- cgit v1.2.3 From 600f5de277ab8736529ec845751bef13721b211f Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 22 Jul 2026 09:29:28 +0200 Subject: scripts: headers_install.sh: Normalize __ASSEMBLY__ to __ASSEMBLER__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A previous patch to headers_install.sh normalized the usage of __ASSEMBLER__ to __ASSEMBLY__ in the UAPI headers due to two reasons: 1) There was the concern that the UAPI headers might be used with non-GCC-compatible compilers, which do not define __ASSEMBLER__ automatically. But other C compilers like PCC (see https://github.com/IanHarvey/pcc/blob/cvs2git/2018.09.20/cc/cc/cc.1#L405) and Tiny-C (see https://repo.or.cz/tinycc.git/commitdiff/a25325e9be13e52a), are defining __ASSEMBLER__ for compiling assembler files, too, so using it in UAPI header files should really be fine. 2) During the migration phase, the UAPI headers will use a mix of *both* __ASSEMBLY__ and __ASSEMBLER__ at the same time, which is ugly and inconsistent. That's true. But since we already shipped a couple of kernel versions that used __ASSEMBLER__ in the UAPI headers for certain architectures, we might now break user space programs that have been developed with these kernel versions if we switch back to __ASSEMBLY__. Thus let's better always use the macro that is defined by the compilers and standardize on __ASSEMBLER__ instead of __ASSEMBLY__ in all of the UAPI header files now. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/all/2030a963-33bc-43fe-9a2b-9c626d7d8360@redhat.com/ Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Signed-off-by: Thomas Huth Link: https://patch.msgid.link/20260722072928.24500-1-thuth@redhat.com Signed-off-by: Nicolas Schier --- scripts/headers_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 83e447596878..2f1d1767ca26 100755 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -36,7 +36,7 @@ sed -E -e ' s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @ - s/__ASSEMBLER__/__ASSEMBLY__/g + s/__ASSEMBLY__/__ASSEMBLER__/g ' $INFILE > $TMPFILE || exit 1 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE -- cgit v1.2.3 From b5baf915301851490b9f5804444d96ffd83e7644 Mon Sep 17 00:00:00 2001 From: Julian Braha Date: Tue, 4 Aug 2026 15:14:36 +0100 Subject: MAINTAINERS: add Julian Braha as Kconfig reviewer Add myself as Kconfig reviewer, as privately discussed with the Kconfig maintainers. Signed-off-by: Julian Braha Acked-by: Randy Dunlap Acked-by: Nathan Chancellor Link: https://patch.msgid.link/20260804141436.1451211-1-julianbraha@gmail.com Signed-off-by: Nicolas Schier --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 15011f5752a9..962cd0c2a963 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13951,6 +13951,7 @@ F: scripts/Makefile.kasan KCONFIG M: Nathan Chancellor M: Nicolas Schier +R: Julian Braha L: linux-kbuild@vger.kernel.org S: Odd Fixes Q: https://patchwork.kernel.org/project/linux-kbuild/list/ -- cgit v1.2.3 From a9b93c34625a27bed5dc0f80ee2a359ceb955172 Mon Sep 17 00:00:00 2001 From: Sergei Litvin Date: Tue, 14 Jul 2026 10:33:31 +0200 Subject: scripts/tags.sh: Prevent binary files appearing in cscope.files When executing the command `make COMPILED_SOURCE=1 cscope`, the resulting `cscope.files` file contains filenames with the extensions *.rlib, *.rmeta, and *.so. To fix this, modify the regular expression in the `all_compiled_sources()` function so that only files with the extensions *.h, *.c, *.S, and *.rs are accepted. The issue has been introduced by commit 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely") which implemented the parsing of compiled sources from *.cmd files instead of using the "find" command. Fixes: 4f491bb6ea2a ("scripts/tags.sh: collect compiled source precisely") Signed-off-by: Sergei Litvin Acked-by: Miguel Ojeda Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260714083331.69482-1-litvindev@gmail.com [nsc: cleaned-up commit message line breaks and removed cc trailers] Signed-off-by: Nicolas Schier --- scripts/tags.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index 243373683f98..c9dc2763a505 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -100,7 +100,7 @@ all_compiled_sources() { echo include/generated/autoconf.h find $ignore -name "*.cmd" -exec \ - grep -Poh '(?<=^ )\S+|(?<== )\S+[^\\](?=$)' {} \+ | + grep -Poh '(?<=^ )\S+\.([chS]|rs)(?=\s)|(?<== )\S+\.(?1)(?=$)' {} \+ | awk '!a[$0]++' } | xargs realpath -esq $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) | sort -u -- cgit v1.2.3 From 2ca47eed701b41c2962429c4dfe2134c49f7a1b3 Mon Sep 17 00:00:00 2001 From: Sergei Litvin Date: Tue, 14 Jul 2026 14:52:59 +0200 Subject: scripts/tags.sh: Add support for rust source files When executing the command `make cscope`, the `cscope.files` file generated by it includes only filenames with the extensions *.h, *.c, *.S and not includes filenames with *.rs extensions. To fix this, modify the functions `find_arch_sources()`, `find_arch_include_sources()`, `find_include_sources()`, and `find_other_sources()` so that they can accept an unlimited number of filename patterns as parameters for the search. Add the `setup_name_pattern()` function to convert these filename pattern parameters into a list of parameters that can be passed to the `find` utility via the new `pattern` variable. Signed-off-by: Sergei Litvin Acked-by: Miguel Ojeda Tested-by: Nicolas Schier Reviewed-by: Nicolas Schier Link: https://patch.msgid.link/20260714125259.78824-1-litvindev@gmail.com [nsc: cleaned-up commit message line breaks and removed cc trailers] Signed-off-by: Nicolas Schier --- scripts/tags.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/tags.sh b/scripts/tags.sh index c9dc2763a505..41e38df96984 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -46,13 +46,31 @@ elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then ALLSOURCE_ARCHS=$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -printf '%f ') fi +setup_name_pattern() +{ + pattern=() + for ext; do + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=("-o" "-name" "$ext") + else + pattern+=("(" "-name" "$ext") + fi + done + if [ ${#pattern[@]} -gt 0 ]; then + pattern+=(")") + fi +} + # find sources in arch/$1 find_arch_sources() { for i in $archincludedir; do local prune="$prune ( -path $i ) -prune -o" done - find ${tree}arch/$1 $ignore $prune -name "$2" -not -type l -print; + local src=${tree}arch/$1 + shift + setup_name_pattern "$@" + find $src $ignore $prune "${pattern[@]}" -not -type l -print; } # find sources in arch/$1/include @@ -61,14 +79,17 @@ find_arch_include_sources() local include=$(find ${tree}arch/$1/ -name include -type d -print); if [ -n "$include" ]; then archincludedir="$archincludedir $include" - find $include $ignore -name "$2" -not -type l -print; + shift + setup_name_pattern "$@" + find $include $ignore "${pattern[@]}" -not -type l -print; fi } # find sources in include/ find_include_sources() { - find ${tree}include $ignore -name config -prune -o -name "$1" \ + setup_name_pattern "$@" + find ${tree}include $ignore -name config -prune -o "${pattern[@]}" \ -not -type l -print; } @@ -76,23 +97,24 @@ find_include_sources() # we could benefit from a list of dirs to search in here find_other_sources() { + setup_name_pattern "$@" find ${tree}* $ignore \ \( -path ${tree}include -o -path ${tree}arch -o -name '.tmp_*' \) -prune -o \ - -name "$1" -not -type l -print; + "${pattern[@]}" -not -type l -print; } all_sources() { - find_arch_include_sources ${SRCARCH} '*.[chS]' + find_arch_include_sources ${SRCARCH} '*.[chS]' '*.rs' if [ -n "$archinclude" ]; then - find_arch_include_sources $archinclude '*.[chS]' + find_arch_include_sources $archinclude '*.[chS]' '*.rs' fi - find_include_sources '*.[chS]' + find_include_sources '*.[chS]' '*.rs' for arch in $ALLSOURCE_ARCHS do - find_arch_sources $arch '*.[chS]' + find_arch_sources $arch '*.[chS]' '*.rs' done - find_other_sources '*.[chS]' + find_other_sources '*.[chS]' '*.rs' } all_compiled_sources() -- cgit v1.2.3 From f915149f5cfbd0d4406ec0b0f57b1d2c8685ae55 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 14 Jul 2026 07:35:42 -0600 Subject: kconfig: abort rather than loop for ever on EOF When a non-interactive 'make oldconfig' or 'syncconfig' meets a new int or hex symbol whose default cannot be applied, conf_string() reads a value from stdin. At end of file fgets() returns NULL, no value is set and the loop asks again. The result is an endless loop which fills the output until it exhausts memory, rather than a clean failure. Detect this in conf_string(): if the value cannot be set and stdin is at end of file, stop with an error that names the symbol. Note that a symbol with no default doesn't trigger this, since sym_calc_value() falls back to 0, which is accepted at end of file. The loop is triggered by a broken Kconfig file, with a default whose text fails sym_string_valid(). Such mistakes do creep in from time to time and are hard to debug, since the build fills the log with repeated prompts instead of pointing at the offending symbol. Some bad defaults draw a parse-time warning, but menu_validate_number() accepts a reference to any int or hex symbol, so a cross-type reference loops with no warning at all. For example, "0xff" is not a valid int value: config HEXSYM hex default 0xff config VAL int "Value" default HEXSYM Interactive use is unaffected, since feof() only becomes true once a read actually hits end of file: an invalid answer at a terminal still re-prompts, while Ctrl-D at such a prompt exits with the error instead of looping. bool and tristate symbols and choices already accept the default on an empty line, so they still take their defaults in a non-interactive build. Tested with int and hex symbols carrying such defaults: with empty stdin, the code without this change produces around 190MB of repeated prompts within two seconds, while with the change it exits 1 naming the symbol. Piped and interactive (pty) sessions still re-prompt on an invalid answer and then accept a valid one. A new string symbol with no default still takes the empty string at end of file, since any text is valid for a string. Signed-off-by: Simon Glass Link: https://patch.msgid.link/20260714133545.3294648-1-sjg@chromium.org Signed-off-by: Nicolas Schier --- scripts/kconfig/conf.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index c368bec5ab60..fe8ba09b0039 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -348,6 +348,23 @@ static int conf_string(struct menu *menu) } if (def && sym_set_string_value(sym, def)) return 0; + + /* + * A new int or hex symbol whose default fails validation + * cannot be set from an empty answer. When standard input is + * exhausted, as it is for a non-interactive oldconfig or + * syncconfig, re-asking would loop forever and grow the output + * until it exhausts memory. Stop with an error that names the + * symbol instead. String symbols accept any text, and bool and + * tristate symbols (conf_sym()) and choices (conf_choice()) + * accept the default on an empty line, so they are unaffected. + */ + if (feof(stdin)) { + fprintf(stderr, + "\nerror: no value for new symbol '%s' at end of input\n", + sym->name); + exit(1); + } } } -- cgit v1.2.3 From 5a0eefdd3267c81add744c054bed51dfe1684e6d Mon Sep 17 00:00:00 2001 From: Martin Weiss Date: Mon, 29 Jun 2026 15:28:06 +0700 Subject: scripts: fix spelling mistakes Fix two minor typographical issues in two scripts under scripts/. Signed-off-by: Martin Weiss Reviewed-by: Nathan Chancellor Acked-by: Randy Dunlap Link: https://patch.msgid.link/20260629082812.551273-1-Martin.weiss2410@gmail.com [nsc: Added minimal commit description] Signed-off-by: Nicolas Schier --- scripts/config | 2 +- scripts/link-vmlinux.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index ea475c07de28..dfa78cfcba67 100755 --- a/scripts/config +++ b/scripts/config @@ -38,7 +38,7 @@ commands: options: --file config-file .config file to change (default .config) - --keep-case|-k Keep next symbols' case (dont' upper-case it) + --keep-case|-k Keep next symbols' case (don't upper-case it) $myname doesn't check the validity of the .config file. This is done at next make time. diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index f99e196abeea..c8f27e4175f9 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -38,7 +38,7 @@ is_enabled() { } # Nice output in kbuild format -# Will be supressed by "make -s" +# Will be suppressed by "make -s" info() { printf " %-7s %s\n" "${1}" "${2}" -- cgit v1.2.3 From 1f1b5149cfcbeced54caff9c04cf48733ec68092 Mon Sep 17 00:00:00 2001 From: Julian Braha Date: Sun, 19 Jul 2026 22:05:36 +0100 Subject: kconfig: fix minor typos in comments Some typos I noticed: 1. expressoin -> expression 2. A property represent -> A property represents Signed-off-by: Julian Braha Acked-by: Randy Dunlap Link: https://patch.msgid.link/20260719210536.9577-1-julianbraha@gmail.com Reviewed-by: Nathan Chancellor Signed-off-by: Nicolas Schier --- scripts/kconfig/expr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 5f900d18dae0..fa3823a97d72 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -38,7 +38,7 @@ union expr_data { * struct expr - expression * * @node: link node for the hash table - * @type: expressoin type + * @type: expression type * @val: calculated tristate value * @val_is_valid: indicate whether the value is valid * @left: left node @@ -160,7 +160,7 @@ struct symbol { #define SYMBOL_MAXLENGTH 256 -/* A property represent the config options that can be associated +/* A property represents the config options that can be associated * with a config "symbol". * Sample: * config FOO -- cgit v1.2.3 From 325ac6f500e71aa6830109f429ea9cf2003ae134 Mon Sep 17 00:00:00 2001 From: Elsie Heck Date: Fri, 17 Jul 2026 13:59:39 -0600 Subject: fixdep: make gendered language gender-neutral Fix awkward phrasing and change instances of gendered language to gender-neutral in code comments to improve consistency and clarity. Signed-off-by: Elsie Heck Link: https://patch.msgid.link/20260717195939.25130-1-its@elc.moe Signed-off-by: Nicolas Schier --- scripts/basic/fixdep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index cdd5da7e009b..54063d980442 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -15,13 +15,13 @@ * gcc produces a very nice and correct list of dependencies which * tells make when to remake a file. * - * To use this list as-is however has the drawback that virtually + * However, to use this list as-is has the drawback that virtually * every file in the kernel includes autoconf.h. * * If the user re-runs make *config, autoconf.h will be * regenerated. make notices that and will rebuild every file which * includes autoconf.h, i.e. basically all files. This is extremely - * annoying if the user just changed CONFIG_HIS_DRIVER from n to m. + * annoying if the user just changed CONFIG_USER_DRIVER from n to m. * * So we play the same trick that "mkdep" played before. We replace * the dependency on autoconf.h by a dependency on every config @@ -33,9 +33,9 @@ * which then let make pick up the changes and the files that use * the config symbols are rebuilt. * - * So if the user changes his CONFIG_HIS_DRIVER option, only the objects - * which depend on "include/config/HIS_DRIVER" will be rebuilt, - * so most likely only his driver ;-) + * So if the user changes their CONFIG_USER_DRIVER option, only the objects + * which depend on "include/config/USER_DRIVER" will be rebuilt, + * so most likely only the user's driver ;-) * * The idea above dates, by the way, back to Michael E Chastain, AFAIK. * -- cgit v1.2.3 From b7408f7cb264eb8d8b93c6cd84bd80cfd5865205 Mon Sep 17 00:00:00 2001 From: Bhaskar Chowdhury Date: Sat, 1 Aug 2026 03:42:11 +0530 Subject: usr: Correct a spelling by changing a letter s/dit/did/ Signed-off-by: Bhaskar Chowdhury Acked-by: Randy Dunlap Link: https://patch.msgid.link/20260731221556.3638651-2-unixbhaskar@gmail.com Signed-off-by: Nicolas Schier --- usr/initramfs_data.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/initramfs_data.S b/usr/initramfs_data.S index cd67edc38797..e92fb59b3fba 100644 --- a/usr/initramfs_data.S +++ b/usr/initramfs_data.S @@ -3,7 +3,7 @@ initramfs_data includes the compressed binary that is the filesystem used for early user space. Note: Older versions of "as" (prior to binutils 2.11.90.0.23 - released on 2001-07-14) dit not support .incbin. + released on 2001-07-14) did not support .incbin. If you are forced to use older binutils than that then the following trick can be applied to create the resulting binary: -- cgit v1.2.3 From 9a5b76027ed91680e10f90111d9cba300f96d1ab Mon Sep 17 00:00:00 2001 From: Robertus Diawan Chris Date: Wed, 24 Jun 2026 11:47:42 +0700 Subject: modpost: prevent leak when early return no suffix .o in read_symbols() The allocation for elf info symsearch and hdr from parse_elf() haven't been released when return because of modname didn't have suffix ".o". And it seems like the suffix ".o" check did not depends on parse_elf() to succeed first. So, move the suffix ".o" check before checking parse_elf() result to prevent resource leak when the modname didn't have suffix ".o" and return early. This is reported by Coverity Scan as "Resource leak". Fixes: 8c9ce89c5b63 ("modpost: simplify mod->name allocation") Signed-off-by: Robertus Diawan Chris Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260624044742.144852-1-robertusdchris@gmail.com Signed-off-by: Nicolas Schier --- scripts/mod/modpost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a7b72a81d248..da90396788dd 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1591,14 +1591,14 @@ static void read_symbols(const char *modname) struct elf_info info = { }; Elf_Sym *sym; - if (!parse_elf(&info, modname)) - return; - if (!strends(modname, ".o")) { error("%s: filename must be suffixed with .o\n", modname); return; } + if (!parse_elf(&info, modname)) + return; + /* strip trailing .o */ mod = new_module(modname, strlen(modname) - strlen(".o")); -- cgit v1.2.3 From dc4ab230d66146cd1f70e257dc773664cfb37a45 Mon Sep 17 00:00:00 2001 From: Rong Zhang Date: Wed, 22 Jul 2026 01:50:48 +0800 Subject: scripts/config: Use POSIX standard ERE (-E) in sed The use of Extended Regular Expressions was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used `-r' to enable ERE, which is indeed non-portable. However, POSIX.1-2024 [1][2] has accepted `-E' as a standard option to use ERE for matching, and major sed implementations (GNU, FreeBSD, OpenBSD, NetBSD, macOS) have supported `-E' for over two decades, so it makes no sense to use Basic Regular Expressions any more. Switch to ERE to get rid of chained calls to sed. A rough benchmark with ~1000 editions showed a 40.0% speedup (8.78s => 5.27s, GNU sed). The FreeBSD sed showed a similar speedup. Link: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html [1] Link: https://austingroupbugs.net/view.php?id=528 [2] Reviewed-by: Nicolas Schier Signed-off-by: Rong Zhang Link: https://patch.msgid.link/20260722-config-sed-v2-1-9f2c4b164666@rong.moe Signed-off-by: Nicolas Schier --- scripts/config | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/config b/scripts/config index dfa78cfcba67..6582b200967c 100755 --- a/scripts/config +++ b/scripts/config @@ -76,7 +76,7 @@ txt_append() { # sed append cmd: 'a\' + newline + text + newline cmd="$(printf "a\\%b$insert" "\n")" - sed -e "/$anchor/$cmd" "$infile" >"$tmpfile" + sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -87,7 +87,7 @@ txt_subst() { local infile="$3" local tmpfile="$infile.swp" - sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" + sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -97,7 +97,7 @@ txt_delete() { local infile="$2" local tmpfile="$infile.swp" - sed -e "/$text/d" "$infile" >"$tmpfile" + sed -E -e "/$text/d" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" } @@ -105,14 +105,12 @@ txt_delete() { set_var() { local name=$1 new=$2 before=$3 - name_re="^($name=|# $name is not set)" + name_re="^($name=.*|# $name is not set)" before_re="^($before=|# $before is not set)" if test -n "$before" && grep -Eq "$before_re" "$FN"; then - txt_append "^$before=" "$new" "$FN" - txt_append "^# $before is not set" "$new" "$FN" + txt_append "$before_re" "$new" "$FN" elif grep -Eq "$name_re" "$FN"; then - txt_subst "^$name=.*" "$new" "$FN" - txt_subst "^# $name is not set" "$new" "$FN" + txt_subst "$name_re" "$new" "$FN" else echo "$new" >>"$FN" fi @@ -121,8 +119,7 @@ set_var() { undef_var() { local name=$1 - txt_delete "^$name=" "$FN" - txt_delete "^# $name is not set" "$FN" + txt_delete "^($name=|# $name is not set)" "$FN" } FN=.config -- cgit v1.2.3 From a75c339a691be98c62ebbee26198e5720072878f Mon Sep 17 00:00:00 2001 From: Rong Zhang Date: Wed, 22 Jul 2026 01:50:49 +0800 Subject: scripts/config: Use in-place editing (-i) in sed portably The use of in-place editing was removed by commit 83e8b90e1d2c ("scripts/config: use sed's POSIX interface"). Before that, the script used bare `-i' to skip creating a backup file. In fact, major sed implementations have supported `-i' for over a decade. It's really doubtful if anyone would still build Linux on a Unix system without it. The issue is more about how we use it: FreeBSD and macOS disallow bare `-i'. To skip creating a backup, an empty string ("zero-length extension") must be passed as a separate argument following `-i'. GNU and other BSDs accept bare `-i' to skip creating a backup, but disallow passing a zero-length extension. That being said, when thinking about it optimistically, using `-i' is portable as long as a backup is created. Use in-place editing (-i) in a portable manner by creating a backup file with a .swp extension (the same name as the current temporary file). The backup file will be deleted on exit. A rough benchmark with ~1000 editions showed a 14.4% speedup (5.27s => 4.51s, GNU sed). The FreeBSD sed showed a similar speedup. Reviewed-by: Nicolas Schier Signed-off-by: Rong Zhang Link: https://patch.msgid.link/20260722-config-sed-v2-2-9f2c4b164666@rong.moe Signed-off-by: Nicolas Schier --- scripts/config | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/config b/scripts/config index 6582b200967c..32428ea909c2 100755 --- a/scripts/config +++ b/scripts/config @@ -71,35 +71,34 @@ txt_append() { local anchor="$1" local insert="$2" local infile="$3" - local tmpfile="$infile.swp" # sed append cmd: 'a\' + newline + text + newline cmd="$(printf "a\\%b$insert" "\n")" - sed -E -e "/$anchor/$cmd" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + # We don't really need a backup file, but in-place editing with backup + # skipped is not portable due to different implementations parsing + # arguments in incompatible manners. + # Create a backup file anyway to ensure portability. The file will be + # deleted on exit. + sed -E -i.swp -e "/$anchor/$cmd" "$infile" + SED_EDITED=1 } txt_subst() { local before="$1" local after="$2" local infile="$3" - local tmpfile="$infile.swp" - sed -E -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" + SED_EDITED=1 } txt_delete() { local text="$1" local infile="$2" - local tmpfile="$infile.swp" - sed -E -e "/$text/d" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" + sed -E -i.swp -e "/$text/d" "$infile" + SED_EDITED=1 } set_var() { @@ -122,6 +121,14 @@ undef_var() { txt_delete "^($name=|# $name is not set)" "$FN" } +SED_EDITED=0 +on_exit() { + if [ "$SED_EDITED" -ge 1 ]; then + rm -f "$FN.swp" + fi +} +trap on_exit EXIT + FN=.config CMDS=() while [[ $# -gt 0 ]]; do -- cgit v1.2.3 From f78f3c4c2ba6b5c2e339867ac84d0c9139f752a9 Mon Sep 17 00:00:00 2001 From: Yuntao Wang Date: Sat, 18 Jul 2026 12:01:46 +0800 Subject: kbuild: set the initial value of subdir-rustflags-y Initialize subdir-rustflags-y to an empty value to prevent it from being inadvertently affected by an environment variable of the same name. Signed-off-by: Yuntao Wang Link: https://patch.msgid.link/20260718040146.294700-1-yuntao.wang@linux.dev Signed-off-by: Nicolas Schier --- scripts/Makefile.build | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d432693e5367..a48209591dee 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -28,6 +28,7 @@ ldflags-y := subdir-asflags-y := subdir-ccflags-y := +subdir-rustflags-y := # Read auto.conf if it exists, otherwise ignore -include $(objtree)/include/config/auto.conf -- cgit v1.2.3 From 69ef27076d19297c0bf3bd22171fab8d87464a09 Mon Sep 17 00:00:00 2001 From: Yuntao Wang Date: Wed, 29 Jul 2026 15:17:37 +0800 Subject: kbuild: fix modules.builtin(.modinfo) targets in the top-level Makefile Commit 7a342e6c7735 ("kbuild: move modules.builtin(.modinfo) rules to Makefile.vmlinux_o") moved the modules.builtin(.modinfo) rules from link-vmlinux.sh to Makefile.vmlinux_o, and added the corresponding targets to the top-level Makefile. Commit 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped") later moved these rules from Makefile.vmlinux_o to Makefile.vmlinux, but left the corresponding targets in the top-level Makefile unchanged. These modules.builtin(.modinfo) targets in the top-level Makefile should be moved alongside the vmlinux target, since they are now generated by Makefile.vmlinux. However, simply removing these trivial targets might be a better choice, as it makes the Makefile cleaner and avoids the need to keep them in sync across multiple files, reducing the chance of future mistakes. Fixes: 39cfd5b12160 ("kbuild: extract modules.builtin.modinfo from vmlinux.unstripped") Signed-off-by: Yuntao Wang Reviewed-by: Nathan Chancellor Link: https://patch.msgid.link/20260729071737.818007-1-yuntao.wang@linux.dev Signed-off-by: Nicolas Schier --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1080fb9511c6..6d4d0c53605e 100644 --- a/Makefile +++ b/Makefile @@ -1353,7 +1353,7 @@ PHONY += vmlinux_o vmlinux_o: vmlinux.a $(KBUILD_VMLINUX_LIBS) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o -vmlinux.o modules.builtin.modinfo modules.builtin: vmlinux_o +vmlinux.o: vmlinux_o @: PHONY += vmlinux -- cgit v1.2.3 From d6bf11a7e8a86135193fae9908e46186796075f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Tue, 28 Jul 2026 13:42:39 +0100 Subject: kallsyms: add symbol size for kallsyms symbols that can change size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add symbol size for kallsyms symbols that can change size so that sizes can be determined easily without having to manually calculate them when inspecting the object files (.tmp_vmlinux?.kallsyms.o or .tmp_vmlinux?). Without, the assembler records the symbol size as 0. This is primarily useful as a debugging aid in case of linker errors as part of link-vmlinux.sh, and because symbol size doesn't have to align with the offset to the next symbol due to padding/alignment. Signed-off-by: André Draszik Tested-by: Nathan Chancellor Reviewed-by: Nicolas Schier Signed-off-by: Nicolas Schier --- scripts/kallsyms.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 37d5c095ad22..494852ade6d8 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -398,11 +398,13 @@ static void write_src(void) strcpy((char *)table[i]->sym, buf); printf("\t/* %s */\n", table[i]->sym); } + printf(".size kallsyms_names, . - kallsyms_names\n"); printf("\n"); output_label("kallsyms_markers"); for (i = 0; i < markers_cnt; i++) printf("\t.long\t%u\n", markers[i]); + printf(".size kallsyms_markers, . - kallsyms_markers\n"); printf("\n"); free(markers); @@ -415,6 +417,7 @@ static void write_src(void) printf("\t.asciz\t\"%s\"\n", buf); off += strlen(buf) + 1; } + printf(".size kallsyms_token_table, . - kallsyms_token_table\n"); printf("\n"); output_label("kallsyms_token_index"); @@ -441,6 +444,7 @@ static void write_src(void) (unsigned int)table[i]->addr, table[i]->sym); } } + printf(".size kallsyms_offsets, . - kallsyms_offsets\n"); printf("\n"); sort_symbols_by_name(); -- cgit v1.2.3 From 14b8b4bf2d7bd5d58c17adbeed0edfda1dfc1a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Tue, 28 Jul 2026 13:42:40 +0100 Subject: kbuild: link-vmlinux.sh: improve detection of third pass requirement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It can happen that symbol sizes within .tmp_vmlinux1.kallsyms.o and .tmp_vmlinux2.kallsyms.o differ, without affecting file size on disk because of section alignment and/or padding emitted by the assembler. link-vmlinux.sh doesn't detect this case currently and keeps using .tmp_vmlinux2.kallsyms.o to link the final vmlinux. Due to the different symbol sizes, other symbols are shifted within the final image compared to .tmp_vmlinux2, and the final comparison of System.map against "${kallsyms_sysmap}" fails with the message: Inconsistent kallsyms data Try "make KALLSYMS_EXTRA_PASS=1" as a workaround This can happen in particular if the linker emits additional symbols that might have different names between our (re-)linking steps, e.g. because those names depend on the virtual address of the symbol. Linker stubs for ARM errata work-arounds are one such case. These changed symbol names can cause the output of the token compression of kallsyms.c to change due to the changed symbol substring count, which in turn can change the size of the kallsyms_names symbol itself, causing the potential shift of subsequent symbol addresses in .tmp_vmlinux2.kallsyms.o and therefore the final image. Update link-vmlinux.sh to not rely on file size of .tmp_vmlinux?.kallsyms.o alone but to also consider symbol offsets within to resolve this, and do a third pass if required. Signed-off-by: André Draszik Tested-by: Nathan Chancellor Reviewed-by: Nicolas Schier Signed-off-by: Nicolas Schier --- scripts/link-vmlinux.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index c8f27e4175f9..ab0b8125c8cb 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -106,6 +106,18 @@ vmlinux_link() ${kallsymso} ${btf_vmlinux_bin_o} ${arch_vmlinux_o} ${ldlibs} } +# Check if kallsymso_prev and kallsymso differ +# If symbol sizes within ${kallsymso} change, any symbols within vmlinux are +# likely to shift, invalidating ${kallsymso}. +# Since file size can remain unchanged even if symbol sizes change, compare the +# actual symbols instead of relying on file size only. +kallsymso_changed() +{ + ${NM} -n "${kallsymso_prev}" > "${kallsymso_prev}.sym" + ${NM} -n "${kallsymso}" > "${kallsymso}.sym" + ! cmp -s "${kallsymso_prev}.sym" "${kallsymso}.sym" +} + # Create ${2}.o file with all symbols from the ${1} object file kallsyms() { @@ -126,6 +138,7 @@ kallsyms() ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \ ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S" + kallsymso_prev="${kallsymso:-}" kallsymso=${2}.o } @@ -255,7 +268,12 @@ if is_enabled CONFIG_KALLSYMS; then sysmap_and_kallsyms .tmp_vmlinux2 size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso}) - if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then + # Due to alignment, file size of the kallsymso object file might remain + # unchanged even if individual symbols within change size. Changed + # symbol sizes can still shift other symbols, though. Therefore, don't + # rely on file size alone. + if [ $size1 -ne $size2 ] || kallsymso_changed || \ + [ -n "${KALLSYMS_EXTRA_PASS}" ]; then vmlinux_link .tmp_vmlinux3 sysmap_and_kallsyms .tmp_vmlinux3 fi -- cgit v1.2.3 From 35e4b60792cd45d57c3af00f67bb5bf9ae4243e9 Mon Sep 17 00:00:00 2001 From: Julian Braha Date: Sat, 1 Aug 2026 15:52:38 +0100 Subject: kconfig: fix submenu rendering of negative dependencies The Kconfig frontend should render options that depend on a previous option in the submenu of that previous option. But currently, this breaks for negative dependencies. For example, option FOO may be rendered in the submenu of option BAR, despite FOO actually depending on !BAR. Let's fix this ironic rendering by modifying Kconfig to explicitly check negative dependencies. I've only tested locally on x86, but as far as I can tell, this only changes how 2 options are rendered in the menu: 1. NTFS3_FS, no longer in the NTFS_FS submenu, and 2. MTD_BLOCK_RO, no longer in the MTD_BLOCK submenu. Tested-by: Nathan Chancellor Reported-by: Xi Ruoyao Closes: https://lore.kernel.org/all/cbe95c15d2760f6fce8eaf207c969ce8fd3703aa.camel@xry111.site/ Assisted-by: Claude:claude-4.8-opus Signed-off-by: Julian Braha Link: https://patch.msgid.link/20260801145238.2140291-1-julianbraha@gmail.com Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Signed-off-by: Nicolas Schier --- scripts/kconfig/expr.c | 33 +++++++++++++++++++++++++++++++++ scripts/kconfig/expr.h | 1 + scripts/kconfig/menu.c | 10 ++++++++++ 3 files changed, 44 insertions(+) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 16f92c4a775a..2b91d16bf14f 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -738,6 +738,39 @@ bool expr_contains_symbol(struct expr *dep, struct symbol *sym) return false; } +/* + * Check if the expression references 'sym' in a way that is satisfiable + * with 'sym' disabled, e.g.'sym!=y'. + * + * Expects that expr_transform() was already called on 'expr'. + */ +bool expr_contains_symbol_negated(struct expr *dep, struct symbol *sym) +{ + if (!dep) + return false; + + switch (dep->type) { + case E_AND: + case E_OR: + return expr_contains_symbol_negated(dep->left.expr, sym) || + expr_contains_symbol_negated(dep->right.expr, sym); + case E_NOT: + return dep->left.expr->type == E_SYMBOL && + dep->left.expr->left.sym == sym; + case E_EQUAL: + /* sym=n */ + return dep->left.sym == sym && dep->right.sym == &symbol_no; + case E_UNEQUAL: + /* sym!=y, sym!=m */ + return dep->left.sym == sym && + (dep->right.sym == &symbol_yes || + dep->right.sym == &symbol_mod); + default: + break; + } + return false; +} + bool expr_depends_symbol(struct expr *dep, struct symbol *sym) { if (!dep) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index fa3823a97d72..b580f9fa0f29 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -307,6 +307,7 @@ tristate expr_calc_value(struct expr *e); struct expr *expr_eliminate_dups(struct expr *e); struct expr *expr_transform(struct expr *e); bool expr_contains_symbol(struct expr *dep, struct symbol *sym); +bool expr_contains_symbol_negated(struct expr *dep, struct symbol *sym); bool expr_depends_symbol(struct expr *dep, struct symbol *sym); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index b2d8d4e11e07..9c079e92a9ed 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -428,9 +428,19 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) if (!expr_contains_symbol(dep, sym)) /* No dependency, quit */ break; + /* + * Note that it's actually possible to depend on both + * 'SYM!=y' and 'SYM=y', so we need to first check if + * it's a positive dependency before checking if it's + * a negative dependency. See example: + * 'SFC && MTD && !(SFC=y && MTD=m)' + */ if (expr_depends_symbol(dep, sym)) /* Absolute dependency, put in submenu */ goto next; + if (expr_contains_symbol_negated(dep, sym)) + /* Negative dependency, quit */ + break; /* * Also consider it a dependency on sym if our -- cgit v1.2.3 From a765d3c6cd88696fd233b9596b721400c6b25396 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 7 Aug 2026 19:29:40 +0300 Subject: modpost: add module as parameter to modpost_log() modpost has a lot of error logging with module name, but the module name is logged in a plethora of ways. Add struct module * parameter to modpost_log(), and wrappers mod_warn() and mod_error(), to allow logging with a unified module name, if provided. If the module is provided, the messages will be of the format: (ERROR|WARNING): modpost: (modname.ko|vmlinux): message Actual conversion is done separately. Signed-off-by: Jani Nikula Link: https://patch.msgid.link/f27bd8810f0ef12fb86068f0190e4e0afa81e0fa.1786120005.git.jani.nikula@intel.com Reviewed-by: Nathan Chancellor Reviewed-by: Nicolas Schier Signed-off-by: Nicolas Schier --- scripts/mod/modpost.c | 12 +++++++++--- scripts/mod/modpost.h | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index da90396788dd..8a4b4f68c13f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -74,7 +74,7 @@ static unsigned int nr_unresolved; #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) -void modpost_log(bool is_error, const char *fmt, ...) +void modpost_log(bool is_error, struct module *mod, const char *fmt, ...) { va_list arglist; @@ -87,11 +87,17 @@ void modpost_log(bool is_error, const char *fmt, ...) fprintf(stderr, "modpost: "); + if (mod) + fprintf(stderr, "%s%s: ", mod->name, mod->is_vmlinux ? "" : ".ko"); + va_start(arglist, fmt); vfprintf(stderr, fmt, arglist); va_end(arglist); } +#define mod_warn(mod, fmt, args...) modpost_log(false, mod, fmt, ##args) +#define mod_error(mod, fmt, args...) modpost_log(true, mod, fmt, ##args) + static inline bool strends(const char *str, const char *postfix) { if (strlen(str) < strlen(postfix)) @@ -1772,7 +1778,7 @@ static void check_exports(struct module *mod) exp = find_symbol(s->name); if (!exp) { if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) - modpost_log(!warn_unresolved, + modpost_log(!warn_unresolved, NULL, "\"%s\" [%s.ko] undefined!\n", s->name, mod->name); continue; @@ -1792,7 +1798,7 @@ static void check_exports(struct module *mod) if (!verify_module_namespace(exp->namespace, basename) && !contains_namespace(&mod->imported_namespaces, exp->namespace)) { - modpost_log(!allow_missing_ns_imports, + modpost_log(!allow_missing_ns_imports, NULL, "module %s uses symbol %s from namespace %s, but does not import it.\n", basename, exp->name, exp->namespace); add_namespace(&mod->missing_namespaces, exp->namespace); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 2aecb8f25c87..d5f6d82837d5 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -223,8 +223,8 @@ char *read_text_file(const char *filename); char *get_line(char **stringp); void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym); -void __attribute__((format(printf, 2, 3))) -modpost_log(bool is_error, const char *fmt, ...); +void __attribute__((format(printf, 3, 4))) +modpost_log(bool is_error, struct module *mod, const char *fmt, ...); /* * warn - show the given message, then let modpost continue running, still @@ -239,6 +239,6 @@ modpost_log(bool is_error, const char *fmt, ...); * fatal - show the given message, and bail out immediately. This should be * used when there is no point to continue running modpost. */ -#define warn(fmt, args...) modpost_log(false, fmt, ##args) -#define error(fmt, args...) modpost_log(true, fmt, ##args) +#define warn(fmt, args...) modpost_log(false, NULL, fmt, ##args) +#define error(fmt, args...) modpost_log(true, NULL, fmt, ##args) #define fatal(fmt, args...) do { error(fmt, ##args); exit(1); } while (1) -- cgit v1.2.3 From d900723d78adec229996aefbab0dcaa66a177b77 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 7 Aug 2026 19:29:41 +0300 Subject: modpost: use mod_warn() and mod_error(), clean up logging Convert all module name logging to use the mod_warn() and mod_error() helpers, and pass the module to modpost_log() where used directly, to always have the module name prefixed in the log message, with .ko suffix for modules. Pass struct module *mod around in a few places instead of just mod->name. Further unify the logging while at it. Use single quotes instead of double quotes for symbols, sections, and namespaces. Explicitly state it's a "symbol" when referencing symbols. Signed-off-by: Jani Nikula Link: https://patch.msgid.link/17ed1bce5d54fb32533ba83bc83c429cb71adcb0.1786120005.git.jani.nikula@intel.com Reviewed-by: Nicolas Schier Reviewed-by: Nathan Chancellor Signed-off-by: Nicolas Schier --- scripts/mod/modpost.c | 104 ++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8a4b4f68c13f..b06c59d03ef7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -365,9 +365,8 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, struct symbol *s = find_symbol(name); if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) { - error("%s: '%s' exported twice. Previous export was in %s%s\n", - mod->name, name, s->module->name, - s->module->is_vmlinux ? "" : ".ko"); + mod_error(mod, "symbol '%s' exported twice. Previous export was in %s%s\n", + name, s->module->name, s->module->is_vmlinux ? "" : ".ko"); } s = alloc_symbol(name); @@ -638,7 +637,7 @@ static void handle_symbol(struct module *mod, struct elf_info *info, if (strstarts(symname, "__gnu_lto_")) { /* Should warn here, but modpost runs before the linker */ } else - warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); + mod_warn(mod, "'%s' is COMMON symbol\n", symname); break; case SHN_UNDEF: /* undefined symbol */ @@ -781,7 +780,7 @@ static const char *const section_white_list[] = * The cause of this is often a section specified in assembler * without "ax" / "aw". */ -static void check_section(const char *modname, struct elf_info *elf, +static void check_section(struct module *mod, struct elf_info *elf, Elf_Shdr *sechdr) { const char *sec = sech_name(elf, sechdr); @@ -789,11 +788,11 @@ static void check_section(const char *modname, struct elf_info *elf, if (sechdr->sh_type == SHT_PROGBITS && !(sechdr->sh_flags & SHF_ALLOC) && !match(sec, section_white_list)) { - warn("%s (%s): unexpected non-allocatable section.\n" - "Did you forget to use \"ax\"/\"aw\" in a .S file?\n" - "Note that for example contains\n" - "section definitions for use in .S files.\n\n", - modname, sec); + mod_warn(mod, "unexpected non-allocatable section '%s'.\n" + "Did you forget to use \"ax\"/\"aw\" in a .S file?\n" + "Note that for example contains\n" + "section definitions for use in .S files.\n\n", + sec); } } @@ -1027,7 +1026,7 @@ static bool is_executable_section(struct elf_info *elf, unsigned int secndx) return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0; } -static void default_mismatch_handler(const char *modname, struct elf_info *elf, +static void default_mismatch_handler(struct module *mod, struct elf_info *elf, const struct sectioncheck* const mismatch, Elf_Sym *tsym, unsigned int fsecndx, const char *fromsec, Elf_Addr faddr, @@ -1057,10 +1056,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, * The format for the reference source: + or
* The format for the reference destination: or
*/ - warn("%s: section mismatch in reference: %s%s0x%x (section: %s) -> %s (section: %s)\n", - modname, fromsym, fromsym[0] ? "+" : "", - (unsigned int)(faddr - (fromsym[0] ? from->st_value : 0)), - fromsec, tosym[0] ? tosym : taddr_str, tosec); + mod_warn(mod, "section mismatch in reference: %s%s0x%x (section: %s) -> %s (section: %s)\n", + fromsym, fromsym[0] ? "+" : "", + (unsigned int)(faddr - (fromsym[0] ? from->st_value : 0)), + fromsec, tosym[0] ? tosym : taddr_str, tosec); if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) { if (match(tosec, mismatch->bad_tosec)) @@ -1069,7 +1068,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, "Something is seriously wrong and should be fixed.\n" "You might get more information about where this is\n" "coming from by using scripts/check_extable.sh %s\n", - fromsec, (long)faddr, tosec, modname); + fromsec, (long)faddr, tosec, mod->name); else if (is_executable_section(elf, get_secindex(elf, tsym))) warn("The relocation at %s+0x%lx references\n" "section \"%s\" which is not in the list of\n" @@ -1099,22 +1098,22 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf, label_name = sym_name(elf, label); if (!strstarts(label_name, prefix)) { - error("%s: .export_symbol section contains strange symbol '%s'\n", - mod->name, label_name); + mod_error(mod, ".export_symbol section contains strange symbol '%s'\n", + label_name); return; } if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && ELF_ST_BIND(sym->st_info) != STB_WEAK) { - error("%s: local symbol '%s' was exported\n", mod->name, - label_name + strlen(prefix)); + mod_error(mod, "local symbol '%s' was exported\n", + label_name + strlen(prefix)); return; } name = sym_name(elf, sym); if (strcmp(label_name + strlen(prefix), name)) { - error("%s: .export_symbol section references '%s', but it does not seem to be an export symbol\n", - mod->name, name); + mod_error(mod, ".export_symbol section references '%s', but it does not seem to be an export symbol\n", + name); return; } @@ -1124,8 +1123,8 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf, } else if (!strcmp(data, "")) { is_gpl = false; } else { - error("%s: unknown license '%s' was specified for '%s'\n", - mod->name, data, name); + mod_error(mod, "unknown license '%s' was specified for '%s'\n", + data, name); return; } @@ -1148,11 +1147,11 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf, s->is_func = true; if (match(secname, PATTERNS(ALL_INIT_SECTIONS))) - warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n", - mod->name, name); + mod_warn(mod, "EXPORT_SYMBOL used for init symbol '%s'. Remove __init or EXPORT_SYMBOL.\n", + name); else if (match(secname, PATTERNS(ALL_EXIT_SECTIONS))) - warn("%s: %s: EXPORT_SYMBOL used for exit symbol. Remove __exit or EXPORT_SYMBOL.\n", - mod->name, name); + mod_warn(mod, "EXPORT_SYMBOL used for exit symbol '%s'. Remove __exit or EXPORT_SYMBOL.\n", + name); } static void check_section_mismatch(struct module *mod, struct elf_info *elf, @@ -1172,7 +1171,7 @@ static void check_section_mismatch(struct module *mod, struct elf_info *elf, if (!mismatch) return; - default_mismatch_handler(mod->name, elf, mismatch, sym, + default_mismatch_handler(mod, elf, mismatch, sym, fsecndx, fromsec, faddr, tosec, taddr); } @@ -1449,7 +1448,7 @@ static void check_sec_ref(struct module *mod, struct elf_info *elf) for (i = 0; i < elf->num_sections; i++) { Elf_Shdr *sechdr = &elf->sechdrs[i]; - check_section(mod->name, elf, sechdr); + check_section(mod, elf, sechdr); /* We want to process only relocation sections and not .init */ if (sechdr->sh_type == SHT_REL || sechdr->sh_type == SHT_RELA) { /* section to which the relocation applies */ @@ -1619,7 +1618,7 @@ static void read_symbols(const char *modname) if (!mod->is_vmlinux) { license = get_modinfo(&info, "license"); if (!license) - error("missing MODULE_LICENSE() in %s\n", modname); + mod_error(mod, "missing MODULE_LICENSE()\n"); while (license) { if (!license_is_gpl_compatible(license)) { mod->is_gpl_compatible = false; @@ -1632,14 +1631,14 @@ static void read_symbols(const char *modname) namespace; namespace = get_next_modinfo(&info, "import_ns", namespace)) { if (strstarts(namespace, MODULE_NS_PREFIX)) - error("%s: explicitly importing namespace \"%s\" is not allowed.\n", - mod->name, namespace); + mod_error(mod, "explicitly importing namespace '%s' is not allowed.\n", + namespace); add_namespace(&mod->imported_namespaces, namespace); } if (!get_modinfo(&info, "description")) - warn("missing MODULE_DESCRIPTION() in %s\n", modname); + mod_warn(mod, "missing MODULE_DESCRIPTION()\n"); } for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { @@ -1778,14 +1777,13 @@ static void check_exports(struct module *mod) exp = find_symbol(s->name); if (!exp) { if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) - modpost_log(!warn_unresolved, NULL, - "\"%s\" [%s.ko] undefined!\n", - s->name, mod->name); + modpost_log(!warn_unresolved, mod, + "symbol '%s' undefined!\n", + s->name); continue; } if (exp->module == mod) { - error("\"%s\" [%s.ko] was exported without definition\n", - s->name, mod->name); + mod_error(mod, "symbol '%s' was exported without definition\n", s->name); continue; } @@ -1798,15 +1796,15 @@ static void check_exports(struct module *mod) if (!verify_module_namespace(exp->namespace, basename) && !contains_namespace(&mod->imported_namespaces, exp->namespace)) { - modpost_log(!allow_missing_ns_imports, NULL, - "module %s uses symbol %s from namespace %s, but does not import it.\n", - basename, exp->name, exp->namespace); + modpost_log(!allow_missing_ns_imports, mod, + "module uses symbol '%s' from namespace '%s', but does not import it.\n", + exp->name, exp->namespace); add_namespace(&mod->missing_namespaces, exp->namespace); } if (!mod->is_gpl_compatible && exp->is_gpl_only) - error("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", - basename, exp->name); + mod_error(mod, "GPL-incompatible module uses GPL-only symbol '%s'\n", + exp->name); } } @@ -1856,7 +1854,7 @@ static void check_modname_len(struct module *mod) mod_name = get_basename(mod->name); if (strlen(mod_name) >= MODULE_NAME_LEN) - error("module name is too long [%s.ko]\n", mod->name); + mod_error(mod, "module name is too long\n"); } /** @@ -1920,10 +1918,9 @@ static void add_exported_symbols(struct buffer *buf, struct module *mod) continue; if (!sym->crc_valid) - warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n" - "Is \"%s\" prototyped in ?\n", - sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", - sym->name); + mod_warn(mod, "EXPORT symbol '%s' version generation failed, symbol will not be versioned.\n" + "Is '%s' prototyped in ?\n", + sym->name, sym->name); buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x);\n", sym->name, sym->crc); @@ -1947,8 +1944,7 @@ static void add_extended_versions(struct buffer *b, struct module *mod) if (!s->module) continue; if (!s->crc_valid) { - warn("\"%s\" [%s.ko] has no CRC!\n", - s->name, mod->name); + mod_warn(mod, "symbol '%s' has no CRC!\n", s->name); continue; } buf_printf(b, "\t0x%08x,\n", s->crc); @@ -1991,8 +1987,7 @@ static void add_versions(struct buffer *b, struct module *mod) if (!s->module) continue; if (!s->crc_valid) { - warn("\"%s\" [%s.ko] has no CRC!\n", - s->name, mod->name); + mod_warn(mod, "symbol '%s' has no CRC!\n", s->name); continue; } if (strlen(s->name) >= MODULE_NAME_LEN) { @@ -2000,8 +1995,7 @@ static void add_versions(struct buffer *b, struct module *mod) /* this symbol will only be in the extended info */ continue; } else { - error("too long symbol \"%s\" [%s.ko]\n", - s->name, mod->name); + mod_error(mod, "too long symbol '%s'\n", s->name); break; } } -- cgit v1.2.3