1. 07 Jul, 2019 1 commit
  2. 30 Jun, 2019 1 commit
  3. 22 Jun, 2019 1 commit
  4. 16 Jun, 2019 1 commit
  5. 09 Jun, 2019 1 commit
  6. 04 Jun, 2019 1 commit
  7. 02 Jun, 2019 1 commit
  8. 26 May, 2019 1 commit
  9. 19 May, 2019 1 commit
  10. 18 May, 2019 8 commits
    • Masahiro Yamada's avatar
      kbuild: check uniqueness of module names · 3a48a919
      Masahiro Yamada authored
      In the recent build test of linux-next, Stephen saw a build error
      caused by a broken .tmp_versions/*.mod file:
      
        https://lkml.org/lkml/2019/5/13/991
      
      drivers/net/phy/asix.ko and drivers/net/usb/asix.ko have the same
      basename, and there is a race in generating .tmp_versions/asix.mod
      
      Kbuild has not checked this before, and it suddenly shows up with
      obscure error messages when this kind of race occurs.
      
      Non-unique module names cause various sort of problems, but it is
      not trivial to catch them by eyes.
      
      Hence, this script.
      
      It checks not only real modules, but also built-in modules (i.e.
      controlled by tristate CONFIG option, but currently compiled with =y).
      Non-unique names for built-in modules also cause problems because
      /sys/modules/ would fall over.
      
      For the latest kernel, I tested "make allmodconfig all" (or more
      quickly "make allyesconfig modules"), and it detected the following:
      
      warning: same basename if the following are built as modules:
        drivers/regulator/88pm800.ko
        drivers/mfd/88pm800.ko
      warning: same basename if the following are built as modules:
        drivers/gpu/drm/bridge/adv7511/adv7511.ko
        drivers/media/i2c/adv7511.ko
      warning: same basename if the following are built as modules:
        drivers/net/phy/asix.ko
        drivers/net/usb/asix.ko
      warning: same basename if the following are built as modules:
        fs/coda/coda.ko
        drivers/media/platform/coda/coda.ko
      warning: same basename if the following are built as modules:
        drivers/net/phy/realtek.ko
        drivers/net/dsa/realtek.ko
      Reported-by: 's avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: 's avatarKees Cook <keescook@chromium.org>
      Reviewed-by: 's avatarStephen Rothwell <sfr@canb.auug.org.au>
      Reviewed-by: 's avatarLucas De Marchi <lucas.demarchi@intel.com>
      3a48a919
    • Masahiro Yamada's avatar
      kbuild: add LICENSES to KBUILD_ALLDIRS · 233c741d
      Masahiro Yamada authored
      For *-pkg targets, the LICENSES directory should be included in the
      source tarball.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      233c741d
    • Masahiro Yamada's avatar
      kbuild: terminate Kconfig when $(CC) or $(LD) is missing · 902a6898
      Masahiro Yamada authored
      If the compiler specified by $(CC) is not present, the Kconfig stage
      sprinkles 'not found' messages, then succeeds.
      
        $ make CROSS_COMPILE=foo defconfig
        /bin/sh: 1: foogcc: not found
        /bin/sh: 1: foogcc: not found
        *** Default configuration is based on 'x86_64_defconfig'
        ./scripts/gcc-version.sh: 17: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 18: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 19: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 17: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 18: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 19: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/clang-version.sh: 11: ./scripts/clang-version.sh: foogcc: not found
        ./scripts/gcc-plugin.sh: 11: ./scripts/gcc-plugin.sh: foogcc: not found
        init/Kconfig:16:warning: 'GCC_VERSION': number is invalid
        #
        # configuration written to .config
        #
      
      Terminate parsing files immediately if $(CC) or $(LD) is not found.
      "make *config" will fail more nicely.
      
        $ make CROSS_COMPILE=foo defconfig
        *** Default configuration is based on 'x86_64_defconfig'
        scripts/Kconfig.include:34: compiler 'foogcc' not found
        make[1]: *** [scripts/kconfig/Makefile;82: defconfig] Error 1
        make: *** [Makefile;557: defconfig] Error 2
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      902a6898
    • Masahiro Yamada's avatar
      kbuild: turn auto.conf.cmd into a mandatory include file · d2f8ae0e
      Masahiro Yamada authored
      syncconfig is responsible for keeping auto.conf up-to-date, so if it
      fails for any reason, the build must be terminated immediately.
      
      However, since commit 9390dff6 ("kbuild: invoke syncconfig if
      include/config/auto.conf.cmd is missing"), Kbuild continues running
      even after syncconfig fails.
      
      You can confirm this by intentionally making syncconfig error out:
      
        diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
        index 08ba146..307b9de 100644
        --- a/scripts/kconfig/confdata.c
        +++ b/scripts/kconfig/confdata.c
        @@ -1023,6 +1023,9 @@ int conf_write_autoconf(int overwrite)
                FILE *out, *tristate, *out_h;
                int i;
      
        +       if (overwrite)
        +               return 1;
        +
                if (!overwrite && is_present(autoconf_name))
                        return 0;
      
      Then, syncconfig fails, but Make would not stop:
      
        $ make -s mrproper allyesconfig defconfig
        $ make
        scripts/kconfig/conf  --syncconfig Kconfig
      
        *** Error during sync of the configuration.
      
        make[2]: *** [scripts/kconfig/Makefile;69: syncconfig] Error 1
        make[1]: *** [Makefile;557: syncconfig] Error 2
        make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf'
        make: Failed to remake makefile 'include/config/auto.conf'.
          SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
          SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
          SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
          SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
        [ continue running ... ]
      
      The reason is in the behavior of a pattern rule with multi-targets.
      
        %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
                $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
      
      GNU Make knows this rule is responsible for making all the three files
      simultaneously. As far as examined, auto.conf.cmd is the target in
      question when this rule is invoked. It is probably because auto.conf.cmd
      is included below the inclusion of auto.conf.
      
      The inclusion of auto.conf is mandatory, while that of auto.conf.cmd
      is optional. GNU Make does not care about the failure in the process
      of updating optional include files.
      
      I filed this issue (https://savannah.gnu.org/bugs/?56301) in case this
      behavior could be improved somehow in future releases of GNU Make.
      Anyway, it is quite easy to fix our Makefile.
      
      Given that auto.conf is already a mandatory include file, there is no
      reason to stick auto.conf.cmd optional. Make it mandatory as well.
      
      Cc: linux-stable <stable@vger.kernel.org> # 5.0+
      Fixes: 9390dff6 ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing")
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d2f8ae0e
    • Masahiro Yamada's avatar
      kbuild: add all Clang-specific flags unconditionally · a1494304
      Masahiro Yamada authored
      We do not support old Clang versions. Upgrade your clang version
      if any of these flags is unsupported.
      
      Let's add all flags inside ifdef CONFIG_CC_IS_CLANG unconditionally.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: 's avatarSedat Dilek <sedat.dilek@gmail.com>
      Reviewed-by: 's avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: 's avatarNick Desaulniers <ndesaulniers@google.com>
      a1494304
    • Nathan Chancellor's avatar
      7eb8e5f0
    • Masahiro Yamada's avatar
      kbuild: add -Wvla flag unconditionally · 8289f913
      Masahiro Yamada authored
      This flag is documented in the GCC 4.6 manual, and recognized by
      Clang as well. Let's rip off the cc-option switch.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: 's avatarSedat Dilek <sedat.dilek@gmail.com>
      Reviewed-by: 's avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: 's avatarKees Cook <keescook@chromium.org>
      Tested-by: 's avatarNick Desaulniers <ndesaulniers@google.com>
      8289f913
    • Masahiro Yamada's avatar
      kbuild: re-enable int-in-bool-context warning · a3bc8864
      Masahiro Yamada authored
      This warning was disabled by commit bd664f6b ("disable new
      gcc-7.1.1 warnings for now") just because it was too noisy.
      
      Thanks to Arnd Bergmann, all warnings have been fixed. Now, we are
      ready to re-enable it.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      a3bc8864
  11. 07 May, 2019 1 commit
    • Alexey Gladkov's avatar
      moduleparam: Save information about built-in modules in separate file · 898490c0
      Alexey Gladkov authored
      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: 's avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: 's avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: 's avatarAlexey Gladkov <gladkov.alexey@gmail.com>
      Acked-by: 's avatarJessica Yu <jeyu@kernel.org>
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      898490c0
  12. 06 May, 2019 1 commit
  13. 03 May, 2019 2 commits
  14. 01 May, 2019 1 commit
  15. 29 Apr, 2019 1 commit
  16. 24 Apr, 2019 1 commit
    • Kees Cook's avatar
      security: Implement Clang's stack initialization · 709a972e
      Kees Cook authored
      CONFIG_INIT_STACK_ALL turns on stack initialization based on
      -ftrivial-auto-var-init in Clang builds, which has greater coverage
      than CONFIG_GCC_PLUGINS_STRUCTLEAK_BYREF_ALL.
      
      -ftrivial-auto-var-init Clang option provides trivial initializers for
      uninitialized local variables, variable fields and padding.
      
      It has three possible values:
        pattern - uninitialized locals are filled with a fixed pattern
          (mostly 0xAA on 64-bit platforms, see https://reviews.llvm.org/D54604
          for more details, but 0x000000AA for 32-bit pointers) likely to cause
          crashes when uninitialized value is used;
        zero (it's still debated whether this flag makes it to the official
          Clang release) - uninitialized locals are filled with zeroes;
        uninitialized (default) - uninitialized locals are left intact.
      
      This patch uses only the "pattern" mode when CONFIG_INIT_STACK_ALL is
      enabled.
      
      Developers have the possibility to opt-out of this feature on a
      per-variable basis by using __attribute__((uninitialized)), but such
      use should be well justified in comments.
      Co-developed-by: 's avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: 's avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: 's avatarKees Cook <keescook@chromium.org>
      Tested-by: 's avatarAlexander Potapenko <glider@google.com>
      Acked-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      709a972e
  17. 21 Apr, 2019 1 commit
  18. 14 Apr, 2019 1 commit
  19. 09 Apr, 2019 2 commits
  20. 08 Apr, 2019 2 commits
  21. 02 Apr, 2019 3 commits
    • Andrii Nakryiko's avatar
      kbuild: add ability to generate BTF type info for vmlinux · e83b9f55
      Andrii Nakryiko authored
      This patch adds new config option to trigger generation of BTF type
      information from DWARF debuginfo for vmlinux and kernel modules through
      pahole, which in turn relies on libbpf for btf_dedup() algorithm.
      
      The intent is to record compact type information of all types used
      inside kernel, including all the structs/unions/typedefs/etc. This
      enables BPF's compile-once-run-everywhere ([0]) approach, in which
      tracing programs that are inspecting kernel's internal data (e.g.,
      struct task_struct) can be compiled on a system running some kernel
      version, but would be possible to run on other kernel versions (and
      configurations) without recompilation, even if the layout of structs
      changed and/or some of the fields were added, removed, or renamed.
      
      This is only possible if BPF loader can get kernel type info to adjust
      all the offsets correctly. This patch is a first time in this direction,
      making sure that BTF type info is part of Linux kernel image in
      non-loadable ELF section.
      
      BTF deduplication ([1]) algorithm typically provides 100x savings
      compared to DWARF data, so resulting .BTF section is not big as is
      typically about 2MB in size.
      
      [0] http://vger.kernel.org/lpc-bpf2018.html#session-2
      [1] https://facebookmicrosites.github.io/bpf/blog/2018/11/14/btf-enhancement.html
      
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Signed-off-by: 's avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: 's avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: 's avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: 's avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: 's avatarDaniel Borkmann <daniel@iogearbox.net>
      e83b9f55
    • Masahiro Yamada's avatar
      kbuild: use $(srctree) instead of KBUILD_SRC to check out-of-tree build · a9a49c2a
      Masahiro Yamada authored
      KBUILD_SRC was conventionally used for some different purposes:
       [1] To remember the source tree path
       [2] As a flag to check if sub-make is already done
       [3] As a flag to check if Kbuild runs out of tree
      
      For [1], we do not need to remember it because the top Makefile
      can compute it by $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
      
      [2] has been replaced with self-commenting 'sub_make_done'.
      
      For [3], we can distinguish in-tree/out-of-tree by comparing
      $(srctree) and '.'
      
      This commit converts [3] to prepare for the KBUILD_SRC removal.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a9a49c2a
    • Masahiro Yamada's avatar
      kbuild: allow Kbuild to start from any directory · 25b146c5
      Masahiro Yamada authored
      Kbuild always runs in the top of the output directory.
      
      If Make starts in the source directory with O=, it relocates the
      working directory to the location specified by O=.
      
      Also, users can start build from the output directory by using the
      Makefile generated by scripts/mkmakefile.
      
      With a little more effort, Kbuild will be able to start from any
      directory path.
      
      This commit allows to specify the source directory by using
      the -f option.
      
      For example, you can do:
      
        $ cd path/to/output/dir
        $ make -f path/to/source/dir/Makefile
      
      Or, for the equivalent behavior, you can do:
      
        $ make O=path/to/output/dir -f path/to/source/dir/Makefile
      
      KBUILD_SRC is now deprecated.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: 's avatarKieran Bingham <kbingham@kernel.org>
      25b146c5
  22. 01 Apr, 2019 3 commits
  23. 31 Mar, 2019 1 commit
  24. 28 Mar, 2019 3 commits