Merge tag 'kbuild-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Jun 2020 19:00:25 +0000 (12:00 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Jun 2020 19:00:25 +0000 (12:00 -0700)
Pull Kbuild updates from Masahiro Yamada:

 - fix warnings in 'make clean' for ARCH=um, hexagon, h8300, unicore32

 - ensure to rebuild all objects when the compiler is upgraded

 - exclude system headers from dependency tracking and fixdep processing

 - fix potential bit-size mismatch between the kernel and BPF user-mode
   helper

 - add the new syntax 'userprogs' to build user-space programs for the
   target architecture (the same arch as the kernel)

 - compile user-space sample code under samples/ for the target arch
   instead of the host arch

 - make headers_install fail if a CONFIG option is leaked to user-space

 - sanitize the output format of scripts/checkstack.pl

 - handle ARM 'push' instruction in scripts/checkstack.pl

 - error out before modpost if a module name conflict is found

 - error out when multiple directories are passed to M= because this
   feature is broken for a long time

 - add CONFIG_DEBUG_INFO_COMPRESSED to support compressed debug info

 - a lot of cleanups of modpost

 - dump vmlinux symbols out into vmlinux.symvers, and reuse it in the
   second pass of modpost

 - do not run the second pass of modpost if nothing in modules is
   updated

 - install modules.builtin(.modinfo) by 'make install' as well as by
   'make modules_install' because it is useful even when
   CONFIG_MODULES=n

 - add new command line variables, GZIP, BZIP2, LZOP, LZMA, LZ4, and XZ
   to allow users to use alternatives such as pigz, pbzip2, etc.

* tag 'kbuild-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (96 commits)
  kbuild: add variables for compression tools
  Makefile: install modules.builtin even if CONFIG_MODULES=n
  mksysmap: Fix the mismatch of '.L' symbols in System.map
  kbuild: doc: rename LDFLAGS to KBUILD_LDFLAGS
  modpost: change elf_info->size to size_t
  modpost: remove is_vmlinux() helper
  modpost: strip .o from modname before calling new_module()
  modpost: set have_vmlinux in new_module()
  modpost: remove mod->skip struct member
  modpost: add mod->is_vmlinux struct member
  modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}()
  modpost: remove mod->is_dot_o struct member
  modpost: move -d option in scripts/Makefile.modpost
  modpost: remove -s option
  modpost: remove get_next_text() and make {grab,release_}file static
  modpost: use read_text_file() and get_line() for reading text files
  modpost: avoid false-positive file open error
  modpost: fix potential mmap'ed file overrun in get_src_version()
  modpost: add read_text_file() and get_line() helpers
  modpost: do not call get_modinfo() for vmlinux(.o)
  ...

1  2 
Makefile
arch/arm/Makefile
arch/arm64/Makefile
arch/parisc/Makefile
init/Kconfig
lib/Kconfig.debug
samples/Kconfig
scripts/link-vmlinux.sh
scripts/mod/modpost.c

diff --combined Makefile
+++ b/Makefile
@@@ -2,7 -2,7 +2,7 @@@
  VERSION = 5
  PATCHLEVEL = 7
  SUBLEVEL = 0
 -EXTRAVERSION = -rc5
 +EXTRAVERSION =
  NAME = Kleptomaniac Octopus
  
  # *DOCUMENTATION*
  # Comments in this file are targeted only to the developer, do not
  # expect to learn how to build the kernel reading this file.
  
+ $(if $(filter __%, $(MAKECMDGOALS)), \
+       $(error targets prefixed with '__' are only for internal use))
  # That's our default target when none is given on the command line
- PHONY := _all
- _all:
+ PHONY := __all
+ __all:
  
  # We are using a recursive build, so we need to do a little thinking
  # to get the ordering right.
@@@ -157,12 -160,14 +160,14 @@@ MAKEFLAGS += --include-dir=$(abs_srctre
  need-sub-make := 1
  endif
  
+ this-makefile := $(lastword $(MAKEFILE_LIST))
  ifneq ($(filter 3.%,$(MAKE_VERSION)),)
  # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
  # We need to invoke sub-make to avoid implicit rules in the top Makefile.
  need-sub-make := 1
  # Cancel implicit rules for this Makefile.
- $(lastword $(MAKEFILE_LIST)): ;
+ $(this-makefile): ;
  endif
  
  export abs_srctree abs_objtree
@@@ -170,13 -175,13 +175,13 @@@ export sub_make_done := 
  
  ifeq ($(need-sub-make),1)
  
- PHONY += $(MAKECMDGOALS) sub-make
+ PHONY += $(MAKECMDGOALS) __sub-make
  
- $(filter-out _all sub-make $(lastword $(MAKEFILE_LIST)), $(MAKECMDGOALS)) _all: sub-make
+ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
        @:
  
  # Invoke a second make in the output directory, passing relevant variables
- sub-make:
__sub-make:
        $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
  
  endif # need-sub-make
@@@ -213,6 -218,9 +218,9 @@@ ifeq ("$(origin M)", "command line"
    KBUILD_EXTMOD := $(M)
  endif
  
+ $(if $(word 2, $(KBUILD_EXTMOD)), \
+       $(error building multiple external modules is not supported))
  export KBUILD_CHECKSRC KBUILD_EXTMOD
  
  extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
@@@ -321,7 -329,7 +329,7 @@@ ifdef mixed-buil
  
  PHONY += $(MAKECMDGOALS) __build_one_by_one
  
- $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one
+ $(MAKECMDGOALS): __build_one_by_one
        @:
  
  __build_one_by_one:
@@@ -406,9 -414,12 +414,12 @@@ els
  HOSTCC        = gcc
  HOSTCXX       = g++
  endif
- KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
-               -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
-               $(HOSTCFLAGS)
+ export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
+                             -O2 -fomit-frame-pointer -std=gnu89
+ export KBUILD_USERLDFLAGS :=
+ KBUILD_HOSTCFLAGS   := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
  KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
  KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
  KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@@@ -447,6 -458,26 +458,26 @@@ PYTHON           = pytho
  PYTHON3               = python3
  CHECK         = sparse
  BASH          = bash
+ GZIP          = gzip
+ BZIP2         = bzip2
+ LZOP          = lzop
+ LZMA          = lzma
+ LZ4           = lz4c
+ XZ            = xz
+ # GZIP, BZIP2, LZOP env vars are used by the tools. Support them as the command
+ # line interface, but use _GZIP, _BZIP2, _LZOP internally.
+ _GZIP          := $(GZIP)
+ _BZIP2         := $(BZIP2)
+ _LZOP          := $(LZOP)
+ # Reset GZIP, BZIP2, LZOP in this Makefile
+ override GZIP=
+ override BZIP2=
+ override LZOP=
+ # Reset GZIP, BZIP2, LZOP in recursive invocations
+ MAKEOVERRIDES += GZIP= BZIP2= LZOP=
  
  CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@@ -495,6 -526,7 +526,7 @@@ CLANG_FLAGS :
  export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
  export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
  export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
+ export _GZIP _BZIP2 _LZOP LZMA LZ4 XZ
  export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
  
  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@@ -593,12 -625,12 +625,12 @@@ else #!config-buil
  # targets and others. In general all targets except *config targets.
  
  # If building an external module we do not care about the all: rule
- # but instead _all depend on modules
+ # but instead __all depend on modules
  PHONY += all
  ifeq ($(KBUILD_EXTMOD),)
- _all: all
+ __all: all
  else
- _all: modules
+ __all: modules
  endif
  
  # Decide whether to build built-in, modular, or both.
@@@ -608,19 -640,15 +640,15 @@@ KBUILD_MODULES :
  KBUILD_BUILTIN := 1
  
  # If we have only "make modules", don't compile built-in objects.
- # When we're building modules with modversions, we need to consider
- # the built-in objects during the descend as well, in order to
- # make sure the checksums are up to date before we record them.
  ifeq ($(MAKECMDGOALS),modules)
-   KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
+   KBUILD_BUILTIN :=
  endif
  
  # If we have "make <whatever> modules", compile modules
  # in addition to whatever we do anyway.
  # Just "make" or "make all" shall build modules as well
  
- ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),)
+ ifneq ($(filter all modules nsdeps,$(MAKECMDGOALS)),)
    KBUILD_MODULES := 1
  endif
  
