Skip to content
Snippets Groups Projects
  1. 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: export_report: read modules.order instead of .tmp_versions/*.mod · 7deb55f5
      Masahiro Yamada authored
      
      Towards the goal of removing MODVERDIR aka .tmp_versions, read out
      modules.order to get the list of modules to be processed. This is
      simpler than parsing *.mod files in .tmp_versions.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7deb55f5
    • Masahiro Yamada's avatar
      kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod · ff9b45c5
      Masahiro Yamada authored
      
      Towards the goal of removing MODVERDIR, read out modules.order to get
      the list of modules to be processed. This is simpler than parsing *.mod
      files in $(MODVERDIR).
      
      For external modules, $(KBUILD_EXTMOD)/modules.order should be read.
      
      I removed the single target %.ko from the top Makefile. To make sure
      modpost works correctly, vmlinux and the other modules must be built.
      You cannot build a particular .ko file alone.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      ff9b45c5
    • Masahiro Yamada's avatar
      kbuild: modsign: read modules.order instead of $(MODVERDIR)/*.mod · c35c87d6
      Masahiro Yamada authored
      
      Towards the goal of removing MODVERDIR, read out modules.order to get
      the list of modules to be signed. This is simpler than parsing *.mod
      files in $(MODVERDIR).
      
      The modules_sign target is only supported for in-kernel modules.
      So, this commit does not take care of external modules.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      c35c87d6
    • Masahiro Yamada's avatar
      kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod · d56aec10
      Masahiro Yamada authored
      
      Towards the goal of removing MODVERDIR, read out modules.order to get
      the list of modules to be installed. This is simpler than parsing *.mod
      files in $(MODVERDIR).
      
      For external modules, $(KBUILD_EXTMOD)/modules.order should be read.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d56aec10
    • 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
    • Himanshu Jha's avatar
      coccinelle: api: add devm_platform_ioremap_resource script · d09778d1
      Himanshu Jha authored
      
      Use recently introduced devm_platform_ioremap_resource
      helper which wraps platform_get_resource() and
      devm_ioremap_resource() together. This helps produce much
      cleaner code and remove local `struct resource` declaration.
      
      Signed-off-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
      Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d09778d1
    • 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
    • Masahiro Yamada's avatar
      kbuild: remove unused hostcc-option · c04d1e46
      Masahiro Yamada authored
      
      We can re-add this whenever it is needed. At this moment, it is unused.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      c04d1e46
    • Masahiro Yamada's avatar
      kconfig: fix missing choice values in auto.conf · 8e2442a5
      Masahiro Yamada authored
      
      Since commit 00c864f8 ("kconfig: allow all config targets to write
      auto.conf if missing"), Kconfig creates include/config/auto.conf in the
      defconfig stage when it is missing.
      
      Joonas Kylmälä reported incorrect auto.conf generation under some
      circumstances.
      
      To reproduce it, apply the following diff:
      
      |  --- a/arch/arm/configs/imx_v6_v7_defconfig
      |  +++ b/arch/arm/configs/imx_v6_v7_defconfig
      |  @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y
      |   CONFIG_USB_CONFIGFS_F_HID=y
      |   CONFIG_USB_CONFIGFS_F_UVC=y
      |   CONFIG_USB_CONFIGFS_F_PRINTER=y
      |  -CONFIG_USB_ZERO=m
      |  -CONFIG_USB_AUDIO=m
      |  -CONFIG_USB_ETH=m
      |  -CONFIG_USB_G_NCM=m
      |  -CONFIG_USB_GADGETFS=m
      |  -CONFIG_USB_FUNCTIONFS=m
      |  -CONFIG_USB_MASS_STORAGE=m
      |  -CONFIG_USB_G_SERIAL=m
      |  +CONFIG_USB_FUNCTIONFS=y
      |   CONFIG_MMC=y
      |   CONFIG_MMC_SDHCI=y
      |   CONFIG_MMC_SDHCI_PLTFM=y
      
      And then, run:
      
      $ make ARCH=arm mrproper imx_v6_v7_defconfig
      
      You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the
      .config, but not in the auto.conf.
      
      Please note drivers/usb/gadget/legacy/Kconfig is included from a choice
      block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value.
      
      This is probably a similar situation described in commit beaaddb6
      ("kconfig: tests: test defconfig when two choices interact").
      
      When sym_calc_choice() is called, the choice symbol forgets the
      SYMBOL_DEF_USER unless all of its choice values are explicitly set by
      the user.
      
      The choice symbol is given just one chance to recall it because
      set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES
      is set.
      
      When sym_calc_choice() is called again, the choice symbol forgets it
      forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid.
      Hence, we cannot call sym_clear_all_valid() again and again.
      
      It is crazy to repeat set and unset of internal flags. However, we
      cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;"
      Doing so would re-introduce the problem solved by commit 5d09598d
      ("kconfig: fix new choices being skipped upon config update").
      
      To work around the issue, conf_write_autoconf() stopped calling
      sym_clear_all_valid().
      
      conf_write() must be changed accordingly. Currently, it clears
      SYMBOL_WRITE after the symbol is written into the .config file. This
      is needed to prevent it from writing the same symbol multiple times in
      case the symbol is declared in two or more locations. I added the new
      flag SYMBOL_WRITTEN, to track the symbols that have been written.
      
      Anyway, this is a cheesy workaround in order to suppress the issue
      as far as defconfig is concerned.
      
      Handling of choices is totally broken. sym_clear_all_valid() is called
      every time a user touches a symbol from the GUI interface. To reproduce
      it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch
      around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear
      from the .config file.
      
      I added the Fixes tag since it is more fatal than before. But, this
      has been broken since long long time before, and still it is.
      We should take a closer look to fix this correctly somehow.
      
      Fixes: 00c864f8 ("kconfig: allow all config targets to write auto.conf if missing")
      Cc: linux-stable <stable@vger.kernel.org> # 4.19+
      Reported-by: default avatarJoonas Kylmälä <joonas.kylmala@iki.fi>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: default avatarJoonas Kylmälä <joonas.kylmala@iki.fi>
      8e2442a5
    • Cedric Hombourger's avatar
      builddeb: generate multi-arch friendly linux-libc-dev package · 5a464217
      Cedric Hombourger authored
      
      Debian-based distributions place libc header files in a machine
      specific directory (/usr/include/<libc-machine>) instead of
      /usr/include/asm to support installation of the linux-libc-dev
      package from multiple architectures. Move headers installed by
      "make headers_install" accordingly using Debian's tuple from
      dpkg-architecture (stored in debian/arch).
      
      Signed-off-by: default avatarCedric Hombourger <Cedric_Hombourger@mentor.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      5a464217
    • Masahiro Yamada's avatar
      kconfig: run olddefconfig instead of oldconfig after merging fragments · 3266c806
      Masahiro Yamada authored
      
      'make olddefconfig' is non-interactive, so we can drop 'yes'.
      The behavior is equivalent.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      3266c806
  2. Jul 14, 2019
    • Kirill Smelkov's avatar
      *: convert stream-like files -> stream_open, even if they use noop_llseek · 3975b097
      Kirill Smelkov authored
      
      This patch continues 10dce8af (fs: stream_open - opener for
      stream-like files so that read and write can run simultaneously without
      deadlock) and c5bf68fe (*: convert stream-like files from
      nonseekable_open -> stream_open) and teaches steam_open.cocci to
      consider files as being stream-like not only if they have
      .llseek=no_llseek, but also if they have .llseek=noop_llseek.
      
      This is safe to do: the comment about noop_llseek says
      
      	This is an implementation of ->llseek useable for the rare special case when
      	userspace expects the seek to succeed but the (device) file is actually not
      	able to perform the seek. In this case you use noop_llseek() instead of
      	falling back to the default implementation of ->llseek.
      
      and in general noop_llseek was massively added to drivers in 6038f373
      (llseek: automatically add .llseek fop) when changing default for NULL .llseek
      from NOP to no_llseek with the idea to avoid breaking compatibility, if
      maybe some user-space program was using lseek on a device without caring
      about the result, but caring if it was an error or not.
      
      Amended semantic patch produces two changes when applied tree-wide:
      
              drivers/hid/hid-sensor-custom.c:690:8-24: WARNING: hid_sensor_custom_fops: .read() has stream semantic; safe to change nonseekable_open -> stream_open.
              drivers/input/mousedev.c:564:1-17: ERROR: mousedev_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      
      Cc: Julia Lawall <Julia.Lawall@lip6.fr>
      Cc: Jan Blunck <jblunck@suse.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarKirill Smelkov <kirr@nexedi.com>
      3975b097
  3. Jul 12, 2019
  4. Jul 11, 2019
    • Masahiro Yamada's avatar
      kconfig: remove meaningless if-conditional in conf_read() · e3cd5136
      Masahiro Yamada authored
      
      sym_is_choice(sym) has already been checked by previous if-block:
      
          if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
                  continue;
      
      Hence, the following code is redundant, and the comment is misleading:
      
          if (!sym_is_choice(sym))
                  continue;
          /* fall through */
      
      It always takes 'continue', never falls though.
      
      Clean up the dead code.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e3cd5136
    • Masahiro Yamada's avatar
      kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix · d4a74bbf
      Masahiro Yamada authored
      
      arch/mips/Makefile passes prefixes that start with '-' to cc-cross-prefix
      when $(tool-archpref) evaluates to the empty string.
      
      They are filtered-out before the $(shell ...) invocation. Otherwise,
      'command -v' would be confused.
      
        $ command -v -linux-gcc
        bash: command: -l: invalid option
        command: usage: command [-pVv] command [arg ...]
      
      Since commit 913ab978 ("kbuild: use more portable 'command -v' for
      cc-cross-prefix"), cc-cross-prefix throws away the stderr output, so
      the console is not polluted in any way.
      
      This is not a big deal in practice, but I see a slightly better taste
      in adding '--' to teach it that '-linux-gcc' is an argument instead of
      a command option.
      
      This will cause extra forking of subshell, but it will not be noticeable
      performance regression.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d4a74bbf
  5. Jul 10, 2019
    • Harald Seiler's avatar
      kbuild: fix compression errors getting ignored · b956c7a6
      Harald Seiler authored
      
      A missing compression utility or other errors were not picked up by make
      and an empty kernel image was produced.  By removing the &&, errors will
      no longer be ignored.
      
      Signed-off-by: default avatarHarald Seiler <hws@denx.de>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      b956c7a6
    • Masahiro Yamada's avatar
      kbuild: add a flag to force absolute path for srctree · 95fd3f87
      Masahiro Yamada authored
      
      In old days, Kbuild always used an absolute path for $(srctree).
      
      Since commit 890676c6 ("kbuild: Use relative path when building in
      the source tree"), $(srctree) is '.' when O= was not passed from the
      command line.
      
      Yet, using absolute paths is useful in some cases even without O=, for
      instance, to create a cscope file with absolute path tags.
      
      'O=.' was known to work as a workaround to force Kbuild to use absolute
      paths even when you are building in the source tree.
      
      Since commit 25b146c5 ("kbuild: allow Kbuild to start from any
      directory"), Kbuild is too clever to be tricked. Even if you pass 'O=.'
      Kbuild notices you are building in the source tree, then use '.' for
      $(srctree).
      
      So, 'make O=. cscope' is no help to create absolute path tags.
      
      We cannot force one or the other according to commit e93bc1a0
      ("Revert "kbuild: specify absolute paths for cscope""). Both of
      relative path and absolute path have pros and cons.
      
      This commit adds a new flag KBUILD_ABS_SRCTREE to allow users to
      choose the absolute path for $(srctree).
      
      'make KBUILD_ABS_SRCTREE=1 cscope' will work as a replacement of
      'make O=. cscope'.
      
      Reported-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      95fd3f87
    • Masahiro Yamada's avatar
      kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree · 051f278e
      Masahiro Yamada authored
      
      Commit 25b146c5 ("kbuild: allow Kbuild to start from any directory")
      deprecated KBUILD_SRCTREE.
      
      It is only used in tools/testing/selftest/ to distinguish out-of-tree
      build. Replace it with a new boolean flag, building_out_of_srctree.
      
      I also replaced the conditional ($(srctree),.) because the next commit
      will allow an absolute path to be used for $(srctree) even when building
      in the source tree.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      051f278e
  6. Jul 09, 2019
    • Masahiro Yamada's avatar
      scripts/tags.sh: remove unused environment variables from comments · b3b3eb9d
      Masahiro Yamada authored
      
      This script has no reference to ${ARCH}, ${src}, ${obj}.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      b3b3eb9d
    • Masahiro Yamada's avatar
      scripts/tags.sh: drop SUBARCH support for ARM · d1db881d
      Masahiro Yamada authored
      
      Our goal is to have more and more sub-architectures to join the
      ARM multi-platform, and support them in a single configuration.
      
      Remove the ARM SUBARCH support because it is ugly.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d1db881d
    • Masahiro Yamada's avatar
      kbuild: support header-test-pattern-y · 1e21cbfa
      Masahiro Yamada authored
      
      In my view, most of headers can be self-contained. So, it would be
      tedious to add every header to header-test-y explicitly. We usually
      end up with "all headers with some exceptions".
      
      There are two types in exceptions:
      
      [1] headers that are never compiled as standalone units
      
        For examples, include/linux/compiler-gcc.h is not intended for
        direct inclusion. We should always exclude such ones.
      
      [2] headers that are conditionally compiled as standalone units
      
        Some headers can be compiled only for particular architectures.
        For example, include/linux/arm-cci.h can be compiled only for
        arm/arm64 because it requires <asm/arm-cci.h> to exist.
        Clang can compile include/soc/nps/mtm.h only for arc because
        it contains an arch-specific register in inline assembler.
      
      So, you can write Makefile like this:
      
        header-test-                += linux/compiler-gcc.h
        header-test-$(CONFIG_ARM)   += linux/arm-cci.h
        header-test-$(CONFIG_ARM64) += linux/arm-cci.h
        header-test-$(CONFIG_ARC)   += soc/nps/mtm.h
      
      The new syntax header-test-pattern-y will be useful to specify
      "the rest".
      
      The typical usage is like this:
      
        header-test-pattern-y += */*.h
      
      This will add all the headers in sub-directories to the test coverage,
      excluding $(header-test-). In this regards, header-test-pattern-y
      behaves like a weaker variant of header-test-y.
      
      Caveat:
      The patterns in header-test-pattern-y are prefixed with $(srctree)/$(src)/
      but not $(objtree)/$(obj)/. Stale generated headers are often left over
      when you traverse the git history without cleaning. Wildcard patterns for
      $(objtree) may match to stale headers, which could fail to compile.
      One pitfall is $(srctree)/$(src)/ and $(objtree)/$(obj)/ point to the
      same directory for in-tree building. So, header-test-pattern-y should
      be used with care since it can potentially match to stale headers.
      
      Caveat2:
      You could use wildcard for header-test-. For example,
      
        header-test- += asm-generic/%
      
      ... will exclude headers in asm-generic directory. Unfortunately, the
      wildcard character is '%' instead of '*' here because this is evaluated
      by $(filter-out ...) whereas header-test-pattern-y is evaluated by
      $(wildcard ...). This is a kludge, but seems useful in some places...
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: default avatarJani Nikula <jani.nikula@intel.com>
      1e21cbfa
    • 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
  7. Jul 07, 2019
  8. Jul 06, 2019
  9. Jul 01, 2019
    • Naveen N. Rao's avatar
      recordmcount: Fix spurious mcount entries on powerpc · 80e5302e
      Naveen N. Rao authored
      
      An impending change to enable HAVE_C_RECORDMCOUNT on powerpc leads to
      warnings such as the following:
      
        # modprobe kprobe_example
        ftrace-powerpc: Not expected bl: opcode is 3c4c0001
        WARNING: CPU: 0 PID: 227 at kernel/trace/ftrace.c:2001 ftrace_bug+0x90/0x318
        Modules linked in:
        CPU: 0 PID: 227 Comm: modprobe Not tainted 5.2.0-rc6-00678-g1c329100b942 #2
        NIP:  c000000000264318 LR: c00000000025d694 CTR: c000000000f5cd30
        REGS: c000000001f2b7b0 TRAP: 0700   Not tainted  (5.2.0-rc6-00678-g1c329100b942)
        MSR:  900000010282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]>  CR: 28228222  XER: 00000000
        CFAR: c0000000002642fc IRQMASK: 0
        <snip>
        NIP [c000000000264318] ftrace_bug+0x90/0x318
        LR [c00000000025d694] ftrace_process_locs+0x4f4/0x5e0
        Call Trace:
        [c000000001f2ba40] [0000000000000004] 0x4 (unreliable)
        [c000000001f2bad0] [c00000000025d694] ftrace_process_locs+0x4f4/0x5e0
        [c000000001f2bb90] [c00000000020ff10] load_module+0x25b0/0x30c0
        [c000000001f2bd00] [c000000000210cb0] sys_finit_module+0xc0/0x130
        [c000000001f2be20] [c00000000000bda4] system_call+0x5c/0x70
        Instruction dump:
        419e0018 2f83ffff 419e00bc 2f83ffea 409e00cc 4800001c 0fe00000 3c62ff96
        39000001 39400000 386386d0 480000c4 <0fe00000> 3ce20003 39000001 3c62ff96
        ---[ end trace 4c438d5cebf78381 ]---
        ftrace failed to modify
        [<c0080000012a0008>] 0xc0080000012a0008
         actual:   01:00:4c:3c
        Initializing ftrace call sites
        ftrace record flags: 2000000
         (0)
         expected tramp: c00000000006af4c
      
      Looking at the relocation records in __mcount_loc shows a few spurious
      entries:
      
        RELOCATION RECORDS FOR [__mcount_loc]:
        OFFSET           TYPE              VALUE
        0000000000000000 R_PPC64_ADDR64    .text.unlikely+0x0000000000000008
        0000000000000008 R_PPC64_ADDR64    .text.unlikely+0x0000000000000014
        0000000000000010 R_PPC64_ADDR64    .text.unlikely+0x0000000000000060
        0000000000000018 R_PPC64_ADDR64    .text.unlikely+0x00000000000000b4
        0000000000000020 R_PPC64_ADDR64    .init.text+0x0000000000000008
        0000000000000028 R_PPC64_ADDR64    .init.text+0x0000000000000014
      
      The first entry in each section is incorrect. Looking at the
      relocation records, the spurious entries correspond to the
      R_PPC64_ENTRY records:
      
        RELOCATION RECORDS FOR [.text.unlikely]:
        OFFSET           TYPE              VALUE
        0000000000000000 R_PPC64_REL64     .TOC.-0x0000000000000008
        0000000000000008 R_PPC64_ENTRY     *ABS*
        0000000000000014 R_PPC64_REL24     _mcount
        <snip>
      
      The problem is that we are not validating the return value from
      get_mcountsym() in sift_rel_mcount(). With this entry, mcountsym is 0,
      but Elf_r_sym(relp) also ends up being 0. Fix this by ensuring
      mcountsym is valid before processing the entry.
      
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Tested-by: default avatarSatheesh Rajendran <sathnaga@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      80e5302e
    • Masahiro Yamada's avatar
      fixdep: check return value of printf() and putchar() · 6f9ac9f4
      Masahiro Yamada authored
      
      When there is not enough space on your storage device, the build will
      fail with 'No space left on device' error message.
      
      The reason is obvious from the message, so you will free up some disk
      space, then you will resume the build.
      
      However, sometimes you may still see a mysterious error message:
      
        unterminated call to function 'wildcard': missing ')'.
      
      If you run out of the disk space, fixdep may end up with generating
      incomplete .*.cmd files.
      
      For example, if the disk-full error occurs while fixdep is running
      print_dep(), the .*.cmd might be truncated like this:
      
         $(wildcard include/config/
      
      When you run 'make' next time, this broken .*.cmd will be included,
      then Make will terminate parsing since it is a wrong syntax.
      
      Once this happens, you need to run 'make clean' or delete the broken
      .*.cmd file manually.
      
      Even if you do not see any error message, the .*.cmd files after any
      error could be potentially incomplete, and unreliable. You may miss
      the re-compilation due to missing header dependency.
      
      If printf() cannot output the string for disk shortage or whatever
      reason, it returns a negative value, but currently fixdep does not
      check it at all. Consequently, fixdep *successfully* generates a
      broken .*.cmd file. Make never notices that since fixdep exits with 0,
      which means success.
      
      Given the intended usage of fixdep, it must respect the return value
      of not only malloc(), but also printf() and putchar().
      
      This seems a long-standing issue since the introduction of fixdep.
      
      In old days, Kbuild tried to provide an extra safety by letting fixdep
      output to a temporary file and renaming it after everything is done:
      
        scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
        rm -f $(depfile);                                                    \
        mv -f $(dot-target).tmp $(dot-target).cmd)
      
      It was no help to avoid the current issue; fixdep successfully created
      a truncated tmp file, which would be renamed to a .*.cmd file.
      
      This problem should be fixed by propagating the error status to the
      build system because:
      
      [1] Since commit 9c2af1c7 ("kbuild: add .DELETE_ON_ERROR special
          target"), Make will delete the target automatically on any failure
          in the recipe.
      
      [2] Since commit 392885ee ("kbuild: let fixdep directly write to
          .*.cmd files"), .*.cmd file is included only when the corresponding
          target already exists.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      6f9ac9f4
Loading