13 Jan, 2021

1 commit

  • [ Upstream commit 87dbc209ea04645fd2351981f09eff5d23f8e2e9 ]

    Make mandatory in include/asm-generic/Kbuild and
    remove all arch/*/include/asm/local64.h arch-specific files since they
    only #include .

    This fixes build errors on arch/c6x/ and arch/nios2/ for
    block/blk-iocost.c.

    Build-tested on 21 of 25 arch-es. (tools problems on the others)

    Yes, we could even rename to
    and change all #includes to use
    instead.

    Link: https://lkml.kernel.org/r/20201227024446.17018-1-rdunlap@infradead.org
    Signed-off-by: Randy Dunlap
    Suggested-by: Christoph Hellwig
    Reviewed-by: Masahiro Yamada
    Cc: Jens Axboe
    Cc: Ley Foon Tan
    Cc: Mark Salter
    Cc: Aurelien Jacquiot
    Cc: Peter Zijlstra
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Randy Dunlap
     

16 Nov, 2020

1 commit


15 Nov, 2020

1 commit

  • Commit 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h
    mutually exclusive") neglected to copy barrier_data() from
    compiler-gcc.h into compiler-clang.h.

    The definition in compiler-gcc.h was really to work around clang's more
    aggressive optimization, so this broke barrier_data() on clang, and
    consequently memzero_explicit() as well.

    For example, this results in at least the memzero_explicit() call in
    lib/crypto/sha256.c:sha256_transform() being optimized away by clang.

    Fix this by moving the definition of barrier_data() into compiler.h.

    Also move the gcc/clang definition of barrier() into compiler.h,
    __memory_barrier() is icc-specific (and barrier() is already defined
    using it in compiler-intel.h) and doesn't belong in compiler.h.

    [rdunlap@infradead.org: fix ALPHA builds when SMP is not enabled]

    Link: https://lkml.kernel.org/r/20201101231835.4589-1-rdunlap@infradead.org
    Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive")
    Signed-off-by: Arvind Sankar
    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Tested-by: Nick Desaulniers
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Kees Cook
    Cc:
    Link: https://lkml.kernel.org/r/20201014212631.207844-1-nivedita@alum.mit.edu
    Signed-off-by: Linus Torvalds

    Arvind Sankar
     

31 Oct, 2020

1 commit


28 Oct, 2020

1 commit

  • Under some circumstances, the compiler generates .ctors.* sections. This
    is seen doing a cross compile of x86_64 from a powerpc64el host:

    x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/trace_clock.o' being
    placed in section `.ctors.65435'
    x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/ftrace.o' being
    placed in section `.ctors.65435'
    x86_64-linux-gnu-ld: warning: orphan section `.ctors.65435' from `kernel/trace/ring_buffer.o' being
    placed in section `.ctors.65435'

    Include these orphans along with the regular .ctors section.

    Reported-by: Stephen Rothwell
    Tested-by: Stephen Rothwell
    Fixes: 83109d5d5fba ("x86/build: Warn on orphan section placement")
    Signed-off-by: Kees Cook
    Acked-by: Nick Desaulniers
    Link: https://lore.kernel.org/r/20201005025720.2599682-1-keescook@chromium.org

    Kees Cook
     

27 Oct, 2020

2 commits

  • Without the explicit __always_inline, some RISC-V configs place the
    functions out of line, triggering the BUILD_BUG_ON checks in the
    function.

    Fixes: 11129e8ed4d9 ("riscv: use memcpy based uaccess for nommu again")
    Reported-by: kernel test robot
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Arnd Bergmann

    Christoph Hellwig
     
  • Nesting macros that use the same local variable names causes
    warnings when building with "make W=2":

    include/asm-generic/percpu.h:117:14: warning: declaration of '__ret' shadows a previous local [-Wshadow]
    include/asm-generic/percpu.h:126:14: warning: declaration of '__ret' shadows a previous local [-Wshadow]

    These are fairly harmless, but since the warning comes from
    a global header, the warning happens every time the headers
    are included, which is fairly annoying.

    Rename the variables to avoid shadowing and shut up the warning.

    Signed-off-by: Arnd Bergmann
    Reviewed-by: Luc Van Oostenryck
    Signed-off-by: Dennis Zhou

    Arnd Bergmann
     

26 Oct, 2020

1 commit

  • Use a more generic form for __section that requires quotes to avoid
    complications with clang and gcc differences.

    Remove the quote operator # from compiler_attributes.h __section macro.

    Convert all unquoted __section(foo) uses to quoted __section("foo").
    Also convert __attribute__((section("foo"))) uses to __section("foo")
    even if the __attribute__ has multiple list entry forms.

    Conversion done using the script at:

    https://lore.kernel.org/lkml/75393e5ddc272dc7403de74d645e6c6e0f4e70eb.camel@perches.com/2-convert_section.pl

    Signed-off-by: Joe Perches
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Miguel Ojeda
    Signed-off-by: Linus Torvalds

    Joe Perches
     

25 Oct, 2020

1 commit

  • Pull more RISC-V updates from Palmer Dabbelt:
    "Just a single patch set: the remainder of Christoph's work to remove
    set_fs, including the RISC-V portion"

    * tag 'riscv-for-linus-5.10-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
    riscv: remove address space overrides using set_fs()
    riscv: implement __get_kernel_nofault and __put_user_nofault
    riscv: refactor __get_user and __put_user
    riscv: use memcpy based uaccess for nommu again
    asm-generic: make the set_fs implementation optional
    asm-generic: add nommu implementations of __{get,put}_kernel_nofault
    asm-generic: improve the nommu {get,put}_user handling
    uaccess: provide a generic TASK_SIZE_MAX definition

    Linus Torvalds
     

23 Oct, 2020

2 commits

  • Pull Kbuild updates from Masahiro Yamada:

    - Support 'make compile_commands.json' to generate the compilation
    database more easily, avoiding stale entries

    - Support 'make clang-analyzer' and 'make clang-tidy' for static checks
    using clang-tidy

    - Preprocess scripts/modules.lds.S to allow CONFIG options in the
    module linker script

    - Drop cc-option tests from compiler flags supported by our minimal
    GCC/Clang versions

    - Use always 12-digits commit hash for CONFIG_LOCALVERSION_AUTO=y

    - Use sha1 build id for both BFD linker and LLD

    - Improve deb-pkg for reproducible builds and rootless builds

    - Remove stale, useless scripts/namespace.pl

    - Turn -Wreturn-type warning into error

    - Fix build error of deb-pkg when CONFIG_MODULES=n

    - Replace 'hostname' command with more portable 'uname -n'

    - Various Makefile cleanups

    * tag 'kbuild-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits)
    kbuild: Use uname for LINUX_COMPILE_HOST detection
    kbuild: Only add -fno-var-tracking-assignments for old GCC versions
    kbuild: remove leftover comment for filechk utility
    treewide: remove DISABLE_LTO
    kbuild: deb-pkg: clean up package name variables
    kbuild: deb-pkg: do not build linux-headers package if CONFIG_MODULES=n
    kbuild: enforce -Werror=return-type
    scripts: remove namespace.pl
    builddeb: Add support for all required debian/rules targets
    builddeb: Enable rootless builds
    builddeb: Pass -n to gzip for reproducible packages
    kbuild: split the build log of kallsyms
    kbuild: explicitly specify the build id style
    scripts/setlocalversion: make git describe output more reliable
    kbuild: remove cc-option test of -Werror=date-time
    kbuild: remove cc-option test of -fno-stack-check
    kbuild: remove cc-option test of -fno-strict-overflow
    kbuild: move CFLAGS_{KASAN,UBSAN,KCSAN} exports to relevant Makefiles
    kbuild: remove redundant CONFIG_KASAN check from scripts/Makefile.kasan
    kbuild: do not create built-in objects for external module builds
    ...

    Linus Torvalds
     
  • Pull PCI updates from Bjorn Helgaas:
    "Enumeration:
    - Print IRQ number used by PCIe Link Bandwidth Notification (Dongdong
    Liu)
    - Add schedule point in pci_read_config() to reduce max latency
    (Jiang Biao)
    - Add Kconfig options for MPS/MRRS strategy (Jim Quinlan)

    Resource management:
    - Fix pci_iounmap() memory leak when !CONFIG_GENERIC_IOMAP (Lorenzo
    Pieralisi)

    PCIe native device hotplug:
    - Reduce noisiness on hot removal (Lukas Wunner)

    Power management:
    - Revert "PCI/PM: Apply D2 delay as milliseconds, not microseconds"
    that was done on the basis of spec typo (Bjorn Helgaas)
    - Rename pci_dev.d3_delay to d3hot_delay to remove D3hot/D3cold
    ambiguity (Krzysztof Wilczyński)
    - Remove unused pcibios_pm_ops (Vaibhav Gupta)

    IOMMU:
    - Enable Translation Blocking for external devices to harden against
    DMA attacks (Rajat Jain)

    Error handling:
    - Add an ACPI APEI notifier chain for vendor CPER records to enable
    device-specific error handling (Shiju Jose)

    ASPM:
    - Remove struct aspm_register_info to simplify code (Saheed O.
    Bolarinwa)

    Amlogic Meson PCIe controller driver:
    - Build as module by default (Kevin Hilman)

    Ampere Altra PCIe controller driver:
    - Add MCFG quirk to work around non-standard ECAM implementation
    (Tuan Phan)

    Broadcom iProc PCIe controller driver:
    - Set affinity mask on MSI interrupts (Mark Tomlinson)

    Broadcom STB PCIe controller driver:
    - Make PCIE_BRCMSTB depend on ARCH_BRCMSTB (Jim Quinlan)
    - Add DT bindings for more Brcmstb chips (Jim Quinlan)
    - Add bcm7278 register info (Jim Quinlan)
    - Add bcm7278 PERST# support (Jim Quinlan)
    - Add suspend and resume pm_ops (Jim Quinlan)
    - Add control of rescal reset (Jim Quinlan)
    - Set additional internal memory DMA viewport sizes (Jim Quinlan)
    - Accommodate MSI for older chips (Jim Quinlan)
    - Set bus max burst size by chip type (Jim Quinlan)
    - Add support for bcm7211, bcm7216, bcm7445, bcm7278 (Jim Quinlan)

    Freescale i.MX6 PCIe controller driver:
    - Use dev_err_probe() to reduce redundant messages (Anson Huang)

    Freescale Layerscape PCIe controller driver:
    - Enforce 4K DMA buffer alignment in endpoint test (Hou Zhiqiang)
    - Add DT compatible strings for ls1088a, ls2088a (Xiaowei Bao)
    - Add endpoint support for ls1088a, ls2088a (Xiaowei Bao)
    - Add endpoint test support for lS1088a (Xiaowei Bao)
    - Add MSI-X support for ls1088a (Xiaowei Bao)

    HiSilicon HIP PCIe controller driver:
    - Handle HIP-specific errors via ACPI APEI (Yicong Yang)

    HiSilicon Kirin PCIe controller driver:
    - Return -EPROBE_DEFER if the GPIO isn't ready (Bean Huo)

    Intel VMD host bridge driver:
    - Factor out physical offset, bus offset, IRQ domain, IRQ allocation
    (Jon Derrick)
    - Use generic PCI PM correctly (Jon Derrick)

    Marvell Aardvark PCIe controller driver:
    - Fix compilation on s390 (Pali Rohár)
    - Implement driver 'remove' function and allow to build it as module
    (Pali Rohár)
    - Move PCIe reset card code to advk_pcie_train_link() (Pali Rohár)
    - Convert mvebu a3700 internal SMCC firmware return codes to errno
    (Pali Rohár)
    - Fix initialization with old Marvell's Arm Trusted Firmware (Pali
    Rohár)

    Microsoft Hyper-V host bridge driver:
    - Fix hibernation in case interrupts are not re-created (Dexuan Cui)

    NVIDIA Tegra PCIe controller driver:
    - Stop checking return value of debugfs_create() functions (Greg
    Kroah-Hartman)
    - Convert to use DEFINE_SEQ_ATTRIBUTE macro (Liu Shixin)

    Qualcomm PCIe controller driver:
    - Reset PCIe to work around Qsdk U-Boot issue (Ansuel Smith)

    Renesas R-Car PCIe controller driver:
    - Add DT documentation for r8a774a1, r8a774b1, r8a774e1 endpoints
    (Lad Prabhakar)
    - Add RZ/G2M, RZ/G2N, RZ/G2H IDs to endpoint test (Lad Prabhakar)
    - Add DT support for r8a7742 (Lad Prabhakar)

    Socionext UniPhier Pro5 controller driver:
    - Add DT descriptions of iATU register (host and endpoint) (Kunihiko
    Hayashi)

    Synopsys DesignWare PCIe controller driver:
    - Add link up check in dw_child_pcie_ops.map_bus() (racy, but seems
    unavoidable) (Hou Zhiqiang)
    - Fix endpoint Header Type check so multi-function devices work (Hou
    Zhiqiang)
    - Skip PCIE_MSI_INTR0* programming if MSI is disabled (Jisheng Zhang)
    - Stop leaking MSI page in suspend/resume (Jisheng Zhang)
    - Add common iATU register support instead of keystone-specific code
    (Kunihiko Hayashi)
    - Major config space access and other cleanups in dwc core and
    drivers that use it (al, exynos, histb, imx6, intel-gw, keystone,
    kirin, meson, qcom, tegra) (Rob Herring)
    - Add multiple PFs support for endpoint (Xiaowei Bao)
    - Add MSI-X doorbell mode in endpoint mode (Xiaowei Bao)

    Miscellaneous:
    - Use fallthrough pseudo-keyword (Gustavo A. R. Silva)
    - Fix "0 used as NULL pointer" warnings (Gustavo Pimentel)
    - Fix "cast truncates bits from constant value" warnings (Gustavo
    Pimentel)
    - Remove redundant zeroing for sg_init_table() (Julia Lawall)
    - Use scnprintf(), not snprintf(), in sysfs "show" functions
    (Krzysztof Wilczyński)
    - Remove unused assignments (Krzysztof Wilczyński)
    - Fix "0 used as NULL pointer" warning (Krzysztof Wilczyński)
    - Simplify bool comparisons (Krzysztof Wilczyński)
    - Use for_each_child_of_node() and for_each_node_by_name() (Qinglang
    Miao)
    - Simplify return expressions (Qinglang Miao)"

    * tag 'pci-v5.10-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (147 commits)
    PCI: vmd: Update VMD PM to correctly use generic PCI PM
    PCI: vmd: Create IRQ allocation helper
    PCI: vmd: Create IRQ Domain configuration helper
    PCI: vmd: Create bus offset configuration helper
    PCI: vmd: Create physical offset helper
    PCI: v3-semi: Remove unneeded break
    PCI: dwc: Add link up check in dw_child_pcie_ops.map_bus()
    PCI/ASPM: Remove struct pcie_link_state.l1ss
    PCI/ASPM: Remove struct aspm_register_info.l1ss_cap
    PCI/ASPM: Pass L1SS Capabilities value, not struct aspm_register_info
    PCI/ASPM: Remove struct aspm_register_info.l1ss_ctl1
    PCI/ASPM: Remove struct aspm_register_info.l1ss_ctl2 (unused)
    PCI/ASPM: Remove struct aspm_register_info.l1ss_cap_ptr
    PCI/ASPM: Remove struct aspm_register_info.latency_encoding
    PCI/ASPM: Remove struct aspm_register_info.enabled
    PCI/ASPM: Remove struct aspm_register_info.support
    PCI/ASPM: Use 'parent' and 'child' for readability
    PCI/ASPM: Move LTR path check to where it's used
    PCI/ASPM: Move pci_clear_and_set_dword() earlier
    PCI: dwc: Fix MSI page leakage in suspend/resume
    ...

    Linus Torvalds
     

19 Oct, 2020

1 commit

  • …/kernel/git/shuah/linux-kselftest

    Pull more Kunit updates from Shuah Khan:

    - add Kunit to kernel_init() and remove KUnit from init calls entirely.

    This addresses the concern that Kunit would not work correctly during
    late init phase.

    - add a linker section where KUnit can put references to its test
    suites.

    This is the first step in transitioning to dispatching all KUnit
    tests from a centralized executor rather than having each as its own
    separate late_initcall.

    - add a centralized executor to dispatch tests rather than relying on
    late_initcall to schedule each test suite separately. Centralized
    execution is for built-in tests only; modules will execute tests when
    loaded.

    - convert bitfield test to use KUnit framework

    - Documentation updates for naming guidelines and how
    kunit_test_suite() works.

    - add test plan to KUnit TAP format

    * tag 'linux-kselftest-kunit-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
    lib: kunit: Fix compilation test when using TEST_BIT_FIELD_COMPILE
    lib: kunit: add bitfield test conversion to KUnit
    Documentation: kunit: add a brief blurb about kunit_test_suite
    kunit: test: add test plan to KUnit TAP format
    init: main: add KUnit to kernel init
    kunit: test: create a single centralized executor for all tests
    vmlinux.lds.h: add linker section for KUnit test suites
    Documentation: kunit: Add naming guidelines

    Linus Torvalds
     

16 Oct, 2020

2 commits

  • Pull another Hyper-V update from Wei Liu:
    "One patch from Michael to get VMbus interrupt from ACPI DSDT"

    * tag 'hyperv-next-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
    Drivers: hv: vmbus: Add parsing of VMbus interrupt in ACPI DSDT

    Linus Torvalds
     
  • Pull dma-mapping updates from Christoph Hellwig:

    - rework the non-coherent DMA allocator

    - move private definitions out of

    - lower CMA_ALIGNMENT (Paul Cercueil)

    - remove the omap1 dma address translation in favor of the common code

    - make dma-direct aware of multiple dma offset ranges (Jim Quinlan)

    - support per-node DMA CMA areas (Barry Song)

    - increase the default seg boundary limit (Nicolin Chen)

    - misc fixes (Robin Murphy, Thomas Tai, Xu Wang)

    - various cleanups

    * tag 'dma-mapping-5.10' of git://git.infradead.org/users/hch/dma-mapping: (63 commits)
    ARM/ixp4xx: add a missing include of dma-map-ops.h
    dma-direct: simplify the DMA_ATTR_NO_KERNEL_MAPPING handling
    dma-direct: factor out a dma_direct_alloc_from_pool helper
    dma-direct check for highmem pages in dma_direct_alloc_pages
    dma-mapping: merge into
    dma-mapping: move large parts of to kernel/dma
    dma-mapping: move dma-debug.h to kernel/dma/
    dma-mapping: remove
    dma-mapping: merge into
    dma-contiguous: remove dma_contiguous_set_default
    dma-contiguous: remove dev_set_cma_area
    dma-contiguous: remove dma_declare_contiguous
    dma-mapping: split
    cma: decrease CMA_ALIGNMENT lower limit to 2
    firewire-ohci: use dma_alloc_pages
    dma-iommu: implement ->alloc_noncoherent
    dma-mapping: add new {alloc,free}_noncoherent dma_map_ops methods
    dma-mapping: add a new dma_alloc_pages API
    dma-mapping: remove dma_cache_sync
    53c700: convert to dma_alloc_noncoherent
    ...

    Linus Torvalds
     

15 Oct, 2020

1 commit

  • On ARM64, Hyper-V now specifies the interrupt to be used by VMbus
    in the ACPI DSDT. This information is not used on x86 because the
    interrupt vector must be hardcoded. But update the generic
    VMbus driver to do the parsing and pass the information to the
    architecture specific code that sets up the Linux IRQ. Update
    consumers of the interrupt to get it from an architecture specific
    function.

    Signed-off-by: Michael Kelley
    Link: https://lore.kernel.org/r/1597434304-40631-1-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu

    Michael Kelley
     

13 Oct, 2020

4 commits

  • Pull compat quotactl cleanups from Al Viro:
    "More Christoph's compat cleanups: quotactl(2)"

    * 'work.quota-compat' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    quota: simplify the quotactl compat handling
    compat: add a compat_need_64bit_alignment_fixup() helper
    compat: lift compat_s64 and compat_u64 to

    Linus Torvalds
     
  • Pull copy_and_csum cleanups from Al Viro:
    "Saner calling conventions for csum_and_copy_..._user() and friends"

    [ Removing 800+ lines of code and cleaning stuff up is good - Linus ]

    * 'work.csum_and_copy' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    ppc: propagate the calling conventions change down to csum_partial_copy_generic()
    amd64: switch csum_partial_copy_generic() to new calling conventions
    sparc64: propagate the calling convention changes down to __csum_partial_copy_...()
    xtensa: propagate the calling conventions change down into csum_partial_copy_generic()
    mips: propagate the calling convention change down into __csum_partial_copy_..._user()
    mips: __csum_partial_copy_kernel() has no users left
    mips: csum_and_copy_{to,from}_user() are never called under KERNEL_DS
    sparc32: propagate the calling conventions change down to __csum_partial_copy_sparc_generic()
    i386: propagate the calling conventions change down to csum_partial_copy_generic()
    sh: propage the calling conventions change down to csum_partial_copy_generic()
    m68k: get rid of zeroing destination on error in csum_and_copy_from_user()
    arm: propagate the calling convention changes down to csum_partial_copy_from_user()
    alpha: propagate the calling convention changes down to csum_partial_copy.c helpers
    saner calling conventions for csum_and_copy_..._user()
    csum_and_copy_..._user(): pass 0xffffffff instead of 0 as initial sum
    csum_partial_copy_nocheck(): drop the last argument
    unify generic instances of csum_partial_copy_nocheck()
    icmp_push_reply(): reorder adding the checksum up
    skb_copy_and_csum_bits(): don't bother with the last argument

    Linus Torvalds
     
  • Pull static call support from Ingo Molnar:
    "This introduces static_call(), which is the idea of static_branch()
    applied to indirect function calls. Remove a data load (indirection)
    by modifying the text.

    They give the flexibility of function pointers, but with better
    performance. (This is especially important for cases where retpolines
    would otherwise be used, as retpolines can be pretty slow.)

    API overview:

    DECLARE_STATIC_CALL(name, func);
    DEFINE_STATIC_CALL(name, func);
    DEFINE_STATIC_CALL_NULL(name, typename);

    static_call(name)(args...);
    static_call_cond(name)(args...);
    static_call_update(name, func);

    x86 is supported via text patching, otherwise basic indirect calls are
    used, with function pointers.

    There's a second variant using inline code patching, inspired by
    jump-labels, implemented on x86 as well.

    The new APIs are utilized in the x86 perf code, a heavy user of
    function pointers, where static calls speed up the PMU handler by
    4.2% (!).

    The generic implementation is not really excercised on other
    architectures, outside of the trivial test_static_call_init()
    self-test"

    * tag 'core-static_call-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
    static_call: Fix return type of static_call_init
    tracepoint: Fix out of sync data passing by static caller
    tracepoint: Fix overly long tracepoint names
    x86/perf, static_call: Optimize x86_pmu methods
    tracepoint: Optimize using static_call()
    static_call: Allow early init
    static_call: Add some validation
    static_call: Handle tail-calls
    static_call: Add static_call_cond()
    x86/alternatives: Teach text_poke_bp() to emulate RET
    static_call: Add simple self-test for static calls
    x86/static_call: Add inline static call implementation for x86-64
    x86/static_call: Add out-of-line static call implementation
    static_call: Avoid kprobes on inline static_call()s
    static_call: Add inline static call infrastructure
    static_call: Add basic static call infrastructure
    compiler.h: Make __ADDRESSABLE() symbol truly unique
    jump_label,module: Fix module lifetime for __jump_label_mod_text_reserved()
    module: Properly propagate MODULE_STATE_COMING failure
    module: Fix up module_notifier return values
    ...

    Linus Torvalds
     
  • Pull orphan section checking from Ingo Molnar:
    "Orphan link sections were a long-standing source of obscure bugs,
    because the heuristics that various linkers & compilers use to handle
    them (include these bits into the output image vs discarding them
    silently) are both highly idiosyncratic and also version dependent.

    Instead of this historically problematic mess, this tree by Kees Cook
    (et al) adds build time asserts and build time warnings if there's any
    orphan section in the kernel or if a section is not sized as expected.

    And because we relied on so many silent assumptions in this area, fix
    a metric ton of dependencies and some outright bugs related to this,
    before we can finally enable the checks on the x86, ARM and ARM64
    platforms"

    * tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits)
    x86/boot/compressed: Warn on orphan section placement
    x86/build: Warn on orphan section placement
    arm/boot: Warn on orphan section placement
    arm/build: Warn on orphan section placement
    arm64/build: Warn on orphan section placement
    x86/boot/compressed: Add missing debugging sections to output
    x86/boot/compressed: Remove, discard, or assert for unwanted sections
    x86/boot/compressed: Reorganize zero-size section asserts
    x86/build: Add asserts for unwanted sections
    x86/build: Enforce an empty .got.plt section
    x86/asm: Avoid generating unused kprobe sections
    arm/boot: Handle all sections explicitly
    arm/build: Assert for unwanted sections
    arm/build: Add missing sections
    arm/build: Explicitly keep .ARM.attributes sections
    arm/build: Refactor linker script headers
    arm64/build: Assert for unwanted sections
    arm64/build: Add missing DWARF sections
    arm64/build: Use common DISCARDS in linker script
    arm64/build: Remove .eh_frame* sections due to unwind tables
    ...

    Linus Torvalds
     

10 Oct, 2020

1 commit

  • Add a linker section where KUnit can put references to its test suites.
    This patch is the first step in transitioning to dispatching all KUnit
    tests from a centralized executor rather than having each as its own
    separate late_initcall.

    Co-developed-by: Iurii Zaikin
    Signed-off-by: Iurii Zaikin
    Signed-off-by: Brendan Higgins
    Reviewed-by: Stephen Boyd
    Signed-off-by: Shuah Khan

    Brendan Higgins
     

09 Oct, 2020

1 commit

  • …nux-rcu into locking/core

    Pull KCSAN updates for v5.10 from Paul E. McKenney:

    - Improve kernel messages.

    - Be more permissive with bitops races under KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y.

    - Optimize debugfs stat counters.

    - Introduce the instrument_*read_write() annotations, to provide a
    finer description of certain ops - using KCSAN's compound instrumentation.
    Use them for atomic RNW and bitops, where appropriate.
    Doing this might find new races.
    (Depends on the compiler having tsan-compound-read-before-write=1 support.)

    - Support atomic built-ins, which will help certain architectures, such as s390.

    - Misc enhancements and smaller fixes.

    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Ingo Molnar
     

06 Oct, 2020

1 commit


05 Oct, 2020

4 commits

  • For arches that do not select CONFIG_GENERIC_IOMAP, the current
    pci_iounmap() function does nothing causing obvious memory leaks
    for mapped regions that are backed by MMIO physical space.

    In order to detect if a mapped pointer is IO vs MMIO, a check must made
    available to the pci_iounmap() function so that it can actually detect
    whether the pointer has to be unmapped.

    In configurations where CONFIG_HAS_IOPORT_MAP && !CONFIG_GENERIC_IOMAP,
    a mapped port is detected using an ioport_map() stub defined in
    asm-generic/io.h.

    Use the same logic to implement a stub (ie __pci_ioport_unmap()) that
    detects if the passed in pointer in pci_iounmap() is IO vs MMIO to
    iounmap conditionally and call it in pci_iounmap() fixing the issue.

    Leave __pci_ioport_unmap() as a NOP for all other config options.

    Tested-by: George Cherian
    Link: https://lore.kernel.org/lkml/20200905024811.74701-1-yangyingliang@huawei.com
    Link: https://lore.kernel.org/lkml/20200824132046.3114383-1-george.cherian@marvell.com
    Link: https://lore.kernel.org/r/a9daf8d8444d0ebd00bc6d64e336ec49dbb50784.1600254147.git.lorenzo.pieralisi@arm.com
    Reported-by: George Cherian
    Signed-off-by: Lorenzo Pieralisi
    Signed-off-by: Lorenzo Pieralisi
    Reviewed-by: Catalin Marinas
    Cc: Arnd Bergmann
    Cc: George Cherian
    Cc: Will Deacon
    Cc: Bjorn Helgaas
    Cc: Catalin Marinas
    Cc: Yang Yingliang

    Lorenzo Pieralisi
     
  • Put all the set_fs related code under CONFIG_SET_FS so that
    asm-generic/uaccess.h can be used for set_fs-less builds.

    Signed-off-by: Christoph Hellwig
    Acked-by: Arnd Bergmann
    Signed-off-by: Palmer Dabbelt

    Christoph Hellwig
     
  • Add native implementations of __{get,put}_kernel_nofault using
    {get,put}_unaligned, just like the {get,put}_user implementations.

    Signed-off-by: Christoph Hellwig
    Acked-by: Arnd Bergmann
    Signed-off-by: Palmer Dabbelt

    Christoph Hellwig
     
  • Instead of reusing raw_{copy,to}_from_user implement separate handlers
    using {get,put}_unaligned. This ensures unaligned access is handled
    correctly, and avoid the need for the small constant size optimization
    in raw_{copy,to}_from_user.

    Signed-off-by: Christoph Hellwig
    Acked-by: Arnd Bergmann
    Signed-off-by: Palmer Dabbelt

    Christoph Hellwig
     

24 Sep, 2020

1 commit

  • There was a request to preprocess the module linker script like we
    do for the vmlinux one. (https://lkml.org/lkml/2020/8/21/512)

    The difference between vmlinux.lds and module.lds is that the latter
    is needed for external module builds, thus must be cleaned up by
    'make mrproper' instead of 'make clean'. Also, it must be created
    by 'make modules_prepare'.

    You cannot put it in arch/$(SRCARCH)/kernel/, which is cleaned up by
    'make clean'. I moved arch/$(SRCARCH)/kernel/module.lds to
    arch/$(SRCARCH)/include/asm/module.lds.h, which is included from
    scripts/module.lds.S.

    scripts/module.lds is fine because 'make clean' keeps all the
    build artifacts under scripts/.

    You can add arch-specific sections in .

    Signed-off-by: Masahiro Yamada
    Tested-by: Jessica Yu
    Acked-by: Will Deacon
    Acked-by: Geert Uytterhoeven
    Acked-by: Palmer Dabbelt
    Reviewed-by: Kees Cook
    Acked-by: Jessica Yu

    Masahiro Yamada
     

22 Sep, 2020

1 commit

  • Systems with memory or disk constraints often reduce the kernel footprint
    by configuring LD_DEAD_CODE_DATA_ELIMINATION. However, this can result in
    removal of any BTF information.

    Use the KEEP() macro to preserve the BTF data as done with other important
    sections, while still allowing for smaller kernels.

    Fixes: 90ceddcb4950 ("bpf: Support llvm-objcopy for vmlinux BTF")
    Signed-off-by: Tony Ambardar
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/a635b5d3e2da044e7b51ec1315e8910fbce0083f.1600417359.git.Tony.Ambardar@gmail.com

    Tony Ambardar
     

18 Sep, 2020

1 commit


01 Sep, 2020

8 commits

  • Add the inline static call implementation for x86-64. The generated code
    is identical to the out-of-line case, except we move the trampoline into
    it's own section.

    Objtool uses the trampoline naming convention to detect all the call
    sites. It then annotates those call sites in the .static_call_sites
    section.

    During boot (and module init), the call sites are patched to call
    directly into the destination function. The temporary trampoline is
    then no longer used.

    [peterz: merged trampolines, put trampoline in section]

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Ingo Molnar
    Cc: Linus Torvalds
    Link: https://lore.kernel.org/r/20200818135804.864271425@infradead.org

    Josh Poimboeuf
     
  • Add infrastructure for an arch-specific CONFIG_HAVE_STATIC_CALL_INLINE
    option, which is a faster version of CONFIG_HAVE_STATIC_CALL. At
    runtime, the static call sites are patched directly, rather than using
    the out-of-line trampolines.

    Compared to out-of-line static calls, the performance benefits are more
    modest, but still measurable. Steven Rostedt did some tracepoint
    measurements:

    https://lkml.kernel.org/r/20181126155405.72b4f718@gandalf.local.home

    This code is heavily inspired by the jump label code (aka "static
    jumps"), as some of the concepts are very similar.

    For more details, see the comments in include/linux/static_call.h.

    [peterz: simplified interface; merged trampolines]

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Ingo Molnar
    Reviewed-by: Steven Rostedt (VMware)
    Cc: Linus Torvalds
    Link: https://lore.kernel.org/r/20200818135804.684334440@infradead.org

    Josh Poimboeuf
     
  • Basically, consider .text.{hot|unlikely|unknown}.* part of .text, too.

    When compiling with profiling information (collected via PGO
    instrumentations or AutoFDO sampling), Clang will separate code into
    .text.hot, .text.unlikely, or .text.unknown sections based on profiling
    information. After D79600 (clang-11), these sections will have a
    trailing `.` suffix, ie. .text.hot., .text.unlikely., .text.unknown..

    When using -ffunction-sections together with profiling infomation,
    either explicitly (FGKASLR) or implicitly (LTO), code may be placed in
    sections following the convention:
    .text.hot., .text.unlikely., .text.unknown.
    where , , and are functions. (This produces one section
    per function; we generally try to merge these all back via linker script
    so that we don't have 50k sections).

    For the above cases, we need to teach our linker scripts that such
    sections might exist and that we'd explicitly like them grouped
    together, otherwise we can wind up with code outside of the
    _stext/_etext boundaries that might not be mapped properly for some
    architectures, resulting in boot failures.

    If the linker script is not told about possible input sections, then
    where the section is placed as output is a heuristic-laiden mess that's
    non-portable between linkers (ie. BFD and LLD), and has resulted in many
    hard to debug bugs. Kees Cook is working on cleaning this up by adding
    --orphan-handling=warn linker flag used in ARCH=powerpc to additional
    architectures. In the case of linker scripts, borrowing from the Zen of
    Python: explicit is better than implicit.

    Also, ld.bfd's internal linker script considers .text.hot AND
    .text.hot.* to be part of .text, as well as .text.unlikely and
    .text.unlikely.*. I didn't see support for .text.unknown.*, and didn't
    see Clang producing such code in our kernel builds, but I see code in
    LLVM that can produce such section names if profiling information is
    missing. That may point to a larger issue with generating or collecting
    profiles, but I would much rather be safe and explicit than have to
    debug yet another issue related to orphan section placement.

    Reported-by: Jian Cai
    Suggested-by: Fāng-ruì Sòng
    Signed-off-by: Nick Desaulniers
    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Tested-by: Luis Lozano
    Tested-by: Manoj Gupta
    Acked-by: Kees Cook
    Cc: linux-arch@vger.kernel.org
    Cc: stable@vger.kernel.org
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=add44f8d5c5c05e08b11e033127a744d61c26aee
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1de778ed23ce7492c523d5850c6c6dbb34152655
    Link: https://reviews.llvm.org/D79600
    Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1084760
    Link: https://lore.kernel.org/r/20200821194310.3089815-7-keescook@chromium.org

    Debugged-by: Luis Lozano

    Nick Desaulniers
     
  • When linking vmlinux with LLD, the synthetic sections .symtab, .strtab,
    and .shstrtab are listed as orphaned. Add them to the ELF_DETAILS section
    so there will be no warnings when --orphan-handling=warn is used more
    widely. (They are added above comment as it is the more common
    order[1].)

    ld.lld: warning: :(.symtab) is being placed in '.symtab'
    ld.lld: warning: :(.shstrtab) is being placed in '.shstrtab'
    ld.lld: warning: :(.strtab) is being placed in '.strtab'

    [1] https://lore.kernel.org/lkml/20200622224928.o2a7jkq33guxfci4@google.com/

    Reported-by: Fangrui Song
    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-6-keescook@chromium.org

    Kees Cook
     
  • The .comment section doesn't belong in STABS_DEBUG. Split it out into a
    new macro named ELF_DETAILS. This will gain other non-debug sections
    that need to be accounted for when linking with --orphan-handling=warn.

    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-5-keescook@chromium.org

    Kees Cook
     
  • KASAN (-fsanitize=kernel-address) and KCSAN (-fsanitize=thread)
    produce unwanted[1] .eh_frame and .init_array.* sections. Add them to
    COMMON_DISCARDS, except with CONFIG_CONSTRUCTORS, which wants to keep
    .init_array.* sections.

    [1] https://bugs.llvm.org/show_bug.cgi?id=46478

    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Tested-by: Marco Elver
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-4-keescook@chromium.org

    Kees Cook
     
  • For vmlinux linking, no architecture uses the .gnu.version* sections,
    so remove it via the COMMON_DISCARDS macro in preparation for adding
    --orphan-handling=warn more widely. This is a work-around for what
    appears to be a bug[1] in ld.bfd which warns for this synthetic section
    even when none is found in input objects, and even when no section is
    emitted for an output object[2].

    [1] https://sourceware.org/bugzilla/show_bug.cgi?id=26153
    [2] https://lore.kernel.org/lkml/202006221524.CEB86E036B@keescook/

    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Reviewed-by: Fangrui Song
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-3-keescook@chromium.org

    Kees Cook
     
  • Collect the common DISCARD sections for architectures that need more
    specialized discard control than what the standard DISCARDS section
    provides.

    Signed-off-by: Kees Cook
    Signed-off-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org
    Link: https://lore.kernel.org/r/20200821194310.3089815-2-keescook@chromium.org

    Kees Cook
     

25 Aug, 2020

3 commits

  • Previous to the change to distinguish read-write accesses, when
    CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y is set, KCSAN would consider
    the non-atomic bitops as atomic. We want to partially revert to this
    behaviour, but with one important distinction: report racing
    modifications, since lost bits due to non-atomicity are certainly
    possible.

    Given the operations here only modify a single bit, assuming
    non-atomicity of the writer is sufficient may be reasonable for certain
    usage (and follows the permissible nature of the "assume plain writes
    atomic" rule). In other words:

    1. We want non-atomic read-modify-write races to be reported;
    this is accomplished by kcsan_check_read(), where any
    concurrent write (atomic or not) will generate a report.

    2. We do not want to report races with marked readers, but -do-
    want to report races with unmarked readers; this is
    accomplished by the instrument_write() ("assume atomic
    write" with Kconfig option set).

    With the above rules, when KCSAN_ASSUME_PLAIN_WRITES_ATOMIC is selected,
    it is hoped that KCSAN's reporting behaviour is better aligned with
    current expected permissible usage for non-atomic bitops.

    Note that, a side-effect of not telling KCSAN that the accesses are
    read-writes, is that this information is not displayed in the access
    summary in the report. It is, however, visible in inline-expanded stack
    traces. For now, it does not make sense to introduce yet another special
    case to KCSAN's runtime, only to cater to the case here.

    Cc: Dmitry Vyukov
    Cc: Paul E. McKenney
    Cc: Will Deacon
    Cc: Arnd Bergmann
    Cc: Daniel Axtens
    Cc: Michael Ellerman
    Cc:
    Signed-off-by: Marco Elver
    Signed-off-by: Paul E. McKenney

    Marco Elver
     
  • Use instrument_atomic_read_write() for atomic RMW ops.

    Cc: Will Deacon
    Cc: Boqun Feng
    Cc: Arnd Bergmann
    Cc:
    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: Marco Elver
    Signed-off-by: Paul E. McKenney

    Marco Elver
     
  • Use the new instrument_read_write() where appropriate.

    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: Marco Elver
    Signed-off-by: Paul E. McKenney

    Marco Elver