Skip to content
Snippets Groups Projects
  1. Mar 17, 2019
    • Arseny Maslennikov's avatar
      kbuild: deb-pkg: avoid implicit effects · f6d9db63
      Arseny Maslennikov authored
      
      * The man page for dpkg-source(1) notes:
      
      >      -b, --build directory [format-specific-parameters]
      >             Build  a  source  package  (--build since dpkg 1.17.14).
      >             <...>
      >
      >             dpkg-source will build the source package with the first
      >             format found in this ordered list: the format  indicated
      >             with  the  --format  command  line  option,  the  format
      >             indicated in debian/source/format, “1.0”.  The  fallback
      >             to “1.0” is deprecated and will be removed at some point
      >             in the future, you should always  document  the  desired
      >             source   format  in  debian/source/format.  See  section
      >             SOURCE PACKAGE FORMATS for an extensive  description  of
      >             the various source package formats.
      
        Thus it would be more foolproof to explicitly use 1.0 (as we always
        did) than to rely on dpkg-source's defaults.
      
      * In a similar vein, debian/rules is not made executable by mkdebian,
        and dpkg-source warns about that but still silently fixes the file.
        Let's be explicit once again.
      
      Signed-off-by: default avatarArseny Maslennikov <ar@cs.msu.ru>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      f6d9db63
    • Wen Yang's avatar
      coccinelle: semantic code search for missing put_device() · da9cfb87
      Wen Yang authored
      
      The of_find_device_by_node() takes a reference to the underlying device
      structure, we should release that reference.
      The implementation of this semantic code search is:
      In a function, for a local variable returned by calling
      of_find_device_by_node(),
      a, if it is released by a function such as
         put_device()/of_dev_put()/platform_device_put() after the last use,
         it is considered that there is no reference leak;
      b, if it is passed back to the caller via
         dev_get_drvdata()/platform_get_drvdata()/get_device(), etc., the
         reference will be released in other functions, and the current function
         also considers that there is no reference leak;
      c, for the rest of the situation, the current function should release the
         reference by calling put_device, this code search will report the
         corresponding error message.
      
      By using this semantic code search, we have found some object reference leaks,
      such as:
      commit 11907e9d ("ASoC: fsl-asoc-card: fix object reference leaks in
      fsl_asoc_card_probe")
      commit a12085d1 ("mtd: rawnand: atmel: fix possible object reference leak")
      commit 11493f26 ("mtd: rawnand: jz4780: fix possible object reference leak")
      
      There are still dozens of reference leaks in the current kernel code.
      
      Further, for the case of b, the object returned to other functions may also
      have a reference leak, we will continue to develop other cocci scripts to
      further check the reference leak.
      
      Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
      Reviewed-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
      Reviewed-by: default avatarMarkus Elfring <Markus.Elfring@web.de>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      da9cfb87
  2. Mar 13, 2019
  3. Mar 11, 2019
  4. Mar 08, 2019
  5. Mar 07, 2019
  6. Mar 06, 2019
  7. Mar 04, 2019
    • Kees Cook's avatar
      gcc-plugins: structleak: Generalize to all variable types · 81a56f6d
      Kees Cook authored
      
      This adjusts structleak to also work with non-struct types when they
      are passed by reference, since those variables may leak just like
      anything else. This is exposed via an improved set of Kconfig options.
      (This does mean structleak is slightly misnamed now.)
      
      Building with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL should give the
      kernel complete initialization coverage of all stack variables passed
      by reference, including padding (see lib/test_stackinit.c).
      
      Using CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE to count added initializations
      under defconfig:
      
      	..._BYREF:      5945 added initializations
      	..._BYREF_ALL: 16606 added initializations
      
      There is virtually no change to text+data size (both have less than 0.05%
      growth):
      
         text    data     bss     dec     hex filename
      19502103        5051456 1917000 26470559        193e89f vmlinux.stock
      19513412        5051456 1908808 26473676        193f4cc vmlinux.byref
      19516974        5047360 1900616 26464950        193d2b6 vmlinux.byref_all
      
      The measured performance difference is in the noise for hackbench and
      kernel build benchmarks:
      
      Stock:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.649s
      	Std Dev: 0.339
      
      	5x kernel build (4-way parallel)
      	Mean:  261.98s
      	Std Dev: 1.53
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.540s
      	Std Dev: 0.233
      
      	5x kernel build (4-way parallel)
      	Mean:  260.52s
      	Std Dev: 1.31
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.320
      	Std Dev: 0.413
      
      	5x kernel build (4-way parallel)
      	Mean:  260.10
      	Std Dev: 0.86
      
      This does not yet solve missing padding initialization for structures
      on the stack that are never passed by reference (which should be a tiny
      minority). Hopefully this will be more easily addressed by upstream
      compiler fixes after clarifying the C11 padding initialization
      specification.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      81a56f6d
    • Masahiro Yamada's avatar
      kbuild: clean up scripts/gcc-version.sh · fa7295ab
      Masahiro Yamada authored
      
      Now that the Kconfig is the only user of this script, we can drop
      unneeded code.
      
      Remove the -p option, and stop prepending the output with zero,
      so that Kconfig can directly use the output from this script.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fa7295ab
    • Masahiro Yamada's avatar
      kbuild: remove cc-version macro · d3a918c6
      Masahiro Yamada authored
      
      There is no more direct user of this macro; it is only used by
      cc-ifversion.
      
      Calling this macro is not efficient since it invokes the compiler to
      get the compiler version. CONFIG_GCC_VERSION is already calculated in
      the Kconfig stage, so Makefile can reuse it.
      
      Here is a note about the slight difference between cc-version and
      CONFIG_GCC_VERSION:
      
      When using Clang, cc-version is evaluated to '0402' because Clang
      defines __GNUC__ and __GNUC__MINOR__, and looks like GCC 4.2 in the
      version point of view. On the other hand, CONFIG_GCC_VERSION=0
      when $(CC) is clang.
      
      There are currently two users of cc-ifversion:
        arch/mips/loongson64/Platform
        arch/powerpc/Makefile
      
      They are not affected by this change.
      
      The format of cc-version is <major><minor>, while CONFIG_GCC_VERSION
      <major><minor><patch>. I adjusted cc-ifversion for the difference of
      the number of digits.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d3a918c6
    • Masahiro Yamada's avatar
      kbuild: update comment block of scripts/clang-version.sh · 00250b52
      Masahiro Yamada authored
      
      Commit 469cb737 ("kconfig: add CC_IS_CLANG and CLANG_VERSION")
      changed the code, but missed to update the comment block.
      
      The -p option was gone, and the output is 5-digit (or 6-digit when
      Clang 10 is released).
      
      Update the comment now.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      00250b52
  8. Mar 01, 2019
    • Arnd Bergmann's avatar
      kasan: turn off asan-stack for clang-8 and earlier · 6baec880
      Arnd Bergmann authored
      Building an arm64 allmodconfig kernel with clang results in over 140
      warnings about overly large stack frames, the worst ones being:
      
        drivers/gpu/drm/panel/panel-sitronix-st7789v.c:196:12: error: stack frame size of 20224 bytes in function 'st7789v_prepare'
        drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c:196:12: error: stack frame size of 13120 bytes in function 'td028ttec1_panel_enable'
        drivers/usb/host/max3421-hcd.c:1395:1: error: stack frame size of 10048 bytes in function 'max3421_spi_thread'
        drivers/net/wan/slic_ds26522.c:209:12: error: stack frame size of 9664 bytes in function 'slic_ds26522_probe'
        drivers/crypto/ccp/ccp-ops.c:2434:5: error: stack frame size of 8832 bytes in function 'ccp_run_cmd'
        drivers/media/dvb-frontends/stv0367.c:1005:12: error: stack frame size of 7840 bytes in function 'stv0367ter_algo'
      
      None of these happen with gcc today, and almost all of these are the
      result of a single known issue in llvm.  Hopefully it will eventually
      get fixed with the clang-9 release.
      
      In the meantime, the best idea I have is to turn off asan-stack for
      clang-8 and earlier, so we can produce a kernel that is safe to run.
      
      I have posted three patches that address the frame overflow warnings
      that are not addressed by turning off asan-stack, so in combination with
      this change, we get much closer to a clean allmodconfig build, which in
      turn is necessary to do meaningful build regression testing.
      
      It is still possible to turn on the CONFIG_ASAN_STACK option on all
      versions of clang, and it's always enabled for gcc, but when
      CONFIG_COMPILE_TEST is set, the option remains invisible, so
      allmodconfig and randconfig builds (which are normally done with a
      forced CONFIG_COMPILE_TEST) will still result in a mostly clean build.
      
      Link: http://lkml.kernel.org/r/20190222222950.3997333-1-arnd@arndb.de
      Link: https://bugs.llvm.org/show_bug.cgi?id=38809
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarQian Cai <cai@lca.pw>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Acked-by: default avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6baec880
  9. Feb 28, 2019
  10. 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: refactor cc-cross-prefix implementation · bd55f96f
      Masahiro Yamada authored
      
      - $(word 1, <text>) is equivalent to $(firstword <text>)
      
       - hardcode "gcc" instead of $(CC)
      
       - minimize the shell script part
      
      A little more notes in case $(filter-out -%, ...) is not clear.
      
      arch/mips/Makefile passes prefixes depending on the configuration.
      
      CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- \
          $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-)
      
      In the Kconfig stage (e.g. when you run 'make defconfig'), neither
      CONFIG_32BIT nor CONFIG_64BIT is defined. So, $(tool-archpref) is
      empty. As a result, "-linux -linux-gnu- -unknown-linux-gnu" is passed
      into cc-cross-prefix. The command 'which' assumes arguments starting
      with a hyphen as command options, then emits the following messages:
      
        Illegal option -l
        Illegal option -l
        Illegal option -u
      
      I think it is strange to define CROSS_COMPILE depending on the CONFIG
      options since you need to feed $(CC) to Kconfig, but it is how MIPS
      Makefile currently works. Anyway, it would not hurt to filter-out
      invalid strings beforehand.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      bd55f96f
    • Masahiro Yamada's avatar
      kbuild: hardcode genksyms path and remove GENKSYMS variable · 88110713
      Masahiro Yamada authored
      
      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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      88110713
    • Masahiro Yamada's avatar
      scripts/gdb: refactor rules for symlink creation · b513adf4
      Masahiro Yamada authored
      
      gdb-scripts is not a real object, but (ab)used like a phony target.
      
      Rewrite the code in a more Kbuild-ish way. Add symlinks to extra-y
      and use if_changed.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      b513adf4
    • Masahiro Yamada's avatar
      scripts/gdb: do not descend into scripts/gdb from scripts · 1e5ff84f
      Masahiro Yamada authored
      
      Currently, Kbuild descends from scripts/Makefile to scripts/gdb/Makefile
      just for creating symbolic links, but it does not need to do it so early.
      
      Merge the two descending paths to simplify the code.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      1e5ff84f
  11. Feb 22, 2019
    • Aurélien Cedeyn's avatar
      scripts/spdxcheck.py: fix C++ comment style detection · a5f4cb42
      Aurélien Cedeyn authored
      
      With the last commit to support the SuperH boot code files, we have the
      following regression:
      
      $ ./scripts/checkpatch.pl -f <(echo '/* SPDX-License-Identifier: MIT */')
      WARNING: 'SPDX-License-Identifier: MIT */' is not supported in LICENSES/..
      +/* SPDX-License-Identifier: MIT */
      
      total: 0 errors, 1 warnings, 1 lines checked
      
      NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.
      
      /dev/fd/63 has style problems, please review.
      
      NOTE: If any of the errors are false positives, please report
            them to the maintainer, see CHECKPATCH in MAINTAINERS.
      
      This is not obvious, but spdxcheck.py is launched in checkpatch.pl with :
          ...
          } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
              my $spdx_license = $1;
              if (!is_SPDX_License_valid($spdx_license)) {
                  WARN("SPDX_LICENSE_TAG",
                       "'$spdx_license' is not supported in LICENSES/...\n" . \
                       $herecurr);
              }
          ...
          sub is_SPDX_License_valid {
              my ($license) = @_;
              ...
              my $status = `cd "$root_path"; echo "$license" |
                            python scripts/spdxcheck.py -`;
              ...
          }
      
      The first chars before 'SPDX-License-Identifier:' are ignored.
      This commit fixes this regression.
      
      Fixes:959b4968 (scripts/spdxcheck.py: Handle special quotation mark comments)
      Signed-off-by: default avatarAurélien Cedeyn <aurelien.cedeyn@gmail.com>
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      a5f4cb42
  12. Feb 20, 2019
    • Masahiro Yamada's avatar
      kbuild: generate modules.order only when CONFIG_MODULES=y · 1d8001ef
      Masahiro Yamada authored
      
      Do not generate pointless modules.order when the module support is
      disabled.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1d8001ef
    • Masahiro Yamada's avatar
      kbuild: pkg: use -f $(srctree)/Makefile to recurse to top Makefile · 175209cc
      Masahiro Yamada authored
      
      '$(MAKE) KBUILD_SRC=' changes the working directory back and forth
      between objtree and srctree.
      
      It is better to recurse to the top-level Makefile directly.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      175209cc
    • Masahiro Yamada's avatar
      kbuild: Disable extra debugging info in .s output · 1e88e415
      Masahiro Yamada authored
      
      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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      1e88e415
  13. Feb 19, 2019
Loading