@@@ -636,13 -664,11 +664,11 @@@ endi
  
  ifeq ($(KBUILD_EXTMOD),)
  # Objects we will link into vmlinux / subdirs we need to visit
init-y                := init/
core-y                := init/ usr/
  drivers-y     := drivers/ sound/
  drivers-$(CONFIG_SAMPLES) += samples/
net-y         := net/
drivers-y     += net/ virt/
  libs-y                := lib/
- core-y                := usr/
- virt-y                := virt/
  endif # KBUILD_EXTMOD
  
  # The all: target is the default when no target is given on the
@@@ -695,7 -721,7 +721,7 @@@ $(KCONFIG_CONFIG)
  # This exploits the 'multi-target pattern rule' trick.
  # The syncconfig should be executed only once to make all the targets.
  # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
- %/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
+ %/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG)
        $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
  else # !may-sync-config
  # External modules and some install targets need include/generated/autoconf.h
@@@ -814,6 -840,12 +840,12 @@@ DEBUG_CFLAGS     += $(call cc-option, -femi
                   $(call cc-option,-fno-var-tracking)
  endif
  
+ ifdef CONFIG_DEBUG_INFO_COMPRESSED
+ DEBUG_CFLAGS  += -gz=zlib
+ KBUILD_AFLAGS += -Wa,--compress-debug-sections=zlib
+ KBUILD_LDFLAGS        += --compress-debug-sections=zlib
+ endif
  KBUILD_CFLAGS += $(DEBUG_CFLAGS)
  export DEBUG_CFLAGS
  
@@@ -862,12 -894,6 +894,12 @@@ ifdef CONFIG_LIVEPATC
  KBUILD_CFLAGS += $(call cc-option, -flive-patching=inline-clone)
  endif
  
 +ifdef CONFIG_SHADOW_CALL_STACK
 +CC_FLAGS_SCS  := -fsanitize=shadow-call-stack
 +KBUILD_CFLAGS += $(CC_FLAGS_SCS)
 +export CC_FLAGS_SCS
 +endif
 +
  # arch Makefile may override CC so keep this after arch Makefile is included
  NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  
@@@ -950,6 -976,10 +982,10 @@@ ifeq ($(CONFIG_RELR),y
  LDFLAGS_vmlinux       += --pack-dyn-relocs=relr
  endif
  
+ # Align the bit size of userspace programs with the kernel
+ KBUILD_USERCFLAGS  += $(filter -m32 -m64, $(KBUILD_CFLAGS))
+ KBUILD_USERLDFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
  # make the checker run with the right architecture
  CHECKFLAGS += --arch=$(ARCH)
  
@@@ -1011,10 -1041,10 +1047,10 @@@ export mod_strip_cm
  mod_compress_cmd = true
  ifdef CONFIG_MODULE_COMPRESS
    ifdef CONFIG_MODULE_COMPRESS_GZIP
-     mod_compress_cmd = gzip -n -f
+     mod_compress_cmd = $(_GZIP) -n -f
    endif # CONFIG_MODULE_COMPRESS_GZIP
    ifdef CONFIG_MODULE_COMPRESS_XZ
-     mod_compress_cmd = xz -f
+     mod_compress_cmd = $(XZ) -f
    endif # CONFIG_MODULE_COMPRESS_XZ
  endif # CONFIG_MODULE_COMPRESS
  export mod_compress_cmd
@@@ -1049,34 -1079,33 +1085,33 @@@ export MODULES_NSDEPS := $(extmod-prefi
  ifeq ($(KBUILD_EXTMOD),)
  core-y                += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
  
- vmlinux-dirs  := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
+ vmlinux-dirs  := $(patsubst %/,%,$(filter %/, \
                     $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
-                    $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y)))
+                    $(libs-y) $(libs-m)))
  
  vmlinux-alldirs       := $(sort $(vmlinux-dirs) Documentation \
-                    $(patsubst %/,%,$(filter %/, $(init-) $(core-) \
-                       $(drivers-) $(net-) $(libs-) $(virt-))))
+                    $(patsubst %/,%,$(filter %/, $(core-) \
+                       $(drivers-) $(libs-))))
+ subdir-modorder := $(addsuffix modules.order,$(filter %/, \
+                       $(core-y) $(core-m) $(libs-y) $(libs-m) \
+                       $(drivers-y) $(drivers-m)))
  
  build-dirs    := $(vmlinux-dirs)
  clean-dirs    := $(vmlinux-alldirs)
  
- init-y                := $(patsubst %/, %/built-in.a, $(init-y))
- core-y                := $(patsubst %/, %/built-in.a, $(core-y))
- drivers-y     := $(patsubst %/, %/built-in.a, $(drivers-y))
- net-y         := $(patsubst %/, %/built-in.a, $(net-y))
- libs-y2               := $(patsubst %/, %/built-in.a, $(filter %/, $(libs-y)))
+ # Externally visible symbols (used by link-vmlinux.sh)
+ KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
+ KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
  ifdef CONFIG_MODULES
libs-y1               := $(filter-out %/, $(libs-y))
libs-y2               += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
  else
libs-y1               := $(patsubst %/, %/lib.a, $(libs-y))
KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
  endif
virt-y                := $(patsubst %/, %/built-in.a, $(virt-y))
KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
  
- # Externally visible symbols (used by link-vmlinux.sh)
- export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
-                             $(drivers-y) $(net-y) $(virt-y)
- export KBUILD_VMLINUX_LIBS := $(libs-y1)
+ export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
  export KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
  export LDFLAGS_vmlinux
  # used by scripts/Makefile.package
@@@ -1087,16 -1116,14 +1122,14 @@@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_
  # Recurse until adjust_autoksyms.sh is satisfied
  PHONY += autoksyms_recursive
  ifdef CONFIG_TRIM_UNUSED_KSYMS
- autoksyms_recursive: descend modules.order
-       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
-         "$(MAKE) -f $(srctree)/Makefile vmlinux"
- endif
  # For the kernel to actually contain only the needed exported symbols,
  # we have to build modules as well to determine what those symbols are.
  # (this can be evaluated only once include/config/auto.conf has been included)
- ifdef CONFIG_TRIM_UNUSED_KSYMS
-   KBUILD_MODULES := 1
+ KBUILD_MODULES := 1
+ autoksyms_recursive: descend modules.order
+       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
+         "$(MAKE) -f $(srctree)/Makefile vmlinux"
  endif
  
  autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
@@@ -1122,7 -1149,7 +1155,7 @@@ targets := vmlinu
  
  # The actual objects are generated when descending,
  # make sure no implicit rule kicks in
- $(sort $(vmlinux-deps)): descend ;
+ $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
  
  filechk_kernel.release = \
        echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@@ -1147,7 -1174,8 +1180,8 @@@ scripts: scripts_basic scripts_dt
  PHONY += prepare archprepare
  
  archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
-       asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h
+       asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
+       include/generated/autoconf.h
  
  prepare0: archprepare
        $(Q)$(MAKE) $(build)=scripts/mod
@@@ -1315,12 -1343,29 +1349,29 @@@ dt_binding_check: scripts_dt
  # ---------------------------------------------------------------------------
  # Modules
  
+ # install modules.builtin regardless of CONFIG_MODULES
+ PHONY += _builtin_inst_
+ _builtin_inst_:
+       @mkdir -p $(MODLIB)/
+       @cp -f modules.builtin $(MODLIB)/
+       @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
+ PHONY += install
+ install: _builtin_inst_
  ifdef CONFIG_MODULES
  
  # By default, build modules as well
  
  all: modules
  
