17 Dec, 2020

6 commits

  • With LTO, LLVM bitcode won't be compiled into native code until
    modpost_link, or modfinal for modules. This change postpones calls
    to objtool until after these steps, and moves objtool_args to
    Makefile.lib, so the arguments can be reused in Makefile.modfinal.

    As we didn't have objects to process earlier, we use --duplicate
    when processing vmlinux.o. This change also disables unreachable
    instruction warnings with LTO to avoid warnings about the int3
    padding between functions.

    Bug: 145210207
    Change-Id: I72615f7062d218bf612a5d929f2efb75a18538dd
    Link: https://lore.kernel.org/lkml/20201013003203.4168817-12-samitolvanen@google.com/
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Kees Cook

    Sami Tolvanen
     
  • This change adds a --noinstr flag to objtool to allow us to specify
    that we're processing vmlinux.o without also enabling noinstr
    validation. This is needed to avoid false positives with LTO when we
    run objtool on vmlinux.o without CONFIG_DEBUG_ENTRY.

    Bug: 145210207
    Change-Id: I479c72d2733844d2059253035391a0c6e8ad7771
    Link: https://lore.kernel.org/lkml/20201013003203.4168817-11-samitolvanen@google.com/
    Signed-off-by: Sami Tolvanen

    Sami Tolvanen
     
  • With LTO, we run objtool on vmlinux.o, but don't want noinstr
    validation. This change requires --vmlinux to be passed to objtool
    explicitly.

    Bug: 145210207
    Change-Id: Ibfd814126df6b3d1a52f5461f2e5aac1377b02c9
    Link: https://lore.kernel.org/lkml/20201013003203.4168817-4-samitolvanen@google.com/
    Suggested-by: Peter Zijlstra
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Kees Cook

    Sami Tolvanen
     
  • With LTO, the compiler doesn't necessarily obey the link order for
    initcalls, and initcall variables need globally unique names to avoid
    collisions at link time.

    This change exports __KBUILD_MODNAME and adds the initcall_id() macro,
    which uses it together with __COUNTER__ and __LINE__ to help ensure
    these variables have unique names, and moves each variable to its own
    section when LTO is enabled, so the correct order can be specified using
    a linker script.

    The generate_initcall_ordering.pl script uses nm to find initcalls from
    the object files passed to the linker, and generates a linker script
    that specifies the same order for initcalls that we would have without
    LTO. With LTO enabled, the script is called in link-vmlinux.sh through
    jobserver-exec to limit the number of jobs spawned.

    Bug: 145210207
    Change-Id: I80619eac3674acd9c6d2566443d16b3d09515351
    Link: https://lore.kernel.org/lkml/20201211184633.3213045-8-samitolvanen@google.com/
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Kees Cook

    Sami Tolvanen
     
  • With CONFIG_MODVERSIONS, version information is linked into each
    compilation unit that exports symbols. With LTO, we cannot use this
    method as all C code is compiled into LLVM bitcode instead. This
    change collects symbol versions into .symversions files and merges
    them in link-vmlinux.sh where they are all linked into vmlinux.o at
    the same time.

    Bug: 145210207
    Change-Id: Icd8fd0c760891eff7a0ed12ce48b4db2a85fc2ad
    Link: https://lore.kernel.org/lkml/20201211184633.3213045-1-samitolvanen@google.com/
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Kees Cook

    Sami Tolvanen
     
  • This change adds build system support for Clang's Link Time
    Optimization (LTO). With -flto, instead of ELF object files, Clang
    produces LLVM bitcode, which is compiled into native code at link
    time, allowing the final binary to be optimized globally. For more
    details, see:

    https://llvm.org/docs/LinkTimeOptimization.html

    The Kconfig option CONFIG_LTO_CLANG is implemented as a choice,
    which defaults to LTO being disabled. To use LTO, the architecture
    must select ARCH_SUPPORTS_LTO_CLANG and support:

    - compiling with Clang,
    - compiling all assembly code with Clang's integrated assembler,
    - and linking with LLD.

    While using CONFIG_LTO_CLANG_FULL results in the best runtime
    performance, the compilation is not scalable in time or
    memory. CONFIG_LTO_CLANG_THIN enables ThinLTO, which allows
    parallel optimization and faster incremental builds. ThinLTO is
    used by default if the architecture also selects
    ARCH_SUPPORTS_LTO_CLANG_THIN:

    https://clang.llvm.org/docs/ThinLTO.html

    To enable LTO, LLVM tools must be used to handle bitcode files, by
    passing LLVM=1 and LLVM_IAS=1 options to make:

    $ make LLVM=1 LLVM_IAS=1 defconfig
    $ scripts/config -e LTO_CLANG_THIN
    $ make LLVM=1 LLVM_IAS=1

    To prepare for LTO support with other compilers, common parts are
    gated behind the CONFIG_LTO option, and LTO can be disabled for
    specific files by filtering out CC_FLAGS_LTO.

    Bug: 145210207
    Change-Id: I85eb4523ea787e4f9884e12ed6301f876d0d888e
    Link: https://lore.kernel.org/lkml/20201211184633.3213045-1-samitolvanen@google.com/
    Signed-off-by: Sami Tolvanen
    Reviewed-by: Kees Cook

    Sami Tolvanen
     

23 Oct, 2020

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - Support 'make compile_commands.json' to generate the compilation
    database more easily, avoiding stale entries

    - Support 'make clang-analyzer' and 'make clang-tidy' for static checks
    using clang-tidy

    - Preprocess scripts/modules.lds.S to allow CONFIG options in the
    module linker script

    - Drop cc-option tests from compiler flags supported by our minimal
    GCC/Clang versions

    - Use always 12-digits commit hash for CONFIG_LOCALVERSION_AUTO=y

    - Use sha1 build id for both BFD linker and LLD

    - Improve deb-pkg for reproducible builds and rootless builds

    - Remove stale, useless scripts/namespace.pl

    - Turn -Wreturn-type warning into error

    - Fix build error of deb-pkg when CONFIG_MODULES=n

    - Replace 'hostname' command with more portable 'uname -n'

    - Various Makefile cleanups

    * tag 'kbuild-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits)
    kbuild: Use uname for LINUX_COMPILE_HOST detection
    kbuild: Only add -fno-var-tracking-assignments for old GCC versions
    kbuild: remove leftover comment for filechk utility
    treewide: remove DISABLE_LTO
    kbuild: deb-pkg: clean up package name variables
    kbuild: deb-pkg: do not build linux-headers package if CONFIG_MODULES=n
    kbuild: enforce -Werror=return-type
    scripts: remove namespace.pl
    builddeb: Add support for all required debian/rules targets
    builddeb: Enable rootless builds
    builddeb: Pass -n to gzip for reproducible packages
    kbuild: split the build log of kallsyms
    kbuild: explicitly specify the build id style
    scripts/setlocalversion: make git describe output more reliable
    kbuild: remove cc-option test of -Werror=date-time
    kbuild: remove cc-option test of -fno-stack-check
    kbuild: remove cc-option test of -fno-strict-overflow
    kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles
    kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan
    kbuild: do not create built-in objects for external module builds
    ...

    Linus Torvalds
     

