1. 06 Jun, 2020 40 commits
    • Linus Torvalds's avatar
      Merge tag 'kconfig-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild · b170290c
      Linus Torvalds authored
      Pull Kconfig updates from Masahiro Yamada:
      
       - allow only 'config', 'comment', 'if' statements inside 'choice' since
         the other statements are not sensible inside 'choice' and should be
         grammatical error
      
       - support LMC_KEEP env variable for 'make local{yes,mod}config' to
         preserve some CONFIG options
      
       - deprecate 'make kvmconfig' and 'make xenconfig' in favor of
         'make kvm_guest.config' and 'make xen.config'
      
       - code cleanups
      
      * tag 'kconfig-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        kconfig: announce removal of 'kvmconfig' and 'xenconfig' shorthands
        streamline_config.pl: add LMC_KEEP to preserve some kconfigs
        kconfig: allow only 'config', 'comment', and 'if' inside 'choice'
        kconfig: tests: remove randconfig test for choice in choice
        kconfig: do not assign a variable in the return statement
        kconfig: do not use OR-assignment for zero-cleared structure
      b170290c
    • Linus Torvalds's avatar
      Merge tag 'kbuild-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild · cff11abe
      Linus Torvalds authored
      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)
        ...
      cff11abe
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.8-2' of git://git.infradead.org/users/hch/dma-mapping · 6f2dc3d3
      Linus Torvalds authored
      Pull dma-mapping helpers from Christoph Hellwig:
       "These were in a separate stable branch so that various media and drm
        trees could pull the in for bug fixes, but looking at linux-next that
        hasn't actually happened yet. Still sending the APIs to you in the
        hope that these bug fixes get picked up for 5.8 in one way or another.
      
        Summary:
      
         - add DMA mapping helpers for struct sg_table (Marek Szyprowski)"
      
      * tag 'dma-mapping-5.8-2' of git://git.infradead.org/users/hch/dma-mapping:
        iommu: add generic helper for mapping sgtable objects
        scatterlist: add generic wrappers for iterating over sgtable objects
        dma-mapping: add generic helpers for mapping sgtable objects
      6f2dc3d3
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.8' of git://git.infradead.org/users/hch/dma-mapping · 1ee18de9
      Linus Torvalds authored
      Pull dma-mapping updates from Christoph Hellwig:
      
       - enhance the dma pool to allow atomic allocation on x86 with AMD SEV
         (David Rientjes)
      
       - two small cleanups (Jason Yan and Peter Collingbourne)
      
      * tag 'dma-mapping-5.8' of git://git.infradead.org/users/hch/dma-mapping:
        dma-contiguous: fix comment for dma_release_from_contiguous
        dma-pool: scale the default DMA coherent pool size with memory capacity
        x86/mm: unencrypted non-blocking DMA allocations use coherent pools
        dma-pool: add pool sizes to debugfs
        dma-direct: atomic allocations must come from atomic coherent pools
        dma-pool: dynamically expanding atomic pools
        dma-pool: add additional coherent pools to map to gfp mask
        dma-remap: separate DMA atomic pools from direct remap code
        dma-debug: make __dma_entry_alloc_check_leak() static
      1ee18de9
    • Linus Torvalds's avatar
      Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging · e542e0dc
      Linus Torvalds authored
      Pull dmi update from Jean Delvare.
      
      * 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
        firmware/dmi: Report DMI Bios & EC firmware release
      e542e0dc
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.8-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · 3925c3bb
      Linus Torvalds authored
      Pull PCI updates from Bjorn Helgaas:
       "Enumeration:
      
         - Program MPS for RCiEP devices (Ashok Raj)
      
         - Fix pci_register_host_bridge() device_register() error handling
           (Rob Herring)
      
         - Fix pci_host_bridge struct device release/free handling (Rob
           Herring)
      
        Resource management:
      
         - Allow resizing BARs for devices on root bus (Ard Biesheuvel)
      
        Power management:
      
         - Reduce Thunderbolt resume time by working around devices that don't
           support DLL Link Active reporting (Mika Westerberg)
      
         - Work around a Pericom USB controller OHCI/EHCI PME# defect
           (Kai-Heng Feng)
      
        Virtualization:
      
         - Add ACS quirk for Intel Root Complex Integrated Endpoints (Ashok
           Raj)
      
         - Avoid FLR for AMD Starship USB 3.0 (Kevin Buettner)
      
         - Avoid FLR for AMD Matisse HD Audio & USB 3.0 (Marcos Scriven)
      
        Error handling:
      
         - Use only _OSC (not HEST FIRMWARE_FIRST) to determine AER ownership
           (Alexandru Gagniuc, Kuppuswamy Sathyanarayanan)
      
         - Reduce verbosity by logging only ACPI_NOTIFY_DISCONNECT_RECOVER
           events (Kuppuswamy Sathyanarayanan)
      
         - Don't enable AER by default in Kconfig (Bjorn Helgaas)
      
        Peer-to-peer DMA:
      
         - Add AMD Zen Raven and Renoir Root Ports to whitelist (Alex Deucher)
      
        ASPM:
      
         - Allow ASPM on links to PCIe-to-PCI/PCI-X Bridges (Kai-Heng Feng)
      
        Endpoint framework:
      
         - Fix DMA channel release in test (Kunihiko Hayashi)
      
         - Add page size as argument to pci_epc_mem_init() (Lad Prabhakar)
      
         - Add support to handle multiple base for mapping outbound memory
           (Lad Prabhakar)
      
        Generic host bridge driver:
      
         - Support building as module (Rob Herring)
      
         - Eliminate pci_host_common_probe wrappers (Rob Herring)
      
        Amlogic Meson PCIe controller driver:
      
         - Don't use FAST_LINK_MODE to set up link (Marc Zyngier)
      
        Broadcom STB PCIe controller driver:
      
         - Disable ASPM L0s if 'aspm-no-l0s' in DT (Jim Quinlan)
      
         - Fix clk_put() error (Jim Quinlan)
      
         - Fix window register offset (Jim Quinlan)
      
         - Assert fundamental reset on initialization (Nicolas Saenz Julienne)
      
         - Add notify xHCI reset property (Nicolas Saenz Julienne)
      
         - Add init routine for Raspberry Pi 4 VL805 USB controller (Nicolas
           Saenz Julienne)
      
         - Sync with Raspberry Pi 4 firmware for VL805 initialization (Nicolas
           Saenz Julienne)
      
        Cadence PCIe controller driver:
      
         - Remove "cdns,max-outbound-regions" DT property (replaced by
           "ranges") (Kishon Vijay Abraham I)
      
         - Read 32-bit (not 16-bit) Vendor ID/Device ID property from DT
           (Kishon Vijay Abraham I)
      
        Marvell Aardvark PCIe controller driver:
      
         - Improve link training (Marek Behún)
      
         - Add PHY support (Marek Behún)
      
         - Add "phys", "max-link-speed", "reset-gpios" to dt-binding (Marek
           Behún)
      
         - Train link immediately after enabling training to work around
           detection issues with some cards (Pali Rohár)
      
         - Issue PERST via GPIO to work around detection issues (Pali Rohár)
      
         - Don't blindly enable ASPM L0s (Pali Rohár)
      
         - Replace custom macros by standard linux/pci_regs.h macros (Pali
           Rohár)
      
        Microsoft Hyper-V host bridge driver:
      
         - Fix probe failure path to release resource (Wei Hu)
      
         - Retry PCI bus D0 entry on invalid device state for kdump (Wei Hu)
      
        Renesas R-Car PCIe controller driver:
      
         - Fix incorrect programming of OB windows (Andrew Murray)
      
         - Add suspend/resume (Kazufumi Ikeda)
      
         - Rename pcie-rcar.c to pcie-rcar-host.c (Lad Prabhakar)
      
         - Add endpoint controller driver (Lad Prabhakar)
      
         - Fix PCIEPAMR mask calculation (Lad Prabhakar)
      
         - Add r8a77961 to DT binding (Yoshihiro Shimoda)
      
        Socionext UniPhier Pro5 controller driver:
      
         - Add endpoint controller driver (Kunihiko Hayashi)
      
        Synopsys DesignWare PCIe controller driver:
      
         - Program outbound ATU upper limit register (Alan Mikhak)
      
         - Fix inner MSI IRQ domain registration (Marc Zyngier)
      
        Miscellaneous:
      
         - Check for platform_get_irq() failure consistently (negative return
           means failure) (Aman Sharma)
      
         - Fix several runtime PM get/put imbalances (Dinghao Liu)
      
         - Use flexible-array and struct_size() helpers for code cleanup
           (Gustavo A. R. Silva)
      
         - Update & fix issues in bridge emulation of PCIe registers (Jon
           Derrick)
      
         - Add macros for bridge window names (PCI_BRIDGE_IO_WINDOW, etc)
           (Krzysztof Wilczyński)
      
         - Work around Intel PCH MROMs that have invalid BARs (Xiaochun Lee)"
      
      * tag 'pci-v5.8-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (100 commits)
        PCI: uniphier: Add Socionext UniPhier Pro5 PCIe endpoint controller driver
        PCI: Add ACS quirk for Intel Root Complex Integrated Endpoints
        PCI/DPC: Print IRQ number used by port
        PCI/AER: Use "aer" variable for capability offset
        PCI/AER: Remove redundant dev->aer_cap checks
        PCI/AER: Remove redundant pci_is_pcie() checks
        PCI/AER: Remove HEST/FIRMWARE_FIRST parsing for AER ownership
        PCI: tegra: Fix runtime PM imbalance on error
        PCI: vmd: Filter resource type bits from shadow register
        PCI: tegra194: Fix runtime PM imbalance on error
        dt-bindings: PCI: Add UniPhier PCIe endpoint controller description
        PCI: hv: Use struct_size() helper
        PCI: Rename _DSM constants to align with spec
        PCI: Avoid FLR for AMD Starship USB 3.0
        PCI: Avoid FLR for AMD Matisse HD Audio & USB 3.0
        x86/PCI: Drop unused xen_register_pirq() gsi_override parameter
        PCI: dwc: Use private data pointer of "struct irq_domain" to get pcie_port
        PCI: amlogic: meson: Don't use FAST_LINK_MODE to set up link
        PCI: dwc: Fix inner MSI IRQ domain registration
        PCI: dwc: pci-dra7xx: Use devm_platform_ioremap_resource_byname()
        ...
      3925c3bb
    • Zou Wei's avatar
      hpfs: fix warning due to superfluous semicolon · 9fa88c5d
      Zou Wei authored
      Fixes coccicheck warning:
      
        fs/hpfs/buffer.c:56:2-3: Unneeded semicolon
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarZou Wei <zou_wei@huawei.com>
      Signed-off-by: default avatarMikulas Patocka <mikulas@twibright.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9fa88c5d
    • Linus Torvalds's avatar
      Merge branch 'for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq · fe3bc8a9
      Linus Torvalds authored
      Pull workqueue updates from Tejun Heo:
       "Mostly cleanups and other trivial changes.
      
        The only interesting change is Sebastian's rcuwait conversion for RT"
      
      * 'for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
        workqueue: use BUILD_BUG_ON() for compile time test instead of WARN_ON()
        workqueue: fix a piece of comment about reserved bits for work flags
        workqueue: remove useless unlock() and lock() in series
        workqueue: void unneeded requeuing the pwq in rescuer thread
        workqueue: Convert the pool::lock and wq_mayday_lock to raw_spinlock_t
        workqueue: Use rcuwait for wq_manager_wait
        workqueue: Remove unnecessary kfree() call in rcu_free_wq()
        workqueue: Fix an use after free in init_rescuer()
        workqueue: Use IS_ERR and PTR_ERR instead of PTR_ERR_OR_ZERO.
      fe3bc8a9
    • Linus Torvalds's avatar
      Merge branch 'for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup · 4a7e89c5
      Linus Torvalds authored
      Pull cgroup updates from Tejun Heo:
       "Just two patches: one to add system-level cpu.stat to the root cgroup
        for convenience and a trivial comment update"
      
      * 'for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
        cgroup: add cpu.stat file to root cgroup
        cgroup: Remove stale comments
      4a7e89c5
    • Linus Torvalds's avatar
      Merge tag 'integrity-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity · 3c0ad98c
      Linus Torvalds authored
      Pull integrity updates from Mimi Zohar:
       "The main changes are extending the TPM 2.0 PCR banks with bank
        specific file hashes, calculating the "boot_aggregate" based on other
        TPM PCR banks, using the default IMA hash algorithm, instead of SHA1,
        as the basis for the cache hash table key, and preventing the mprotect
        syscall to circumvent an IMA mmap appraise policy rule.
      
         - In preparation for extending TPM 2.0 PCR banks with bank specific
           digests, commit 0b6cf6b9 ("tpm: pass an array of
           tpm_extend_digest structures to tpm_pcr_extend()") modified
           tpm_pcr_extend(). The original SHA1 file digests were
           padded/truncated, before being extended into the other TPM PCR
           banks. This pull request calculates and extends the TPM PCR banks
           with bank specific file hashes completing the above change.
      
         - The "boot_aggregate", the first IMA measurement list record, is the
           "trusted boot" link between the pre-boot environment and the
           running OS. With TPM 2.0, the "boot_aggregate" record is not
           limited to being based on the SHA1 TPM PCR bank, but can be
           calculated based on any enabled bank, assuming the hash algorithm
           is also enabled in the kernel.
      
        Other changes include the following and five other bug fixes/code
        clean up:
      
         - supporting both a SHA1 and a larger "boot_aggregate" digest in a
           custom template format containing both the the SHA1 ('d') and
           larger digests ('d-ng') fields.
      
         - Initial hash table key fix, but additional changes would be good"
      
      * tag 'integrity-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
        ima: Directly free *entry in ima_alloc_init_template() if digests is NULL
        ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()
        ima: Directly assign the ima_default_policy pointer to ima_rules
        ima: verify mprotect change is consistent with mmap policy
        evm: Fix possible memory leak in evm_calc_hmac_or_hash()
        ima: Set again build_ima_appraise variable
        ima: Remove redundant policy rule set in add_rules()
        ima: Fix ima digest hash table key calculation
        ima: Use ima_hash_algo for collision detection in the measurement list
        ima: Calculate and extend PCR with digests in ima_template_entry
        ima: Allocate and initialize tfm for each PCR bank
        ima: Switch to dynamically allocated buffer for template digests
        ima: Store template digest directly in ima_template_entry
        ima: Evaluate error in init_ima()
        ima: Switch to ima_hash_algo for boot aggregate
      3c0ad98c
    • Denis Efremov's avatar
      kbuild: add variables for compression tools · 8dfb61dc
      Denis Efremov authored
      Allow user to use alternative implementations of compression tools,
      such as pigz, pbzip2, pxz. For example, multi-threaded tools to
      speed up the build:
      $ make GZIP=pigz BZIP2=pbzip2
      
      Variables _GZIP, _BZIP2, _LZOP are used internally because original env
      vars are reserved by the tools. The use of GZIP in gzip tool is obsolete
      since 2015. However, alternative implementations (e.g., pigz) still rely
      on it. BZIP2, BZIP, LZOP vars are not obsolescent.
      
      The credit goes to @grsecurity.
      
      As a sidenote, for multi-threaded lzma, xz compression one can use:
      $ export XZ_OPT="--threads=0"
      Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      8dfb61dc
    • Jonas Zeiger's avatar
      Makefile: install modules.builtin even if CONFIG_MODULES=n · e0b250b5
      Jonas Zeiger authored
      Many applications check for available kernel features via:
      
        - /proc/modules (loaded modules, present if CONFIG_MODULES=y)
        - $(MODLIB)/modules.builtin (builtin modules)
      
      They fail to detect features if the kernel was built with CONFIG_MODULES=n
      and modules.builtin isn't installed.
      
      Therefore, add the target "_builtin_inst_" and make "install" and
      "modules_install" depend on it.
      
      Tests results:
      
        - make install: kernel image is copied as before, modules.builtin copied
        - make modules_install: (CONFIG_MODULES=n) nothing is copied, exit 1
      Signed-off-by: default avatarJonas Zeiger <jonas.zeiger@talpidae.net>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e0b250b5
    • ashimida's avatar
      mksysmap: Fix the mismatch of '.L' symbols in System.map · 72d24acc
      ashimida authored
      When System.map was generated, the kernel used mksysmap to
      filter the kernel symbols, but all the symbols with the
      second letter 'L' in the kernel were filtered out, not just
      the symbols starting with 'dot + L'.
      
      For example:
      ashimida@ubuntu:~/linux$ cat System.map |grep ' .L'
      ashimida@ubuntu:~/linux$ nm -n vmlinux |grep ' .L'
      ffff0000088028e0 t bLength_show
      ......
      ffff0000092e0408 b PLLP_OUTC_lock
      ffff0000092e0410 b PLLP_OUTA_lock
      
      The original intent should be to filter out all local symbols
      starting with '.L', so the dot should be escaped.
      
      Fixes: 00902e98 ("mksysmap: Add h8300 local symbol pattern")
      Signed-off-by: default avatarashimida <ashimida@linux.alibaba.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      72d24acc
    • Masahiro Yamada's avatar
      kbuild: doc: rename LDFLAGS to KBUILD_LDFLAGS · c0901577
      Masahiro Yamada authored
      Commit d503ac53 ("kbuild: rename LDFLAGS to KBUILD_LDFLAGS") missed
      to update the documentation.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      c0901577
    • Masahiro Yamada's avatar
      modpost: change elf_info->size to size_t · 3b09efc4
      Masahiro Yamada authored
      Align with the mmap / munmap APIs.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      3b09efc4
    • Masahiro Yamada's avatar
      modpost: remove is_vmlinux() helper · 4de7b629
      Masahiro Yamada authored
      Now that is_vmlinux() is called only in new_module(), we can inline
      the function call.
      
      modname is the basename with '.o' is stripped. No need to compare it
      with 'vmlinux.o'.
      
      vmlinux is always located at the current working directory. No need
      to strip the directory path.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      4de7b629
    • Masahiro Yamada's avatar
      modpost: strip .o from modname before calling new_module() · a82f794c
      Masahiro Yamada authored
      new_module() conditionally strips the .o because the modname has .o
      suffix when it is called from read_symbols(), but no .o when it is
      called from read_dump().
      
      It is clearer to strip .o in read_symbols().
      
      I also used flexible-array for mod->name.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a82f794c
    • Masahiro Yamada's avatar
      modpost: set have_vmlinux in new_module() · 858b937d
      Masahiro Yamada authored
      Set have_vmlinux flag in a single place.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      858b937d
    • Masahiro Yamada's avatar
      modpost: remove mod->skip struct member · 0b19d54c
      Masahiro Yamada authored
      The meaning of 'skip' is obscure since it does not explain
      "what to skip".
      
      mod->skip is set when it is vmlinux or the module info came from
      a dump file.
      
      So, mod->skip is equivalent to (mod->is_vmlinux || mod->from_dump).
      
      For the check in write_namespace_deps_files(), mod->is_vmlinux is
      unneeded because the -d option is not passed in the first pass of
      modpost.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      0b19d54c
    • Masahiro Yamada's avatar
      modpost: add mod->is_vmlinux struct member · 5a438af9
      Masahiro Yamada authored
      is_vmlinux() is called in several places to check whether the current
      module is vmlinux or not.
      
      It is faster and clearer to check mod->is_vmlinux flag.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5a438af9
    • Masahiro Yamada's avatar
      modpost: remove is_vmlinux() call in check_for_{gpl_usage,unused}() · 1be5fa6c
      Masahiro Yamada authored
      check_exports() is never called for vmlinux because mod->skip is set
      for vmlinux.
      
      Hence, check_for_gpl_usage() and check_for_unused() are not called
      for vmlinux, either. is_vmlinux() is always false here.
      
      Remove the is_vmlinux() calls, and hard-code the ".ko" suffix.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      1be5fa6c
    • Masahiro Yamada's avatar
      modpost: remove mod->is_dot_o struct member · 3379576d
      Masahiro Yamada authored
      Previously, there were two cases where mod->is_dot_o is unset:
      
      [1] the executable 'vmlinux' in the second pass of modpost
      [2] modules loaded by read_dump()
      
      I think [1] was intended usage to distinguish 'vmlinux.o' and 'vmlinux'.
      Now that modpost does not parse the executable 'vmlinux', this case
      does not happen.
      
      [2] is obscure, maybe a bug. Module.symver stores module paths without
      extension. So, none of modules loaded by read_dump() has the .o suffix,
      and new_module() unsets ->is_dot_o. Anyway, it is not a big deal because
      handle_symbol() is not called for the case.
      
      To sum up, all the parsed ELF files are .o files.
      
      mod->is_dot_o is unneeded.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      3379576d
    • Masahiro Yamada's avatar
      modpost: move -d option in scripts/Makefile.modpost · 859c926a
      Masahiro Yamada authored
      Collect options for modules into a single place.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      859c926a
    • Masahiro Yamada's avatar
      modpost: remove -s option · 467b82d7
      Masahiro Yamada authored
      The -s option was added by commit 8d8d8289 ("kbuild: do not do
      section mismatch checks on vmlinux in 2nd pass").
      
      Now that the second pass does not parse vmlinux, this option is
      unneeded.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      467b82d7
    • Masahiro Yamada's avatar
      modpost: remove get_next_text() and make {grab,release_}file static · 75893572
      Masahiro Yamada authored
      get_next_line() is no longer used. Remove.
      
      grab_file() and release_file() are only used in modpost.c. Make them
      static.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      75893572
    • Masahiro Yamada's avatar
      modpost: use read_text_file() and get_line() for reading text files · 70f30cfe
      Masahiro Yamada authored
      grab_file() mmaps a file, but it is not so efficient here because
      get_next_line() copies every line to the temporary buffer anyway.
      
      read_text_file() and get_line() are simpler. get_line() exploits the
      library function strchr().
      
      Going forward, the missing *.symvers or *.cmd is a fatal error.
      This should not happen because scripts/Makefile.modpost guards the
      -i option files with $(wildcard $(input-symdump)).
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      70f30cfe
    • Masahiro Yamada's avatar
      modpost: avoid false-positive file open error · 7c8f5662
      Masahiro Yamada authored
      One problem of grab_file() is that it cannot distinguish the following
      two cases:
      
       - It cannot read the file (the file does not exist, or read permission
         is not set)
      
       - It can read the file, but the file size is zero
      
      This is because grab_file() calls mmap(), which requires the mapped
      length is greater than 0. Hence, grab_file() fails for both cases.
      
      If an empty header file were included for checksum calculation, the
      following warning would be printed:
      
        WARNING: modpost: could not open ...: Invalid argument
      
      An empty file is a valid source file, so it should not fail.
      
      Use read_text_file() instead. It can read a zero-length file.
      Then, parse_file() will succeed with doing nothing.
      
      Going forward, the first case (it cannot read the file) is a fatal
      error. If the source file from which an object was compiled is missing,
      something went wrong.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7c8f5662
    • Masahiro Yamada's avatar
      modpost: fix potential mmap'ed file overrun in get_src_version() · f531c1b5
      Masahiro Yamada authored
      I do not know how reliably this function works, but it looks dangerous
      to me.
      
          strchr(sources, '\n');
      
      ... continues searching until it finds '\n' or it reaches the '\0'
      terminator. In other words, 'sources' should be a null-terminated
      string.
      
      However, grab_file() just mmaps a file, so 'sources' is not terminated
      with null byte. If the file does not contain '\n' at all, strchr() will
      go beyond the mmap'ed memory.
      
      Use read_text_file(), which loads the file content into a malloc'ed
      buffer, appending null byte.
      
      Here we are interested only in the first line of *.mod files. Use
      get_line() helper to get the first line.
      
      This also makes missing *.mod file a fatal error.
      
      Commit 4be40e22 ("kbuild: do not emit src version warning for
      non-modules") ignored missing *.mod files.
      
      I do not fully understand what that commit addressed, but commit
      91341d4b ("kbuild: introduce new option to enhance section mismatch
      analysis") introduced partial section checks by using modpost. built-in.o
      was parsed by modpost. Even modules had a problem because *.mod files
      were created after the modpost check.
      
      Commit b7dca6dd ("kbuild: create *.mod with full directory path and
      remove MODVERDIR") stopped doing that. Now that modpost is only invoked
      after the directory descend, *.mod files should always exist at the
      modpost stage.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f531c1b5
    • Masahiro Yamada's avatar
      modpost: add read_text_file() and get_line() helpers · ac5100f5
      Masahiro Yamada authored
      modpost uses grab_file() to open a file, but it is not suitable for
      a text file because the mmap'ed file is not terminated by null byte.
      Actually, I see some issues for the use of grab_file().
      
      The new helper, read_text_file() loads the whole file content into a
      malloc'ed buffer, and appends a null byte. Then, get_line() reads
      each line.
      
      To handle text files, I intend to replace as follows:
      
        grab_file()    -> read_text_file()
        get_new_line() -> get_line()
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ac5100f5
    • Masahiro Yamada's avatar
      modpost: do not call get_modinfo() for vmlinux(.o) · 4ddea2f8
      Masahiro Yamada authored
      The three calls of get_modinfo() ("license", "import_ns", "version")
      always return NULL for vmlinux(.o) because the built-in module info is
      prefixed with __MODULE_INFO_PREFIX.
      
      It is harmless to call get_modinfo(), but there is no point to search
      for what apparently does not exist.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      4ddea2f8
    • Masahiro Yamada's avatar
      modpost: drop RCS/CVS $Revision handling in MODULE_VERSION() · f6931535
      Masahiro Yamada authored
      As far as I understood, this code gets rid of '$Revision$' or '$Revision:'
      of CVS, RCS or whatever in MODULE_VERSION() tags.
      
      Remove the primeval code.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f6931535
    • Masahiro Yamada's avatar
      modpost: show warning if any of symbol dump files is missing · 48a0f727
      Masahiro Yamada authored
      If modpost fails to load a symbol dump file, it cannot check unresolved
      symbols, hence module dependency will not be added. Nor CRCs can be added.
      
      Currently, external module builds check only $(objtree)/Module.symvers,
      but it should check files specified by KBUILD_EXTRA_SYMBOLS as well.
      
      Move the warning message from the top Makefile to scripts/Makefile.modpost
      and print the warning if any dump file is missing.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      48a0f727
    • Masahiro Yamada's avatar
      modpost: show warning if vmlinux is not found when processing modules · 7e8a3235
      Masahiro Yamada authored
      check_exports() does not print warnings about unresolved symbols if
      vmlinux is missing because there would be too many.
      
      This situation happens when you do 'make modules' from the clean
      tree, or compile external modules against a kernel tree that has
      not been completely built.
      
      It is dangerous to not check unresolved symbols because you might be
      building useless modules. At least it should be warned.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7e8a3235
    • Masahiro Yamada's avatar
      modpost: invoke modpost only when input files are updated · 436b2ac6
      Masahiro Yamada authored
      Currently, the second pass of modpost is always invoked when you run
      'make' or 'make modules' even if none of modules is changed.
      
      Use if_changed to invoke it only when it is necessary.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      436b2ac6
    • Masahiro Yamada's avatar
      modpost: generate vmlinux.symvers and reuse it for the second modpost · 269a535c
      Masahiro Yamada authored
      The full build runs modpost twice, first for vmlinux.o and second for
      modules.
      
      The first pass dumps all the vmlinux symbols into Module.symvers, but
      the second pass parses vmlinux again instead of reusing the dump file,
      presumably because it needs to avoid accumulating stale symbols.
      
      Loading symbol info from a dump file is faster than parsing an ELF object.
      Besides, modpost deals with various issues to parse vmlinux in the second
      pass.
      
      A solution is to make the first pass dumps symbols into a separate file,
      vmlinux.symvers. The second pass reads it, and parses module .o files.
      The merged symbol information is dumped into Module.symvers in the same
      way as before.
      
      This makes further modpost cleanups possible.
      
      Also, it fixes the problem of 'make vmlinux', which previously overwrote
      Module.symvers, throwing away module symbols.
      
      I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
      when you cross this commit. Otherwise, vmlinux.symvers would not be
      generated.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      269a535c
    • Masahiro Yamada's avatar
      modpost: refactor -i option calculation · f1005b30
      Masahiro Yamada authored
      Prepare to use -i for in-tree modpost as well.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f1005b30
    • Masahiro Yamada's avatar
      modpost: print symbol dump file as the build target in short log · bcfedae7
      Masahiro Yamada authored
      The symbol dump *.symvers is the output of modpost. Print it in
      the short log.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      bcfedae7
    • Masahiro Yamada's avatar
      modpost: re-add -e to set external_module flag · e3fb4df7
      Masahiro Yamada authored
      Previously, the -i option had two functions; load a symbol dump file,
      and set the external_module flag.
      
      I want to assign a dedicate option for each of them.
      
      Going forward, the -i is used to load a symbol dump file, and the -e
      to set the external_module flag.
      
      With this, we will be able to use -i for loading in-kernel symbols.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      e3fb4df7
    • Masahiro Yamada's avatar
      modpost: rename ext_sym_list to dump_list · 7924799e
      Masahiro Yamada authored
      The -i option is used to include Modules.symver as well as files from
      $(KBUILD_EXTRA_SYMBOLS).
      
      Make the struct and variable names more generic.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7924799e
    • Masahiro Yamada's avatar
      modpost: allow to pass -i option multiple times to remove -e option · ce2ddd6d
      Masahiro Yamada authored
      Now that there is no difference between -i and -e, they can be unified.
      
      Make modpost accept the -i option multiple times, then remove -e.
      
      I will reuse -e for a different purpose.
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ce2ddd6d