+ # When we're building modules with modversions, we need to consider
+ # the built-in objects during the descend as well, in order to
+ # make sure the checksums are up to date before we record them.
+ ifdef CONFIG_MODVERSIONS
+   KBUILD_BUILTIN := 1
+ endif
  # Build modules
  #
  # A module can be listed more than once in obj-m resulting in
  # using awk while concatenating to the final file.
  
  PHONY += modules
- modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order
+ modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
-       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
  
- modules.order: descend
-       $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
+ PHONY += modules_check
+ modules_check: modules.order
+       $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
+ cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
+ modules.order: $(subdir-modorder) FORCE
+       $(call if_changed,modules_order)
+ targets += modules.order
  
  # Target to prepare building external modules
  PHONY += modules_prepare
@@@ -1344,7 -1396,7 +1402,7 @@@ PHONY += modules_instal
  modules_install: _modinst_ _modinst_post
  
  PHONY += _modinst_
- _modinst_:
+ _modinst_: _builtin_inst_
        @rm -rf $(MODLIB)/kernel
        @rm -f $(MODLIB)/source
        @mkdir -p $(MODLIB)/kernel
                ln -s $(CURDIR) $(MODLIB)/build ; \
        fi
        @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
-       @cp -f modules.builtin $(MODLIB)/
-       @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
  
  # This depmod is only for convenience to give the initial
@@@ -1395,14 -1445,14 +1451,14 @@@ endif # CONFIG_MODULE
  # make distclean Remove editor backup files, patch leftover files and the like
  
  # Directories & files removed with 'make clean'
- CLEAN_DIRS  += include/ksym
CLEAN_FILES += modules.builtin modules.builtin.modinfo modules.nsdeps
+ CLEAN_FILES += include/ksym vmlinux.symvers \
             modules.builtin modules.builtin.modinfo modules.nsdeps
  
  # Directories & files removed with 'make mrproper'
- MRPROPER_DIRS  += include/config include/generated          \
+ MRPROPER_FILES += include/config include/generated          \
                  arch/$(SRCARCH)/include/generated .tmp_objdiff \
-                 debian/ snap/ tar-install/
MRPROPER_FILES += .config .config.old .version \
+                 debian snap tar-install \
                .config .config.old .version \
                  Module.symvers \
                  signing_key.pem signing_key.priv signing_key.x509     \
                  x509.genkey extra_certificates signing_key.x509.keyid \
                  *.spec
  
  # Directories & files removed with 'make distclean'
- DISTCLEAN_DIRS  +=
  DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
  
  # clean - Delete most, but leave enough to build external modules
  #
- clean: rm-dirs  := $(CLEAN_DIRS)
  clean: rm-files := $(CLEAN_FILES)
  
  PHONY += archclean vmlinuxclean
@@@ -1428,7 -1476,6 +1482,6 @@@ clean: archclean vmlinuxclea
  
  # mrproper - Delete all generated files, including .config
  #
- mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
  mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
  mrproper-dirs      := $(addprefix _mrproper_,scripts)
  
@@@ -1437,18 -1484,15 +1490,15 @@@ $(mrproper-dirs)
        $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
  
  mrproper: clean $(mrproper-dirs)
-       $(call cmd,rmdirs)
        $(call cmd,rmfiles)
  
  # distclean
  #
- distclean: rm-dirs  := $(wildcard $(DISTCLEAN_DIRS))
  distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
  
  PHONY += distclean
  
  distclean: mrproper
-       $(call cmd,rmdirs)
        $(call cmd,rmfiles)
        @find $(srctree) $(RCS_FIND_IGNORE) \
                \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
@@@ -1634,17 -1678,9 +1684,9 @@@ else # KBUILD_EXTMO
  # We are always building modules
  KBUILD_MODULES := 1
  
- PHONY += $(objtree)/Module.symvers
- $(objtree)/Module.symvers:
-       @test -e $(objtree)/Module.symvers || ( \
-       echo; \
-       echo "  WARNING: Symbol version dump $(objtree)/Module.symvers"; \
-       echo "           is missing; modules will have no dependencies and modversions."; \
-       echo )
  build-dirs := $(KBUILD_EXTMOD)
  PHONY += modules
- modules: descend $(objtree)/Module.symvers
+ modules: descend
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
  
  PHONY += modules_install
@@@ -1663,10 -1699,6 +1705,6 @@@ _emodinst_post: _emodinst
  clean-dirs := $(KBUILD_EXTMOD)
  clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps
  
- PHONY += /
- /:
-       @echo >&2 '"$(MAKE) /" is no longer supported. Please use "$(MAKE) ./" instead.'
  PHONY += help
  help:
        @echo  '  Building external modules.'
