summaryrefslogtreecommitdiff
path: root/scripts
AgeCommit message (Collapse)Author
2021-10-12scripts: kernel-doc: Ignore __alloc_size() attributeKees Cook
Fixes "Compiler Attributes: add __alloc_size() for better bounds checking" so that the __alloc_size() macro is ignored for function prototypes when generating kerndoc. Avoids warnings like: ./include/linux/slab.h:662: warning: Function parameter or member '1' not described in '__alloc_size' ./include/linux/slab.h:662: warning: Function parameter or member '2' not described in '__alloc_size' ./include/linux/slab.h:662: warning: expecting prototype for kcalloc(). Prototype was for __alloc_size() instead Suggested-by: Matthew Wilcox <willy@infradead.org> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20211011180650.3603988-1-keescook@chromium.org Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2021-10-12kbuild: Add make tarzst-pkg build optionPaweł Jasiak
Add tarzst-pkg and perf-tarzst-src-pkg targets to build zstd compressed tarballs. Signed-off-by: Paweł Jasiak <pawel@jasiak.dev> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-12scripts: update the comments of kallsyms supportHui Su
update the comments of kallsyms support. Fixes: af73d78bd384 ("kbuild: Remove debug info from kallsyms linking") Signed-off-by: Hui Su <suhui_kernel@163.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11Merge tag 'linux-kselftest-kunit-fixes-5.15-rc6' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest Pull Kunit fixes from Shuah Khan: - Fixes to address the structleak plugin causing the stack frame size to grow immensely when used with KUnit. Fixes include adding a new makefile to disable structleak and using it from KUnit iio, device property, thunderbolt, and bitfield tests to disable it. - KUnit framework reference count leak in kfree_at_end - KUnit tool fix to resolve conflict between --json and --raw_output and generate correct test output in either case. - kernel-doc warnings due to mismatched arg names * tag 'linux-kselftest-kunit-fixes-5.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: fix kernel-doc warnings due to mismatched arg names bitfield: build kunit tests without structleak plugin thunderbolt: build kunit tests without structleak plugin device property: build kunit tests without structleak plugin iio/test-format: build kunit tests without structleak plugin gcc-plugins/structleak: add makefile var for disabling structleak kunit: fix reference count leak in kfree_at_end kunit: tool: better handling of quasi-bool args (--json, --raw_output)
2021-10-11kconfig: refactor conf_touch_dep()Masahiro Yamada
If this function fails to touch a dummy header due to missing parent directory, then it creates it and touches the file again. This was needed because CONFIG_FOO_BAR was previously tracked by include/config/foo/bar.h. (include/config/foo/ may not exist here) This is no longer the case since commit 0e0345b77ac4 ("kbuild: redo fake deps at include/config/*.h"); now all the fake headers are placed right under include/config/, like include/config/FOO_BAR. Do not try to create parent directory, include/config/, which already exists. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: refactor conf_write_dep()Masahiro Yamada
The if ... else inside the for-loop is unneeded because one empty line is placed after printing the last element of deps_config. Currently, all errors in conf_write_dep() are ignored. Add proper error checks. Rename it to conf_write_autoconf_cmd(), which is more intuitive. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: refactor conf_write_autoconf()Masahiro Yamada
This function does similar for auto.conf and autoconf.h Create __conf_write_autoconf() helper to factor out the common code. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: add conf_get_autoheader_name()Masahiro Yamada
For consistency with conf_get_autoconfig_name() Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: move sym_escape_string_value() to confdata.cMasahiro Yamada
Now that sym_escape_string_value() is only used in confdata.c it can be a 'static' function. Rename it escape_string_value() because it is agnostic about (struct sym *). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: refactor listnewconfig codeMasahiro Yamada
We can reuse __print_symbol() helper to print symbols for listnewconfig. Only the difference is the format for "n" symbols. This prints "CONFIG_FOO=n" instead of "# CONFIG_FOO is not set". Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: refactor conf_write_symbol()Masahiro Yamada
I do not think 'struct conf_printer' is so useful. Add simple functions, print_symbol_for_*() to write out one symbol. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-11kconfig: refactor conf_write_heading()Masahiro Yamada
All the call sites of conf_write_heading() pass NULL to the third argument, and it is not used in the function. Also, the print_comment hooks are doing much more complex than needed. Rewrite the code. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-10-09Merge tag 'riscv-for-linus-5.15-rc5' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux Pull RISC-V fixes from Palmer Dabbelt: - A pair of fixes (along with the necessory cleanup) to our VDSO, to avoid a locking during OOM and to prevent the text from overflowing into the data page - A fix to checksyscalls to teach it about our rv32 UABI - A fix to add clone3() to the rv32 UABI, which was pointed out by checksyscalls - A fix to properly flush the icache on the local CPU in addition to the remote CPUs * tag 'riscv-for-linus-5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: checksyscalls: Unconditionally ignore fstat{,at}64 riscv: Flush current cpu icache before other cpus RISC-V: Include clone3() on rv32 riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable riscv/vdso: Move vdso data page up front riscv/vdso: Refactor asm/vdso.h
2021-10-07checksyscalls: Unconditionally ignore fstat{,at}64Palmer Dabbelt
These can be replaced by statx(). Since rv32 has a 64-bit time_t we just never ended up with them in the first place. This is now an error due to -Werror. Suggested-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-10-06gcc-plugins/structleak: add makefile var for disabling structleakBrendan Higgins
KUnit and structleak don't play nice, so add a makefile variable for enabling structleak when it complains. Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2021-10-05bpf: Enable TCP congestion control kfunc from modulesKumar Kartikeya Dwivedi
This commit moves BTF ID lookup into the newly added registration helper, in a way that the bbr, cubic, and dctcp implementation set up their sets in the bpf_tcp_ca kfunc_btf_set list, while the ones not dependent on modules are looked up from the wrapper function. This lifts the restriction for them to be compiled as built in objects, and can be loaded as modules if required. Also modify Makefile.modfinal to call resolve_btfids for each module. Note that since kernel kfunc_ids never overlap with module kfunc_ids, we only match the owner for module btf id sets. See following commits for background on use of: CONFIG_X86 ifdef: 569c484f9995 (bpf: Limit static tcp-cc functions in the .BTF_ids list to x86) CONFIG_DYNAMIC_FTRACE ifdef: 7aae231ac93b (bpf: tcp: Limit calling some tcp cc functions to CONFIG_DYNAMIC_FTRACE) Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211002011757.311265-6-memxor@gmail.com
2021-10-05scripts: get_abi.pl: better generate regex from what fieldsMauro Carvalho Chehab
Using repeating sequencies of .* seem to slow down the processing speed on some cases. Also, currently, a "." character is not properly handled as such. Change the way regexes are created, in order to produce better search expressions. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/c69c01c12b1b30466177dcb17e45f833fb47713d.1632994565.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-05scripts: get_abi.pl: fix fallback rule for undefined symbolsMauro Carvalho Chehab
The rule that falls back to the long regex list is wrong: it is just running again the same loop it did before. change it to look at the "others" table. That slows the processing speed, but provides a better list of undefined symbols. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/a3ba919e9a9208a5f012a13c9674c362a9d73169.1632994565.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-04gcc-plugins: remove support for GCC 4.9 and olderArd Biesheuvel
The minimum GCC version has been bumped to 5.1, so we can get rid of all the compatibility code for anything older than that. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20210922182632.633394-1-ardb@kernel.org
2021-10-04Merge 5.15-rc4 into driver-core-nextGreg Kroah-Hartman
We need the driver core fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-01kconfig: remove 'const' from the return type of sym_escape_string_value()Masahiro Yamada
sym_escape_string_value() returns a malloc'ed memory, but as (const char *). So, it must be casted to (void *) when it is free'd. This is odd. The return type of sym_escape_string_value() should be (char *). I exploited that free(NULL) has no effect. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-09-30kconfig: rename a variable in the lexer to a clearer nameMasahiro Yamada
In Kconfig, like Python, you can enclose a string by double-quotes or single-quotes. So, both "foo" and 'foo' are allowed. The variable, "str", is used to remember whether the string started with a double-quote or a single-quote because open/closing quotation marks must match. The name "str" is too generic to understand the intent. Rename it to "open_quote", which is easier to understand. The type should be 'char'. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Boris Kolpackov <boris@codesynthesis.com>
2021-09-30kconfig: narrow the scope of variables in the lexerMasahiro Yamada
The variables, "ts" and "i", are used locally in the action of the [ \t]+ pattern in the <HELP> start state. Define them where they are used. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-09-29scripts: get_abi.pl: make undefined search more deterministicMauro Carvalho Chehab
Sort keys on hashes during undefined search, in order to make the script more deterministic. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/5dc55fd42e632a24a48f95212aa6c6bc4b2d11fd.1632865873.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: show progressMauro Carvalho Chehab
As parsing the sysfs entries can take a long time, add progress information. The progress logic will update the stats on every second, or on 1% steps of the progress. When STDERR is a console, it will use a single line, using a VT-100 command to erase the line before rewriting it. Otherwise, it will put one message on a separate line. That would help to identify what parts of sysfs checking that it is taking more time to process. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/4e581dcbec21ad8a60fff883498018f96f13dd1c.1632823172.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: use STDERR for search-string and show-hintsMauro Carvalho Chehab
On undefined checks, use STDOUT only for the not found entries. All other data (search-string and show-hints) is printed at STDERR. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/51c6a39c82f73b441030c51bf905a1f382452a67.1632823172.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: update its documentationMauro Carvalho Chehab
The current highlight schema is not working properly. So, use, instead, Pod::Text. While here, also update the copyright in order to reflect the latest changes and the e-mail I'm currently using. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/89fcd301e065ed86dfd8670725144b196266b6a4.1632750315.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: fix parse logic for DT firmwareMauro Carvalho Chehab
It doesn't make any sense to parse ABI entries under /sys/firmware, as those are either specified by ACPI specs or by Documentation/devicetree. The current logic to ignore firmware entries is incomplete, as it ignores just the relative name of the file, and not its absolute name. This cause errors while parsing the symlinks. So, rewrite the logic for it to do a better job. Tested with both x86 and arm64 (HiKey970) systems. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/1c806eaec96f6706db4b041bbe6a0e2519e9637e.1632750315.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: produce an error if the ref tree is brokenMauro Carvalho Chehab
The logic under graph_add_file should create, for every entry, a __name name array for all entries of the tree. If this fails, the symlink parsing will break. Add an error if this ever happens. While here, improve the output of data dumper to be more compact and to avoid displaying things like $VAR1=. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/e7dd4d70e206723455d50c851802c8bb6c34941d.1632750315.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-28scripts: get_abi.pl: create a valid ReST with duplicated tagsMauro Carvalho Chehab
As warned, /sys/bus/iio/devices/iio:deviceX/fault_ovuv is defined 2 times: Warning: /sys/bus/iio/devices/iio:deviceX/fault_ovuv is defined 2 times: ./Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856:14 ./Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865:0 The logic with joins the two entries is just places the paragraph for the second entry after the previous one. That could cause more warnings, as the produced ReST may become invalid, as in the case of this specific symbol, which ends with a table: /new_devel/v4l/docs/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856:2: WARNING: Malformed table. No bottom table border found or no blank line after table bottom. === ======================================================= '1' The input voltage is negative or greater than VDD. '0' The input voltage is positive and less than VDD (normal state). === ======================================================= /new_devel/v4l/docs/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856:2: WARNING: Blank line required after table. Address it by adding two blank lines before joining duplicated symbols. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/4ad2e3a65f781f0f8d40bb75aa5a07aca80564d6.1632740376.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-27gcc-plugins: arm-ssp: Prepare for THREAD_INFO_IN_TASK supportArd Biesheuvel
We will be enabling THREAD_INFO_IN_TASK support for ARM, which means that we can no longer load the stack canary value by masking the stack pointer and taking the copy that lives in thread_info. Instead, we will be able to load it from the task_struct directly, by using the TPIDRURO register which will hold the current task pointer when THREAD_INFO_IN_TASK is in effect. This is much more straight-forward, and allows us to declutter this code a bit while at it. Note that this means that ARMv6 (non-v6K) SMP systems can no longer use this feature, but those are quite rare to begin with, so this is a reasonable trade off. Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
2021-09-27Merge 5.15-rc3 into char-misc nextGreg Kroah-Hartman
We need the char/misc fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-25stddef: Introduce struct_group() helper macroKees Cook
Kernel code has a regular need to describe groups of members within a structure usually when they need to be copied or initialized separately from the rest of the surrounding structure. The generally accepted design pattern in C is to use a named sub-struct: struct foo { int one; struct { int two; int three, four; } thing; int five; }; This would allow for traditional references and sizing: memcpy(&dst.thing, &src.thing, sizeof(dst.thing)); However, doing this would mean that referencing struct members enclosed by such named structs would always require including the sub-struct name in identifiers: do_something(dst.thing.three); This has tended to be quite inflexible, especially when such groupings need to be added to established code which causes huge naming churn. Three workarounds exist in the kernel for this problem, and each have other negative properties. To avoid the naming churn, there is a design pattern of adding macro aliases for the named struct: #define f_three thing.three This ends up polluting the global namespace, and makes it difficult to search for identifiers. Another common work-around in kernel code avoids the pollution by avoiding the named struct entirely, instead identifying the group's boundaries using either a pair of empty anonymous structs of a pair of zero-element arrays: struct foo { int one; struct { } start; int two; int three, four; struct { } finish; int five; }; struct foo { int one; int start[0]; int two; int three, four; int finish[0]; int five; }; This allows code to avoid needing to use a sub-struct named for member references within the surrounding structure, but loses the benefits of being able to actually use such a struct, making it rather fragile. Using these requires open-coded calculation of sizes and offsets. The efforts made to avoid common mistakes include lots of comments, or adding various BUILD_BUG_ON()s. Such code is left with no way for the compiler to reason about the boundaries (e.g. the "start" object looks like it's 0 bytes in length), making bounds checking depend on open-coded calculations: if (length > offsetof(struct foo, finish) - offsetof(struct foo, start)) return -EINVAL; memcpy(&dst.start, &src.start, offsetof(struct foo, finish) - offsetof(struct foo, start)); However, the vast majority of places in the kernel that operate on groups of members do so without any identification of the grouping, relying either on comments or implicit knowledge of the struct contents, which is even harder for the compiler to reason about, and results in even more fragile manual sizing, usually depending on member locations outside of the region (e.g. to copy "two" and "three", use the start of "four" to find the size): BUILD_BUG_ON((offsetof(struct foo, four) < offsetof(struct foo, two)) || (offsetof(struct foo, four) < offsetof(struct foo, three)); if (length > offsetof(struct foo, four) - offsetof(struct foo, two)) return -EINVAL; memcpy(&dst.two, &src.two, length); In order to have a regular programmatic way to describe a struct region that can be used for references and sizing, can be examined for bounds checking, avoids forcing the use of intermediate identifiers, and avoids polluting the global namespace, introduce the struct_group() macro. This macro wraps the member declarations to create an anonymous union of an anonymous struct (no intermediate name) and a named struct (for references and sizing): struct foo { int one; struct_group(thing, int two; int three, four; ); int five; }; if (length > sizeof(src.thing)) return -EINVAL; memcpy(&dst.thing, &src.thing, length); do_something(dst.three); There are some rare cases where the resulting struct_group() needs attributes added, so struct_group_attr() is also introduced to allow for specifying struct attributes (e.g. __align(x) or __packed). Additionally, there are places where such declarations would like to have the struct be tagged, so struct_group_tagged() is added. Given there is a need for a handful of UAPI uses too, the underlying __struct_group() macro has been defined in UAPI so it can be used there too. To avoid confusing scripts/kernel-doc, hide the macro from its struct parsing. Co-developed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/lkml/20210728023217.GC35706@embeddedor Enhanced-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Link: https://lore.kernel.org/lkml/41183a98-bdb9-4ad6-7eab-5a7292a6df84@rasmusvillemoes.dk Enhanced-by: Dan Williams <dan.j.williams@intel.com> Link: https://lore.kernel.org/lkml/1d9a2e6df2a9a35b2cdd50a9a68cac5991e7e5f0.camel@intel.com Enhanced-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://lore.kernel.org/lkml/YQKa76A6XuFqgM03@phenom.ffwll.local Acked-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Kees Cook <keescook@chromium.org>
2021-09-25kconfig: Create links to main menu items in searchAriel Marcovitch
When one searches for a main menu item, links aren't created for it like with the rest of the symbols. This happens because we trace the item until we get to the rootmenu, but we don't include it in the path of the item. The rationale was probably that we don't want to show the main menu in the path of all items, because it is redundant. However, when an item has only the rootmenu in its path it should be included, because this way the user can jump to its location. Add a 'Main menu' entry in the 'Location:' section for the kconfig items. This makes the 'if (i > 0)' superfluous because each item with prompt will have at least one menu in its path. Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-09-24kasan: always respect CONFIG_KASAN_STACKNathan Chancellor
Currently, the asan-stack parameter is only passed along if CFLAGS_KASAN_SHADOW is not empty, which requires KASAN_SHADOW_OFFSET to be defined in Kconfig so that the value can be checked. In RISC-V's case, KASAN_SHADOW_OFFSET is not defined in Kconfig, which means that asan-stack does not get disabled with clang even when CONFIG_KASAN_STACK is disabled, resulting in large stack warnings with allmodconfig: drivers/video/fbdev/omap2/omapfb/displays/panel-lgphilips-lb035q02.c:117:12: error: stack frame size (14400) exceeds limit (2048) in function 'lb035q02_connect' [-Werror,-Wframe-larger-than] static int lb035q02_connect(struct omap_dss_device *dssdev) ^ 1 error generated. Ensure that the value of CONFIG_KASAN_STACK is always passed along to the compiler so that these warnings do not happen when CONFIG_KASAN_STACK is disabled. Link: https://github.com/ClangBuiltLinux/linux/issues/1453 References: 6baec880d7a5 ("kasan: turn off asan-stack for clang-8 and earlier") Link: https://lkml.kernel.org/r/20210922205525.570068-1-nathan@kernel.org Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Marco Elver <elver@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-09-24scripts/sorttable: riscv: fix undeclared identifier 'EM_RISCV' errorMiles Chen
Fix the following build failure reported in [1] by adding a conditional definition of EM_RISCV in order to allow cross-compilation on machines which do not have EM_RISCV definition in their host. scripts/sorttable.c:352:7: error: use of undeclared identifier 'EM_RISCV' EM_RISCV was added to <elf.h> in glibc 2.24 so builds on systems with glibc headers < 2.24 should show this error. [mkubecek@suse.cz: changelog addition] Link: https://lore.kernel.org/lkml/e8965b25-f15b-c7b4-748c-d207dda9c8e8@i2se.com/ [1] Link: https://lkml.kernel.org/r/20210913030625.4525-1-miles.chen@mediatek.com Fixes: 54fed35fd393 ("riscv: Enable BUILDTIME_TABLE_SORT") Signed-off-by: Miles Chen <miles.chen@mediatek.com> Reported-by: Stefan Wahren <stefan.wahren@i2se.com> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Jisheng Zhang <jszhang@kernel.org> Cc: Michal Kubecek <mkubecek@suse.cz> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Markus Mayer <mmayer@broadcom.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-09-23scripts: get_abi.pl: ensure that "others" regex will be parsedMauro Carvalho Chehab
The way the search algorithm works is that reduces the number of regex expressions that will be checked for a given file entry at sysfs. It does that by looking at the devnode name. For instance, when it checks for this file: /sys/bus/pci/drivers/iosf_mbi_pci/bind The logic will seek only the "What:" expressions that end with "bind". Currently, there are just a couple of What expressions that matches it: What: /sys/bus/fsl\-mc/drivers/.*/bind What: /sys/bus/pci/drivers/.*/bind It will then run an O(n²) algorithm to seek, which runs quickly when there are few regexs to seek. There are, however, some What: expressions that end with a wildcard. Those are harder to process. Right now, they're all grouped together at the "others" group. As those don't depend on the basename of the node, add an extra loop to ensure that those will be processed at the end, if not done yet. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/9fe7ab46f67575def5db9e83034e9fab43846d84.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: precompile what match regexesMauro Carvalho Chehab
In order to earn some time during matches, pre-compile regexes. Before this patch: $ time ./scripts/get_abi.pl undefined |wc -l 6970 real 0m54,751s user 0m54,022s sys 0m0,592s Afterwards: $ time ./scripts/get_abi.pl undefined |wc -l 6970 real 0m5,888s user 0m5,310s sys 0m0,562s Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/ec45de8fcae791aab0880644974a110424423e68.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: stop check loop earlier when regex is foundMauro Carvalho Chehab
Right now, there are two loops used to seek for a regex. Make sure that both will be skip when a match is found. While here, drop the unused $defined variable. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/2ba722d2cdbe7c7d0f1d1b58d350052576d1d703.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: ignore some sysfs nodes earlierMauro Carvalho Chehab
When checking for undefined symbols, some nodes aren't easy or don't make sense to be checked right now. Prevent allocating memory for those, as they'll be ignored anyway. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/5228789cbef8241d44504ad29fca5cab356cdc53.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: Better handle leaves with wildcardsMauro Carvalho Chehab
When the the leaf of a regex ends with a wildcard, the speedup algorithm to reduce the number of regexes to seek won't work. So, when those are found, place at the "others" exception. That slows down the search from 0.14s to 1 minute on my machine, but the results are a lot more consistent. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/60bb97cf337333783f9f52e114b896439e9cc215.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: improve debug logicMauro Carvalho Chehab
Add a level for debug, in order to allow it to be extended to debug other parts of the script. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/0203416c6c418abb4fc20577a5f48d0d2a41bae7.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: call get_leave() a little lateMauro Carvalho Chehab
The $what conversions need to replace some characters to avoid breaking regex expressions found on some What:. only after replacing them back, the script should get the $leave devnode. Fixes: ca8e055c2215 ("scripts: get_abi.pl: add a graph to speedup the undefined algorithm") Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/a21631f8a884f50a962beafdd800f27891348d95.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-23scripts: get_abi.pl: Fix get_abi.pl search outputMauro Carvalho Chehab
Currently, the get_abi.pl will print an invalid symbol (\xac character). Fix it. Fixes: ab9c14805b37 ("scripts: get_abi.pl: Better handle multiple What parameters") Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/fb27ac372e38f5ae9d088f9f4e9710c659e0b9e8.1632411447.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-09-22kbuild: reuse $(cmd_objtool) for cmd_cc_lto_link_modulesMasahiro Yamada
For CONFIG_LTO_CLANG=y, the objtool processing is not possible at the compilation, hence postponed by the link time. Reuse $(cmd_objtool) for CONFIG_LTO_CLANG=y by defining objtool-enabled properly. For CONFIG_LTO_CLANG=y: objtool-enabled is off for %.o compilation objtool-enabled is on for %.lto link For CONFIG_LTO_CLANG=n: objtool-enabled is on for %.o compilation (but, it depends on OBJECT_FILE_NON_STANDARD) Set part-of-module := y for %.lto.o to avoid repeating --module. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
2021-09-22kbuild: detect objtool update without using .SECONDEXPANSIONMasahiro Yamada
Redo commit 8852c5524029 ("kbuild: Fix objtool dependency for 'OBJECT_FILES_NON_STANDARD_<obj> := n'") to add the objtool dependency in a cleaner way. Using .SECONDEXPANSION ends up with unreadable code due to escaped dollars. Also, it is not efficient because the second half of Makefile.build is parsed twice every time. Append the objtool dependency to the *.cmd files at the build time. This is what fixdep and gen_ksymdeps.sh already do. So, following the same pattern seems a natural solution. This allows us to drop $$(objtool_dep) entirely. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
2021-09-22kbuild: factor out OBJECT_FILES_NON_STANDARD check into a macroMasahiro Yamada
The OBJECT_FILES_NON_STANDARD check is quite long. Factor it out into a new macro, objtool-enabled, to not repeat it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
2021-09-22kbuild: store the objtool command in *.cmd filesMasahiro Yamada
objtool_dep includes include/config/{ORC_UNWINDER,STACK_VALIDATION} so that all the objects are rebuilt when CONFIG_ORC_UNWINDER or CONFIG_STACK_VALIDATION is toggled. BTW, the correct option name is not CONFIG_ORC_UNWINDER, but CONFIG_UNWINDER_ORC. Commit 11af847446ed ("x86/unwind: Rename unwinder config options to 'CONFIG_UNWINDER_*'") missed to adjust this part. So, this dependency has been broken for a long time. As you can see in 'objtool_args', there are more CONFIG options that affect the objtool command line. Adding more and more include/config/* is ugly and unmaintainable. Another issue is that non-standard objects are needlessly rebuilt. Objects specified as OBJECT_FILES_NON_STANDARD is not processed by objtool, but they are rebuilt anyway when CONFIG_STACK_VALIDATION is toggled. This is not a big deal, but better to fix. A cleaner and more precise fix is to include the objtool command in *.cmd files so any command change is naturally detected by if_change. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
2021-09-22kbuild: rename __objtool_obj and reuse it for cmd_cc_lto_link_modulesMasahiro Yamada
Rename __objtool_obj to objtool, and move it out of the 'ifndef CONFIG_LTO_CLANG' conditional, so it can be used for cmd_cc_lto_link_modules as well. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
2021-09-22kbuild: move objtool_args back to scripts/Makefile.buildMasahiro Yamada
Commit b1a1a1a09b46 ("kbuild: lto: postpone objtool") moved objtool_args to Makefile.lib, so the arguments can be used in Makefile.modfinal as well as Makefile.build. With commit 850ded46c642 ("kbuild: Fix TRIM_UNUSED_KSYMS with LTO_CLANG"), module LTO linking came back to scripts/Makefile.build again. So, there is no more reason to keep objtool_args in a separate file. Get it back to the original place, close to the objtool command. Remove the stale comment too. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>