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
    • Leonard Crestez's avatar
      scripts/gdb: add helpers to find and list devices · 778c1f5c
      Leonard Crestez authored
      Add helper commands and functions for finding pointers to struct device
      by enumerating linux device bus/class infrastructure.  This can be used
      to fetch subsystem and driver-specific structs:
      
        (gdb) p *$container_of($lx_device_find_by_class_name("net", "eth0"), "struct net_device", "dev")
        (gdb) p *$container_of($lx_device_find_by_bus_name("i2c", "0-004b"), "struct i2c_client", "dev")
        (gdb) p *(struct imx_port*)$lx_device_find_by_class_name("tty", "ttymxc1")->parent->driver_data
      
      Several generic "lx-device-list" functions are included to enumerate
      devices by bus and class:
      
        (gdb) lx-device-list-bus usb
        (gdb) lx-device-list-class
        (gdb) lx-device-list-tree &platform_bus
      
      Similar information is available in /sys but pointer values are
      deliberately hidden.
      
      Link: http://lkml.kernel.org/r/c948628041311cbf1b9b4cff3dda7d2073cb3eaa.1561492937.git.leonard.crestez@nxp.com
      
      
      Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
      Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      778c1f5c
    • Leonard Crestez's avatar
      scripts/gdb: add lx-genpd-summary command · 8207d4a8
      Leonard Crestez authored
      This is like /sys/kernel/debug/pm/pm_genpd_summary except it's
      accessible through a debugger.
      
      This can be useful if the target crashes or hangs because power domains
      were not properly enabled.
      
      Link: http://lkml.kernel.org/r/f9ee627a0d4f94b894aa202fee8a98444049bed8.1561492937.git.leonard.crestez@nxp.com
      
      
      Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
      Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8207d4a8
    • Matteo Croce's avatar
      checkpatch.pl: warn on duplicate sysctl local variable · 6a8d76cb
      Matteo Croce authored
      Commit d91bff3011cf ("proc/sysctl: add shared variables for range
      check") adds some shared const variables to be used instead of a local
      copy in each source file.  Warn when a chunk duplicates one of these
      values in a ctl_table struct:
      
          $ scripts/checkpatch.pl 0001-test-commit.patch
          WARNING: duplicated sysctl range checking value 'zero', consider using the shared one in include/linux/sysctl.h
          #27: FILE: arch/arm/kernel/isa.c:48:
          +               .extra1         = &zero,
      
          WARNING: duplicated sysctl range checking value 'int_max', consider using the shared one in include/linux/sysctl.h
          #28: FILE: arch/arm/kernel/isa.c:49:
          +               .extra2         = &int_max,
      
          total: 0 errors, 2 warnings, 14 lines checked
      
      Link: http://lkml.kernel.org/r/20190531131422.14970-1-mcroce@redhat.com
      
      
      Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Aaron Tomlin <atomlin@redhat.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6a8d76cb
    • Joe Perches's avatar
      get_maintainer: add ability to skip moderated mailing lists · 49662503
      Joe Perches authored
      Add a command line switch --no-moderated to skip L: mailing lists marked
      with 'moderated'.
      
      Some people prefer not emailing moderated mailing lists as the
      moderation time can be indeterminate and some emails can be
      intentionally dropped by a moderator.
      
      This can cause fragmentation of email threads when some are subscribed
      to a moderated list but others are not and emails are dropped.
      
      Link: http://lkml.kernel.org/r/6f23c2918ad9fc744269feb8f909bdfb105c5afc.camel@perches.com
      
      
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Tested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      49662503
    • 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 15, 2019
  3. 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
  4. Jul 12, 2019
  5. 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
  6. 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
  7. 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
  8. Jul 07, 2019
    • Vasily Gorbik's avatar
      kallsyms: exclude kasan local symbols on s390 · 33177f01
      Vasily Gorbik authored
      
      gcc asan instrumentation emits the following sequence to store frame pc
      when the kernel is built with CONFIG_RELOCATABLE:
      debug/vsprintf.s:
              .section        .data.rel.ro.local,"aw"
              .align  8
      .LC3:
              .quad   .LASANPC4826@GOTOFF
      .text
              .align  8
              .type   number, @function
      number:
      .LASANPC4826:
      
      and in case reloc is issued for LASANPC label it also gets into .symtab
      with the same address as actual function symbol:
      $ nm -n vmlinux | grep 0000000001397150
      0000000001397150 t .LASANPC4826
      0000000001397150 t number
      
      In the end kernel backtraces are almost unreadable:
      [  143.748476] Call Trace:
      [  143.748484] ([<000000002da3e62c>] .LASANPC2671+0x114/0x190)
      [  143.748492]  [<000000002eca1a58>] .LASANPC2612+0x110/0x160
      [  143.748502]  [<000000002de9d830>] print_address_description+0x80/0x3b0
      [  143.748511]  [<000000002de9dd64>] __kasan_report+0x15c/0x1c8
      [  143.748521]  [<000000002ecb56d4>] strrchr+0x34/0x60
      [  143.748534]  [<000003ff800a9a40>] kasan_strings+0xb0/0x148 [test_kasan]
      [  143.748547]  [<000003ff800a9bba>] kmalloc_tests_init+0xe2/0x528 [test_kasan]
      [  143.748555]  [<000000002da2117c>] .LASANPC4069+0x354/0x748
      [  143.748563]  [<000000002dbfbb16>] do_init_module+0x136/0x3b0
      [  143.748571]  [<000000002dbff3f4>] .LASANPC3191+0x2164/0x25d0
      [  143.748580]  [<000000002dbffc4c>] .LASANPC3196+0x184/0x1b8
      [  143.748587]  [<000000002ecdf2ec>] system_call+0xd8/0x2d8
      
      Since LASANPC labels are not even unique and get into .symtab only due
      to relocs filter them out in kallsyms.
      
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      33177f01
    • Kirill Smelkov's avatar
      coccinelle: api/stream_open: treat all wait_.*() calls as blocking · 0c4ab18f
      Kirill Smelkov authored
      Previously steam_open.cocci was treating only wait_event_.* - e.g.
      wait_event_interruptible - as a blocking operation. However e.g.
      wait_for_completion_interruptible is also blocking, and so from this
      point of view it would be more logical to treat all wait_.* as a
      blocking point.
      
      The logic of this change actually came up for real when
      drivers/pci/switch/switchtec.c changed from using
      wait_event_interruptible to wait_for_completion_interruptible:
      
      	https://lore.kernel.org/linux-pci/20190413170056.GA11293@deco.navytux.spb.ru/
      	https://lore.kernel.org/linux-pci/20190415145456.GA15280@deco.navytux.spb.ru/
      	https://lore.kernel.org/linux-pci/20190415154102.GB17661@deco.navytux.spb.ru/
      
      
      
      For a driver that uses nonseekable_open with read/write having stream
      semantic and read also calling e.g. wait_for_completion_interruptible,
      running stream_open.cocci before this patch would produce:
      
      	WARNING: <driver>_fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open.
      
      while after this patch it will report:
      
      	ERROR: <driver>_fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.
      
      Signed-off-by: default avatarKirill Smelkov <kirr@nexedi.com>
      Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0c4ab18f
Loading