@@@ -1724,6 -1756,10 +1762,10 @@@ build-dirs := $(foreach d, $(build-dirs
  
  endif
  
+ ifndef CONFIG_MODULES
+ KBUILD_MODULES :=
+ endif
  # Handle descending into subdirectories listed in $(build-dirs)
  # Preset locale variables to speed up the build process. Limit locale
  # tweaks to this spot to avoid wrong language settings when running
@@@ -1742,7 -1778,6 +1784,6 @@@ $(clean-dirs)
        $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  
  clean: $(clean-dirs)
-       $(call cmd,rmdirs)
        $(call cmd,rmfiles)
        @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
                \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
@@@ -1837,14 -1872,8 +1878,8 @@@ tools/%: FORC
        $(Q)mkdir -p $(objtree)/tools
        $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
  
- # FIXME Should go into a make.lib or something
- # ===========================================================================
- quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
-       cmd_rmdirs = rm -rf $(rm-dirs)
  quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
-       cmd_rmfiles = rm -f $(rm-files)
+       cmd_rmfiles = rm -rf $(rm-files)
  
  # Run depmod only if we have System.map and depmod is executable
  quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
diff --combined arch/arm/Makefile
@@@ -45,12 -45,10 +45,10 @@@ endi
  ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
  KBUILD_CPPFLAGS       += -mbig-endian
  CHECKFLAGS    += -D__ARMEB__
- AS            += -EB
  KBUILD_LDFLAGS        += -EB
  else
  KBUILD_CPPFLAGS       += -mlittle-endian
  CHECKFLAGS    += -D__ARMEL__
- AS            += -EL
  KBUILD_LDFLAGS        += -EL
  endif
  
@@@ -148,8 -146,6 +146,8 @@@ head-y             := arch/arm/kernel/head$(MMUEXT
  textofs-y     := 0x00008000
  # We don't want the htc bootloader to corrupt kernel during resume
  textofs-$(CONFIG_PM_H1940)      := 0x00108000
 +# RTD1195 has Boot ROM at start of address space
 +textofs-$(CONFIG_ARCH_REALTEK)  := 0x00108000
  # SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory
  ifeq ($(CONFIG_ARCH_SA1100),y)
  textofs-$(CONFIG_SA1111) := 0x00208000
@@@ -210,7 -206,6 +208,7 @@@ machine-$(CONFIG_ARCH_PICOXCELL)   += pic
  machine-$(CONFIG_ARCH_PXA)            += pxa
  machine-$(CONFIG_ARCH_QCOM)           += qcom
  machine-$(CONFIG_ARCH_RDA)            += rda
 +machine-$(CONFIG_ARCH_REALTEK)                += realtek
  machine-$(CONFIG_ARCH_REALVIEW)               += realview
  machine-$(CONFIG_ARCH_ROCKCHIP)               += rockchip
  machine-$(CONFIG_ARCH_RPC)            += rpc
diff --combined arch/arm64/Makefile
@@@ -12,6 -12,7 +12,6 @@@
  
  LDFLAGS_vmlinux       :=--no-undefined -X
  CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
 -GZFLAGS               :=-9
  
  ifeq ($(CONFIG_RELOCATABLE), y)
  # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
@@@ -70,14 -71,7 +70,14 @@@ branch-prot-flags-y += $(call cc-option
  
  ifeq ($(CONFIG_ARM64_PTR_AUTH),y)
  branch-prot-flags-$(CONFIG_CC_HAS_SIGN_RETURN_ADDRESS) := -msign-return-address=all
 +# We enable additional protection for leaf functions as there is some
 +# narrow potential for ROP protection benefits and no substantial
 +# performance impact has been observed.
 +ifeq ($(CONFIG_ARM64_BTI_KERNEL),y)
 +branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI) := -mbranch-protection=pac-ret+leaf+bti
 +else
  branch-prot-flags-$(CONFIG_CC_HAS_BRANCH_PROT_PAC_RET) := -mbranch-protection=pac-ret+leaf
 +endif
  # -march=armv8.3-a enables the non-nops instructions for PAC, to avoid the
  # compiler to generate them and consequently to break the single image contract
  # we pass it only to the assembler. This option is utilized only in case of non
@@@ -87,14 -81,9 +87,13 @@@ endi
  
  KBUILD_CFLAGS += $(branch-prot-flags-y)
  
 +ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
 +KBUILD_CFLAGS += -ffixed-x18
 +endif
 +
  ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  KBUILD_CPPFLAGS       += -mbig-endian
  CHECKFLAGS    += -D__AARCH64EB__
- AS            += -EB
  # Prefer the baremetal ELF build target, but not all toolchains include
  # it so fall back to the standard linux version if needed.
  KBUILD_LDFLAGS        += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
@@@ -102,7 -91,6 +101,6 @@@ UTS_MACHINE := aarch64_b
  else
  KBUILD_CPPFLAGS       += -mlittle-endian
  CHECKFLAGS    += -D__AARCH64EL__
- AS            += -EL
  # Same as above, prefer ELF but fall back to linux target if needed.
  KBUILD_LDFLAGS        += -EL $(call ld-option, -maarch64elf, -maarch64linux)
  UTS_MACHINE   := aarch64
@@@ -128,7 -116,7 +126,7 @@@ TEXT_OFFSET := $(shell awk "BEGIN {sran
                 int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \
                 rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}")
  else
 -TEXT_OFFSET := 0x00080000
 +TEXT_OFFSET := 0x0
  endif
  
  ifeq ($(CONFIG_KASAN_SW_TAGS), y)
@@@ -141,7 -129,7 +139,7 @@@ KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_S
  KBUILD_CPPFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
  KBUILD_AFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT)
  
 -export        TEXT_OFFSET GZFLAGS
 +export        TEXT_OFFSET
  
  core-y                += arch/arm64/
  libs-y                := arch/arm64/lib/ $(libs-y)
diff --combined arch/parisc/Makefile
@@@ -21,6 -21,8 +21,6 @@@ KBUILD_IMAGE := vmlinu
  
  NM            = sh $(srctree)/arch/parisc/nm
  CHECKFLAGS    += -D__hppa__=1
 -LIBGCC                = $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 -export LIBGCC
  
  ifdef CONFIG_64BIT
  UTS_MACHINE   := parisc64
@@@ -108,8 -110,6 +108,8 @@@ cflags-$(CONFIG_PA8X00)            += -march=2.0 
  head-y                        := arch/parisc/kernel/head.o 
  
  KBUILD_CFLAGS += $(cflags-y)
 +LIBGCC                := $(shell $(CC) -print-libgcc-file-name)
 +export LIBGCC
  
  kernel-y                      := mm/ kernel/ math-emu/
  
@@@ -162,7 -162,7 +162,7 @@@ vmlinuz: bzImag
        $(OBJCOPY) $(boot)/bzImage $@
  else
  vmlinuz: vmlinux
-       @gzip -cf -9 $< > $@
+       @$(_GZIP) -cf -9 $< > $@
  endif
  
  install:
diff --combined init/Kconfig
@@@ -8,8 -8,25 +8,25 @@@ config DEFCONFIG_LIS
        default "/boot/config-$(shell,uname -r)"
        default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
  
+ config CC_VERSION_TEXT
+       string
+       default "$(CC_VERSION_TEXT)"
+       help
+         This is used in unclear ways:
+         - Re-run Kconfig when the compiler is updated
+           The 'default' property references the environment variable,
+           CC_VERSION_TEXT so it is recorded in include/config/auto.conf.cmd.
+           When the compiler is updated, Kconfig will be invoked.
+         - Ensure full rebuild when the compier is updated
+           include/linux/kconfig.h contains this option in the comment line so
+           fixdep adds include/config/cc/version/text.h into the auto-generated
+           dependency. When the compiler is updated, syncconfig will touch it
+           and then every file will be rebuilt.
  config CC_IS_GCC
-       def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc)
+       def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q gcc)
  
  config GCC_VERSION
        int
@@@ -21,25 -38,25 +38,32 @@@ config LD_VERSIO
        default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
  
  config CC_IS_CLANG
-       def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)
+       def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q clang)
  
 +config LD_IS_LLD
 +      def_bool $(success,$(LD) -v | head -n 1 | grep -q LLD)
 +
  config CLANG_VERSION
        int
        default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
  
  config CC_CAN_LINK
-       def_bool $(success,$(srctree)/scripts/cc-can-link.sh $(CC))
+       bool
+       default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m64-flag)) if 64BIT
+       default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(m32-flag))
+ config CC_CAN_LINK_STATIC
+       bool
+       default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m64-flag)) if 64BIT
+       default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m32-flag))
  
  config CC_HAS_ASM_GOTO
        def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
  
 +config CC_HAS_ASM_GOTO_OUTPUT
 +      depends on CC_HAS_ASM_GOTO
 +      def_bool $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
 +
  config TOOLS_SUPPORT_RELR
        def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
  
@@@ -264,16 -281,6 +288,16 @@@ config KERNEL_UNCOMPRESSE
  
  endchoice
  
 +config DEFAULT_INIT
 +      string "Default init path"
 +      default ""
 +      help
 +        This option determines the default init for the system if no init=
 +        option is passed on the kernel command line. If the requested path is
 +        not present, we will still then move on to attempting further
 +        locations (e.g. /sbin/init, etc). If this is empty, we will just use
 +        the fallback list when init= is not passed.
 +
  config DEFAULT_HOSTNAME
        string "Default hostname"
        default "(none)"
@@@ -836,9 -843,24 +860,9 @@@ config MEMC
          Provides control over the memory footprint of tasks in a cgroup.
  
  config MEMCG_SWAP
 -      bool "Swap controller"
 +      bool
        depends on MEMCG && SWAP
 -      help
 -        Provides control over the swap space consumed by tasks in a cgroup.
 -
 -config MEMCG_SWAP_ENABLED
 -      bool "Swap controller enabled by default"
 -      depends on MEMCG_SWAP
        default y
 -      help
 -        Memory Resource Controller Swap Extension comes with its price in
 -        a bigger memory consumption. General purpose distribution kernels
 -        which want to enable the feature but keep it disabled by default
 -        and let the user enable it by swapaccount=1 boot command line
 -        parameter should have this option unselected.
 -        For those who want to have the feature enabled by default should
 -        select this option (if, for some reason, they need to disable it
 -        then swapaccount=0 does the trick).
  
  config MEMCG_KMEM
        bool
@@@ -2263,9 -2285,6 +2287,9 @@@ config ASN
  
  source "kernel/Kconfig.locks"
  
 +config ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
 +      bool
 +
  config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
        bool
  
diff --combined lib/Kconfig.debug
@@@ -213,6 -213,23 +213,23 @@@ config DEBUG_INFO_REDUCE
          DEBUG_INFO build and compile times are reduced too.
          Only works with newer gcc versions.
  