09 Oct, 2020

1 commit

  • Currently, the build log shows KSYM + object name.

    Precisely speaking, kallsyms generates a .S file and then the compiler
    compiles it into a .o file. Split the build log into two.

    [Before]

    GEN modules.builtin
    LD .tmp_vmlinux.kallsyms1
    KSYM .tmp_vmlinux.kallsyms1.o
    LD .tmp_vmlinux.kallsyms2
    KSYM .tmp_vmlinux.kallsyms2.o
    LD vmlinux

    [After]

    GEN modules.builtin
    LD .tmp_vmlinux.kallsyms1
    KSYMS .tmp_vmlinux.kallsyms1.S
    AS .tmp_vmlinux.kallsyms1.o
    LD .tmp_vmlinux.kallsyms2
    KSYMS .tmp_vmlinux.kallsyms2.S
    AS .tmp_vmlinux.kallsyms2.o
    LD vmlinux

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

24 Sep, 2020

1 commit

  • Currently all the resolve_btfids 'users' are under CONFIG_BPF
    code, so if we have CONFIG_BPF disabled, resolve_btfids will
    fail, because there's no data to resolve.

    Disabling resolve_btfids if there's CONFIG_BPF disabled,
    so we won't fail such builds.

    Suggested-by: Andrii Nakryiko
    Signed-off-by: Jiri Olsa
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200923185735.3048198-1-jolsa@kernel.org

    Jiri Olsa
     

10 Aug, 2020

2 commits

  • Pull Kbuild updates from Masahiro Yamada:

    - run the checker (e.g. sparse) after the compiler

    - remove unneeded cc-option tests for old compiler flags

    - fix tar-pkg to install dtbs

    - introduce ccflags-remove-y and asflags-remove-y syntax

    - allow to trace functions in sub-directories of lib/

    - introduce hostprogs-always-y and userprogs-always-y syntax

    - various Makefile cleanups

    * tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kbuild: stop filtering out $(GCC_PLUGINS_CFLAGS) from cc-option base
    kbuild: include scripts/Makefile.* only when relevant CONFIG is enabled
    kbuild: introduce hostprogs-always-y and userprogs-always-y
    kbuild: sort hostprogs before passing it to ifneq
    kbuild: move host .so build rules to scripts/gcc-plugins/Makefile
    kbuild: Replace HTTP links with HTTPS ones
    kbuild: trace functions in subdirectories of lib/
    kbuild: introduce ccflags-remove-y and asflags-remove-y
    kbuild: do not export LDFLAGS_vmlinux
    kbuild: always create directories of targets
    powerpc/boot: add DTB to 'targets'
    kbuild: buildtar: add dtbs support
    kbuild: remove cc-option test of -ffreestanding
    kbuild: remove cc-option test of -fno-stack-protector
    Revert "kbuild: Create directory for target DTB"
    kbuild: run the checker after the compiler

    Linus Torvalds
     
  • When you clean the build tree for ARCH=arm, you may see the following
    error message from 'nm' command:

    $ make -j24 ARCH=arm clean
    CLEAN arch/arm/crypto
    CLEAN arch/arm/kernel
    CLEAN arch/arm/mach-at91
    CLEAN arch/arm/mach-omap2
    CLEAN arch/arm/vdso
    CLEAN certs
    CLEAN lib
    CLEAN usr
    CLEAN net/wireless
    CLEAN drivers/firmware/efi/libstub
    nm: 'arch/arm/boot/compressed/../../../../vmlinux': No such file
    /bin/sh: 1: arithmetic expression: expecting primary: " "
    CLEAN arch/arm/boot/compressed
    CLEAN drivers/scsi
    CLEAN drivers/tty/vt
    CLEAN arch/arm/boot
    CLEAN vmlinux.symvers modules.builtin modules.builtin.modinfo

    Even if you rerun the same command, the error message will not be
    shown despite vmlinux is already gone.

    To reproduce it, the parallel option -j is needed. Single thread
    cleaning always executes 'archclean', 'vmlinuxclean' in this order,
    so vmlinux still exists when arch/arm/boot/compressed/ is cleaned.

    Looking at arch/arm/boot/compressed/Makefile does not help understand
    the reason of the error message. Both KBSS_SZ and LDFLAGS_vmlinux are
    assigned with '=' operator, hence, they are not expanded unless used.
    Obviously, 'make clean' does not use them.

    In fact, the root cause exists in the top Makefile:

    export LDFLAGS_vmlinux

    Since LDFLAGS_vmlinux is an exported variable, LDFLAGS_vmlinux in
    arch/arm/boot/compressed/Makefile is expanded when scripts/Makefile.clean
    has a command to execute. This is why the error message shows up only
    when there exist build artifacts in arch/arm/boot/compressed/.

    Adding 'unexport LDFLAGS_vmlinux' to arch/arm/boot/compressed/Makefile
    will fix it as far as ARCH=arm is concerned, but I think the proper fix
    is to get rid of 'export LDFLAGS_vmlinux' from the top Makefile.

    LDFLAGS_vmlinux in the top Makefile contains linker flags for the top
    vmlinux. LDFLAGS_vmlinux in arch/arm/boot/compressed/Makefile is for
    arch/arm/boot/compressed/vmlinux. They just happen to have the same
    variable name, but are used for different purposes. Stop shadowing
    LDFLAGS_vmlinux.

    This commit passes LDFLAGS_vmlinux to scripts/link-vmlinux.sh via a
    command line parameter instead of via an environment variable. LD and
    KBUILD_LDFLAGS are exported, but I did the same for consistency. Anyway,
    they must be included in cmd_link-vmlinux to allow if_changed to detect
    the changes in LD or KBUILD_LDFLAGS.

    The following Makefiles are not affected:

    arch/arm/boot/compressed/Makefile
    arch/h8300/boot/compressed/Makefile
    arch/nios2/boot/compressed/Makefile
    arch/parisc/boot/compressed/Makefile
    arch/s390/boot/compressed/Makefile
    arch/sh/boot/compressed/Makefile
    arch/sh/boot/romimage/Makefile
    arch/x86/boot/compressed/Makefile

    They use ':=' or '=' to clear the LDFLAGS_vmlinux inherited from the
    top Makefile.

    We need to take a closer look at the impact to unicore32 and xtensa.

    arch/unicore32/boot/compressed/Makefile only uses '+=' operator for
    LDFLAGS_vmlinux. So, the decompressor previously inherited the linker
    flags from the top Makefile.

    However, commit 70fac51feaf2 ("unicore32 additional architecture files:
    boot process") was merged before commit 1f2bfbd00e46 ("kbuild: link of
    vmlinux moved to a script"). So, I rather consider this is a bug fix of
    1f2bfbd00e46.

    arch/xtensa/boot/boot-elf/Makefile is also affected, but this is also
    considered a fix for the same reason. It did not inherit LDFLAGS_vmlinux
    when commit 4bedea945451 ("[PATCH] xtensa: Architecture support for
    Tensilica Xtensa Part 2") was merged. I deleted $(LDFLAGS_vmlinux),
    which is now empty.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Nick Desaulniers
    Tested-by: Nick Desaulniers

    Masahiro Yamada
     

14 Jul, 2020

1 commit

  • Using BTF_ID_LIST macro to define lists for several helpers
    using BTF arguments.

    And running resolve_btfids on vmlinux elf object during linking,
    so the .BTF_ids section gets the IDs resolved.

    Signed-off-by: Jiri Olsa
    Signed-off-by: Alexei Starovoitov
    Tested-by: Andrii Nakryiko
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200711215329.41165-5-jolsa@kernel.org

    Jiri Olsa
     

14 Jun, 2020

1 commit

  • Alexei Starovoitov says:

    ====================
    pull-request: bpf 2020-06-12

    The following pull-request contains BPF updates for your *net* tree.

    We've added 26 non-merge commits during the last 10 day(s) which contain
    a total of 27 files changed, 348 insertions(+), 93 deletions(-).

    The main changes are:

    1) sock_hash accounting fix, from Andrey.

    2) libbpf fix and probe_mem sanitizing, from Andrii.

    3) sock_hash fixes, from Jakub.

    4) devmap_val fix, from Jesper.

    5) load_bytes_relative fix, from YiFei.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

