Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Mar 22, 2022
  2. Mar 21, 2022
    • Kees Cook's avatar
      um: Allow builds with Clang · c7500c1b
      Kees Cook authored
      Add SUBARCH target for Clang+um (which must go last, not alphabetically,
      so the other SUBARCHes are assigned). Remove open-coded "DEFINE"
      macro, instead using linux/kbuild.h's version which was updated to use
      Clang-friendly assembly in commit cf0c3e68 ("kbuild: fix asm-offset
      generation to work with clang"). Redefine "DEFINE_LONGS" in terms of
      "COMMENT" and "DEFINE" so that the intended coment actually has useful
      content. Add a missed "break" to avoid implicit fall-through warnings.
      
      This lets me run KUnit tests with Clang:
      
      $ ./tools/testing/kunit/kunit.py run --make_options LLVM=1
      ...
      
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: David Gow <davidgow@google.com>
      Cc: linux-um@lists.infradead.org
      Cc: linux-kbuild@vger.kernel.org
      Cc: linux-kselftest@vger.kernel.or...
      c7500c1b
  3. Mar 11, 2022
  4. Feb 24, 2022
  5. Feb 12, 2022
  6. Feb 11, 2022
    • Mark Rutland's avatar
      atomics: Fix atomic64_{read_acquire,set_release} fallbacks · dc1b4df0
      Mark Rutland authored
      Arnd reports that on 32-bit architectures, the fallbacks for
      atomic64_read_acquire() and atomic64_set_release() are broken as they
      use smp_load_acquire() and smp_store_release() respectively, which do
      not work on types larger than the native word size.
      
      Since those contain compiletime_assert_atomic_type(), any attempt to use
      those fallbacks will result in a build-time error. e.g. with the
      following added to arch/arm/kernel/setup.c:
      
      | void test_atomic64(atomic64_t *v)
      | {
      |        atomic64_set_release(v, 5);
      |        atomic64_read_acquire(v);
      | }
      
      The compiler will complain as follows:
      
      | In file included from <command-line>:
      | In function 'arch_atomic64_set_release',
      |     inlined from 'test_atomic64' at ./include/linux/atomic/atomic-instrumented.h:669:2:
      | ././include/linux/compiler_types.h:346:38: error: call to '__compiletime_assert_9' declared with attribute error: Need native word sized stores/loads for atomicity.
      |   346 |  _compiletime_ass...
      dc1b4df0
  7. Feb 09, 2022
  8. Feb 07, 2022
  9. Feb 06, 2022
  10. Jan 27, 2022
    • Steven Rostedt (Google)'s avatar
      ftrace: Have architectures opt-in for mcount build time sorting · 4ed308c4
      Steven Rostedt (Google) authored
      First S390 complained that the sorting of the mcount sections at build
      time caused the kernel to crash on their architecture. Now PowerPC is
      complaining about it too. And also ARM64 appears to be having issues.
      
      It may be necessary to also update the relocation table for the values
      in the mcount table. Not only do we have to sort the table, but also
      update the relocations that may be applied to the items in the table.
      
      If the system is not relocatable, then it is fine to sort, but if it is,
      some architectures may have issues (although x86 does not as it shifts all
      addresses the same).
      
      Add a HAVE_BUILDTIME_MCOUNT_SORT that an architecture can set to say it is
      safe to do the sorting at build time.
      
      Also update the config to compile in build time sorting in the sorttable
      code in scripts/ to depend on CONFIG_BUILDTIME_MCOUNT_SORT.
      
      Link: https://lore.kernel.org/all/944D10DA-8200-4BA9-8D0A-3BED9AA99F82@linux.ibm.com/
      Link: https://lkml.kernel.org...
      4ed308c4
  11. Jan 20, 2022
  12. Jan 18, 2022
  13. Jan 17, 2022
  14. Jan 15, 2022
  15. Jan 13, 2022
    • Yinan Liu's avatar
      scripts: ftrace - move the sort-processing in ftrace_init · 72b3942a
      Yinan Liu authored
      When the kernel starts, the initialization of ftrace takes
      up a portion of the time (approximately 6~8ms) to sort mcount
      addresses. We can save this time by moving mcount-sorting to
      compile time.
      
      Link: https://lkml.kernel.org/r/20211212113358.34208-2-yinan@linux.alibaba.com
      
      
      
      Signed-off-by: default avatarYinan Liu <yinan@linux.alibaba.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      72b3942a
    • Masahiro Yamada's avatar
      kbuild: add cmd_file_size · c4d7f40b
      Masahiro Yamada authored
      
      Some architectures support self-extracting kernel, which embeds the
      compressed vmlinux.
      
      It has 4 byte data at the end so the decompressor can know the vmlinux
      size beforehand.
      
      GZIP natively has it in the trailer, but for the other compression
      algorithms, the hand-crafted trailer is added.
      
      It is unneeded to generate such _corrupted_ compressed files because
      it is possible to pass the size data as a separate file.
      
      For example, the assembly code:
      
           .incbin "compressed-vmlinux-with-size-data"
      
      can be transformed to:
      
           .incbin "compressed-vmlinux"
           .incbin "size-data"
      
      My hope is, after some reworks of the decompressors, the macros
      cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}_with_size will go away.
      
      This new macro, cmd_file_size, will be useful to generate a separate
      size-data file.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <n.schier@avm.de>
      c4d7f40b
    • Masahiro Yamada's avatar
      kbuild: rename cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22} · 7ce7e984
      Masahiro Yamada authored
      GZIP-compressed files end with 4 byte data that represents the size
      of the original input. The decompressors (the self-extracting kernel)
      exploit it to know the vmlinux size beforehand. To mimic the GZIP's
      trailer, Kbuild provides cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}.
      Unfortunately these macros are used everywhere despite the appended
      size data is only useful for the decompressors.
      
      There is no guarantee that such hand-crafted trailers are safely ignored.
      In fact, the kernel refuses compressed initramdfs with the garbage data.
      That is why usr/Makefile overrides size_append to make it no-op.
      
      To limit the use of such broken compressed files, this commit renames
      the existing macros as follows:
      
        cmd_bzip2   --> cmd_bzip2_with_size
        cmd_lzma    --> cmd_lzma_with_size
        cmd_lzo     --> cmd_lzo_with_size
        cmd_lz4     --> cmd_lz4_with_size
        cmd_xzkern  --> cmd_xzkern_with_size
        cmd_zstd22  --> cmd_zstd22_with_size
      
      To keep the decompressors working, I...
      7ce7e984
    • Masahiro Yamada's avatar
      kbuild: drop $(size_append) from cmd_zstd · 64d8aaa4
      Masahiro Yamada authored
      The appended file size is only used by the decompressors, which some
      architectures support.
      
      As the comment "zstd22 is used for kernel compression" says, cmd_zstd22
      is used in arch/{mips,s390,x86}/boot/compressed/Makefile.
      
      On the other hand, there is no good reason to append the file size to
      cmd_zstd since it is used for other purposes.
      
      Actually cmd_zstd is only used in usr/Makefile, where the appended file
      size is rather harmful.
      
      The initramfs with its file size appended is considered as corrupted
      data, so commit 65e00e04
      
       ("initramfs: refactor the initramfs build
      rules") added 'override size_append := :' to make it no-op.
      
      As a conclusion, this $(size_append) should not exist here.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <n.schier@avm.de>
      64d8aaa4
  16. Jan 08, 2022
    • Masahiro Yamada's avatar
      certs: move scripts/extract-cert to certs/ · 340a0253
      Masahiro Yamada authored
      
      extract-cert is only used in certs/Makefile.
      
      Move it there and build extract-cert on demand.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      340a0253
    • Masahiro Yamada's avatar
      kbuild: do not quote string values in include/config/auto.conf · 129ab0d2
      Masahiro Yamada authored
      The previous commit fixed up all shell scripts to not include
      include/config/auto.conf.
      
      Now that include/config/auto.conf is only included by Makefiles,
      we can change it into a more Make-friendly form.
      
      Previously, Kconfig output string values enclosed with double-quotes
      (both in the .config and include/config/auto.conf):
      
          CONFIG_X="foo bar"
      
      Unlike shell, Make handles double-quotes (and single-quotes as well)
      verbatim. We must rip them off when used.
      
      There are some patterns:
      
        [1] $(patsubst "%",%,$(CONFIG_X))
        [2] $(CONFIG_X:"%"=%)
        [3] $(subst ",,$(CONFIG_X))
        [4] $(shell echo $(CONFIG_X))
      
      These are not only ugly, but also fragile.
      
      [1] and [2] do not work if the value contains spaces, like
         CONFIG_X=" foo bar "
      
      [3] does not work correctly if the value contains double-quotes like
         CONFIG_X="foo\"bar"
      
      [4] seems to work better, but has a cost of forking a process.
      
      Anyway, quoted strings were always PITA for our Makefiles.
      
      T...
      129ab0d2