+ config DEBUG_INFO_COMPRESSED
+       bool "Compressed debugging information"
+       depends on DEBUG_INFO
+       depends on $(cc-option,-gz=zlib)
+       depends on $(as-option,-Wa$(comma)--compress-debug-sections=zlib)
+       depends on $(ld-option,--compress-debug-sections=zlib)
+       help
+         Compress the debug information using zlib.  Requires GCC 5.0+ or Clang
+         5.0+, binutils 2.26+, and zlib.
+         Users of dpkg-deb via scripts/package/builddeb may find an increase in
+         size of their debug .deb packages with this config set, due to the
+         debug info being compressed with zlib, then the object files being
+         recompressed with a different compression scheme. But this is still
+         preferable to setting $KDEB_COMPRESS to "none" which would be even
+         larger.
  config DEBUG_INFO_SPLIT
        bool "Produce split debuginfo in .dwo files"
        depends on DEBUG_INFO
@@@ -369,11 -386,6 +386,11 @@@ config STACK_VALIDATIO
          For more information, see
          tools/objtool/Documentation/stack-validation.txt.
  
 +config VMLINUX_VALIDATION
 +      bool
 +      depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT
 +      default y
 +
  config DEBUG_FORCE_WEAK_PER_CPU
        bool "Force weak per-cpu definitions"
        depends on DEBUG_KERNEL
@@@ -658,12 -670,6 +675,12 @@@ config SCHED_STACK_END_CHEC
          data corruption or a sporadic crash at a later stage once the region
          is examined. The runtime overhead introduced is minimal.
  
 +config ARCH_HAS_DEBUG_VM_PGTABLE
 +      bool
 +      help
 +        An architecture should select this when it can successfully
 +        build and run DEBUG_VM_PGTABLE.
 +
  config DEBUG_VM
        bool "Debug VM"
        depends on DEBUG_KERNEL
@@@ -699,22 -705,6 +716,22 @@@ config DEBUG_VM_PGFLAG
  
          If unsure, say N.
  
 +config DEBUG_VM_PGTABLE
 +      bool "Debug arch page table for semantics compliance"
 +      depends on MMU
 +      depends on ARCH_HAS_DEBUG_VM_PGTABLE
 +      default y if DEBUG_VM
 +      help
 +        This option provides a debug method which can be used to test
 +        architecture page table helper functions on various platforms in
 +        verifying if they comply with expected generic MM semantics. This
 +        will help architecture code in making sure that any changes or
 +        new additions of these helpers still conform to expected
 +        semantics of the generic MM. Platforms will have to opt in for
 +        this through ARCH_HAS_DEBUG_VM_PGTABLE.
 +
 +        If unsure, say N.
 +
  config ARCH_HAS_DEBUG_VIRTUAL
        bool
  
@@@ -1537,7 -1527,7 +1554,7 @@@ config PROVIDE_OHCI1394_DMA_INI
          This code (~1k) is freed after boot. By then, the firewire stack
          in charge of the OHCI-1394 controllers should be used instead.
  
 -        See Documentation/debugging-via-ohci1394.txt for more information.
 +        See Documentation/core-api/debugging-via-ohci1394.rst for more information.
  
  source "samples/Kconfig"
  
@@@ -1796,15 -1786,6 +1813,15 @@@ config KCOV_INSTRUMENT_AL
          filesystem fuzzing with AFL) then you will want to enable coverage
          for more specific subsets of files, and should say n here.
  
 +config KCOV_IRQ_AREA_SIZE
 +      hex "Size of interrupt coverage collection area in words"
 +      depends on KCOV
 +      default 0x40000
 +      help
 +        KCOV uses preallocated per-cpu areas to collect coverage from
 +        soft interrupts. This specifies the size of those areas in the
 +        number of unsigned long words.
 +
  menuconfig RUNTIME_TESTING_MENU
        bool "Runtime Testing"
        def_bool y
@@@ -2022,19 -2003,6 +2039,19 @@@ config TEST_LK
  
          If unsure, say N.
  
 +config TEST_BITOPS
 +      tristate "Test module for compilation of clear_bit/set_bit operations"
 +      depends on m
 +      help
 +        This builds the "test_bitops" module that is much like the
 +        TEST_LKM module except that it does a basic exercise of the
 +        clear_bit and set_bit macros to make sure there are no compiler
 +        warnings from C=1 sparse checker or -Wextra compilations. It has
 +        no dependencies and doesn't run or load unless explicitly requested
 +        by name.  for example: modprobe test_bitops.
 +
 +        If unsure, say N.
 +
  config TEST_VMALLOC
        tristate "Test module for stress/performance analysis of vmalloc allocator"
        default n
@@@ -2141,18 -2109,6 +2158,18 @@@ config LIST_KUNIT_TES
  
          If unsure, say N.
  
 +config LINEAR_RANGES_TEST
 +      tristate "KUnit test for linear_ranges"
 +      depends on KUNIT
 +      select LINEAR_RANGES
 +      help
 +        This builds the linear_ranges unit test, which runs on boot.
 +        Tests the linear_ranges logic correctness.
 +        For more information on KUnit and unit tests in general please refer
 +        to the KUnit documentation in Documentation/dev-tools/kunit/.
 +
 +        If unsure, say N.
 +
  config TEST_UDELAY
        tristate "udelay test driver"
        help
@@@ -2262,19 -2218,6 +2279,19 @@@ config TEST_MEMINI
  
          If unsure, say N.
  
 +config TEST_HMM
 +      tristate "Test HMM (Heterogeneous Memory Management)"
 +      depends on TRANSPARENT_HUGEPAGE
 +      depends on DEVICE_PRIVATE
 +      select HMM_MIRROR
 +      select MMU_NOTIFIER
 +      help
 +        This is a pseudo device driver solely for testing HMM.
 +        Say M here if you want to build the HMM test module.
 +        Doing so will allow you to run tools/testing/selftest/vm/hmm-tests.
 +
 +        If unsure, say N.
 +
  endif # RUNTIME_TESTING_MENU
  
  config MEMTEST
diff --combined samples/Kconfig
@@@ -6,6 -6,10 +6,10 @@@ menuconfig SAMPLE
  
  if SAMPLES
  
+ config SAMPLE_AUXDISPLAY
+       bool "auxdisplay sample"
+       depends on CC_CAN_LINK
  config SAMPLE_TRACE_EVENTS
        tristate "Build trace_events examples -- loadable modules only"
        depends on EVENT_TRACING && m
@@@ -118,19 -122,29 +122,29 @@@ config SAMPLE_CONNECTO
  
  config SAMPLE_HIDRAW
        bool "hidraw sample"
-       depends on HEADERS_INSTALL
+       depends on CC_CAN_LINK && HEADERS_INSTALL
  
  config SAMPLE_PIDFD
        bool "pidfd sample"
-       depends on HEADERS_INSTALL
+       depends on CC_CAN_LINK && HEADERS_INSTALL
  
  config SAMPLE_SECCOMP
        bool "Build seccomp sample code"
-       depends on SECCOMP_FILTER && HEADERS_INSTALL
+       depends on SECCOMP_FILTER && CC_CAN_LINK && HEADERS_INSTALL
        help
          Build samples of seccomp filters using various methods of
          BPF filter construction.
  
+ config SAMPLE_TIMER
+       bool "Timer sample"
+       depends on CC_CAN_LINK && HEADERS_INSTALL
+ config SAMPLE_UHID
+       bool "UHID sample"
+       depends on CC_CAN_LINK && HEADERS_INSTALL
+       help
+         Build UHID sample program.
  config SAMPLE_VFIO_MDEV_MTTY
        tristate "Build VFIO mtty example mediated device sample code -- loadable modules only"
        depends on VFIO_MDEV_DEVICE && m
@@@ -171,14 -185,14 +185,14 @@@ config SAMPLE_VFIO_MDEV_MBOCH
  
  config SAMPLE_ANDROID_BINDERFS
        bool "Build Android binderfs example"
 -      depends on CONFIG_ANDROID_BINDERFS
 +      depends on ANDROID_BINDERFS
        help
          Builds a sample program to illustrate the use of the Android binderfs
          filesystem.
  
  config SAMPLE_VFS
        bool "Build example programs that use new VFS system calls"