10 Jun, 2020

1 commit

  • bpf_iter requires the kernel BTF to be generated with
    pahole >= 1.16, since otherwise the function definitions
    that the iterator attaches to are not included.
    This failure mode is indistiguishable from trying to attach
    to an iterator that really doesn't exist.

    Since it's really easy to miss this requirement, bump the
    pahole version check used at build time to at least 1.16.

    Fixes: 15d83c4d7cef ("bpf: Allow loading of a bpf_iter program")
    Suggested-by: Ivan Babrou
    Signed-off-by: Lorenz Bauer
    Signed-off-by: Alexei Starovoitov
    Acked-by: Yonghong Song
    Link: https://lore.kernel.org/bpf/20200608094257.47366-1-lmb@cloudflare.com

    Lorenz Bauer
     

07 Jun, 2020

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - fix warnings in 'make clean' for ARCH=um, hexagon, h8300, unicore32

    - ensure to rebuild all objects when the compiler is upgraded

    - exclude system headers from dependency tracking and fixdep processing

    - fix potential bit-size mismatch between the kernel and BPF user-mode
    helper

    - add the new syntax 'userprogs' to build user-space programs for the
    target architecture (the same arch as the kernel)

    - compile user-space sample code under samples/ for the target arch
    instead of the host arch

    - make headers_install fail if a CONFIG option is leaked to user-space

    - sanitize the output format of scripts/checkstack.pl

    - handle ARM 'push' instruction in scripts/checkstack.pl

    - error out before modpost if a module name conflict is found

    - error out when multiple directories are passed to M= because this
    feature is broken for a long time

    - add CONFIG_DEBUG_INFO_COMPRESSED to support compressed debug info

    - a lot of cleanups of modpost

    - dump vmlinux symbols out into vmlinux.symvers, and reuse it in the
    second pass of modpost

    - do not run the second pass of modpost if nothing in modules is
    updated

    - install modules.builtin(.modinfo) by 'make install' as well as by
    'make modules_install' because it is useful even when
    CONFIG_MODULES=n

    - add new command line variables, GZIP, BZIP2, LZOP, LZMA, LZ4, and XZ
    to allow users to use alternatives such as pigz, pbzip2, etc.

    * tag 'kbuild-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (96 commits)
    kbuild: add variables for compression tools
    Makefile: install modules.builtin even if CONFIG_MODULES=n
    mksysmap: Fix the mismatch of '.L' symbols in System.map
    kbuild: doc: rename LDFLAGS to KBUILD_LDFLAGS
    modpost: change elf_info->size to size_t
    modpost: remove is_vmlinux() helper
    modpost: strip .o from modname before calling new_module()
    modpost: set have_vmlinux in new_module()
    modpost: remove mod->skip struct member
    modpost: add mod->is_vmlinux struct member
    modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}()
    modpost: remove mod->is_dot_o struct member
    modpost: move -d option in scripts/Makefile.modpost
    modpost: remove -s option
    modpost: remove get_next_text() and make {grab,release_}file static
    modpost: use read_text_file() and get_line() for reading text files
    modpost: avoid false-positive file open error
    modpost: fix potential mmap'ed file overrun in get_src_version()
    modpost: add read_text_file() and get_line() helpers
    modpost: do not call get_modinfo() for vmlinux(.o)
    ...

    Linus Torvalds
     

06 Jun, 2020

