Skip to content
Snippets Groups Projects
  1. May 07, 2019
    • 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: default avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: default avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: default avatarAlexey Gladkov <gladkov.alexey@gmail.com>
      Acked-by: default avatarJessica Yu <jeyu@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      898490c0
  2. May 06, 2019
  3. May 03, 2019
  4. May 01, 2019
  5. Apr 29, 2019
  6. Apr 24, 2019
    • 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: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarAlexander Potapenko <glider@google.com>
      Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      709a972e
  7. Apr 21, 2019
  8. Apr 14, 2019
  9. Apr 09, 2019
  10. Apr 08, 2019
  11. Apr 02, 2019
    • 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: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default 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: default 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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKieran Bingham <kbingham@kernel.org>
      25b146c5
  12. Apr 01, 2019
  13. Mar 31, 2019
  14. Mar 28, 2019
  15. Mar 24, 2019
  16. Mar 21, 2019
  17. Mar 20, 2019
  18. Mar 17, 2019
    • Linus Torvalds's avatar
    • Masahiro Yamada's avatar
      kbuild: force all architectures except um to include mandatory-y · 037fc336
      Masahiro Yamada authored
      
      Currently, every arch/*/include/uapi/asm/Kbuild explicitly includes
      the common Kbuild.asm file. Factor out the duplicated include directives
      to scripts/Makefile.asm-generic so that no architecture would opt out
      of the mandatory-y mechanism.
      
      um is not forced to include mandatory-y since it is a very exceptional
      case which does not support UAPI.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      037fc336
    • Douglas Anderson's avatar
      kbuild: Make NOSTDINC_FLAGS a simply expanded variable · 0c22be07
      Douglas Anderson authored
      
      During a simple no-op (nothing changed) build I saw 39 invocations of
      the C compiler with the argument "-print-file-name=include".  We don't
      need to call the C compiler 39 times for this--one time will suffice.
      
      Let's change NOSTDINC_FLAGS to a simply expanded variable to avoid
      this since there doesn't appear to be any reason it should be
      recursively expanded.
      
      On my build this shaved ~400 ms off my "no-op" build.
      
      Note that the recursive expansion seems to date back to the (really
      old) commit e8f5bdb0 ("[PATCH] Makefile include path ordering").
      It's a little unclear to me if the point of that patch was to switch
      the variable to be recursively expanded (which it did) or to avoid
      directly assigning to NOSTDINC_FLAGS (AKA to switch to +=) because
      someone else (out of tree?) was setting it.  I presume later since if
      the only goal was to switch to recursive expansion the patch would
      have just removed the ":".
      
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0c22be07
  19. Mar 13, 2019
    • Masahiro Yamada's avatar
      kbuild: add workaround for Debian make-kpkg · 2b50f7ab
      Masahiro Yamada authored
      
      Since commit 3812b8c5 ("kbuild: make -r/-R effective in top
      Makefile for old Make versions"), make-kpkg is not working.
      
      make-kpkg directly includes the top Makefile of Linux kernel, and
      appends some debian_* targets.
      
        /usr/share/kernel-package/ruleset/kernel_version.mk:
      
          # Include the kernel makefile
          override dot-config := 1
          include Makefile
          dot-config := 1
      
      I did not know the kernel Makefile was used in that way, and it is
      hard to guarantee the behavior when the kernel Makefile is included
      by another Makefile from a different project.
      
      It looks like Debian Stretch stopped providing make-kpkg. Maybe it is
      obsolete and being replaced with 'make deb-pkg' etc. but still widely
      used.
      
      This commit adds a workaround; if the top Makefile is included by
      another Makefile, skip sub-make in order to make the main part visible.
      'MAKEFLAGS += -rR' does not become effective for GNU Make < 4.0, but
      Debian/Ubuntu is already using newer versions.
      
      The effect of this commit:
      
        Debian 8 (Jessie)  : Fixed
        Debian 9 (Stretch) : make-kpkg (kernel-package) is not provided
        Ubuntu 14.04 LTS   : NOT Fixed
        Ubuntu 16.04 LTS   : Fixed
        Ubuntu 18.04 LTS   : Fixed
      
      This commit cannot fix Ubuntu 14.04 because it installs GNU Make 3.81,
      but its support will end in Apr 2019, which is before the Linux v5.1
      release.
      
      I added warning so that nobody would try to include the top Makefile.
      
      Fixes: 3812b8c5 ("kbuild: make -r/-R effective in top Makefile for old Make versions")
      Reported-by: default avatarLiz Zhang <lizzha@microsoft.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: default avatarLili Deng <v-lide@microsoft.com>
      Cc: Manoj Srivastava <srivasta@debian.org>
      2b50f7ab
  20. Mar 04, 2019
  21. Mar 03, 2019
  22. Feb 28, 2019
  23. Feb 27, 2019
    • Masahiro Yamada's avatar
      kbuild: move ".config not found!" message from Kconfig to Makefile · 05850719
      Masahiro Yamada authored
      
      If you run "make" in a pristine source tree, currently Kbuild will
      start to build Kconfig to let it show the error message.
      
      It would be more straightforward to check it in Makefile and let
      it fail immediately.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      05850719
    • Masahiro Yamada's avatar
      kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing · 9390dff6
      Masahiro Yamada authored
      If include/config/auto.conf.cmd is lost for some reasons, it is not
      self-healing, so the top Makefile misses to run syncconfig.
      Move include/config/auto.conf.cmd to the target side.
      
      I used a pattern rule instead of a normal rule here although it is
      a bit gross.
      
      If the rule were written with a normal rule like this,
      
        include/config/auto.conf \
        include/config/auto.conf.cmd \
        include/config/tristate.conf: $(KCONFIG_CONFIG)
                $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
      
      ... syncconfig would be executed per target.
      
      Using a pattern rule makes sure that syncconfig is executed just once
      because Make assumes the recipe will create all of the targets.
      
      Here is a quote from the GNU Make manual [1]:
      
      "Pattern rules may have more than one target. Unlike normal rules,
      this does not act as many different rules with the same prerequisites
      and recipe. If a pattern rule has multiple targets, make knows that
      the rule's recipe is responsible for making all of the targets. The
      recipe is executed only once to make all the targets. When searching
      for a pattern rule to match a target, the target patterns of a rule
      other than the one that matches the target in need of a rule are
      incidental: make worries only about giving a recipe and prerequisites
      to the file presently in question. However, when this file's recipe is
      run, the other targets are marked as having been updated themselves."
      
      [1]: https://www.gnu.org/software/make/manual/html_node/Pattern-Intro.html
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9390dff6
    • Masahiro Yamada's avatar
      kbuild: simplify single target rules · 6b12de69
      Masahiro Yamada authored
      
      The dependency will be checked anyway after Kbuild descends into a
      sub-directory. Skip object/source dependency checks in top Makefile.
      
      VPATH can be simpler since the top Makefile no longer checks the
      presence of the source file, which is located in in the external
      module directory.
      
      One good thing is, it can compile an object from a generated source
      file.
      
        $ make crypto/rsapubkey.asn1.o
          ...
        ASN.1   crypto/rsapubkey.asn1.c
        CC      crypto/rsapubkey.asn1.o
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      6b12de69
    • Masahiro Yamada's avatar
      kbuild: remove empty rules for makefiles · b999923c
      Masahiro Yamada authored
      
      The previous commit made 'MAKEFLAGS += -rR' effective in the top
      Makefile regardless of O= option, GNU Make versions.
      
      The top Makefile does not need to cancel implicit rules for makefiles.
      
      There is still one place where an empty rule is useful. Since -rR is
      effective only after sub-make, GNU Make would try implicit rules to
      update the top Makefile. Although it is not a big overhead, cancel it
      just in case.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      b999923c
    • Masahiro Yamada's avatar
      kbuild: make -r/-R effective in top Makefile for old Make versions · 3812b8c5
      Masahiro Yamada authored
      
      Adding -rR to MAKEFLAGS is important because we do not want to
      be bothered by built-in implicit rules or variables.
      
      One problem that used to exist in older GNU Make versions is
      
        MAKEFLAGS += -rR
      
      ... does not become effective in the current Makefile. When you are
      building with O= option, it becomes effective in the top Makefile
      since it recurses via 'sub-make' target. Otherwise, the top Makefile
      tries implicit rules. That is why we explicitly add empty rules for
      Makefiles, but we often miss to do that.
      
      In fact, adding -d option to older GNU Make versions shows it is
      trying a bunch of implicit pattern rules.
      
       Considering target file `scripts/Makefile.kcov'.
        Looking for an implicit rule for `scripts/Makefile.kcov'.
        Trying pattern rule with stem `Makefile.kcov'.
        Trying implicit prerequisite `scripts/Makefile.kcov.o'.
        Trying pattern rule with stem `Makefile.kcov'.
        Trying implicit prerequisite `scripts/Makefile.kcov.c'.
        Trying pattern rule with stem `Makefile.kcov'.
        Trying implicit prerequisite `scripts/Makefile.kcov.cc'.
        Trying pattern rule with stem `Makefile.kcov'.
        Trying implicit prerequisite `scripts/Makefile.kcov.C'.
        ...
      
      This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501]
      Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer
      a problem if you use GNU Make 4.0 or later. However, older versions are
      still widely used.
      
      So, I decided to patch the kernel Makefile to invoke sub-make regardless
      of O= option. This will allow further cleanups.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      3812b8c5
Loading