-       depends on HEADERS_INSTALL
+       depends on CC_CAN_LINK && HEADERS_INSTALL
        help
          Build example userspace programs that use new VFS system calls such
          as mount API and statx().  Note that this is restricted to the x86
  config SAMPLE_INTEL_MEI
        bool "Build example program working with intel mei driver"
        depends on INTEL_MEI
+       depends on CC_CAN_LINK && HEADERS_INSTALL
        help
          Build a sample program to work with mei device.
  
+ config SAMPLE_WATCHDOG
+       bool "watchdog sample"
+       depends on CC_CAN_LINK
  
  endif # SAMPLES
diff --combined scripts/link-vmlinux.sh
@@@ -55,29 -55,6 +55,29 @@@ modpost_link(
        ${LD} ${KBUILD_LDFLAGS} -r -o ${1} ${objects}
  }
  
 +objtool_link()
 +{
 +      local objtoolopt;
 +
 +      if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then
 +              objtoolopt="check"
 +              if [ -z "${CONFIG_FRAME_POINTER}" ]; then
 +                      objtoolopt="${objtoolopt} --no-fp"
 +              fi
 +              if [ -n "${CONFIG_GCOV_KERNEL}" ]; then
 +                      objtoolopt="${objtoolopt} --no-unreachable"
 +              fi
 +              if [ -n "${CONFIG_RETPOLINE}" ]; then
 +                      objtoolopt="${objtoolopt} --retpoline"
 +              fi
 +              if [ -n "${CONFIG_X86_SMAP}" ]; then
 +                      objtoolopt="${objtoolopt} --uaccess"
 +              fi
 +              info OBJTOOL ${1}
 +              tools/objtool/objtool ${objtoolopt} ${1}
 +      fi
 +}
 +
  # Link of vmlinux
  # ${1} - output file
  # ${2}, ${3}, ... - optional extra .o files
@@@ -241,8 -218,6 +241,6 @@@ on_signals(
  }
  trap on_signals HUP INT QUIT TERM
  
- #
- #
  # Use "make V=1" to debug this script
  case "${KBUILD_VERBOSE}" in
  *1*)
@@@ -274,7 -249,6 +272,7 @@@ ${MAKE} -f "${srctree}/scripts/Makefile
  #link vmlinux.o
  info LD vmlinux.o
  modpost_link vmlinux.o
 +objtool_link vmlinux.o
  
  # modpost vmlinux.o to check for section mismatches
  ${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
diff --combined scripts/mod/modpost.c
@@@ -30,8 -30,6 +30,6 @@@ static int have_vmlinux = 0
  static int all_versions = 0;
  /* If we are modposting external module set to 1 */
  static int external_module = 0;
- /* Warn about section mismatch in vmlinux if set to 1 */
- static int vmlinux_section_warnings = 1;
  /* Only warn about unresolved symbols */
  static int warn_unresolved = 0;
  /* How a symbol is exported */
@@@ -90,26 -88,61 +88,61 @@@ static inline bool strends(const char *
        return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
  }
  
static int is_vmlinux(const char *modname)
void *do_nofail(void *ptr, const char *expr)
  {
-       const char *myname;
+       if (!ptr)
+               fatal("Memory allocation failure: %s.\n", expr);
  
-       myname = strrchr(modname, '/');
-       if (myname)
-               myname++;
-       else
-               myname = modname;
+       return ptr;
+ }
+ char *read_text_file(const char *filename)
+ {
+       struct stat st;
+       size_t nbytes;
+       int fd;
+       char *buf;
+       fd = open(filename, O_RDONLY);
+       if (fd < 0) {
+               perror(filename);
+               exit(1);
+       }
  
-       return (strcmp(myname, "vmlinux") == 0) ||
-              (strcmp(myname, "vmlinux.o") == 0);
+       if (fstat(fd, &st) < 0) {
+               perror(filename);
+               exit(1);
+       }
+       buf = NOFAIL(malloc(st.st_size + 1));
+       nbytes = st.st_size;
+       while (nbytes) {
+               ssize_t bytes_read;
+               bytes_read = read(fd, buf, nbytes);
+               if (bytes_read < 0) {
+                       perror(filename);
+                       exit(1);
+               }
+               nbytes -= bytes_read;
+       }
+       buf[st.st_size] = '\0';
+       close(fd);
+       return buf;
  }
  
void *do_nofail(void *ptr, const char *expr)
char *get_line(char **stringp)
  {
-       if (!ptr)
-               fatal("Memory allocation failure: %s.\n", expr);
+       /* do not return the unwanted extra line at EOF */
+       if (*stringp && **stringp == '\0')
+               return NULL;
  
-       return ptr;
+       return strsep(stringp, "\n");
  }
  
  /* A list of all modules we processed */
@@@ -128,24 -161,20 +161,20 @@@ static struct module *find_module(cons
  static struct module *new_module(const char *modname)
  {
        struct module *mod;
-       char *p;
  
-       mod = NOFAIL(malloc(sizeof(*mod)));
+       mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1));
        memset(mod, 0, sizeof(*mod));
-       p = NOFAIL(strdup(modname));
-       /* strip trailing .o */
-       if (strends(p, ".o")) {
-               p[strlen(p) - 2] = '\0';
-               mod->is_dot_o = 1;
-       }
  
        /* add to list */
-       mod->name = p;
+       strcpy(mod->name, modname);
+       mod->is_vmlinux = (strcmp(modname, "vmlinux") == 0);
        mod->gpl_compatible = -1;
        mod->next = modules;
        modules = mod;
  
+       if (mod->is_vmlinux)
+               have_vmlinux = 1;
        return mod;
  }
  
@@@ -161,12 -190,9 +190,9 @@@ struct symbol 
        int crc_valid;
        char *namespace;
        unsigned int weak:1;
-       unsigned int vmlinux:1;    /* 1 if symbol is defined in vmlinux */
-       unsigned int kernel:1;     /* 1 if symbol is from kernel
-                                   *  (only for external modules) **/
        unsigned int is_static:1;  /* 1 if symbol is not global */
        enum export  export;       /* Type of export */
-       char name[0];
+       char name[];
  };
  
  static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
@@@ -288,29 -314,32 +314,32 @@@ static enum export export_no(const cha
        return export_unknown;
  }
  
- static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
+ static void *sym_get_data_by_offset(const struct elf_info *info,
+                                   unsigned int secindex, unsigned long offset)
  {
-       return (void *)elf->hdr +
-               elf->sechdrs[elf->secindex_strings].sh_offset +
-               sechdr->sh_name;
- }
+       Elf_Shdr *sechdr = &info->sechdrs[secindex];
  
- static const char *sec_name(struct elf_info *elf, int secindex)
- {
-       return sech_name(elf, &elf->sechdrs[secindex]);
+       if (info->hdr->e_type != ET_REL)
+               offset -= sechdr->sh_addr;
+       return (void *)info->hdr + sechdr->sh_offset + offset;
  }
  
  static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
  {
-       unsigned int secindex = get_secindex(info, sym);
-       Elf_Shdr *sechdr = &info->sechdrs[secindex];
-       unsigned long offset;
+       return sym_get_data_by_offset(info, get_secindex(info, sym),
+                                     sym->st_value);
+ }
  
-       offset = sym->st_value;
-       if (info->hdr->e_type != ET_REL)
-               offset -= sechdr->sh_addr;
+ static const char *sech_name(const struct elf_info *info, Elf_Shdr *sechdr)
+ {
+       return sym_get_data_by_offset(info, info->secindex_strings,
+                                     sechdr->sh_name);
+ }
  
-       return (void *)info->hdr + sechdr->sh_offset + offset;
+ static const char *sec_name(const struct elf_info *info, int secindex)
+ {
+       return sech_name(info, &info->sechdrs[secindex]);
  }
  
  #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
@@@ -386,17 -415,15 +415,15 @@@ static struct symbol *sym_add_exported(
  
        if (!s) {
                s = new_symbol(name, mod, export);
-       } else if (!external_module || is_vmlinux(s->module->name) ||
+       } else if (!external_module || s->module->is_vmlinux ||
                   s->module == mod) {
                warn("%s: '%s' exported twice. Previous export was in %s%s\n",
                     mod->name, name, s->module->name,
-                    is_vmlinux(s->module->name) ? "" : ".ko");
+                    s->module->is_vmlinux ? "" : ".ko");
                return s;
        }
  
        s->module = mod;