1 commit

  • The full build runs modpost twice, first for vmlinux.o and second for
    modules.

    The first pass dumps all the vmlinux symbols into Module.symvers, but
    the second pass parses vmlinux again instead of reusing the dump file,
    presumably because it needs to avoid accumulating stale symbols.

    Loading symbol info from a dump file is faster than parsing an ELF object.
    Besides, modpost deals with various issues to parse vmlinux in the second
    pass.

    A solution is to make the first pass dumps symbols into a separate file,
    vmlinux.symvers. The second pass reads it, and parses module .o files.
    The merged symbol information is dumped into Module.symvers in the same
    way as before.

    This makes further modpost cleanups possible.

    Also, it fixes the problem of 'make vmlinux', which previously overwrote
    Module.symvers, throwing away module symbols.

    I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
    when you cross this commit. Otherwise, vmlinux.symvers would not be
    generated.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

22 Apr, 2020

1 commit

  • Now that objtool is capable of processing vmlinux.o and actually has
    something useful to do there, (conditionally) add it to the final link
    pass.

    This will increase build time by a few seconds.

    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Miroslav Benes
    Reviewed-by: Alexandre Chartre
    Acked-by: Josh Poimboeuf
    Link: https://lkml.kernel.org/r/20200416115119.287494491@infradead.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

19 Mar, 2020

1 commit

  • Simplify gen_btf logic to make it work with llvm-objcopy. The existing
    'file format' and 'architecture' parsing logic is brittle and does not
    work with llvm-objcopy/llvm-objdump.

    'file format' output of llvm-objdump>=11 will match GNU objdump, but
    'architecture' (bfdarch) may not.

    .BTF in .tmp_vmlinux.btf is non-SHF_ALLOC. Add the SHF_ALLOC flag
    because it is part of vmlinux image used for introspection. C code
    can reference the section via linker script defined __start_BTF and
    __stop_BTF. This fixes a small problem that previous .BTF had the
    SHF_WRITE flag (objcopy -I binary -O elf* synthesized .data).

    Additionally, `objcopy -I binary` synthesized symbols
    _binary__btf_vmlinux_bin_start and _binary__btf_vmlinux_bin_stop (not
    used elsewhere) are replaced with more commonplace __start_BTF and
    __stop_BTF.

    Add 2>/dev/null because GNU objcopy (but not llvm-objcopy) warns
    "empty loadable segment detected at vaddr=0xffffffff81000000, is this intentional?"

    We use a dd command to change the e_type field in the ELF header from
    ET_EXEC to ET_REL so that lld will accept .btf.vmlinux.bin.o. Accepting
    ET_EXEC as an input file is an extremely rare GNU ld feature that lld
    does not intend to support, because this is error-prone.

    The output section description .BTF in include/asm-generic/vmlinux.lds.h
    avoids potential subtle orphan section placement issues and suppresses
    --orphan-handling=warn warnings.

    Fixes: df786c9b9476 ("bpf: Force .BTF section start to zero when dumping from vmlinux")
    Fixes: cb0cc635c7a9 ("powerpc: Include .BTF section")
    Reported-by: Nathan Chancellor
    Signed-off-by: Fangrui Song
    Signed-off-by: Daniel Borkmann
    Tested-by: Stanislav Fomichev
    Tested-by: Andrii Nakryiko
    Reviewed-by: Stanislav Fomichev
    Reviewed-by: Kees Cook
    Acked-by: Andrii Nakryiko
    Acked-by: Michael Ellerman (powerpc)
    Link: https://github.com/ClangBuiltLinux/linux/issues/871
    Link: https://lore.kernel.org/bpf/20200318222746.173648-1-maskray@google.com

    Fangrui Song
     

05 Mar, 2020

1 commit

  • When CONFIG_DEBUG_INFO is enabled, the two kallsyms linking steps spend
    time collecting and writing the dwarf sections to the temporary output
    files. kallsyms does not need this information, and leaving it off
    halves their linking time. This is especially noticeable without
    CONFIG_DEBUG_INFO_REDUCED. The BTF linking stage, however, does still
    need those details.

    Refactor the BTF and kallsyms generation stages slightly for more
    regularized temporary names. Skip debug during kallsyms links.
    Additionally move "info BTF" to the correct place since commit
    8959e39272d6 ("kbuild: Parameterize kallsyms generation and correct
    reporting"), which added "info LD ..." to vmlinux_link calls.

    For a full debug info build with BTF, my link time goes from 1m06s to
    0m54s, saving about 12 seconds, or 18%.

    Signed-off-by: Kees Cook
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/202003031814.4AEA3351@keescook

    Kees Cook
     

11 Feb, 2020

1 commit

  • Since commit 56d589361572 ("kbuild: do not create orphan built-in.a or
    obj-y objects"), scripts/link-vmlinux.sh does nothing when descending
    into init/.

    Once the version number becomes out of sync between .version and
    include/generated/compile.h, it is not self-healing.

    [How to reproduce]

    $ echo 100 > .version
    $ make

    You will see the number in the .version is always bigger than that in
    compile.h by one. After this, every time you run 'make', the vmlinux is
    re-linked even when none of source files is updated.

    Fixes: 56d589361572 ("kbuild: do not create orphan built-in.a or obj-y objects")
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

02 Feb, 2020

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - detect missing include guard in UAPI headers

    - do not create orphan built-in.a or obj-y objects

    - generate modules.builtin more simply, and drop tristate.conf

    - simplify built-in initramfs creation

    - make linux-headers deb package thinner

    - optimize the deb package build script

    - misc cleanups

    * tag 'kbuild-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits)
    builddeb: split libc headers deployment out into a function
    builddeb: split kernel headers deployment out into a function
    builddeb: remove redundant make for ARCH=um
    builddeb: avoid invoking sub-shells where possible
    builddeb: remove redundant $objtree/
    builddeb: match temporary directory name to the package name
    builddeb: remove unneeded files in hdrobjfiles for headers package
    kbuild: use -S instead of -E for precise cc-option test in Kconfig
    builddeb: allow selection of .deb compressor
    kbuild: remove 'Building modules, stage 2.' log
    kbuild: remove *.tmp file when filechk fails
    kbuild: remove PYTHON2 variable
    modpost: assume STT_SPARC_REGISTER is defined
    gen_initramfs.sh: remove intermediate cpio_list on errors
    initramfs: refactor the initramfs build rules
    gen_initramfs.sh: always output cpio even without -o option
    initramfs: add default_cpio_list, and delete -d option support
    initramfs: generate dependency list and cpio at the same time
    initramfs: specify $(src)/gen_initramfs.sh as a prerequisite in Makefile
    initramfs: make initramfs compression choice non-optional
    ...

    Linus Torvalds
     

29 Jan, 2020

1 commit

  • Pull networking updates from David Miller:

    1) Add WireGuard

    2) Add HE and TWT support to ath11k driver, from John Crispin.

    3) Add ESP in TCP encapsulation support, from Sabrina Dubroca.

    4) Add variable window congestion control to TIPC, from Jon Maloy.

    5) Add BCM84881 PHY driver, from Russell King.

    6) Start adding netlink support for ethtool operations, from Michal
    Kubecek.

    7) Add XDP drop and TX action support to ena driver, from Sameeh
    Jubran.

    8) Add new ipv4 route notifications so that mlxsw driver does not have
    to handle identical routes itself. From Ido Schimmel.

    9) Add BPF dynamic program extensions, from Alexei Starovoitov.

    10) Support RX and TX timestamping in igc, from Vinicius Costa Gomes.

    11) Add support for macsec HW offloading, from Antoine Tenart.

    12) Add initial support for MPTCP protocol, from Christoph Paasch,
    Matthieu Baerts, Florian Westphal, Peter Krystad, and many others.

    13) Add Octeontx2 PF support, from Sunil Goutham, Geetha sowjanya, Linu
    Cherian, and others.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (1469 commits)
    net: phy: add default ARCH_BCM_IPROC for MDIO_BCM_IPROC
    udp: segment looped gso packets correctly
    netem: change mailing list
    qed: FW 8.42.2.0 debug features
    qed: rt init valid initialization changed
    qed: Debug feature: ilt and mdump
    qed: FW 8.42.2.0 Add fw overlay feature
    qed: FW 8.42.2.0 HSI changes
    qed: FW 8.42.2.0 iscsi/fcoe changes
    qed: Add abstraction for different hsi values per chip
    qed: FW 8.42.2.0 Additional ll2 type
    qed: Use dmae to write to widebus registers in fw_funcs
    qed: FW 8.42.2.0 Parser offsets modified
    qed: FW 8.42.2.0 Queue Manager changes
    qed: FW 8.42.2.0 Expose new registers and change windows
    qed: FW 8.42.2.0 Internal ram offsets modifications
    MAINTAINERS: Add entry for Marvell OcteonTX2 Physical Function driver
    Documentation: net: octeontx2: Add RVU HW and drivers overview
    octeontx2-pf: ethtool RSS config support
    octeontx2-pf: Add basic ethtool support
    ...

    Linus Torvalds
     

