Skip to content
  1. Jun 01, 2020
  2. May 25, 2020
  3. May 17, 2020
    • Masahiro Yamada's avatar
      kbuild: add infrastructure to build userspace programs · 7f3a59db
      Masahiro Yamada authored
      Kbuild supports the infrastructure to build host programs, but there
      was no support to build userspace programs for the target architecture
      (i.e. the same architecture as the kernel).
      
      Sam Ravnborg worked on this in 2014 (https://lkml.org/lkml/2014/7/13/154),
      but it was not merged. One problem at that time was, there was no good way
      to know whether $(CC) can link standalone programs. In fact, pre-built
      kernel.org toolchains [1] are often used for building the kernel, but they
      do not provide libc.
      
      Now, we can handle this cleanly because the compiler capability is
      evaluated at the Kconfig time. If $(CC) cannot link standalone programs,
      the relevant options are hidden by 'depends on CC_CAN_LINK'.
      
      The implementation just mimics scripts/Makefile.host
      
      The userspace programs are compiled with the same flags as the host
      programs. In addition, it uses -m32 or -m64 if it is found in
      $(KBUILD_CFLAGS).
      
      This new syntax has two usecases.
      
      - Sample programs
      
        Several userspace programs under samples/ include UAPI headers
        installed in usr/include. Most of them were previously built for
        the host architecture just to use the 'hostprogs' syntax.
      
        However, 'make headers' always works for the target architecture.
        This caused the arch mismatch in cross-compiling. To fix this
        distortion, sample code should be built for the target architecture.
      
      - Bpfilter
      
        net/bpfilter/Makefile compiles bpfilter_umh as the user mode helper,
        and embeds it into the kernel. Currently, it overrides HOSTCC with
        CC to use the 'hostprogs' syntax. This hack should go away.
      
      [1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      7f3a59db
  4. Apr 08, 2020
    • Masahiro Yamada's avatar
      kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y · 7273ad2b
      Masahiro Yamada authored
      Kbuild supports not only obj-y but also lib-y to list objects linked to
      vmlinux.
      
      The difference between them is that all the objects from obj-y are
      forcibly linked to vmlinux, whereas the objects from lib-y are linked
      as needed; if there is no user of a lib-y object, it is not linked.
      
      lib-y is intended to list utility functions that may be called from all
      over the place (and may be unused at all), but it is a problem for
      EXPORT_SYMBOL(). Even if there is no call-site in the vmlinux, we need
      to keep exported symbols for the use from loadable modules.
      
      Commit 7f2084fa ("[kbuild] handle exports in lib-y objects reliably")
      worked around it by linking a dummy object, lib-ksyms.o, which contains
      references to all the symbols exported from lib.a in that directory.
      It uses the linker script command, EXTERN. Unfortunately, the meaning of
      EXTERN of ld.lld is different from that of ld.bfd. Therefore, this does
      not work with LD=ld.lld (CBL issue #515).
      
      Anyway, the build rule of lib-ksyms.o is somewhat tricky. So, I want to
      get rid of it.
      
      At first, I was thinking of accumulating lib-y objects into obj-y
      (or even replacing lib-y with obj-y entirely), but the lib-y syntax
      is used beyond the ordinary use in lib/ and arch/*/lib/.
      
      Examples:
      
       - drivers/firmware/efi/libstub/Makefile builds lib.a, which is linked
         into vmlinux in the own way (arm64), or linked to the decompressor
         (arm, x86).
      
       - arch/alpha/lib/Makefile builds lib.a which is linked not only to
         vmlinux, but also to bootloaders in arch/alpha/boot/Makefile.
      
       - arch/xtensa/boot/lib/Makefile builds lib.a for use from
         arch/xtensa/boot/boot-redboot/Makefile.
      
      One more thing, adding everything to obj-y would increase the vmlinux
      size of allnoconfig (or tinyconfig).
      
      For less impact, I tweaked the destination of lib.a at the top Makefile;
      when CONFIG_MODULES=y, lib.a goes to KBUILD_VMLINUX_OBJS, which is
      forcibly linked to vmlinux, otherwise lib.a goes to KBUILD_VMLINUX_LIBS
      as before.
      
      The size impact for normal usecases is quite small since at lease one
      symbol in every lib-y object is eventually called by someone. In case
      you are intrested, here are the figures.
      
      x86_64_defconfig:
      
         text	   data	    bss	    dec	    hex	filename
      19566602 5422072 1589328 26578002 1958c52 vmlinux.before
      19566932 5422104 1589328 26578364 1958dbc vmlinux.after
      
      The case with the biggest impact is allnoconfig + CONFIG_MODULES=y.
      
      ARCH=x86 allnoconfig + CONFIG_MODULES=y:
      
         text	   data	    bss	    dec	    hex	filename
      1175162	 254740	1220608	2650510	 28718e	vmlinux.before
      1177974	 254836	1220608	2653418	 287cea	vmlinux.after
      
      Hopefully this is still not a big deal. The per-file trimming with the
      static library is not so effective after all.
      
      If fine-grained optimization is desired, some architectures support
      CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, which trims dead code per-symbol
      basis. When LTO is supported in mainline, even better optimization will
      be possible.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/515
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      7273ad2b
    • Masahiro Yamada's avatar
      gcc-plugins: drop support for GCC <= 4.7 · 77342a02
      Masahiro Yamada authored
      Nobody was opposed to raising minimum GCC version to 4.8 [1]
      So, we will drop GCC <= 4.7 support sooner or later.
      
      We always use C++ compiler for building plugins for GCC >= 4.8.
      
      This commit drops the plugin support for GCC <= 4.7 a bit earlier,
      which allows us to dump lots of code.
      
      [1] https://lkml.org/lkml/2020/1/23/545
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      77342a02
  5. Feb 03, 2020
    • Masahiro Yamada's avatar
      kbuild: rename hostprogs-y/always to hostprogs/always-y · 5f2fb52f
      Masahiro Yamada authored
      
      
      In old days, the "host-progs" syntax was used for specifying host
      programs. It was renamed to the current "hostprogs-y" in 2004.
      
      It is typically useful in scripts/Makefile because it allows Kbuild to
      selectively compile host programs based on the kernel configuration.
      
      This commit renames like follows:
      
        always       ->  always-y
        hostprogs-y  ->  hostprogs
      
      So, scripts/Makefile will look like this:
      
        always-$(CONFIG_BUILD_BIN2C) += ...
        always-$(CONFIG_KALLSYMS)    += ...
            ...
        hostprogs := $(always-y) $(always-m)
      
      I think this makes more sense because a host program is always a host
      program, irrespective of the kernel configuration. We want to specify
      which ones to compile by CONFIG options, so always-y will be handier.
      
      The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
      compatibility for a while.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5f2fb52f
  6. Jan 06, 2020
  7. Nov 14, 2019
    • Masahiro Yamada's avatar
      kbuild: remove header compile test · fcbb8461
      Masahiro Yamada authored
      There are both positive and negative options about this feature.
      At first, I thought it was a good idea, but actually Linus stated a
      negative opinion (https://lkml.org/lkml/2019/9/29/227
      
      ). I admit it
      is ugly and annoying.
      
      The baseline I'd like to keep is the compile-test of uapi headers.
      (Otherwise, kernel developers have no way to ensure the correctness
      of the exported headers.)
      
      I will maintain a small build rule in usr/include/Makefile.
      Remove the other header test functionality.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fcbb8461
  8. Nov 11, 2019
  9. Oct 01, 2019
  10. Sep 06, 2019
  11. Aug 21, 2019
    • Masahiro Yamada's avatar
      kbuild: move modkern_{c,a}flags to Makefile.lib from Makefile.build · eb27ea5c
      Masahiro Yamada authored
      
      
      Makefile.lib is included by Makefile.modfinal as well as Makefile.build.
      
      Move modkern_cflags to Makefile.lib in order to simplify cmd_cc_o_c
      in Makefile.modfinal. Move modkern_cflags as well for consistency.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      eb27ea5c
    • Masahiro Yamada's avatar
      kbuild: add CONFIG_ASM_MODVERSIONS · 2ff2b7ec
      Masahiro Yamada authored
      
      
      Add CONFIG_ASM_MODVERSIONS. This allows to remove one if-conditional
      nesting in scripts/Makefile.build.
      
      scripts/Makefile.build is run every time Kbuild descends into a
      sub-directory. So, I want to avoid $(wildcard ...) evaluation
      where possible although computing $(wildcard ...) is so cheap that
      it may not make measurable performance difference.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      2ff2b7ec
    • Masahiro Yamada's avatar
      kbuild: make single targets work more correctly · 394053f4
      Masahiro Yamada authored
      
      
      Currently, the single target build directly descends into the directory
      of the target. For example,
      
        $ make foo/bar/baz.o
      
      ... directly descends into foo/bar/.
      
      On the other hand, the normal build usually descends one directory at
      a time, i.e. descends into foo/, and then foo/bar/.
      
      This difference causes some problems.
      
      [1] miss subdir-asflags-y, subdir-ccflags-y in upper Makefiles
      
          The options in subdir-{as,cc}flags-y take effect in the current
          and its sub-directories. In other words, they are inherited
          downward. In the example above, the single target will miss
          subdir-{as,cc}flags-y if they are defined in foo/Makefile.
      
      [2] could be built in a different directory
      
          As Documentation/kbuild/modules.rst section 4.3 says, Kbuild can
          handle files that are spread over several sub-directories.
      
          The build rule of foo/bar/baz.o may not necessarily be specified in
          foo/bar/Makefile. It might be specifies in foo/Makefile as follows:
      
          [foo/Makefile]
          obj-y := bar/baz.o
      
          This often happens when a module is so big that its source files
          are divided into sub-directories.
      
          In this case, there is no Makefile in the foo/bar/ directory, yet
          the single target descends into foo/bar/, then fails due to the
          missing Makefile. You can still do 'make foo/bar/' for partial
          building, but cannot do 'make foo/bar/baz.s'. I believe the single
          target '%.s' is a useful feature for inspecting the compiler output.
      
          Some modules work around this issue by putting an empty Makefile
          in every sub-directory.
      
      This commit fixes those problems by making the single target build
      descend in the same way as the normal build does.
      
      Another change is the single target build will observe the CONFIG
      options. Previously, it allowed users to build the foo.o even when
      the corresponding CONFIG_FOO is disabled:
      
         obj-$(CONFIG_FOO) += foo.o
      
      In the new behavior, the single target build will just fail and show
      "No rule to make target ..." (or "Nothing to be done for ..." if the
      stale object already exists, but cannot be updated).
      
      The disadvantage of this commit is the build speed. Now that the
      single target build visits every directory and parses lots of
      Makefiles, it is slower than before. (But, I hope it will not be
      too slow.)
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      394053f4
  12. Aug 14, 2019
  13. Aug 13, 2019
    • Masahiro Yamada's avatar
      kbuild: use $(basename ...) for cmd_asn1_compiler · 49d5089d
      Masahiro Yamada authored
      
      
      $(basename ...) trims the last suffix. Using it is more intuitive in
      my opinion.
      
      This pattern rule makes %.asn1.c and %.asn1.h at the same time.
      Previously, the short log showed only either of them, depending on
      the target file in question.
      
      To clarify that two files are being generated by the single recipe,
      I changed the log as follows:
      
      Before:
      
        ASN.1   crypto/asymmetric_keys/x509.asn1.c
      
      After:
      
        ASN.1   crypto/asymmetric_keys/x509.asn1.[ch]
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      49d5089d
  14. Aug 09, 2019
    • Masahiro Yamada's avatar
      kbuild: show hint if subdir-y/m is used to visit module Makefile · c07d8d47
      Masahiro Yamada authored
      
      
      Since commit ff9b45c5 ("kbuild: modpost: read modules.order instead
      of $(MODVERDIR)/*.mod"), a module is no longer built in the following
      pattern:
      
        [Makefile]
        subdir-y := some-module
      
        [some-module/Makefile]
        obj-m := some-module.o
      
      You cannot write Makefile this way in upstream because modules.order is
      not correctly generated. subdir-y is used to descend to a sub-directory
      that builds tools, device trees, etc.
      
      For external modules, the modules order does not matter. So, the
      Makefile above was known to work.
      
      I believe the Makefile should be re-written as follows:
      
        [Makefile]
        obj-m := some-module/
      
        [some-module/Makefile]
        obj-m := some-module.o
      
      However, people will have no idea if their Makefile suddenly stops
      working. In fact, I received questions from multiple people.
      
      Show a warning for a while if obj-m is specified in a Makefile visited
      by subdir-y or subdir-m.
      
      I touched the %/ rule to avoid false-positive warnings for the single
      target.
      
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Tom Stonecypher <thomas.edwardx.stonecypher@intel.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      c07d8d47
    • Masahiro Yamada's avatar
      kbuild: generate modules.order only in directories visited by obj-y/m · 4f2c8f30
      Masahiro Yamada authored
      
      
      The modules.order files in directories visited by the chain of obj-y
      or obj-m are merged to the upper-level ones, and become parts of the
      top-level modules.order. On the other hand, there is no need to
      generate modules.order in directories visited by subdir-y or subdir-m
      since they would become orphan anyway.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4f2c8f30
    • Masahiro Yamada's avatar
      kbuild: fix false-positive need-builtin calculation · d9f78edf
      Masahiro Yamada authored
      
      
      The current implementation of need-builtin is false-positive,
      for example, in the following Makefile:
      
        obj-m := foo/
        obj-y := foo/bar/
      
      ..., where foo/built-in.a is not required.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d9f78edf
  15. Jul 17, 2019
    • Masahiro Yamada's avatar
      kbuild: split out *.mod out of {single,multi}-used-m rules · 9f69a496
      Masahiro Yamada authored
      
      
      Currently, *.mod is created as a side-effect of obj-m.
      
      Split out *.mod as a dedicated build rule, which allows to unify
      the %.c -> %.o rule, and remove the single-used-m rule.
      
      This also makes the incremental build of allmodconfig faster because
      it saves $(NM) invocation when there is no change in the module.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9f69a496
    • Masahiro Yamada's avatar
      kbuild: remove the first line of *.mod files · 60ae1b19
      Masahiro Yamada authored
      
      
      The current format of *.mod is like this:
      
        line 1: directory path to the .ko file
        line 2: a list of objects linked into this module
        line 3: unresolved symbols (only when CONFIG_TRIM_UNUSED_KSYMS=y)
      
      Now that *.mod and *.ko are created in the same directory, the line 1
      provides no valuable information. It can be derived by replacing the
      extension .mod with .ko. In fact, nobody uses the first line any more.
      
      Cut down the first line.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      60ae1b19
    • Masahiro Yamada's avatar
      kbuild: create *.mod with full directory path and remove MODVERDIR · b7dca6dd
      Masahiro Yamada authored
      While descending directories, Kbuild produces objects for modules,
      but do not link final *.ko files; it is done in the modpost.
      
      To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
      for every module it is building. Some post-processing steps read the
      necessary information from *.mod files. This avoids descending into
      directories again. This mechanism was introduced in 2003 or so.
      
      Later, commit 551559e1 ("kbuild: implement modules.order") added
      modules.order. So, we can simply read it out to know all the modules
      with directory paths. This is easier than parsing the first line of
      *.mod files.
      
      $(MODVERDIR) has a flat directory structure, that is, *.mod files
      are named only with base names. This is based on the assumption that
      the module name is unique across the tree. This assumption is really
      fragile.
      
      Stephen Rothwell reported a race condition caused by a module name
      conflict:
      
        https://lkml.org/lkml/2019/5/13/991
      
      
      
      In parallel building, two different threads could write to the same
      $(MODVERDIR)/*.mod simultaneously.
      
      Non-unique module names are the source of all kind of troubles, hence
      commit 3a48a919 ("kbuild: check uniqueness of module names")
      introduced a new checker script.
      
      However, it is still fragile in the build system point of view because
      this race happens before scripts/modules-check.sh is invoked. If it
      happens again, the modpost will emit unclear error messages.
      
      To fix this issue completely, create *.mod with full directory path
      so that two threads never attempt to write to the same file.
      
      $(MODVERDIR) is no longer needed.
      
      Since modules with directory paths are listed in modules.order, Kbuild
      is still able to find *.mod files without additional descending.
      
      I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash
      for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y,
      it occurs not only in the modpost stage, but also during directory
      descending, where sumversion.c may parse stale *.mod files. It would emit
      'No such file or directory' warning when an object consisting a module is
      renamed, or when a single-obj module is turned into a multi-obj module or
      vice versa.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarNicolas Pitre <nico@fluxnic.net>
      b7dca6dd
    • Masahiro Yamada's avatar
      kbuild: remove duplication from modules.order in sub-directories · e0e1b1ec
      Masahiro Yamada authored
      
      
      Currently, only the top-level modules.order drops duplicated entries.
      
      The modules.order files in sub-directories potentially contain
      duplication. To list out the paths of all modules, I want to use
      modules.order instead of parsing *.mod files in $(MODVERDIR).
      
      To achieve this, I want to rip off duplication from modules.order
      of external modules too.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e0e1b1ec
    • Masahiro Yamada's avatar
      kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin} · 1bd9a468
      Masahiro Yamada authored
      
      
      Removing the 'kernel/' prefix will make our life easier because we can
      simply do 'cat modules.order' to get all built modules with full paths.
      
      Currently, we parse the first line of '*.mod' files in $(MODVERDIR).
      Since we have duplicated functionality here, I plan to remove MODVERDIR
      entirely.
      
      In fact, modules.order is generated also for external modules in a
      broken format. It adds the 'kernel/' prefix to the absolute path of
      the module, like this:
      
        kernel//path/to/your/external/module/foo.ko
      
      This is fine for now since modules.order is not used for external
      modules. However, I want to sanitize the format everywhere towards
      the goal of removing MODVERDIR.
      
      We cannot change the format of installed module.{order,builtin}.
      So, 'make modules_install' will add the 'kernel/' prefix while copying
      them to $(MODLIB)/.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1bd9a468
    • Masahiro Yamada's avatar
      kbuild: do not create empty modules.order in the prepare stage · 7e131918
      Masahiro Yamada authored
      
      
      Currently, $(objtree)/modules.order is touched in two places.
      
      In the 'prepare0' rule, scripts/Makefile.build creates an empty
      modules.order while processing 'obj=.'
      
      In the 'modules' rule, the top-level Makefile overwrites it with
      the correct list of modules.
      
      While this might be a good side-effect that modules.order is made
      empty every time (probably this is not intended functionality),
      I personally do not like this behavior.
      
      Create modules.order only when it is sensible to do so.
      
      This avoids creating the following pointless files:
      
        scripts/basic/modules.order
        scripts/dtc/modules.order
        scripts/gcc-plugins/modules.order
        scripts/genksyms/modules.order
        scripts/mod/modules.order
        scripts/modules.order
        scripts/selinux/genheaders/modules.order
        scripts/selinux/mdp/modules.order
        scripts/selinux/modules.order
      
      Going forward, $(objtree)/modules.order lists the modules that
      was built in the last successful build.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7e131918
    • Masahiro Yamada's avatar
      kbuild: compile-test headers listed in header-test-m as well · 4bd01de8
      Masahiro Yamada authored
      
      
      It will be useful to control the header-test by a tristate option.
      
      If CONFIG_FOO is a tristate option, you can write like this:
      
        header-test-$(CONFIG_FOO) += foo.h
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4bd01de8
  16. Jul 10, 2019
  17. Jul 09, 2019
    • Masahiro Yamada's avatar
      kbuild: do not create wrappers for header-test-y · c93a0368
      Masahiro Yamada authored
      
      
      header-test-y does not work with headers in sub-directories.
      
      For example, you may want to write a Makefile, like this:
      
      include/linux/Kbuild:
      
        header-test-y += mtd/nand.h
      
      This entry will create a wrapper include/linux/mtd/nand.hdrtest.c
      with the following content:
      
        #include "mtd/nand.h"
      
      To make this work, we need to add $(srctree)/include/linux to the
      header search path. It would be tedious to add ccflags-y.
      
      Instead, we could change the *.hdrtest.c rule to wrap:
      
        #include "nand.h"
      
      This works for in-tree build since #include "..." searches in the
      relative path from the header with this directive. For O=... build,
      we need to add $(srctree)/include/linux/mtd to the header search path,
      which will be even more tedious.
      
      After all, I thought it would be handier to compile headers directly
      without creating wrappers.
      
      I added a new build rule to compile %.h into %.h.s
      
      The target is %.h.s instead of %.h.o because it is slightly faster.
      Also, as for GCC, an empty assembly is smaller than an empty object.
      
      I wrote the build rule:
      
        $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $<
      
      instead of:
      
        $(CC) $(c_flags) -S -o $@ -x c $<
      
      Both work fine with GCC, but the latter is bad for Clang.
      
      This comes down to the difference in the -Wunused-function policy.
      GCC does not warn about unused 'static inline' functions at all.
      Clang does not warn about the ones in included headers, but does
      about the ones in the source. So, we should handle headers as
      headers, not as source files.
      
      In fact, this has been hidden since commit abb2ea7d ("compiler,
      clang: suppress warning for unused static inline functions"), but we
      should not rely on that.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Tested-by: default avatarJani Nikula <jani.nikula@intel.com>
      c93a0368
  18. Jun 15, 2019
  19. Apr 03, 2019
    • Peter Zijlstra's avatar
      objtool: Add UACCESS validation · ea24213d
      Peter Zijlstra authored
      
      
      It is important that UACCESS regions are as small as possible;
      furthermore the UACCESS state is not scheduled, so doing anything that
      might directly call into the scheduler will cause random code to be
      ran with UACCESS enabled.
      
      Teach objtool too track UACCESS state and warn about any CALL made
      while UACCESS is enabled. This very much includes the __fentry__()
      and __preempt_schedule() calls.
      
      Note that exceptions _do_ save/restore the UACCESS state, and therefore
      they can drive preemption. This also means that all exception handlers
      must have an otherwise redundant UACCESS disable instruction;
      therefore ignore this warning for !STT_FUNC code (exception handlers
      are not normal functions).
      
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ea24213d
  20. Apr 02, 2019
    • 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
  21. Mar 28, 2019
    • Joe Lawrence's avatar
      kbuild: strip whitespace in cmd_record_mcount findstring · 1a49b2fd
      Joe Lawrence authored
      
      
      CC_FLAGS_FTRACE may contain trailing whitespace that interferes with
      findstring.
      
      For example, commit 6977f95e ("powerpc: avoid -mno-sched-epilog on
      GCC 4.9 and newer") introduced a change such that on my ppc64le box,
      CC_FLAGS_FTRACE="-pg -mprofile-kernel ".  (Note the trailing space.)
      When cmd_record_mcount is now invoked, findstring fails as the ftrace
      flags were found at very end of _c_flags, without the trailing space.
      
        _c_flags=" ... -pg -mprofile-kernel"
        CC_FLAGS_FTRACE="-pg -mprofile-kernel "
                                             ^
          findstring is looking for this extra space
      
      Remove the redundant whitespaces from CC_FLAGS_FTRACE in
      cmd_record_mcount to avoid this problem.
      
      [masahiro.yamada: This issue only happens in the released versions
      of GNU Make. CC_FLAGS_FTRACE will not contain the trailing space if
      you use the latest GNU Make, which contains commit b90fabc8d6f3
      ("* NEWS: Do not insert a space during '+=' if the value is empty.") ]
      
      Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com> (refactoring)
      Fixes: 6977f95e ("powerpc: avoid -mno-sched-epilog on GCC 4.9 and newer").
      Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1a49b2fd
  22. Mar 13, 2019
Loading