-       s->vmlinux   = is_vmlinux(mod->name);
-       s->kernel    = 0;
        s->export    = export;
        return s;
  }
@@@ -416,7 -443,7 +443,7 @@@ static void sym_set_crc(const char *nam
        s->crc_valid = 1;
  }
  
void *grab_file(const char *filename, unsigned long *size)
static void *grab_file(const char *filename, size_t *size)
  {
        struct stat st;
        void *map = MAP_FAILED;
@@@ -438,41 -465,7 +465,7 @@@ failed
        return map;
  }
  
- /**
-   * Return a copy of the next line in a mmap'ed file.
-   * spaces in the beginning of the line is trimmed away.
-   * Return a pointer to a static buffer.
-   **/
- char *get_next_line(unsigned long *pos, void *file, unsigned long size)
- {
-       static char line[4096];
-       int skip = 1;
-       size_t len = 0;
-       signed char *p = (signed char *)file + *pos;
-       char *s = line;
-       for (; *pos < size ; (*pos)++) {
-               if (skip && isspace(*p)) {
-                       p++;
-                       continue;
-               }
-               skip = 0;
-               if (*p != '\n' && (*pos < size)) {
-                       len++;
-                       *s++ = *p++;
-                       if (len > 4095)
-                               break; /* Too long, stop */
-               } else {
-                       /* End of string */
-                       *s = '\0';
-                       return line;
-               }
-       }
-       /* End of buffer */
-       return NULL;
- }
- void release_file(void *file, unsigned long size)
+ static void release_file(void *file, size_t size)
  {
        munmap(file, size);
  }
@@@ -528,9 -521,8 +521,8 @@@ static int parse_elf(struct elf_info *i
  
        /* Check if file offset is correct */
        if (hdr->e_shoff > info->size) {
-               fatal("section header offset=%lu in file '%s' is bigger than "
-                     "filesize=%lu\n", (unsigned long)hdr->e_shoff,
-                     filename, info->size);
+               fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n",
+                     (unsigned long)hdr->e_shoff, filename, info->size);
                return 0;
        }
  
@@@ -683,7 -675,7 +675,7 @@@ static void handle_modversion(const str
  
        if (sym->st_shndx == SHN_UNDEF) {
                warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n",
-                    symname, mod->name, is_vmlinux(mod->name) ? "":".ko");
+                    symname, mod->name, mod->is_vmlinux ? "" : ".ko");
                return;
        }
  
@@@ -705,8 -697,7 +697,7 @@@ static void handle_symbol(struct modul
        enum export export;
        const char *name;
  
-       if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
-           strstarts(symname, "__ksymtab"))
+       if (strstarts(symname, "__ksymtab"))
                export = export_from_secname(info, get_secindex(info, sym));
        else
                export = export_from_sec(info, get_secindex(info, sym));