23 Jan, 2020

1 commit

  • When trying to compile with CONFIG_DEBUG_INFO_BTF enabled, I got this
    error:

    % make -s
    Failed to generate BTF for vmlinux
    Try to disable CONFIG_DEBUG_INFO_BTF
    make[3]: *** [vmlinux] Error 1

    Compiling again without -s shows the true error (that pahole is
    missing), but since this is fatal, we should show the error
    unconditionally on stderr as well, not silence it using the `info`
    function. With this patch:

    % make -s
    BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
    Failed to generate BTF for vmlinux
    Try to disable CONFIG_DEBUG_INFO_BTF
    make[3]: *** [vmlinux] Error 1

    Signed-off-by: Chris Down
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20200122000110.GA310073@chrisdown.name

    Chris Down
     

07 Jan, 2020

1 commit

  • Commit bc081dd6e9f6 ("kbuild: generate modules.builtin") added
    infrastructure to generate modules.builtin, the list of all
    builtin modules.

    Basically, it works like this:

    - Kconfig generates include/config/tristate.conf, the list of
    tristate CONFIG options with a value in a capital letter.

    - scripts/Makefile.modbuiltin makes Kbuild descend into
    directories to collect the information of builtin modules.

    I am not a big fan of it because Kbuild ends up with traversing
    the source tree twice.

    I am not sure how perfectly it should work, but this approach cannot
    avoid false positives; even if the relevant CONFIG option is tristate,
    some Makefiles forces obj-m to obj-y.

    Some examples are:

    arch/powerpc/platforms/powermac/Makefile:
    obj-$(CONFIG_NVRAM:m=y) += nvram.o

    net/ipv6/Makefile:
    obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o

    net/netlabel/Makefile:
    obj-$(subst m,y,$(CONFIG_IPV6)) += netlabel_calipso.o

    Nobody has complained about (or noticed) it, so it is probably fine to
    have false positives in modules.builtin.

    This commit simplifies the implementation. Let's exploit the fact
    that every module has MODULE_LICENSE(). (modpost shows a warning if
    MODULE_LICENSE is missing. If so, 0-day bot would already have blocked
    such a module.)

    I added MODULE_FILE to . When the code is being compiled
    as builtin, it will be filled with the file path of the module, and
    collected into modules.builtin.info. Then, scripts/link-vmlinux.sh
    extracts the list of builtin modules out of it.

    This new approach fixes the false-positives above, but adds another
    type of false-positives; non-modular code may have MODULE_LICENSE()
    by mistake. This is not a big deal, it is just the code is always
    orphan. We can clean it up if we like. You can see cleanup examples by:

    $ git log --grep='make.* explicitly non-modular'

    To sum up, this commits deletes lots of code, but still produces almost
    equivalent results. Please note it does not increase the vmlinux size at
    all. As you can see in include/asm-generic/vmlinux.lds.h, the .modinfo
    section is discarded in the link stage.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

13 Dec, 2019

2 commits

  • Now that the orc_unwind and orc_unwind_ip tables are sorted at build time,
    remove the boot time sorting pass.

    No change in functionality.

    [ mingo: Rewrote the changelog and code comments. ]

    Signed-off-by: Shile Zhang
    Acked-by: Peter Zijlstra (Intel)
    Cc: Josh Poimboeuf
    Cc: Masahiro Yamada
    Cc: Peter Zijlstra
    Cc: linux-kbuild@vger.kernel.org
    Link: https://lkml.kernel.org/r/20191204004633.88660-8-shile.zhang@linux.alibaba.com
    Signed-off-by: Ingo Molnar

    Shile Zhang
     
  • Use a more generic name for additional table sorting usecases,
    such as the upcoming ORC table sorting feature. This tool is
    not tied to exception table sorting anymore.

    No functional changes intended.

    [ mingo: Rewrote the changelog. ]

    Signed-off-by: Shile Zhang
    Acked-by: Peter Zijlstra (Intel)
    Cc: Josh Poimboeuf
    Cc: Masahiro Yamada
    Cc: Michal Marek
    Cc: linux-kbuild@vger.kernel.org
    Link: https://lkml.kernel.org/r/20191204004633.88660-6-shile.zhang@linux.alibaba.com
    Signed-off-by: Ingo Molnar

    Shile Zhang
     

