1. 08 5月, 2022 6 次提交
  2. 03 4月, 2022 1 次提交
  3. 23 3月, 2022 1 次提交
  4. 13 3月, 2022 1 次提交
    • M
      Kbuild: use -Wdeclaration-after-statement · 4d94f910
      Mark Rutland 提交于
      The kernel is moving from using `-std=gnu89` to `-std=gnu11`, permitting
      the use of additional C11 features such as for-loop initial declarations.
      
      One contentious aspect of C99 is that it permits mixed declarations and
      code, and for now at least, it seems preferable to enforce that
      declarations must come first.
      
      These warnings were already enabled in the kernel itself, but not
      for KBUILD_USERCFLAGS or the compat VDSO on arch/arm64, which uses
      a separate set of CFLAGS.
      
      This patch fixes an existing violation in modpost.c, which is not
      reported because of the missing flag in KBUILD_USERCFLAGS:
      
      | scripts/mod/modpost.c: In function ‘match’:
      | scripts/mod/modpost.c:837:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
      |   837 |   const char *endp = p + strlen(p) - 1;
      |       |   ^~~~~
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      [arnd: don't add a duplicate flag to the default set, update changelog]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NNathan Chancellor <nathan@kernel.org>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v13.0.0 (x86-64)
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4d94f910
  5. 10 3月, 2022 1 次提交
    • V
      s390/nospec: add an option to use thunk-extern · 1d2ad084
      Vasily Gorbik 提交于
      Currently with -mindirect-branch=thunk and -mfunction-return=thunk compiler
      options expoline thunks are put into individual COMDAT group sections. s390
      is the only architecture which has group sections and it has implications
      for kpatch and objtool tools support.
      
      Using -mindirect-branch=thunk-extern and -mfunction-return=thunk-extern
      is an alternative, which comes with a need to generate all required
      expoline thunks manually. Unfortunately modules area is too far away from
      the kernel image, and expolines from the kernel image cannon be used.
      But since all new distributions (except Debian) build kernels for machine
      generations newer than z10, where "exrl" instruction is available, that
      leaves only 16 expolines thunks possible.
      
      Provide an option to build the kernel with
      -mindirect-branch=thunk-extern and -mfunction-return=thunk-extern for
      z10 or newer. This also requires to postlink expoline thunks into all
      modules explicitly. Currently modules already contain most expolines
      anyhow.
      
      Unfortunately -mindirect-branch=thunk-extern and
      -mfunction-return=thunk-extern options support is broken in gcc <= 11.2.
      Additional compile test is required to verify proper gcc support.
      Acked-by: NIlya Leoshkevich <iii@linux.ibm.com>
      Co-developed-by: NSumanth Korikkar <sumanthk@linux.ibm.com>
      Signed-off-by: NSumanth Korikkar <sumanthk@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      1d2ad084
  6. 06 1月, 2022 1 次提交
    • J
      riscv: switch to relative exception tables · bb1f85d6
      Jisheng Zhang 提交于
      Similar as other architectures such as arm64, x86 and so on, use
      offsets relative to the exception table entry values rather than
      absolute addresses for both the exception locationand the fixup.
      
      However, RISCV label difference will actually produce two relocations,
      a pair of R_RISCV_ADD32 and R_RISCV_SUB32. Take below simple code for
      example:
      
      $ cat test.S
      .section .text
      1:
              nop
      .section __ex_table,"a"
              .balign 4
              .long (1b - .)
      .previous
      
      $ riscv64-linux-gnu-gcc -c test.S
      $ riscv64-linux-gnu-readelf -r test.o
      Relocation section '.rela__ex_table' at offset 0x100 contains 2 entries:
        Offset          Info           Type           Sym. Value    Sym. Name + Addend
      000000000000  000600000023 R_RISCV_ADD32     0000000000000000 .L1^B1 + 0
      000000000000  000500000027 R_RISCV_SUB32     0000000000000000 .L0  + 0
      
      The modpost will complain the R_RISCV_SUB32 relocation, so we need to
      patch modpost.c to skip this relocation for .rela__ex_table section.
      
      After this patch, the __ex_table section size of defconfig vmlinux is
      reduced from 7072 Bytes to 3536 Bytes.
      Signed-off-by: NJisheng Zhang <jszhang@kernel.org>
      Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: NPalmer Dabbelt <palmer@rivosinc.com>
      bb1f85d6
  7. 03 9月, 2021 1 次提交
    • M
      modpost: get the *.mod file path more simply · e54dd93a
      Masahiro Yamada 提交于
      get_src_version() strips 'o' or 'lto.o' from the end of the object file
      path (so, postfixlen is 1 or 5), then adds 'mod'.
      
      If you look at the code closely, mod->name already holds the base path
      with the extension stripped.
      
      Most of the code changes made by commit 7ac204b5 ("modpost: lto:
      strip .lto from module names") was actually unneeded.
      
      sumversion.c does not need strends(), so it can get back local in
      modpost.c again.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      e54dd93a
  8. 15 8月, 2021 1 次提交
    • C
      powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto · 1e688dd2
      Christophe Leroy 提交于
      Using asm goto in __WARN_FLAGS() and WARN_ON() allows more
      flexibility to GCC.
      
      For that add an entry to the exception table so that
      program_check_exception() knowns where to resume execution
      after a WARNING.
      
      Here are two exemples. The first one is done on PPC32 (which
      benefits from the previous patch), the second is on PPC64.
      
      	unsigned long test(struct pt_regs *regs)
      	{
      		int ret;
      
      		WARN_ON(regs->msr & MSR_PR);
      
      		return regs->gpr[3];
      	}
      
      	unsigned long test9w(unsigned long a, unsigned long b)
      	{
      		if (WARN_ON(!b))
      			return 0;
      		return a / b;
      	}
      
      Before the patch:
      
      	000003a8 <test>:
      	 3a8:	81 23 00 84 	lwz     r9,132(r3)
      	 3ac:	71 29 40 00 	andi.   r9,r9,16384
      	 3b0:	40 82 00 0c 	bne     3bc <test+0x14>
      	 3b4:	80 63 00 0c 	lwz     r3,12(r3)
      	 3b8:	4e 80 00 20 	blr
      
      	 3bc:	0f e0 00 00 	twui    r0,0
      	 3c0:	80 63 00 0c 	lwz     r3,12(r3)
      	 3c4:	4e 80 00 20 	blr
      
      	0000000000000bf0 <.test9w>:
      	 bf0:	7c 89 00 74 	cntlzd  r9,r4
      	 bf4:	79 29 d1 82 	rldicl  r9,r9,58,6
      	 bf8:	0b 09 00 00 	tdnei   r9,0
      	 bfc:	2c 24 00 00 	cmpdi   r4,0
      	 c00:	41 82 00 0c 	beq     c0c <.test9w+0x1c>
      	 c04:	7c 63 23 92 	divdu   r3,r3,r4
      	 c08:	4e 80 00 20 	blr
      
      	 c0c:	38 60 00 00 	li      r3,0
      	 c10:	4e 80 00 20 	blr
      
      After the patch:
      
      	000003a8 <test>:
      	 3a8:	81 23 00 84 	lwz     r9,132(r3)
      	 3ac:	71 29 40 00 	andi.   r9,r9,16384
      	 3b0:	40 82 00 0c 	bne     3bc <test+0x14>
      	 3b4:	80 63 00 0c 	lwz     r3,12(r3)
      	 3b8:	4e 80 00 20 	blr
      
      	 3bc:	0f e0 00 00 	twui    r0,0
      
      	0000000000000c50 <.test9w>:
      	 c50:	7c 89 00 74 	cntlzd  r9,r4
      	 c54:	79 29 d1 82 	rldicl  r9,r9,58,6
      	 c58:	0b 09 00 00 	tdnei   r9,0
      	 c5c:	7c 63 23 92 	divdu   r3,r3,r4
      	 c60:	4e 80 00 20 	blr
      
      	 c70:	38 60 00 00 	li      r3,0
      	 c74:	4e 80 00 20 	blr
      
      In the first exemple, we see GCC doesn't need to duplicate what
      happens after the trap.
      
      In the second exemple, we see that GCC doesn't need to emit a test
      and a branch in the likely path in addition to the trap.
      
      We've got some WARN_ON() in .softirqentry.text section so it needs
      to be added in the OTHER_TEXT_SECTIONS in modpost.c
      Signed-off-by: NChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/389962b1b702e3c78d169e59bcfac56282889173.1618331882.git.christophe.leroy@csgroup.eu
      1e688dd2
  9. 17 6月, 2021 1 次提交
    • M
      kbuild: modpost: Explicitly warn about unprototyped symbols · 4a679593
      Mark Brown 提交于
      One common cause of modpost version generation failures is a failure to
      prototype exported assembly functions - the tooling requires this for
      exported functions even if they are not and should not be called from C
      code in order to do the version mangling for symbols. Unfortunately the
      error message is currently rather abstruse, simply saying that "version
      generation failed" and even diving into the code doesn't directly show
      what's going on since there's several steps between the problem and it
      being observed.
      
      Provide an explicit hint as to the likely cause of a version generation
      failure to help anyone who runs into this in future more readily diagnose
      and fix the problem.
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4a679593
  10. 25 4月, 2021 4 次提交
    • Y
      kbuild: add an elfnote for whether vmlinux is built with lto · 1fdd7433
      Yonghong Song 提交于
      Currently, clang LTO built vmlinux won't work with pahole.
      LTO introduced cross-cu dwarf tag references and broke
      current pahole model which handles one cu as a time.
      The solution is to merge all cu's as one pahole cu as in [1].
      We would like to do this merging only if cross-cu dwarf
      references happens. The LTO build mode is a pretty good
      indication for that.
      
      In earlier version of this patch ([2]), clang flag
      -grecord-gcc-switches is proposed to add to compilation flags
      so pahole could detect "-flto" and then merging cu's.
      This will increate the binary size of 1% without LTO though.
      
      Arnaldo suggested to use a note to indicate the vmlinux
      is built with LTO. Such a cheap way to get whether the vmlinux
      is built with LTO or not helps pahole but is also useful
      for tracing as LTO may inline/delete/demote global functions,
      promote static functions, etc.
      
      So this patch added an elfnote with a new type LINUX_ELFNOTE_LTO_INFO.
      The owner of the note is "Linux".
      
      With gcc 8.4.1 and clang trunk, without LTO, I got
        $ readelf -n vmlinux
        Displaying notes found in: .notes
          Owner                Data size        Description
        ...
          Linux                0x00000004       func
           description data: 00 00 00 00
        ...
      With "readelf -x ".notes" vmlinux", I can verify the above "func"
      with type code 0x101.
      
      With clang thin-LTO, I got the same as above except the following:
           description data: 01 00 00 00
      which indicates the vmlinux is built with LTO.
      
        [1] https://lore.kernel.org/bpf/20210325065316.3121287-1-yhs@fb.com/
        [2] https://lore.kernel.org/bpf/20210331001623.2778934-1-yhs@fb.com/Suggested-by: NArnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM/Clang v12.0.0-rc4 (x86-64)
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1fdd7433
    • B
      scripts: modpost.c: Fix a few typos · f3945833
      Bhaskar Chowdhury 提交于
      s/agorithm/algorithm/
      s/criterias/criteria/
      s/targetting/targeting/   ....two different places.
      Signed-off-by: NBhaskar Chowdhury <unixbhaskar@gmail.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      f3945833
    • M
      kbuild: fix false-positive modpost warning when all symbols are trimmed · 4475dff5
      Masahiro Yamada 提交于
      Nathan reports that the mips defconfig emits the following warning:
      
        WARNING: modpost: Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.
      
      This false-positive happens when CONFIG_TRIM_UNUSED_KSYMS is enabled,
      but no CONFIG option is set to 'm'.
      
      Commit a0590473 ("nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default")
      turned the last 'm' into 'y' for the mips defconfig, and uncovered
      this issue.
      
      In this case, the module feature itself is enabled, but we have no
      module to build. As a result, CONFIG_TRIM_UNUSED_KSYMS drops all the
      instances of EXPORT_SYMBOL. Then, modpost wrongly assumes vmlinux is
      missing because vmlinux.symvers is empty. (As another false-positive
      case, you can create a module that does not use any symbol of vmlinux).
      
      The current behavior is to entirely suppress the unresolved symbol
      warnings when vmlinux is missing just because there are too many.
      I found the origin of this code in the historical git tree. [1]
      
      If this is a matter of noisiness, I think modpost can display the
      first 10 warnings, and the number of suppressed warnings at the end.
      
      You will get a bit noisier logs when you run 'make modules' without
      vmlinux, but such warnings are better to show because you never know
      the resulting modules are actually loadable or not.
      
      This commit changes the following:
      
       - If any of input *.symver files is missing, pass -w option to let
         the module build keep going with warnings instead of errors.
      
       - If there are too many (10+) unresolved symbol warnings, show only
         the first 10, and also the number of suppressed warnings.
      
      [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=1cc0e0529569bf6a94f6d49770aa6d4b599d2c46Reported-by: NNathan Chancellor <nathan@kernel.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4475dff5
    • M
      kbuild: generate Module.symvers only when vmlinux exists · 69bc8d38
      Masahiro Yamada 提交于
      The external module build shows the following warning if Module.symvers
      is missing in the kernel tree.
      
        WARNING: Symbol version dump "Module.symvers" is missing.
                 Modules may not have dependencies or modversions.
      
      I think this is an important heads-up because the resulting modules may
      not work as expected. This happens when you did not build the entire
      kernel tree, for example, you might have prepared the minimal setups
      for external modules by 'make defconfig && make modules_preapre'.
      
      A problem is that 'make modules' creates Module.symvers even without
      vmlinux. In this case, that warning is suppressed since Module.symvers
      already exists in spite of its incomplete content.
      
      The incomplete (i.e. invalid) Module.symvers should not be created.
      
      This commit changes the second pass of modpost to dump symbols into
      modules-only.symvers. The final Module.symvers is created by
      concatenating vmlinux.symvers and modules-only.symvers if both exist.
      
      Module.symvers is supposed to collect symbols from both vmlinux and
      modules. It might be a bit confusing, and I am not quite sure if it
      is an official interface, but presumably it is difficult to rename it
      because some tools (e.g. kmod) parse it.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      69bc8d38
  11. 08 2月, 2021 2 次提交
  12. 15 1月, 2021 1 次提交
  13. 21 12月, 2020 6 次提交
    • Q
      modpost: turn static exports into error · b9ed847b
      Quentin Perret 提交于
      Using EXPORT_SYMBOL*() on static functions is fundamentally wrong.
      Modpost currently reports that as a warning, but clearly this is not a
      pattern we should allow, and all in-tree occurences should have been
      fixed by now. So, promote the warn() message to error() to make sure
      this never happens again.
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NMatthias Maennich <maennich@google.com>
      Signed-off-by: NQuentin Perret <qperret@google.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      b9ed847b
    • M
      modpost: turn section mismatches to error from fatal() · c7299d98
      Masahiro Yamada 提交于
      There is code that reports static EXPORT_SYMBOL a few lines below.
      It is not a good idea to bail out here.
      
      I renamed sec_mismatch_fatal to sec_mismatch_warn_only (with logical
      inversion) to match to CONFIG_SECTION_MISMATCH_WARN_ONLY.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      c7299d98
    • M
      modpost: change license incompatibility to error() from fatal() · d6d692fa
      Masahiro Yamada 提交于
      Change fatal() to error() to continue running to report more possible
      issues.
      
      There is no difference in the fact that modpost will fail anyway.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      d6d692fa
    • M
      modpost: turn missing MODULE_LICENSE() into error · 1d6cd392
      Masahiro Yamada 提交于
      Do not create modules with no license tag.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1d6cd392
    • M
      modpost: refactor error handling and clarify error/fatal difference · 0fd3fbad
      Masahiro Yamada 提交于
      We have 3 log functions. fatal() is special because it lets modpost bail
      out immediately. The difference between warn() and error() is the only
      prefix parts ("WARNING:" vs "ERROR:").
      
      In my understanding, the expected handling of error() is to propagate
      the return code of the function to the exit code of modpost, as
      check_exports() etc. already does. This is a good manner in general
      because we should display as many error messages as possible in a
      single run of modpost.
      
      What is annoying about fatal() is that it kills modpost at the first
      error. People would need to run Kbuild again and again until they fix
      all errors.
      
      But, unfortunately, people tend to do:
      "This case should not be allowed. Let's replace warn() with fatal()."
      
      One of the reasons is probably it is tedious to manually hoist the error
      code to the main() function.
      
      This commit refactors error() so any single call for it automatically
      makes modpost return the error code.
      
      I also added comments in modpost.h for warn(), error(), and fatal().
      
      Please use fatal() only when you have a strong reason to do so.
      For example:
      
        - Memory shortage (i.e. malloc() etc. has failed)
        - The ELF file is broken, and there is no point to continue parsing
        - Something really odd has happened
      
      For general coding errors, please use error().
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: NQuentin Perret <qperret@google.com>
      0fd3fbad
    • M
      modpost: rename merror() to error() · bc72d723
      Masahiro Yamada 提交于
      The log function names, warn(), merror(), fatal() are inconsistent.
      
      Commit 2a116659 ("kbuild: distinguish between errors and warnings
      in modpost") intentionally chose merror() to avoid the conflict with
      the library function error(). See man page of error(3).
      
      But, we are already causing the conflict with warn() because it is also
      a library function. See man page of warn(3). err() would be a problem
      for the same reason.
      
      The common technique to work around name conflicts is to use macros.
      For example:
      
          /* in a header */
          #define error(fmt, ...)  __error(fmt, ##__VA_ARGS__)
          #define warn(fmt, ...)   __warn(fmt, ##__VA_ARGS__)
      
          /* function definition */
          void __error(const char *fmt, ...)
          {
                  <our implementation>
          }
      
          void __warn(const char *fmt, ...)
          {
                  <our implementation>
          }
      
      In this way, we can implement our own warn() and error(), still we can
      include <error.h> and <err.h> with no problem.
      
      And, commit 93c95e52 ("modpost: rework and consolidate logging
      interface") already did that.
      
      Since the log functions are all macros, we can use error() without
      causing "conflicting types" errors.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      bc72d723
  14. 26 10月, 2020 1 次提交
  15. 27 7月, 2020 1 次提交
  16. 07 7月, 2020 1 次提交
  17. 06 6月, 2020 10 次提交