@@@ -948,7 -939,7 +939,7 @@@ static void check_section(const char *m
  
  #define DATA_SECTIONS ".data", ".data.rel"
  #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \
 -              ".kprobes.text", ".cpuidle.text"
 +              ".kprobes.text", ".cpuidle.text", ".noinstr.text"
  #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \
                ".fixup", ".entry.text", ".exception.text", ".text.*", \
                ".coldtext"
@@@ -1752,11 -1743,7 +1743,7 @@@ static void check_section_mismatch(cons
  static unsigned int *reloc_location(struct elf_info *elf,
                                    Elf_Shdr *sechdr, Elf_Rela *r)
  {
-       Elf_Shdr *sechdrs = elf->sechdrs;
-       int section = sechdr->sh_info;
-       return (void *)elf->hdr + sechdrs[section].sh_offset +
-               r->r_offset;
+       return sym_get_data_by_offset(elf, sechdr->sh_info, r->r_offset);
  }
  
  static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
@@@ -2005,34 -1992,36 +1992,36 @@@ static void read_symbols(const char *mo
        if (!parse_elf(&info, modname))
                return;
  
-       mod = new_module(modname);
-       /* When there's no vmlinux, don't print warnings about
-        * unresolved symbols (since there'll be too many ;) */
-       if (is_vmlinux(modname)) {
-               have_vmlinux = 1;
-               mod->skip = 1;
-       }
-       license = get_modinfo(&info, "license");
-       if (!license && !is_vmlinux(modname))
-               warn("missing MODULE_LICENSE() in %s\n"
-                    "see include/linux/module.h for "
-                    "more information\n", modname);
-       while (license) {
-               if (license_is_gpl_compatible(license))
-                       mod->gpl_compatible = 1;
-               else {
-                       mod->gpl_compatible = 0;
-                       break;
+       {
+               char *tmp;
+               /* strip trailing .o */
+               tmp = NOFAIL(strdup(modname));
+               tmp[strlen(tmp) - 2] = '\0';
+               mod = new_module(tmp);
+               free(tmp);
+       }
+       if (!mod->is_vmlinux) {
+               license = get_modinfo(&info, "license");
+               if (!license)
+                       warn("missing MODULE_LICENSE() in %s\n", modname);
+               while (license) {
+                       if (license_is_gpl_compatible(license))
+                               mod->gpl_compatible = 1;
+                       else {
+                               mod->gpl_compatible = 0;
+                               break;
+                       }
+                       license = get_next_modinfo(&info, "license", license);
                }
-               license = get_next_modinfo(&info, "license", license);
-       }
  
-       namespace = get_modinfo(&info, "import_ns");
-       while (namespace) {
-               add_namespace(&mod->imported_namespaces, namespace);
-               namespace = get_next_modinfo(&info, "import_ns", namespace);
+               namespace = get_modinfo(&info, "import_ns");
+               while (namespace) {
+                       add_namespace(&mod->imported_namespaces, namespace);
+                       namespace = get_next_modinfo(&info, "import_ns",
+                                                    namespace);
+               }
        }
  
        for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
                }
        }
  
-       if (!is_vmlinux(modname) || vmlinux_section_warnings)
-               check_sec_ref(mod, modname, &info);
+       check_sec_ref(mod, modname, &info);
  
-       version = get_modinfo(&info, "version");
-       if (version)
-               maybe_frob_rcs_version(modname, version, info.modinfo,
-                                      version - (char *)info.hdr);
-       if (version || (all_versions && !is_vmlinux(modname)))
-               get_src_version(modname, mod->srcversion,
-                               sizeof(mod->srcversion)-1);
+       if (!mod->is_vmlinux) {
+               version = get_modinfo(&info, "version");
+               if (version || all_versions)
+                       get_src_version(modname, mod->srcversion,
+                                       sizeof(mod->srcversion) - 1);
+       }
  
        parse_elf_finish(&info);
  
@@@ -2143,20 -2130,18 +2130,18 @@@ void buf_write(struct buffer *buf, cons
  
  static void check_for_gpl_usage(enum export exp, const char *m, const char *s)
  {
-       const char *e = is_vmlinux(m) ?"":".ko";
        switch (exp) {
        case export_gpl:
-               fatal("GPL-incompatible module %s%s "
-                     "uses GPL-only symbol '%s'\n", m, e, s);
+               fatal("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n",
+                     m, s);
                break;
        case export_unused_gpl:
-               fatal("GPL-incompatible module %s%s "
-                     "uses GPL-only symbol marked UNUSED '%s'\n", m, e, s);
+               fatal("GPL-incompatible module %s.ko uses GPL-only symbol marked UNUSED '%s'\n",
+                     m, s);
                break;
        case export_gpl_future:
-               warn("GPL-incompatible module %s%s "
-                     "uses future GPL-only symbol '%s'\n", m, e, s);
+               warn("GPL-incompatible module %s.ko uses future GPL-only symbol '%s'\n",
+                    m, s);
                break;
        case export_plain:
        case export_unused:
  
  static void check_for_unused(enum export exp, const char *m, const char *s)
  {
-       const char *e = is_vmlinux(m) ?"":".ko";
        switch (exp) {
        case export_unused:
        case export_unused_gpl:
-               warn("module %s%s "
-                     "uses symbol '%s' marked UNUSED\n", m, e, s);
+               warn("module %s.ko uses symbol '%s' marked UNUSED\n",
+                    m, s);
                break;
        default:
                /* ignore */
@@@ -2251,7 -2234,6 +2234,7 @@@ static void add_header(struct buffer *b
         * Include build-salt.h after module.h in order to
         * inherit the definitions.
         */
 +      buf_printf(b, "#define INCLUDE_VERMAGIC\n");
        buf_printf(b, "#include <linux/build-salt.h>\n");
        buf_printf(b, "#include <linux/vermagic.h>\n");
        buf_printf(b, "#include <linux/compiler.h>\n");
@@@ -2349,7 -2331,7 +2332,7 @@@ static void add_depends(struct buffer *
        /* Clear ->seen flag of modules that own symbols needed by this. */
        for (s = mod->unres; s; s = s->next)
                if (s->module)
-                       s->module->seen = is_vmlinux(s->module->name);
+                       s->module->seen = s->module->is_vmlinux;
  
        buf_printf(b, "\n");
        buf_printf(b, "MODULE_INFO(depends, \"");
@@@ -2382,6 -2364,25 +2365,25 @@@ static void add_srcversion(struct buffe
        }
  }
  
+ static void write_buf(struct buffer *b, const char *fname)
+ {
+       FILE *file;
+       file = fopen(fname, "w");
+       if (!file) {
+               perror(fname);
+               exit(1);
+       }
+       if (fwrite(b->p, 1, b->pos, file) != b->pos) {
+               perror(fname);
+               exit(1);
+       }
+       if (fclose(file) != 0) {
+               perror(fname);
+               exit(1);
+       }
+ }
  static void write_if_changed(struct buffer *b, const char *fname)
  {
        char *tmp;
   close_write:
        fclose(file);
   write:
-       file = fopen(fname, "w");
-       if (!file) {
-               perror(fname);
-               exit(1);
-       }
-       if (fwrite(b->p, 1, b->pos, file) != b->pos) {
-               perror(fname);
-               exit(1);
-       }
-       fclose(file);
+       write_buf(b, fname);
  }
  
  /* parse Module.symvers file. line format:
   * 0x12345678<tab>symbol<tab>module<tab>export<tab>namespace
   **/
- static void read_dump(const char *fname, unsigned int kernel)
+ static void read_dump(const char *fname)
  {
-       unsigned long size, pos = 0;
-       void *file = grab_file(fname, &size);
-       char *line;
+       char *buf, *pos, *line;
  
-       if (!file)
+       buf = read_text_file(fname);
+       if (!buf)
                /* No symbol versions, silently ignore */
                return;
  
-       while ((line = get_next_line(&pos, file, size))) {
+       pos = buf;
+       while ((line = get_line(&pos))) {
                char *symname, *namespace, *modname, *d, *export;
                unsigned int crc;
                struct module *mod;
                        goto fail;
                mod = find_module(modname);
                if (!mod) {
-                       if (is_vmlinux(modname))
-                               have_vmlinux = 1;
                        mod = new_module(modname);
-                       mod->skip = 1;
+                       mod->from_dump = 1;
                }
                s = sym_add_exported(symname, mod, export_no(export));
-               s->kernel    = kernel;
                s->is_static = 0;
                sym_set_crc(symname, crc);
                sym_update_namespace(symname, namespace);
        }
-       release_file(file, size);
+       free(buf);
        return;
  fail:
-       release_file(file, size);
+       free(buf);
        fatal("parse error in symbol dump file\n");
  }
  
@@@ -2489,7 -2479,7 +2480,7 @@@ static int dump_sym(struct symbol *sym
  {
        if (!external_module)
                return 1;
-       if (sym->vmlinux || sym->kernel)
+       if (sym->module->from_dump)
                return 0;
        return 1;
  }
@@@ -2515,7 -2505,7 +2506,7 @@@ static void write_dump(const char *fnam
                        symbol = symbol->next;
                }
        }
-       write_if_changed(&buf, fname);
+       write_buf(&buf, fname);
        free(buf.p);
  }
  
@@@ -2527,7 -2517,7 +2518,7 @@@ static void write_namespace_deps_files(
  
        for (mod = modules; mod; mod = mod->next) {
  
-               if (mod->skip || !mod->missing_namespaces)
+               if (mod->from_dump || !mod->missing_namespaces)
                        continue;
  
                buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
        free(ns_deps_buf.p);
  }
  
- struct ext_sym_list {
-       struct ext_sym_list *next;
+ struct dump_list {
+       struct dump_list *next;
        const char *file;
  };
  
@@@ -2551,28 -2541,24 +2542,24 @@@ int main(int argc, char **argv
  {
        struct module *mod;
        struct buffer buf = { };
-       char *kernel_read = NULL;
        char *missing_namespace_deps = NULL;
        char *dump_write = NULL, *files_source = NULL;
        int opt;
        int err;
        int n;
-       struct ext_sym_list *extsym_iter;
-       struct ext_sym_list *extsym_start = NULL;
+       struct dump_list *dump_read_start = NULL;
+       struct dump_list **dump_read_iter = &dump_read_start;
  
-       while ((opt = getopt(argc, argv, "i:e:mnsT:o:awENd:")) != -1) {
+       while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) {
                switch (opt) {
-               case 'i':
-                       kernel_read = optarg;
-                       external_module = 1;
-                       break;
                case 'e':
                        external_module = 1;
-                       extsym_iter =
-                          NOFAIL(malloc(sizeof(*extsym_iter)));
-                       extsym_iter->next = extsym_start;
-                       extsym_iter->file = optarg;
-                       extsym_start = extsym_iter;
+                       break;
+               case 'i':
+                       *dump_read_iter =
+                               NOFAIL(calloc(1, sizeof(**dump_read_iter)));
+                       (*dump_read_iter)->file = optarg;
+                       dump_read_iter = &(*dump_read_iter)->next;
                        break;
                case 'm':
                        modversions = 1;
                case 'a':
                        all_versions = 1;
                        break;
-               case 's':
-                       vmlinux_section_warnings = 0;
-                       break;
                case 'T':
                        files_source = optarg;
                        break;
                }
        }
  
-       if (kernel_read)
-               read_dump(kernel_read, 1);
-       while (extsym_start) {
-               read_dump(extsym_start->file, 0);
-               extsym_iter = extsym_start->next;
-               free(extsym_start);
-               extsym_start = extsym_iter;
+       while (dump_read_start) {
+               struct dump_list *tmp;
+               read_dump(dump_read_start->file);
+               tmp = dump_read_start->next;
+               free(dump_read_start);
+               dump_read_start = tmp;
        }
  
        while (optind < argc)
        if (files_source)
                read_symbols_from_files(files_source);
  
+       /*
+        * When there's no vmlinux, don't print warnings about
+        * unresolved symbols (since there'll be too many ;)
+        */
+       if (!have_vmlinux)
+               warn("Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.\n");
        err = 0;
  
        for (mod = modules; mod; mod = mod->next) {
                char fname[PATH_MAX];
  
-               if (mod->skip)
+               if (mod->is_vmlinux || mod->from_dump)
                        continue;
  
                buf.pos = 0;
                struct symbol *s;
  
                for (s = symbolhash[n]; s; s = s->next) {
-                       /*
-                        * Do not check "vmlinux". This avoids the same warnings
-                        * shown twice, and false-positives for ARCH=um.
-                        */
-                       if (is_vmlinux(s->module->name) && !s->module->is_dot_o)
-                               continue;
                        if (s->is_static)
                                warn("\"%s\" [%s] is a static %s\n",
                                     s->name, s->module->name,