29 Nov, 2019

1 commit

  • While trying to figure out why fentry_fexit selftest doesn't pass for me
    (old pahole, broken BTF), I found out that my latest patch can break vmlinux
    .BTF generation. objcopy preserves section start when doing --only-section,
    so there is a chance (depending on where pahole inserts .BTF section) to
    have leading empty zeroes. Let's explicitly force section offset to zero.

    Before:

    $ objcopy --set-section-flags .BTF=alloc -O binary \
    --only-section=.BTF vmlinux .btf.vmlinux.bin
    $ xxd .btf.vmlinux.bin | head -n1
    00000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................

    After:

    $ objcopy --change-section-address .BTF=0 \
    --set-section-flags .BTF=alloc -O binary \
    --only-section=.BTF vmlinux .btf.vmlinux.bin
    $ xxd .btf.vmlinux.bin | head -n1
    00000000: 9feb 0100 1800 0000 0000 0000 80e1 1c00 ................
    ^BTF magic

    As part of this change, I'm also dropping '2>/dev/null' from objcopy
    invocation to be able to catch possible other issues (objcopy doesn't
    produce any warnings for me anymore, it did before with --dump-section).

    Fixes: da5fb18225b4 ("bpf: Support pre-2.25-binutils objcopy for vmlinux BTF")
    Signed-off-by: Stanislav Fomichev
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Cc: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191127225759.39923-1-sdf@google.com

    Stanislav Fomichev
     

28 Nov, 2019

1 commit

  • If vmlinux BTF generation fails, but CONFIG_DEBUG_INFO_BTF is set,
    .BTF section of vmlinux is empty and kernel will prohibit
    BPF loading and return "in-kernel BTF is malformed".

    --dump-section argument to binutils' objcopy was added in version 2.25.
    When using pre-2.25 binutils, BTF generation silently fails. Convert
    to --only-section which is present on pre-2.25 binutils.

    Documentation/process/changes.rst states that binutils 2.21+
    is supported, not sure those standards apply to BPF subsystem.

    v2:
    * exit and print an error if gen_btf fails (John Fastabend)

    v3:
    * resend with Andrii's Acked-by/Tested-by tags

    Fixes: 341dfcf8d78ea ("btf: expose BTF info through sysfs")
    Signed-off-by: Stanislav Fomichev
    Signed-off-by: Alexei Starovoitov
    Tested-by: Andrii Nakryiko
    Acked-by: Andrii Nakryiko
    Cc: John Fastabend
    Link: https://lore.kernel.org/bpf/20191127161410.57327-1-sdf@google.com

    Stanislav Fomichev
     

20 Sep, 2019

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - add modpost warn exported symbols marked as 'static' because 'static'
    and EXPORT_SYMBOL is an odd combination

    - break the build early if gold linker is used

    - optimize the Bison rule to produce .c and .h files by a single
    pattern rule

    - handle PREEMPT_RT in the module vermagic and UTS_VERSION

    - warn CONFIG options leaked to the user-space except existing ones

    - make single targets work properly

    - rebuild modules when module linker scripts are updated

    - split the module final link stage into scripts/Makefile.modfinal

    - fix the missed error code in merge_config.sh

    - improve the error message displayed on the attempt of the O= build in
    unclean source tree

    - remove 'clean-dirs' syntax

    - disable -Wimplicit-fallthrough warning for Clang

    - add CONFIG_CC_OPTIMIZE_FOR_SIZE_O3 for ARC

    - remove ARCH_{CPP,A,C}FLAGS variables

    - add $(BASH) to run bash scripts

    - change *CFLAGS_.o to take the relative path to $(obj)
    instead of the basename

    - stop suppressing Clang's -Wunused-function warnings when W=1

    - fix linux/export.h to avoid genksyms calculating CRC of trimmed
    exported symbols

    - misc cleanups

    * tag 'kbuild-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (63 commits)
    genksyms: convert to SPDX License Identifier for lex.l and parse.y
    modpost: use __section in the output to *.mod.c
    modpost: use MODULE_INFO() for __module_depends
    export.h, genksyms: do not make genksyms calculate CRC of trimmed symbols
    export.h: remove defined(__KERNEL__), which is no longer needed
    kbuild: allow Clang to find unused static inline functions for W=1 build
    kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN
    kbuild: refactor scripts/Makefile.extrawarn
    merge_config.sh: ignore unwanted grep errors
    kbuild: change *FLAGS_.o to take the path relative to $(obj)
    modpost: add NOFAIL to strndup
    modpost: add guid_t type definition
    kbuild: add $(BASH) to run scripts with bash-extension
    kbuild: remove ARCH_{CPP,A,C}FLAGS
    kbuild,arc: add CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 for ARC
    kbuild: Do not enable -Wimplicit-fallthrough for clang for now
    kbuild: clean up subdir-ymn calculation in Makefile.clean
    kbuild: remove unneeded '+' marker from cmd_clean
    kbuild: remove clean-dirs syntax
    kbuild: check clean srctree even earlier
    ...

    Linus Torvalds
     

07 Sep, 2019

