1. 17 7月, 2019 3 次提交
    • M
      kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin} · 1bd9a468
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1bd9a468
    • M
      kbuild: do not create empty modules.order in the prepare stage · 7e131918
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      7e131918
    • M
      kbuild: compile-test headers listed in header-test-m as well · 4bd01de8
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      4bd01de8
  2. 10 7月, 2019 1 次提交
  3. 09 7月, 2019 1 次提交
    • M
      kbuild: do not create wrappers for header-test-y · c93a0368
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NJani Nikula <jani.nikula@intel.com>
      Tested-by: NJani Nikula <jani.nikula@intel.com>
      c93a0368
  4. 15 6月, 2019 1 次提交
  5. 03 4月, 2019 1 次提交
    • P
      objtool: Add UACCESS validation · ea24213d
      Peter Zijlstra 提交于
      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: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NJosh 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: NIngo Molnar <mingo@kernel.org>
      ea24213d
  6. 02 4月, 2019 1 次提交
    • M
      kbuild: use $(srctree) instead of KBUILD_SRC to check out-of-tree build · a9a49c2a
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      a9a49c2a
  7. 28 3月, 2019 1 次提交
    • J
      kbuild: strip whitespace in cmd_record_mcount findstring · 1a49b2fd
      Joe Lawrence 提交于
      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: NJoe Lawrence <joe.lawrence@redhat.com>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1a49b2fd
  8. 14 3月, 2019 1 次提交
  9. 27 2月, 2019 1 次提交
    • M
      kbuild: hardcode genksyms path and remove GENKSYMS variable · 88110713
      Masahiro Yamada 提交于
      The genksyms source was integrated into the kernel tree in 2003.
      
      I do not expect anybody still using the external /sbin/genksyms.
      Kbuild does not need to provide the ability to override GENKSYMS.
      
      Let's remove the GENKSYMS variable, and use the hardcoded path.
      
      Since it occurred in the pre-git era, I attached the commit message
      in case somebody is interested in the historical background.
      
        | Author: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
        | Date:   Wed Feb 19 04:17:28 2003 -0600
        |
        | kbuild: [PATCH] put genksyms in scripts dir
        |
        | This puts genksyms into scripts/genksyms/.
        |
        | genksyms used to be maintained externally, though the only possible user
        | was the kernel build. Moving it into the kernel sources makes it easier to
        | keep it uptodate, like for example updating it to generate linker scripts
        | directly instead of postprocessing the generated header file fragments
        | with sed, as we do currently.
        |
        | Also, genksyms does not handle __typeof__, which needs to be fixed since
        | some of the exported symbol in the kernel are defined using __typeof__.
        |
        | (Rusty Russell/me)
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      88110713
  10. 20 2月, 2019 2 次提交
    • M
      kbuild: generate modules.order only when CONFIG_MODULES=y · 1d8001ef
      Masahiro Yamada 提交于
      Do not generate pointless modules.order when the module support is
      disabled.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1d8001ef
    • M
      kbuild: Disable extra debugging info in .s output · 1e88e415
      Masahiro Yamada 提交于
      Modern gcc adds view assignments, reset assertion checking in .loc
      directives and a couple more additional debug markers, which clutters
      the asm output unnecessarily:
      
      For example:
      
        bsp_resume:
        .LFB3466:
                .loc 1 1868 1 is_stmt 1 view -0
                .cfi_startproc
                .loc 1 1869 2 view .LVU73
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                .loc 1 1869 14 is_stmt 0 view .LVU74
                movq    this_cpu(%rip), %rax    # this_cpu, this_cpu
                movq    64(%rax), %rax  # this_cpu.94_1->c_bsp_resume, _2
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                .loc 1 1869 5 view .LVU75
                testq   %rax, %rax      # _2
                je      .L8     #,
                .loc 1 1870 3 is_stmt 1 view .LVU76
                movq    $boot_cpu_data, %rdi    #,
                jmp     __x86_indirect_thunk_rax
      
      or
              .loc 2 57 9 view .LVU478
              .loc 2 57 9 view .LVU479
              .loc 2 57 9 view .LVU480
              .loc 2 57 9 view .LVU481
        .LBB1385:
        .LBB1383:
        .LBB1379:
        .LBB1377:
        .LBB1375:
              .loc 2 57 9 view .LVU482
              .loc 2 57 9 view .LVU483
              movl	%edi, %edx	# cpu, cpu
        .LVL87:
              .loc 2 57 9 is_stmt 0 view .LVU484
      
      That MOV in there is drowned in debugging information and latter makes
      it hard to follow the asm. And that DWARF info is not really needed for
      asm output staring.
      
      Disable the debug information generation which clutters the asm output
      unnecessarily:
      
        bsp_resume:
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                movq    this_cpu(%rip), %rax    # this_cpu, this_cpu
                movq    64(%rax), %rax  # this_cpu.94_1->c_bsp_resume, _2
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                testq   %rax, %rax      # _2
                je      .L8     #,
        # arch/x86/kernel/cpu/common.c:1870:            this_cpu->c_bsp_resume(&boot_cpu_data);
                movq    $boot_cpu_data, %rdi    #,
                jmp     __x86_indirect_thunk_rax
        .L8:
        # arch/x86/kernel/cpu/common.c:1871: }
                rep ret
                .size   bsp_resume, .-bsp_resume
      
        [ bp: write commit message. ]
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      1e88e415
  11. 28 1月, 2019 3 次提交
  12. 16 12月, 2018 4 次提交
  13. 02 12月, 2018 1 次提交
    • M
      kbuild: move .SECONDARY special target to Kbuild.include · 8e9b61b2
      Masahiro Yamada 提交于
      In commit 54a702f7 ("kbuild: mark $(targets) as .SECONDARY and
      remove .PRECIOUS markers"), I missed one important feature of the
      .SECONDARY target:
      
          .SECONDARY with no prerequisites causes all targets to be
          treated as secondary.
      
      ... which agrees with the policy of Kbuild.
      
      Let's move it to scripts/Kbuild.include, with no prerequisites.
      
      Note:
      If an intermediate file is generated by $(call if_changed,...), you
      still need to add it to "targets" so its .*.cmd file is included.
      
      The arm/arm64 crypto files are generated by $(call cmd,shipped),
      so they do not need to be added to "targets", but need to be added
      to "clean-files" so "make clean" can properly clean them away.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      8e9b61b2
  14. 01 12月, 2018 7 次提交
    • M
      kbuild: remove redundant 'set -e' from cmd_* defines · 5439f09f
      Masahiro Yamada 提交于
      These three cmd_* are invoked in the $(call cmd,*) form.
      
      Now that 'set -e' moved to the 'cmd' macro, they do not need to
      explicitly give 'set -e'.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      5439f09f
    • M
      kbuild: remove trailing semicolon from cmd_* passed to if_changed_rule · e5d28910
      Masahiro Yamada 提交于
      With the change of rule_cc_o_c / rule_as_o_S in the last commit, each
      command is executed in a separate subshell. Rip off unneeded semicolons.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      e5d28910
    • M
      kbuild: change if_changed_rule for multi-line recipe · 3a2429e1
      Masahiro Yamada 提交于
      The 'define' ... 'endef' directive is useful to confine a series of
      shell commands into a single macro:
      
        define foo
                [action1]
                [action2]
                [action3]
        endif
      
      Each action is executed in a separate subshell.
      
      However, rule_cc_o_c and rule_as_o_S in scripts/Makefile.build are
      written as follows (with a trailing semicolon in each cmd_*):
      
        define rule_cc_o_c
                [action1] ; \
                [action2] ; \
                [action3] ;
        endef
      
      All shell commands are concatenated with '; \' so that it looks like
      a single command from the Makefile point of view. This does not
      exploit the benefits of 'define' ... 'endef' form because a single
      shell command can be more simply written, like this:
      
        rule_cc_o_c = \
                [action1] ; \
                [action2] ; \
                [action3] ;
      
      I guess the intention for the command concatenation was to let the
      '@set -e' in if_changed_rule cover all the commands.
      
      We can improve the readability by moving '@set -e' to the 'cmd' macro.
      The combo of $(call echo-cmd,*) $(cmd_*) in rule_cc_o_c and rule_as_o_S
      have been replaced with $(call cmd,*). The trailing back-slashes have
      been removed.
      
      Here is a note about the performance: the commands in rule_cc_o_c and
      rule_as_o_S were previously executed all together in a single subshell,
      but now each line in a separate subshell. This means Make will spawn
      extra subshells [1]. I measured the build performance for
        x86_64_defconfig + CONFIG_MODVERSIONS + CONFIG_TRIM_UNUSED_KSYMS
      and I saw slight performance regression, but I believe code readability
      and maintainability wins.
      
      [1] Precisely, GNU Make may optimize this by executing the command
          directly instead of forking a subshell, if no shell special
          characters are found in the command line and omitting the subshell
          will not change the behavior.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      3a2429e1
    • M
      kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS · bbda5ec6
      Masahiro Yamada 提交于
      My main motivation of this commit is to clean up scripts/Kbuild.include
      and scripts/Makefile.build.
      
      Currently, CONFIG_TRIM_UNUSED_KSYMS works with a tricky gimmick;
      possibly exported symbols are detected by letting $(CPP) replace
      EXPORT_SYMBOL* with a special string '=== __KSYM_*===', which is
      post-processed by sed, and passed to fixdep. The extra preprocessing
      is costly, and hacking cmd_and_fixdep is ugly.
      
      I came up with a new way to find exported symbols; insert a dummy
      symbol __ksym_marker_* to each potentially exported symbol. Those
      dummy symbols are picked up by $(NM), post-processed by sed, then
      appended to .*.cmd files. I collected the post-process part to a
      new shell script scripts/gen_ksymdeps.sh for readability. The dummy
      symbols are put into the .discard.* section so that the linker
      script rips them off the final vmlinux or modules.
      
      A nice side-effect is building with CONFIG_TRIM_UNUSED_KSYMS will
      be much faster.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NNicolas Pitre <nico@linaro.org>
      bbda5ec6
    • M
      kbuild: refactor modversions build rules · ee3e46b7
      Masahiro Yamada 提交于
      Let $(CC) compile objects into normal files *.o instead of .tmp_*.o
      whether CONFIG_MODVERSIONS is enabled or not. With this, the input
      file for objtool is always *.o so objtool_o can go away.
      
      I guess the reason of using .tmp_*.o for intermediate objects was
      to avoid leaving incomplete *.o file (, whose timestamp says it is
      up-to-date) when the genksyms tool failed for some reasons.
      
      It no longer matters because any targets are deleted on errors since
      commit 9c2af1c7 ("kbuild: add .DELETE_ON_ERROR special target").
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      ee3e46b7
    • M
      kbuild: remove redundant 'set -e' from sub_cmd_record_mcount · 4317ee3b
      Masahiro Yamada 提交于
      This is executed inside the if_changed_rule, which already sets
      'set -e'.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      4317ee3b
    • M
      kbuild: let fixdep directly write to .*.cmd files · 392885ee
      Masahiro Yamada 提交于
      Currently, fixdep writes dependencies to .*.tmp, which is renamed to
      .*.cmd after everything succeeds. This is a very safe way to avoid
      corrupted .*.cmd files. The if_changed_dep has carried this safety
      mechanism since it was added in 2002.
      
      If fixdep fails for some reasons or a user terminates the build while
      fixdep is running, the incomplete output from the fixdep could be
      troublesome.
      
      This is my insight about some bad scenarios:
      
      [1] If the compiler succeeds to generate *.o file, but fixdep fails
          to write necessary dependencies to .*.cmd file, Make will miss
          to rebuild the object when headers or CONFIG options are changed.
          In this case, fixdep should not generate .*.cmd file at all so
          that 'arg-check' will surely trigger the rebuild of the object.
      
      [2] A partially constructed .*.cmd file may not be a syntactically
          correct makefile. The next time Make runs, it would include it,
          then fail to parse it. Once this happens, 'make clean' is be the
          only way to fix it.
      
      In fact, [1] is no longer a problem since commit 9c2af1c7 ("kbuild:
      add .DELETE_ON_ERROR special target"). Make deletes a target file on
      any failure in its recipe. Because fixdep is a part of the recipe of
      *.o target, if it fails, the *.o is deleted anyway. However, I am a
      bit worried about the slight possibility of [2].
      
      So, here is a solution. Let fixdep directly write to a .*.cmd file,
      but allow makefiles to include it only when its corresponding target
      exists.
      
      This effectively reverts commit 2982c953 ("kbuild: remove redundant
      $(wildcard ...) for cmd_files calculation"), and commit 00d78ab2
      ("kbuild: remove dead code in cmd_files calculation in top Makefile")
      because now we must check the presence of targets.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      392885ee
  15. 28 11月, 2018 1 次提交
  16. 19 10月, 2018 2 次提交
    • M
      kbuild: use 'else ifeq' for checksrc to improve readability · 7d0ea252
      Masahiro Yamada 提交于
      'ifeq ... else ifeq ... endif' notation is supported by GNU Make 3.81
      or later, which is the requirement for building the kernel since
      commit 37d69ee3 ("docs: bump minimal GNU Make version to 3.81").
      
      Use it to improve the readability.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      7d0ea252
    • M
      kbuild: remove unneeded link_multi_deps · 69ea912f
      Masahiro Yamada 提交于
      Since commit c8589d1e ("kbuild: handle multi-objs dependency
      appropriately"), $^ really represents all the prerequisite of the
      composite object being built.
      
      Hence, $(filter %.o,$^) contains all the objects to link together,
      which is much simpler than link_multi_deps calculation.
      
      Please note $(filter-out FORCE,$^) does not work here. When a single
      object module is turned into a multi object module, $^ will contain
      header files that were previously included for building the single
      object, and recorded in the .*.cmd file. To filter out such headers,
      $(filter %.o,$^) should be used here.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      69ea912f
  17. 19 9月, 2018 1 次提交
  18. 12 9月, 2018 1 次提交
  19. 30 8月, 2018 1 次提交
  20. 24 8月, 2018 2 次提交
  21. 16 8月, 2018 1 次提交
  22. 09 8月, 2018 1 次提交
  23. 06 7月, 2018 1 次提交
  24. 22 6月, 2018 1 次提交