fixdep: suppress consecutive / from file paths in dependency list filesUnderscores in symbol names are translated into slashes for path names.Filesystems treat consecutive slashes as if there was
fixdep: suppress consecutive / from file paths in dependency list filesUnderscores in symbol names are translated into slashes for path names.Filesystems treat consecutive slashes as if there was only one, solet's do the same in the dependency list for easier grepping, etc.Signed-off-by: Nicolas Pitre <nico@linaro.org>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
show more ...
kbuild: move include/config/ksym/* to include/ksym/*The idea of using fixdep was inspired by Kconfig, but autoksymsbelongs to a different group. So, I want to move those touchedfiles under inclu
kbuild: move include/config/ksym/* to include/ksym/*The idea of using fixdep was inspired by Kconfig, but autoksymsbelongs to a different group. So, I want to move those touchedfiles under include/config/ksym/ to include/ksym/.The directory include/ksym/ can be removed by 'make clean' becauseit is meaningless for the external module building.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>Acked-by: Nicolas Pitre <nico@linaro.org>
fixdep: do not ignore kconfig.hkconfig.h was excluded from consideration by fixdep by6a5be57f0f00 (fixdep: fix extraneous dependencies) to avoid some falsepositive hits(1) include/config/.h(2)
fixdep: do not ignore kconfig.hkconfig.h was excluded from consideration by fixdep by6a5be57f0f00 (fixdep: fix extraneous dependencies) to avoid some falsepositive hits(1) include/config/.h(2) include/config/h.h(3) include/config/foo.h(1) occurred because kconfig.h contains the string CONFIG_ in acomment. However, since dee81e988674 (fixdep: faster CONFIG_ search), wehave a check that the part after CONFIG_ is non-empty, so this does nothappen anymore (and CONFIG_ appears by itself elsewhere, so that checkis worthwhile).(2) comes from the include guard, __LINUX_KCONFIG_H. But with theprevious patch, we no longer match that either.That leaves (3), which amounts to one [1] false dependency (aka stat() calldone by make), which I think we can live with:We've already had one case [2] where the lack of include/linux/kconfig.h inthe .o.cmd file caused a missing rebuild, and while I originally thoughtwe should just put kconfig.h in the dependency list without parsing itfor the CONFIG_ pattern, we actually do have some real CONFIG_ symbolsmentioned in it, and one can imagine some translation unit that justdoes '#ifdef __BIG_ENDIAN' but doesn't through some other headeractually depend on CONFIG_CPU_BIG_ENDIAN - so changing the targetendianness could end up rebuilding the world, minus that smallTU. Quoting Linus, ... when missing dependencies cause a missed re-compile, the resulting bugs can be _really_ subtle.[1] well, two, we now also have CONFIG_BOOGER/booger.h - we could changethat to FOO if we care[2] https://lkml.org/lkml/2018/2/22/838Cc: Linus Torvalds <torvalds@linux-foundation.org>Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: remove some false CONFIG_ matchesThe string CONFIG_ quite often appears after other alphanumerics,meaning that that instance cannot be referencing a Kconfigsymbol. Omitting these means ma
fixdep: remove some false CONFIG_ matchesThe string CONFIG_ quite often appears after other alphanumerics,meaning that that instance cannot be referencing a Kconfigsymbol. Omitting these means make has fewer files to stat() whendeciding what needs to be rebuilt - for a defconfig build, this seems toremove about 2% of the (wildcard ...) lines from the .o.cmd files.Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: remove stale references to uml-config.huml-config.h hasn't existed in this decade (87e299e5c750 - x86, um: getrid of uml-config.h). The few remaining UML_CONFIG instances are defineddirec
fixdep: remove stale references to uml-config.huml-config.h hasn't existed in this decade (87e299e5c750 - x86, um: getrid of uml-config.h). The few remaining UML_CONFIG instances are defineddirectly in terms of their real CONFIG symbol in common-offsets.h, sounlike when the symbols got defined via a sed script, anything that usesUML_CONFIG_FOO now should also automatically pick up a dependency onCONFIG_FOO via the normal fixdep mechanism (since common-offsets.hshould at least recursively be a dependency). Hence I believe we shouldactually be able to ignore the HELLO_CONFIG_BOOM cases.Cc: Al Viro <viro@zeniv.linux.org.uk>Cc: Richard Weinberger <richard@nod.at>Cc: user-mode-linux-devel@lists.sourceforge.netSigned-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: use existing helper to check modular CONFIG optionsstr_ends_with() tests if the given token ends with a particular string.Currently, it is used to check file paths without $(srctree).Act
fixdep: use existing helper to check modular CONFIG optionsstr_ends_with() tests if the given token ends with a particular string.Currently, it is used to check file paths without $(srctree).Actually, we have one more place where this helper is useful. Use itto check if CONFIG option ends with _MODULE.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: refactor parse_dep_file()parse_dep_file() has too much indentation, and puts the code far tothe right. This commit refactors the code and reduces the one levelof indentation.strrcmp()
fixdep: refactor parse_dep_file()parse_dep_file() has too much indentation, and puts the code far tothe right. This commit refactors the code and reduces the one levelof indentation.strrcmp() computes 'slen' by itself, but the caller already knows thelength of the token, so 'slen' can be passed via function argument.With this, we can swap the order of strrcmp() and "*p = \0;"Also, strrcmp() is an ambiguous function name. Flip the logic andrename it to str_ends_with().I added a new helper is_ignored_file() - this returns 1 if the tokenrepresents a file that should be ignored.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: move global variables to local variables of main()I do not mind global variables where they are useful enough. In thiscase, I do not see a good reason to use global variables since theya
fixdep: move global variables to local variables of main()I do not mind global variables where they are useful enough. In thiscase, I do not see a good reason to use global variables since theyare just referenced in shallow places. It is easy to pass them viafunction arguments.I squashed print_cmdline() into main() since it is just one line code.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: remove unneeded memcpy() in parse_dep_file()Each token in the depfile is copied to the temporary buffer 's' toterminate the token with zero. We do not need to do this any morebecause the
fixdep: remove unneeded memcpy() in parse_dep_file()Each token in the depfile is copied to the temporary buffer 's' toterminate the token with zero. We do not need to do this any morebecause the parsed buffer is now writable. Insert '\0' directly inthe buffer without calling memcpy().<limits.h> is no longer necessary. (It was needed for PATH_MAX).Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: factor out common code for reading filesNow, do_config_files() and print_deps() are almost the same. Onlythe difference is the parser function called (parse_config_file vsparse_dep_file)
fixdep: factor out common code for reading filesNow, do_config_files() and print_deps() are almost the same. Onlythe difference is the parser function called (parse_config_file vsparse_dep_file).We can reduce the code duplication by factoring out the common codeinto read_file() - this function allocates a buffer and loads a fileto it. It returns the pointer to the allocated buffer. (As before,it bails out by exit(2) for any error.) The caller must free thebuffer when done.Having empty source files is possible; fixdep should simply skip them.I deleted the "st.st_size == 0" check, so read_file() allocates 1-bytebuffer for an empty file. strstr() will immediately return NULL, andthis is what we expect.On the other hand, an empty dep_file should be treated as an error.In this case, parse_dep_file() will error out with "no targets found"and it is a correct error message.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: use malloc() and read() to load dep_file to bufferCommit dee81e988674 ("fixdep: faster CONFIG_ search") changed how toread files in which CONFIG options are searched. It used malloc()and
fixdep: use malloc() and read() to load dep_file to bufferCommit dee81e988674 ("fixdep: faster CONFIG_ search") changed how toread files in which CONFIG options are searched. It used malloc()and read() instead of mmap() because it needed to zero-terminate thebuffer in order to use strstr(). print_deps() was left untouchedsince there was no reason to change it.Now, I have two motivations to change it in the same way. - do_config_file() and print_deps() do quite similar things; they open a file, load it onto memory, and pass it to a parser function. If we use malloc() and read() for print_deps() too, we can factor out the common code. (I will do this in the next commit.) - parse_dep_file() copies each token to a temporary buffer because it needs to zero-terminate it to be passed to printf(). It is not possible to modify the buffer directly because it is mmap'ed with O_RDONLY. If we load the file content into a malloc'ed buffer, we can insert '\0' after each token, and save memcpy(). (I will do this in the commit after next.)Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: remove unnecessary <arpa/inet.h> inclusion<arpa/inet.h> was included for ntohl(), but it was removed bycommit dee81e988674 ("fixdep: faster CONFIG_ search").Signed-off-by: Masahiro Yamad
fixdep: remove unnecessary <arpa/inet.h> inclusion<arpa/inet.h> was included for ntohl(), but it was removed bycommit dee81e988674 ("fixdep: faster CONFIG_ search").Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: exit with error code in error branches of do_config_file()do_config_file() should exit with an error code on internal run-timeerrors, and not return if it fails as then the error in do_con
fixdep: exit with error code in error branches of do_config_file()do_config_file() should exit with an error code on internal run-timeerrors, and not return if it fails as then the error in do_config_file()would go unnoticed in the current code and allow the build to continue.The exit with error code will make the build fail in those veryexceptional cases. If this occurs, this actually indicates a deeperproblem in the execution of the kernel build process.Now, in these error cases, we do not explicitly free memory and closethe file handlers in do_config_file(), as this is covered by exit().This issue in the fixdep script was introduced with its initialimplementation back in 2002 by the original author Kai Germaschewski withthis commit 04bd72170653 ("kbuild: Make dependencies at compile time")in the linux history git tree, i.e.,git://git.kernel.org/pub/scm/linux/kernel/git/history/history.git.This issue was identified during the review of a previous patch thatintended to address a memory leak detected by a static analysis tool.Link: https://lkml.org/lkml/2017/12/14/736Suggested-by: Nicholas Mc Guire <der.herr@hofr.at>Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: trivial: typo fix and correctionSigned-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
kbuild: trivial cleanups on the commentsThis is a bunch of trivial fixes and cleanups.Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.c
kbuild: trivial cleanups on the commentsThis is a bunch of trivial fixes and cleanups.Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
fixdep: faster CONFIG_ searchDo you think kernel build is 100% dominated by gcc? You are wrong!One small utility called "fixdep" consistently manages to sneak intoprofile's first page (unless you
fixdep: faster CONFIG_ searchDo you think kernel build is 100% dominated by gcc? You are wrong!One small utility called "fixdep" consistently manages to sneak intoprofile's first page (unless you have small monitor of course).The choke point is this clever code: for (; m < end; m++) { if (*m == INT_CONF) { p = (char *) m ; goto conf; } if (*m == INT_ONFI) { p = (char *) m-1; goto conf; } if (*m == INT_NFIG) { p = (char *) m-2; goto conf; } if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }4 branches per 4 characters is not fast.Use strstr(3), so that SSE2 etc can be used.With this patch, fixdep is so deep at the bottom, it is hard to find it.Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>Signed-off-by: Michal Marek <mmarek@suse.com>
scripts: Fix size mismatch of kexec_purgatory_sizebin2c is used to create a valid C file out of a binary file where twosymbols will be globally defined: <name> and <name>_size. <name> ispassed as
scripts: Fix size mismatch of kexec_purgatory_sizebin2c is used to create a valid C file out of a binary file where twosymbols will be globally defined: <name> and <name>_size. <name> ispassed as the first parameter of the host binary.Building using goto-cc reported that the purgatory binary code (the onlycurrent user of this utility) declares kexec_purgatory_size as 'size_t'where bin2c generate <name>_size to be 'int' so in a 64-bit host wheresizeof(size_t) > sizeof(int) this type mismatch will always yield thewrong value for big-endian architectures while for little-endian it willbe wrong if the object laid in memory directly afterkexec_purgatory_size contains non-zero value at the time of reading.This commit changes <name>_size to be size_t instead.Note:Another way to fix the problem is to change the type ofkexec_purgatory_size to be 'int' as there's this check in code:(kexec_purgatory_size <= 0)Signed-off-by: Michael Tautschnig <tautschn@amazon.com>Cc: Vivek Goyal <vgoyal@redhat.com>Acked-by: Dave Young <dyoung@redhat.com>Signed-off-by: Michal Marek <mmarek@suse.com>
kbuild: add fine grained build dependencies for exported symbolsLike with kconfig options, we now have the ability to compile in andout individual EXPORT_SYMBOL() declarations based on the content
kbuild: add fine grained build dependencies for exported symbolsLike with kconfig options, we now have the ability to compile in andout individual EXPORT_SYMBOL() declarations based on the content ofinclude/generated/autoksyms.h. However we don't want the entireworld to be rebuilt whenever that file is touched.Let's apply the same build dependency trick used for CONFIG_* symbolswhere the time stamp of empty files whose paths matching those symbolsis used to trigger fine grained rebuilds. In our case the key is thesymbol name passed to EXPORT_SYMBOL().However, unlike config options, we cannot just use fixdep to parsethe source code for EXPORT_SYMBOL(ksym) because several variants existand parsing them all in a separate tool, and keeping it in synch, isnot trivially maintainable. Furthermore, there are variants such as EXPORT_SYMBOL_GPL(pci_user_read_config_##size);that are instanciated via a macro for which we can't easily determinethe actual exported symbol name(s) short of actually running thepreprocessor on them.Storing the symbol name string in a special ELF section doesn't workfor targets that output assembly or preprocessed source.So the best way is really to leverage the preprocessor by having itoutput actual symbol names anchored by a special sequence that can beeasily filtered out. Then the list of symbols is simply fed to fixdepto be merged with the other dependencies.That implies the preprocessor is executed twice for each source file.A previous attempt relied on a warning pragma for each EXPORT_SYMBOL()instance that was filtered apart from stderr by the build system witha sed script during the actual compilation pass. Unfortunately thepreprocessor/compiler diagnostic output isn't stable between versionsand this solution, although more efficient, was deemed too fragile.Because of the lowercasing performed by fixdep, there might be namecollisions triggering spurious rebuilds for similar symbols. But thisshouldn't be a big issue in practice. (This is the case for CONFIG_*symbols and I didn't want to be different here, whatever the originalreason for doing so.)To avoid needless build overhead, the exported symbol name gathering isperformed only when CONFIG_TRIM_UNUSED_KSYMS is selected.Signed-off-by: Nicolas Pitre <nico@linaro.org>Acked-by: Rusty Russell <rusty@rustcorp.com.au>
fixdep: accept extra dependencies on stdin... and merge them in the list of parsed dependencies.Signed-off-by: Nicolas Pitre <nico@linaro.org>
kbuild: fixdep: Check fstat(2) return valueCoverity has recently added a check that will find when we don't checkthe return code from fstat(2). Copy/paste the checking logic thatprint_deps() has
kbuild: fixdep: Check fstat(2) return valueCoverity has recently added a check that will find when we don't checkthe return code from fstat(2). Copy/paste the checking logic thatprint_deps() has with an appropriate re-wording of the perror() message.Signed-off-by: Tom Rini <trini@konsulko.com>Signed-off-by: Michal Marek <mmarek@suse.com>
fixdep: constify strrcmp argumentsstrrcmp only performs read access to the memory addressed by itsarguments so make them const pointers.Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
fixdep: constify strrcmp argumentsstrrcmp only performs read access to the memory addressed by itsarguments so make them const pointers.Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>Signed-off-by: Michal Marek <mmarek@suse.com>
kbuild: fixdep: drop meaningless hash table initializationThe clear_config() is called just once at the beginning of thisprogram, but the global variable hashtab[] is already zero-filledat the st
kbuild: fixdep: drop meaningless hash table initializationThe clear_config() is called just once at the beginning of thisprogram, but the global variable hashtab[] is already zero-filledat the start-up.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>Signed-off-by: Michal Marek <mmarek@suse.com>
kbuild: fixdep: optimize code slightlyIf the target string matches "CONFIG_", move the pointer pforward. This saves several 7-chars adjustments.Signed-off-by: Masahiro Yamada <yamada.masahiro@s
kbuild: fixdep: optimize code slightlyIf the target string matches "CONFIG_", move the pointer pforward. This saves several 7-chars adjustments.Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>Signed-off-by: Michal Marek <mmarek@suse.com>
kernel: build bin2c based on config option CONFIG_BUILD_BIN2Ccurrently bin2c builds only if CONFIG_IKCONFIG=y. But bin2c will now beused by kexec too. So make it compilation dependent on CONFIG_B
kernel: build bin2c based on config option CONFIG_BUILD_BIN2Ccurrently bin2c builds only if CONFIG_IKCONFIG=y. But bin2c will now beused by kexec too. So make it compilation dependent on CONFIG_BUILD_BIN2Cand this config option can be selected by CONFIG_KEXEC and CONFIG_IKCONFIG.Signed-off-by: Vivek Goyal <vgoyal@redhat.com>Cc: Borislav Petkov <bp@suse.de>Cc: Michael Kerrisk <mtk.manpages@gmail.com>Cc: Yinghai Lu <yinghai@kernel.org>Cc: Eric Biederman <ebiederm@xmission.com>Cc: H. Peter Anvin <hpa@zytor.com>Cc: Matthew Garrett <mjg59@srcf.ucam.org>Cc: Greg Kroah-Hartman <greg@kroah.com>Cc: Dave Young <dyoung@redhat.com>Cc: WANG Chao <chaowang@redhat.com>Cc: Baoquan He <bhe@redhat.com>Cc: Andy Lutomirski <luto@amacapital.net>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
bin2c: move bin2c in scripts/basicThis patch series does not do kernel signature verification yet. I planto post another patch series for that. Now distributions are alreadysigning PE/COFF bzIm
bin2c: move bin2c in scripts/basicThis patch series does not do kernel signature verification yet. I planto post another patch series for that. Now distributions are alreadysigning PE/COFF bzImage with PKCS7 signature I plan to parse and verifythose signatures.Primary goal of this patchset is to prepare groundwork so that kernelimage can be signed and signatures be verified during kexec load. Thisshould help with two things.- It should allow kexec/kdump on secureboot enabled machines.- In general it can help even without secureboot. By being able to verify kernel image signature in kexec, it should help with avoiding module signing restrictions. Matthew Garret showed how to boot into a custom kernel, modify first kernel's memory and then jump back to old kernel and bypass any policy one wants to.This patch (of 15):Kexec wants to use bin2c and it wants to use it really early in the buildprocess. See arch/x86/purgatory/ code in later patches.So move bin2c in scripts/basic so that it can be built very early andbe usable by arch/x86/purgatory/Signed-off-by: Vivek Goyal <vgoyal@redhat.com>Cc: Borislav Petkov <bp@suse.de>Cc: Michael Kerrisk <mtk.manpages@gmail.com>Cc: Yinghai Lu <yinghai@kernel.org>Cc: Eric Biederman <ebiederm@xmission.com>Cc: H. Peter Anvin <hpa@zytor.com>Cc: Matthew Garrett <mjg59@srcf.ucam.org>Cc: Greg Kroah-Hartman <greg@kroah.com>Cc: Dave Young <dyoung@redhat.com>Cc: WANG Chao <chaowang@redhat.com>Cc: Baoquan He <bhe@redhat.com>Cc: Andy Lutomirski <luto@amacapital.net>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1234