1 commit

  • ${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
    BASH. Use shift and ${@} instead to fix this issue.

    Reported-by: Stephen Rothwell
    Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
    Cc: Stephen Rothwell
    Cc: Masahiro Yamada
    Signed-off-by: Andrii Nakryiko
    Acked-by: Yonghong Song
    Reviewed-by: Masahiro Yamada
    Signed-off-by: Alexei Starovoitov

    Andrii Nakryiko
     

21 Aug, 2019

2 commits

  • Building s390 kernel with CONFIG_DEBUG_INFO_BTF fails, because
    CONFIG_OUTPUT_FORMAT is not defined. As a matter of fact, this variable
    appears to be x86-only, so other arches might be affected as well.

    Fix by obtaining this value from objdump output, just like it's already
    done for bin_arch. The exact objdump invocation is "inspired" by
    arch/powerpc/boot/wrapper.

    Also, use LANG=C for the existing bin_arch objdump invocation to avoid
    potential build issues on systems with non-English locale.

    Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Daniel Borkmann

    Ilya Leoshkevich
     
  • When kallsyms generation happens, temporary vmlinux outputs are linked
    but the quiet make output didn't report it, giving the impression that
    the prior command is taking longer than expected.

    Instead, report the linking step explicitly. While at it, this
    consolidates the repeated "kallsyms generation step" into a single
    function and removes the existing copy/pasting.

    Signed-off-by: Kees Cook
    Signed-off-by: Masahiro Yamada

    Kees Cook
     

14 Aug, 2019

2 commits

  • Daniel Borkmann says:

    ====================
    The following pull-request contains BPF updates for your *net-next* tree.

    There is a small merge conflict in libbpf (Cc Andrii so he's in the loop
    as well):

    for (i = 1; i info = BTF_INFO_ENC(BTF_KIND_INT, 0, 0);
    <<<<<<< HEAD
    /*
    * using size = 1 is the safest choice, 4 will be too
    * big and cause kernel BTF validation failure if
    * original variable took less than 4 bytes
    */
    t->size = 1;
    *(int *)(t+1) = BTF_INT_ENC(0, 0, 8);
    } else if (!has_datasec && kind == BTF_KIND_DATASEC) {
    =======
    t->size = sizeof(int);
    *(int *)(t + 1) = BTF_INT_ENC(0, 0, 32);
    } else if (!has_datasec && btf_is_datasec(t)) {
    >>>>>>> 72ef80b5ee131e96172f19e74b4f98fa3404efe8
    /* replace DATASEC with STRUCT */

    Conflict is between the two commits 1d4126c4e119 ("libbpf: sanitize VAR to
    conservative 1-byte INT") and b03bc6853c0e ("libbpf: convert libbpf code to
    use new btf helpers"), so we need to pick the sanitation fixup as well as
    use the new btf_is_datasec() helper and the whitespace cleanup. Looks like
    the following:

    [...]
    if (!has_datasec && btf_is_var(t)) {
    /* replace VAR with INT */
    t->info = BTF_INFO_ENC(BTF_KIND_INT, 0, 0);
    /*
    * using size = 1 is the safest choice, 4 will be too
    * big and cause kernel BTF validation failure if
    * original variable took less than 4 bytes
    */
    t->size = 1;
    *(int *)(t + 1) = BTF_INT_ENC(0, 0, 8);
    } else if (!has_datasec && btf_is_datasec(t)) {
    /* replace DATASEC with STRUCT */
    [...]

    The main changes are:

    1) Addition of core parts of compile once - run everywhere (co-re) effort,
    that is, relocation of fields offsets in libbpf as well as exposure of
    kernel's own BTF via sysfs and loading through libbpf, from Andrii.

    More info on co-re: http://vger.kernel.org/bpfconf2019.html#session-2
    and http://vger.kernel.org/lpc-bpf2018.html#session-2

    2) Enable passing input flags to the BPF flow dissector to customize parsing
    and allowing it to stop early similar to the C based one, from Stanislav.

    3) Add a BPF helper function that allows generating SYN cookies from XDP and
    tc BPF, from Petar.

    4) Add devmap hash-based map type for more flexibility in device lookup for
    redirects, from Toke.

    5) Improvements to XDP forwarding sample code now utilizing recently enabled
    devmap lookups, from Jesper.

    6) Add support for reporting the effective cgroup progs in bpftool, from Jakub
    and Takshak.

    7) Fix reading kernel config from bpftool via /proc/config.gz, from Peter.

    8) Fix AF_XDP umem pages mapping for 32 bit architectures, from Ivan.

    9) Follow-up to add two more BPF loop tests for the selftest suite, from Alexei.

    10) Add perf event output helper also for other skb-based program types, from Allan.

    11) Fix a co-re related compilation error in selftests, from Yonghong.
    ====================

    Signed-off-by: Jakub Kicinski

    Jakub Kicinski
     
  • Expose kernel's BTF under the name vmlinux to be more uniform with using
    kernel module names as file names in the future.

    Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
    Suggested-by: Daniel Borkmann
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann

    Andrii Nakryiko
     

13 Aug, 2019

1 commit

  • Make .BTF section allocated and expose its contents through sysfs.

    /sys/kernel/btf directory is created to contain all the BTFs present
    inside kernel. Currently there is only kernel's main BTF, represented as
    /sys/kernel/btf/kernel file. Once kernel modules' BTFs are supported,
    each module will expose its BTF as /sys/kernel/btf/ file.

    Current approach relies on a few pieces coming together:
    1. pahole is used to take almost final vmlinux image (modulo .BTF and
    kallsyms) and generate .BTF section by converting DWARF info into
    BTF. This section is not allocated and not mapped to any segment,
    though, so is not yet accessible from inside kernel at runtime.
    2. objcopy dumps .BTF contents into binary file and subsequently
    convert binary file into linkable object file with automatically
    generated symbols _binary__btf_kernel_bin_start and
    _binary__btf_kernel_bin_end, pointing to start and end, respectively,
    of BTF raw data.
    3. final vmlinux image is generated by linking this object file (and
    kallsyms, if necessary). sysfs_btf.c then creates
    /sys/kernel/btf/kernel file and exposes embedded BTF contents through
    it. This allows, e.g., libbpf and bpftool access BTF info at
    well-known location, without resorting to searching for vmlinux image
    on disk (location of which is not standardized and vmlinux image
    might not be even available in some scenarios, e.g., inside qemu
    during testing).

    Alternative approach using .incbin assembler directive to embed BTF
    contents directly was attempted but didn't work, because sysfs_proc.o is
    not re-compiled during link-vmlinux.sh stage. This is required, though,
    to update embedded BTF data (initially empty data is embedded, then
    pahole generates BTF info and we need to regenerate sysfs_btf.o with
    updated contents, but it's too late at that point).

    If BTF couldn't be generated due to missing or too old pahole,
    sysfs_btf.c handles that gracefully by detecting that
    _binary__btf_kernel_bin_start (weak symbol) is 0 and not creating
    /sys/kernel/btf at all.

    v2->v3:
    - added Documentation/ABI/testing/sysfs-kernel-btf (Greg K-H);
    - created proper kobject (btf_kobj) for btf directory (Greg K-H);
    - undo v2 change of reusing vmlinux, as it causes extra kallsyms pass
    due to initially missing __binary__btf_kernel_bin_{start/end} symbols;

    v1->v2:
    - allow kallsyms stage to re-use vmlinux generated by gen_btf();

    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann

    Andrii Nakryiko
     

31 Jul, 2019

1 commit

  • Since commit ff9b45c55b26 ("kbuild: modpost: read modules.order instead
    of $(MODVERDIR)/*.mod"), 'make vmlinux' emits a warning, like this:

    $ make defconfig vmlinux
    [ snip ]
    LD vmlinux.o
    cat: modules.order: No such file or directory
    MODPOST vmlinux.o
    MODINFO modules.builtin.modinfo
    KSYM .tmp_kallsyms1.o
    KSYM .tmp_kallsyms2.o
    LD vmlinux
    SORTEX vmlinux
    SYSMAP System.map

    When building only vmlinux, KBUILD_MODULES is not set. Hence, the
    modules.order is not generated. For the vmlinux modpost, it is not
    necessary at all.

    Separate scripts/Makefile.modpost for the vmlinux/modules stages.
    This works more efficiently because the vmlinux modpost does not
    need to include .*.cmd files.

    Fixes: ff9b45c55b26 ("kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod")
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

09 May, 2019

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - allow users to invoke 'make' out of the source tree

    - refactor scripts/mkmakefile

    - deprecate KBUILD_SRC, which was used to track the source tree
    location for O= build.

    - fix recordmcount.pl in case objdump output is localized

    - turn unresolved symbols in external modules to errors from warnings
    by default; pass KBUILD_MODPOST_WARN=1 to get them back to warnings

    - generate modules.builtin.modinfo to collect .modinfo data from
    built-in modules

    - misc Makefile cleanups

    * tag 'kbuild-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (21 commits)
    .gitignore: add more all*.config patterns
    moduleparam: Save information about built-in modules in separate file
    Remove MODULE_ALIAS() calls that take undefined macro
    .gitignore: add leading and trailing slashes to generated directories
    scripts/tags.sh: fix direct execution of scripts/tags.sh
    scripts: override locale from environment when running recordmcount.pl
    samples: kobject: allow CONFIG_SAMPLE_KOBJECT to become y
    samples: seccomp: turn CONFIG_SAMPLE_SECCOMP into a bool option
    kbuild: move Documentation to vmlinux-alldirs
    kbuild: move samples/ to KBUILD_VMLINUX_OBJS
    modpost: make KBUILD_MODPOST_WARN also configurable for external modules
    kbuild: check arch/$(SRCARCH)/include/generated before out-of-tree build
    kbuild: remove unneeded dependency for include/config/kernel.release
    memory: squash drivers/memory/Makefile.asm-offsets
    kbuild: use $(srctree) instead of KBUILD_SRC to check out-of-tree build
    kbuild: mkmakefile: generate a simple wrapper of top Makefile
    kbuild: mkmakefile: do not check the generated Makefile marker
    kbuild: allow Kbuild to start from any directory
    kbuild: pass $(MAKECMDGOALS) to sub-make as is
    kbuild: fix warning "overriding recipe for target 'Makefile'"
    ...

    Linus Torvalds
     

07 May, 2019

1 commit

  • Problem:

    When a kernel module is compiled as a separate module, some important
    information about the kernel module is available via .modinfo section of
    the module. In contrast, when the kernel module is compiled into the
    kernel, that information is not available.

    Information about built-in modules is necessary in the following cases:

    1. When it is necessary to find out what additional parameters can be
    passed to the kernel at boot time.

    2. When you need to know which module names and their aliases are in
    the kernel. This is very useful for creating an initrd image.

    Proposal:

    The proposed patch does not remove .modinfo section with module
    information from the vmlinux at the build time and saves it into a
    separate file after kernel linking. So, the kernel does not increase in
    size and no additional information remains in it. Information is stored
    in the same format as in the separate modules (null-terminated string
    array). Because the .modinfo section is already exported with a separate
    modules, we are not creating a new API.

    It can be easily read in the userspace:

    $ tr '\0' '\n' < modules.builtin.modinfo
    ext4.softdep=pre: crc32c
    ext4.license=GPL
    ext4.description=Fourth Extended Filesystem
    ext4.author=Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
    ext4.alias=fs-ext4
    ext4.alias=ext3
    ext4.alias=fs-ext3
    ext4.alias=ext2
    ext4.alias=fs-ext2
    md_mod.alias=block-major-9-*
    md_mod.alias=md
    md_mod.description=MD RAID framework
    md_mod.license=GPL
    md_mod.parmtype=create_on_open:bool
    md_mod.parmtype=start_dirty_degraded:int
    ...

    Co-Developed-by: Gleb Fotengauer-Malinovskiy
    Signed-off-by: Gleb Fotengauer-Malinovskiy
    Signed-off-by: Alexey Gladkov
    Acked-by: Jessica Yu
    Signed-off-by: Masahiro Yamada

    Alexey Gladkov
     

06 May, 2019

1 commit

  • When BTF generation is enabled through CONFIG_DEBUG_INFO_BTF,
    scripts/link-vmlinux.sh detects if pahole version is too old and
    gracefully continues build process, skipping BTF generation build step.
    But if pahole is not available, build will still fail. This patch adds
    check for whether pahole exists at all and bails out gracefully, if not.

    Cc: Alexei Starovoitov
    Reported-by: Yonghong Song
    Fixes: e83b9f55448a ("kbuild: add ability to generate BTF type info for vmlinux")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann

    Andrii Nakryiko
     

16 Apr, 2019

1 commit

  • When CONFIG_DEBUG_INFO_BTF is enabled but available version of pahole is too
    old to support BTF generation, build script is supposed to emit warning and
    proceed with the build. Due to using exit instead of return from BASH function,
    existing handling code prematurely exits exit code 0, not completing some of
    the build steps. This patch fixes issue by correctly returning just from
    gen_btf() function only.

    Fixes: e83b9f55448a ("kbuild: add ability to generate BTF type info for vmlinux")
    Cc: Masahiro Yamada
    Cc: Arnaldo Carvalho de Melo
    Cc: Daniel Borkmann
    Cc: Alexei Starovoitov
    Cc: Yonghong Song
    Cc: Martin KaFai Lau
    Signed-off-by: Andrii Nakryiko
    Acked-by: Song Liu
    Signed-off-by: Daniel Borkmann

    Andrii Nakryiko