1. 13 Oct, 2022 3 commits
    • Linus Torvalds's avatar
      Merge tag 'ceph-for-6.1-rc1' of https://github.com/ceph/ceph-client · 524d0c68
      Linus Torvalds authored
      Pull ceph updates from Ilya Dryomov:
       "A quiet round this time: several assorted filesystem fixes, the most
        noteworthy one being some additional wakeups in cap handling code, and
        a messenger cleanup"
      
      * tag 'ceph-for-6.1-rc1' of https://github.com/ceph/ceph-client:
        ceph: remove Sage's git tree from documentation
        ceph: fix incorrectly showing the .snap size for stat
        ceph: fail the open_by_handle_at() if the dentry is being unlinked
        ceph: increment i_version when doing a setattr with caps
        ceph: Use kcalloc for allocating multiple elements
        ceph: no need to wait for transition RDCACHE|RD -> RD
        ceph: fail the request if the peer MDS doesn't support getvxattr op
        ceph: wake up the waiters if any new caps comes
        libceph: drop last_piece flag from ceph_msg_data_cursor
      524d0c68
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-6.1-1' of git://git.linux-nfs.org/projects/anna/linux-nfs · 66b83455
      Linus Torvalds authored
      Pull NFS client updates from Anna Schumaker:
       "New Features:
         - Add NFSv4.2 xattr tracepoints
         - Replace xprtiod WQ in rpcrdma
         - Flexfiles cancels I/O on layout recall or revoke
      
        Bugfixes and Cleanups:
         - Directly use ida_alloc() / ida_free()
         - Don't open-code max_t()
         - Prefer using strscpy over strlcpy
         - Remove unused forward declarations
         - Always return layout states on flexfiles layout return
         - Have LISTXATTR treat NFS4ERR_NOXATTR as an empty reply instead of
           error
         - Allow more xprtrdma memory allocations to fail without triggering a
           reclaim
         - Various other xprtrdma clean ups
         - Fix rpc_killall_tasks() races"
      
      * tag 'nfs-for-6.1-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (27 commits)
        NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked
        SUNRPC: Add API to force the client to disconnect
        SUNRPC: Add a helper to allow pNFS drivers to selectively cancel RPC calls
        SUNRPC: Fix races with rpc_killall_tasks()
        xprtrdma: Fix uninitialized variable
        xprtrdma: Prevent memory allocations from driving a reclaim
        xprtrdma: Memory allocation should be allowed to fail during connect
        xprtrdma: MR-related memory allocation should be allowed to fail
        xprtrdma: Clean up synopsis of rpcrdma_regbuf_alloc()
        xprtrdma: Clean up synopsis of rpcrdma_req_create()
        svcrdma: Clean up RPCRDMA_DEF_GFP
        SUNRPC: Replace the use of the xprtiod WQ in rpcrdma
        NFSv4.2: Add a tracepoint for listxattr
        NFSv4.2: Add tracepoints for getxattr, setxattr, and removexattr
        NFSv4.2: Move TRACE_DEFINE_ENUM(NFS4_CONTENT_*) under CONFIG_NFS_V4_2
        NFSv4.2: Add special handling for LISTXATTR receiving NFS4ERR_NOXATTR
        nfs: remove nfs_wait_atomic_killable() and nfs_write_prepare() declaration
        NFSv4: remove nfs4_renewd_prepare_shutdown() declaration
        fs/nfs/pnfs_nfs.c: fix spelling typo and syntax error in comment
        NFSv4/pNFS: Always return layout stats on layout return for flexfiles
        ...
      66b83455
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.1-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux · 531d3b5f
      Linus Torvalds authored
      Pull orangefs update from Mike Marshall:
       "Change iterate to iterate_shared"
      
      * tag 'for-linus-6.1-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
        Orangefs: change iterate to iterate_shared
      531d3b5f
  2. 12 Oct, 2022 37 commits
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-kunit-6.1-rc1-2' of... · a185a099
      Linus Torvalds authored
      Merge tag 'linux-kselftest-kunit-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull more KUnit updates from Shuah Khan:
       "Features and fixes:
      
         - simplify resource use
      
         - make kunit_malloc() and kunit_free() allocations and frees
           consistent. kunit_free() frees only the memory allocated by
           kunit_malloc()
      
         - stop downloading risc-v opensbi binaries using wget
      
         - other fixes and improvements to tool and KUnit framework"
      
      * tag 'linux-kselftest-kunit-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        Documentation: kunit: Update description of --alltests option
        kunit: declare kunit_assert structs as const
        kunit: rename base KUNIT_ASSERTION macro to _KUNIT_FAILED
        kunit: remove format func from struct kunit_assert, get it to 0 bytes
        kunit: tool: Don't download risc-v opensbi firmware with wget
        kunit: make kunit_kfree(NULL) a no-op to match kfree()
        kunit: make kunit_kfree() not segfault on invalid inputs
        kunit: make kunit_kfree() only work on pointers from kunit_malloc() and friends
        kunit: drop test pointer in string_stream_fragment
        kunit: string-stream: Simplify resource use
      a185a099
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-next-6.1-rc1-2' of... · 661e0096
      Linus Torvalds authored
      Merge tag 'linux-kselftest-next-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull more Kselftest updates from Shuah Khan:
       "This consists of fixes and improvements to memory-hotplug test and a
        minor spelling fix to ftrace test"
      
      * tag 'linux-kselftest-next-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        docs: notifier-error-inject: Correct test's name
        selftests/memory-hotplug: Adjust log info for maintainability
        selftests/memory-hotplug: Restore memory before exit
        selftests/memory-hotplug: Add checking after online or offline
        selftests/ftrace: func_event_triggers: fix typo in user message
      661e0096
    • Linus Torvalds's avatar
      Merge tag 'vfio-v6.1-rc1' of https://github.com/awilliam/linux-vfio · d3cf4051
      Linus Torvalds authored
      Pull VFIO updates from Alex Williamson:
      
       - Prune private items from vfio_pci_core.h to a new internal header,
         fix missed function rename, and refactor vfio-pci interrupt defines
         (Jason Gunthorpe)
      
       - Create consistent naming and handling of ioctls with a function per
         ioctl for vfio-pci and vfio group handling, use proper type args
         where available (Jason Gunthorpe)
      
       - Implement a set of low power device feature ioctls allowing userspace
         to make use of power states such as D3cold where supported (Abhishek
         Sahu)
      
       - Remove device counter on vfio groups, which had restricted the page
         pinning interface to singleton groups to account for limitations in
         the type1 IOMMU backend. Document usage as limited to emulated IOMMU
         devices, ie. traditional mdev devices where this restriction is
         consistent (Jason Gunthorpe)
      
       - Correct function prefix in hisi_acc driver incurred during previous
         refactoring (Shameer Kolothum)
      
       - Correct typo and remove redundant warning triggers in vfio-fsl driver
         (Christophe JAILLET)
      
       - Introduce device level DMA dirty tracking uAPI and implementation in
         the mlx5 variant driver (Yishai Hadas & Joao Martins)
      
       - Move much of the vfio_device life cycle management into vfio core,
         simplifying and avoiding duplication across drivers. This also
         facilitates adding a struct device to vfio_device which begins the
         introduction of device rather than group level user support and fills
         a gap allowing userspace identify devices as vfio capable without
         implicit knowledge of the driver (Kevin Tian & Yi Liu)
      
       - Split vfio container handling to a separate file, creating a more
         well defined API between the core and container code, masking IOMMU
         backend implementation from the core, allowing for an easier future
         transition to an iommufd based implementation of the same (Jason
         Gunthorpe)
      
       - Attempt to resolve race accessing the iommu_group for a device
         between vfio releasing DMA ownership and removal of the device from
         the IOMMU driver. Follow-up with support to allow vfio_group to exist
         with NULL iommu_group pointer to support existing userspace use cases
         of holding the group file open (Jason Gunthorpe)
      
       - Fix error code and hi/lo register manipulation issues in the hisi_acc
         variant driver, along with various code cleanups (Longfang Liu)
      
       - Fix a prior regression in GVT-g group teardown, resulting in
         unreleased resources (Jason Gunthorpe)
      
       - A significant cleanup and simplification of the mdev interface,
         consolidating much of the open coded per driver sysfs interface
         support into the mdev core (Christoph Hellwig)
      
       - Simplification of tracking and locking around vfio_groups that fall
         out from previous refactoring (Jason Gunthorpe)
      
       - Replace trivial open coded f_ops tests with new helper (Alex
         Williamson)
      
      * tag 'vfio-v6.1-rc1' of https://github.com/awilliam/linux-vfio: (77 commits)
        vfio: More vfio_file_is_group() use cases
        vfio: Make the group FD disassociate from the iommu_group
        vfio: Hold a reference to the iommu_group in kvm for SPAPR
        vfio: Add vfio_file_is_group()
        vfio: Change vfio_group->group_rwsem to a mutex
        vfio: Remove the vfio_group->users and users_comp
        vfio/mdev: add mdev available instance checking to the core
        vfio/mdev: consolidate all the description sysfs into the core code
        vfio/mdev: consolidate all the available_instance sysfs into the core code
        vfio/mdev: consolidate all the name sysfs into the core code
        vfio/mdev: consolidate all the device_api sysfs into the core code
        vfio/mdev: remove mtype_get_parent_dev
        vfio/mdev: remove mdev_parent_dev
        vfio/mdev: unexport mdev_bus_type
        vfio/mdev: remove mdev_from_dev
        vfio/mdev: simplify mdev_type handling
        vfio/mdev: embedd struct mdev_parent in the parent data structure
        vfio/mdev: make mdev.h standalone includable
        drm/i915/gvt: simplify vgpu configuration management
        drm/i915/gvt: fix a memory leak in intel_gvt_init_vgpu_types
        ...
      d3cf4051
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.1-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 778ce723
      Linus Torvalds authored
      Pull xen updates from Juergen Gross:
      
       - Some minor typo fixes
      
       - A fix of the Xen pcifront driver for supporting the device model to
         run in a Linux stub domain
      
       - A cleanup of the pcifront driver
      
       - A series to enable grant-based virtio with Xen on x86
      
       - A cleanup of Xen PV guests to distinguish between safe and faulting
         MSR accesses
      
       - Two fixes of the Xen gntdev driver
      
       - Two fixes of the new xen grant DMA driver
      
      * tag 'for-linus-6.1-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen: Kconfig: Fix spelling mistake "Maxmium" -> "Maximum"
        xen/pv: support selecting safe/unsafe msr accesses
        xen/pv: refactor msr access functions to support safe and unsafe accesses
        xen/pv: fix vendor checks for pmu emulation
        xen/pv: add fault recovery control to pmu msr accesses
        xen/virtio: enable grant based virtio on x86
        xen/virtio: use dom0 as default backend for CONFIG_XEN_VIRTIO_FORCE_GRANT
        xen/virtio: restructure xen grant dma setup
        xen/pcifront: move xenstore config scanning into sub-function
        xen/gntdev: Accommodate VMA splitting
        xen/gntdev: Prevent leaking grants
        xen/virtio: Fix potential deadlock when accessing xen_grant_dma_devices
        xen/virtio: Fix n_pages calculation in xen_grant_dma_map(unmap)_page()
        xen/xenbus: Fix spelling mistake "hardward" -> "hardware"
        xen-pcifront: Handle missed Connected state
      778ce723
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm · 1440f576
      Linus Torvalds authored
      Pull misc hotfixes from Andrew Morton:
       "Five hotfixes - three for nilfs2, two for MM. For are cc:stable, one
        is not"
      
      * tag 'mm-hotfixes-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        nilfs2: fix leak of nilfs_root in case of writer thread creation failure
        nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level()
        nilfs2: fix use-after-free bug of struct nilfs_root
        mm/damon/core: initialize damon_target->list in damon_new_target()
        mm/hugetlb: fix races when looking up a CONT-PTE/PMD size hugetlb page
      1440f576
    • Linus Torvalds's avatar
      Merge tag 'mm-nonmm-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm · 676cb495
      Linus Torvalds authored
      Pull non-MM updates from Andrew Morton:
      
       - hfs and hfsplus kmap API modernization (Fabio Francesco)
      
       - make crash-kexec work properly when invoked from an NMI-time panic
         (Valentin Schneider)
      
       - ntfs bugfixes (Hawkins Jiawei)
      
       - improve IPC msg scalability by replacing atomic_t's with percpu
         counters (Jiebin Sun)
      
       - nilfs2 cleanups (Minghao Chi)
      
       - lots of other single patches all over the tree!
      
      * tag 'mm-nonmm-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (71 commits)
        include/linux/entry-common.h: remove has_signal comment of arch_do_signal_or_restart() prototype
        proc: test how it holds up with mapping'less process
        mailmap: update Frank Rowand email address
        ia64: mca: use strscpy() is more robust and safer
        init/Kconfig: fix unmet direct dependencies
        ia64: update config files
        nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure
        fork: remove duplicate included header files
        init/main.c: remove unnecessary (void*) conversions
        proc: mark more files as permanent
        nilfs2: remove the unneeded result variable
        nilfs2: delete unnecessary checks before brelse()
        checkpatch: warn for non-standard fixes tag style
        usr/gen_init_cpio.c: remove unnecessary -1 values from int file
        ipc/msg: mitigate the lock contention with percpu counter
        percpu: add percpu_counter_add_local and percpu_counter_sub_local
        fs/ocfs2: fix repeated words in comments
        relay: use kvcalloc to alloc page array in relay_alloc_page_array
        proc: make config PROC_CHILDREN depend on PROC_FS
        fs: uninline inode_maybe_inc_iversion()
        ...
      676cb495
    • Linus Torvalds's avatar
      Merge tag 'loongarch-6.1' of... · 95b8b595
      Linus Torvalds authored
      Merge tag 'loongarch-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
      
      Pull LoongArch updates from Huacai Chen:
      
       - Use EXPLICIT_RELOCS (ABIv2.0)
      
       - Use generic BUG() handler
      
       - Refactor TLB/Cache operations
      
       - Add qspinlock support
      
       - Add perf events support
      
       - Add kexec/kdump support
      
       - Add BPF JIT support
      
       - Add ACPI-based laptop driver
      
       - Update the default config file
      
      * tag 'loongarch-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: (25 commits)
        LoongArch: Update Loongson-3 default config file
        LoongArch: Add ACPI-based generic laptop driver
        LoongArch: Add BPF JIT support
        LoongArch: Add some instruction opcodes and formats
        LoongArch: Move {signed,unsigned}_imm_check() to inst.h
        LoongArch: Add kdump support
        LoongArch: Add kexec support
        LoongArch: Use generic BUG() handler
        LoongArch: Add SysRq-x (TLB Dump) support
        LoongArch: Add perf events support
        LoongArch: Add qspinlock support
        LoongArch: Use TLB for ioremap()
        LoongArch: Support access filter to /dev/mem interface
        LoongArch: Refactor cache probe and flush methods
        LoongArch: mm: Refactor TLB exception handlers
        LoongArch: Support R_LARCH_GOT_PC_{LO12,HI20} in modules
        LoongArch: Support PC-relative relocations in modules
        LoongArch: Define ELF relocation types added in ABIv2.0
        LoongArch: Adjust symbol addressing for AS_HAS_EXPLICIT_RELOCS
        LoongArch: Add Kconfig option AS_HAS_EXPLICIT_RELOCS
        ...
      95b8b595
    • Linus Torvalds's avatar
      Merge tag 'irq-core-2022-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 60ac35bf
      Linus Torvalds authored
      Pull interrupt updates from Thomas Gleixner:
       "Core code:
      
         - Provide a generic wrapper which can be utilized in drivers to
           handle the problem of force threaded demultiplex interrupts on RT
           enabled kernels. This avoids conditionals and horrible quirks in
           drivers all over the place
      
         - Fix up affected pinctrl and GPIO drivers to make them cleanly RT
           safe
      
        Interrupt drivers:
      
         - A new driver for the FSL MU platform specific MSI implementation
      
         - Make irqchip_init() available for pure ACPI based systems
      
         - Provide a functional DT binding for the Realtek RTL interrupt chip
      
         - The usual DT updates and small code improvements all over the
           place"
      
      * tag 'irq-core-2022-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
        irqchip: IMX_MU_MSI should depend on ARCH_MXC
        irqchip/imx-mu-msi: Fix wrong register offset for 8ulp
        irqchip/ls-extirq: Fix invalid wait context by avoiding to use regmap
        dt-bindings: irqchip: Describe the IMX MU block as a MSI controller
        irqchip: Add IMX MU MSI controller driver
        dt-bindings: irqchip: renesas,irqc: Add r8a779g0 support
        irqchip/gic-v3: Fix typo in comment
        dt-bindings: interrupt-controller: ti,sci-intr: Fix missing reg property in the binding
        dt-bindings: irqchip: ti,sci-inta: Fix warning for missing #interrupt-cells
        irqchip: Allow extra fields to be passed to IRQCHIP_PLATFORM_DRIVER_END
        platform-msi: Export symbol platform_msi_create_irq_domain()
        irqchip/realtek-rtl: use parent interrupts
        dt-bindings: interrupt-controller: realtek,rtl-intc: require parents
        irqchip/realtek-rtl: use irq_domain_add_linear()
        irqchip: Make irqchip_init() usable on pure ACPI systems
        bcma: gpio: Use generic_handle_irq_safe()
        gpio: mlxbf2: Use generic_handle_irq_safe()
        platform/x86: intel_int0002_vgpio: Use generic_handle_irq_safe()
        ssb: gpio: Use generic_handle_irq_safe()
        pinctrl: amd: Use generic_handle_irq_safe()
        ...
      60ac35bf
    • Huacai Chen's avatar
      LoongArch: Update Loongson-3 default config file · 2c8577f5
      Huacai Chen authored
      1, Enable ZBOOT, KEXEC and BPF_JIT;
      2, Add more patition types;
      3, Add some USB Type-C options;
      4, Add some common network options;
      5, Add some Bluetooth device drivers;
      6, Remove obsolete config options (for some detailed information, see
         Link).
      
      Link: https://lore.kernel.org/kernel-janitors/20220929090645.1389-1-lukas.bulwahn@gmail.com/Co-developed-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Co-developed-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Co-developed-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      2c8577f5
    • Jianmin Lv's avatar
      LoongArch: Add ACPI-based generic laptop driver · 6246ed09
      Jianmin Lv authored
      This add ACPI-based generic laptop driver for Loongson-3. Some of the
      codes are derived from drivers/platform/x86/thinkpad_acpi.c.
      Signed-off-by: default avatarJianmin Lv <lvjianmin@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      6246ed09
    • Tiezhu Yang's avatar
      LoongArch: Add BPF JIT support · 5dc61552
      Tiezhu Yang authored
      BPF programs are normally handled by a BPF interpreter, add BPF JIT
      support for LoongArch to allow the kernel to generate native code when
      a program is loaded into the kernel. This will significantly speed-up
      processing of BPF programs.
      Co-developed-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      5dc61552
    • Tiezhu Yang's avatar
      LoongArch: Add some instruction opcodes and formats · 4e59e5a4
      Tiezhu Yang authored
      According to the "Table of Instruction Encoding" in LoongArch Reference
      Manual [1], add some instruction opcodes and formats which are used in
      the BPF JIT for LoongArch.
      
      [1] https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#table-of-instruction-encodingSigned-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4e59e5a4
    • Tiezhu Yang's avatar
      LoongArch: Move {signed,unsigned}_imm_check() to inst.h · 8a34228e
      Tiezhu Yang authored
      {signed,unsigned}_imm_check() will also be used in the bpf jit, so move
      them from module.c to inst.h, this is preparation for later patches.
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      8a34228e
    • Youling Tang's avatar
      LoongArch: Add kdump support · 4e62d1d8
      Youling Tang authored
      This patch adds support for kdump. In kdump case the normal kernel will
      reserve a region for the crash kernel and jump there on panic.
      
      Arch-specific functions are added to allow for implementing a crash dump
      file interface, /proc/vmcore, which can be viewed as a ELF file.
      
      A user-space tool, such as kexec-tools, is responsible for allocating a
      separate region for the core's ELF header within the crash kdump kernel
      memory and filling it in when executing kexec_load().
      
      Then, its location will be advertised to the crash dump kernel via a
      command line argument "elfcorehdr=", and the crash dump kernel will
      preserve this region for later use with arch_reserve_vmcore() at boot
      time.
      
      At the same time, the crash kdump kernel is also limited within the
      "crashkernel" area via a command line argument "mem=", so as not to
      destroy the original kernel dump data.
      
      In the crash dump kernel environment, /proc/vmcore is used to access the
      primary kernel's memory with copy_oldmem_page().
      
      I tested kdump on LoongArch machines (Loongson-3A5000) and it works as
      expected (suggested crashkernel parameter is "crashkernel=512M@2560M"),
      you may test it by triggering a crash through /proc/sysrq-trigger:
      
       $ sudo kexec -p /boot/vmlinux-kdump --reuse-cmdline --append="nr_cpus=1"
       # echo c > /proc/sysrq-trigger
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4e62d1d8
    • Youling Tang's avatar
      LoongArch: Add kexec support · 4a03b2ac
      Youling Tang authored
      Add three new files, kexec.h, machine_kexec.c and relocate_kernel.S to
      the LoongArch architecture, so as to add support for the kexec re-boot
      mechanism (CONFIG_KEXEC) on LoongArch platforms.
      
      Kexec supports loading vmlinux.elf in ELF format and vmlinux.efi in PE
      format.
      
      I tested kexec on LoongArch machines (Loongson-3A5000) and it works as
      expected:
      
       $ sudo kexec -l /boot/vmlinux.efi --reuse-cmdline
       $ sudo kexec -e
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4a03b2ac
    • Youling Tang's avatar
      LoongArch: Use generic BUG() handler · 2d2c3952
      Youling Tang authored
      Inspired by commit 9fb7410f("arm64/BUG: Use BRK instruction for
      generic BUG traps"), do similar for LoongArch to use generic BUG()
      handler.
      
      This patch uses the BREAK software breakpoint instruction to generate
      a trap instead, similarly to most other arches, with the generic BUG
      code generating the dmesg boilerplate.
      
      This allows bug metadata to be moved to a separate table and reduces
      the amount of inline code at BUG() and WARN() sites. This also avoids
      clobbering any registers before they can be dumped.
      
      To mitigate the size of the bug table further, this patch makes use of
      the existing infrastructure for encoding addresses within the bug table
      as 32-bit relative pointers instead of absolute pointers.
      
      (Note: this limits the max kernel size to 2GB.)
      
      Before patch:
      [ 3018.338013] lkdtm: Performing direct entry BUG
      [ 3018.342445] Kernel bug detected[#5]:
      [ 3018.345992] CPU: 2 PID: 865 Comm: cat Tainted: G D 6.0.0-rc6+ #35
      
      After patch:
      [  125.585985] lkdtm: Performing direct entry BUG
      [  125.590433] ------------[ cut here ]------------
      [  125.595020] kernel BUG at drivers/misc/lkdtm/bugs.c:78!
      [  125.600211] Oops - BUG[#1]:
      [  125.602980] CPU: 3 PID: 410 Comm: cat Not tainted 6.0.0-rc6+ #36
      
      Out-of-line file/line data information obtained compared to before.
      Signed-off-by: default avatarYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      2d2c3952
    • Huacai Chen's avatar
      LoongArch: Add SysRq-x (TLB Dump) support · dea2df3c
      Huacai Chen authored
      Add SysRq-x (TLB Dump) support for LoongArch, which is useful for
      debugging.
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      dea2df3c
    • Huacai Chen's avatar
      LoongArch: Add perf events support · b37042b2
      Huacai Chen authored
      The perf events infrastructure of LoongArch is very similar to old MIPS-
      based Loongson, so most of the codes are derived from MIPS.
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      b37042b2
    • Huacai Chen's avatar
      LoongArch: Add qspinlock support · 5f1e001b
      Huacai Chen authored
      On NUMA system, the performance of qspinlock is better than generic
      spinlock. Below is the UnixBench test results on a 8 nodes (4 cores
      per node, 32 cores in total) machine.
      
      A. With generic spinlock:
      
      System Benchmarks Index Values               BASELINE       RESULT    INDEX
      Dhrystone 2 using register variables         116700.0  449574022.5  38523.9
      Double-Precision Whetstone                       55.0      85190.4  15489.2
      Execl Throughput                                 43.0      14696.2   3417.7
      File Copy 1024 bufsize 2000 maxblocks          3960.0     143157.8    361.5
      File Copy 256 bufsize 500 maxblocks            1655.0      37631.8    227.4
      File Copy 4096 bufsize 8000 maxblocks          5800.0     444814.2    766.9
      Pipe Throughput                               12440.0    5047490.7   4057.5
      Pipe-based Context Switching                   4000.0    2021545.7   5053.9
      Process Creation                                126.0      23829.8   1891.3
      Shell Scripts (1 concurrent)                     42.4      33756.7   7961.5
      Shell Scripts (8 concurrent)                      6.0       4062.9   6771.5
      System Call Overhead                          15000.0    2479748.6   1653.2
                                                                         ========
      System Benchmarks Index Score                                        2955.6
      
      B. With qspinlock:
      
      System Benchmarks Index Values               BASELINE       RESULT    INDEX
      Dhrystone 2 using register variables         116700.0  449467876.9  38514.8
      Double-Precision Whetstone                       55.0      85174.6  15486.3
      Execl Throughput                                 43.0      14769.1   3434.7
      File Copy 1024 bufsize 2000 maxblocks          3960.0     146150.5    369.1
      File Copy 256 bufsize 500 maxblocks            1655.0      37496.8    226.6
      File Copy 4096 bufsize 8000 maxblocks          5800.0     447527.0    771.6
      Pipe Throughput                               12440.0    5175989.2   4160.8
      Pipe-based Context Switching                   4000.0    2207747.8   5519.4
      Process Creation                                126.0      25125.5   1994.1
      Shell Scripts (1 concurrent)                     42.4      33461.2   7891.8
      Shell Scripts (8 concurrent)                      6.0       4024.7   6707.8
      System Call Overhead                          15000.0    2917278.6   1944.9
                                                                         ========
      System Benchmarks Index Score                                        3040.1
      Signed-off-by: default avatarRui Wang <wangrui@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      5f1e001b
    • Huacai Chen's avatar
      LoongArch: Use TLB for ioremap() · d2791341
      Huacai Chen authored
      We can support more cache attributes (e.g., CC, SUC and WUC) and page
      protection when we use TLB for ioremap(). The implementation is based
      on GENERIC_IOREMAP.
      
      The existing simple ioremap() implementation has better performance so
      we keep it and introduce ARCH_IOREMAP to control the selection.
      
      We move pagetable_init() earlier to make early ioremap() works, and we
      modify the PCI ecam mapping because the TLB-based version of ioremap()
      will actually take the size into account.
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      d2791341
    • Huacai Chen's avatar
      LoongArch: Support access filter to /dev/mem interface · 235d074f
      Huacai Chen authored
      Accidental access to /dev/mem is obviously disastrous, but specific
      access can be used by people debugging the kernel. So select GENERIC_
      LIB_DEVMEM_IS_ALLOWED, as well as define ARCH_HAS_VALID_PHYS_ADDR_RANGE
      and related helpers, to support access filter to /dev/mem interface.
      Signed-off-by: default avatarWeihao Li <liweihao@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      235d074f
    • Huacai Chen's avatar
      LoongArch: Refactor cache probe and flush methods · b61a40af
      Huacai Chen authored
      Current cache probe and flush methods have some drawbacks:
      1, Assume there are 3 cache levels and only 3 levels;
      2, Assume L1 = I + D, L2 = V, L3 = S, V is exclusive, S is inclusive.
      
      However, the fact is I + D, I + D + V, I + D + S and I + D + V + S are
      all valid. So, refactor the cache probe and flush methods to adapt more
      types of cache hierarchy.
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      b61a40af
    • Rui Wang's avatar
      LoongArch: mm: Refactor TLB exception handlers · a2a84e36
      Rui Wang authored
      This patch simplifies TLB load, store and modify exception handlers:
      
      1. Reduce instructions, such as alu/csr and memory access;
      2. Execute tlb search instruction only in the fast path;
      3. Return directly from the fast path for both normal and huge pages;
      4. Re-tab the assembly for better vertical alignment.
      
      And fixes the concurrent modification issue of fast path for huge pages.
      
      This issue will occur in the following steps:
      
         CPU-1 (In TLB exception)         CPU-2 (In THP splitting)
      1: Load PMD entry (HUGE=1)
      2: Goto huge path
      3:                                  Store PMD entry (HUGE=0)
      4: Reload PMD entry (HUGE=0)
      5: Fill TLB entry (PA is incorrect)
      
      This patch also slightly improves the TLB processing performance:
      
      * Normal pages: 2.15%, Huge pages: 1.70%.
      
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
        #include <sys/mman.h>
      
        int main(int argc, char *argv[])
        {
              size_t page_size;
              size_t mem_size;
              size_t off;
              void *base;
              int flags;
              int i;
      
              if (argc < 2) {
                      fprintf(stderr, "%s MEM_SIZE [HUGE]\n", argv[0]);
                      return -1;
              }
      
              page_size = sysconf(_SC_PAGESIZE);
              flags = MAP_PRIVATE | MAP_ANONYMOUS;
              mem_size = strtoul(argv[1], NULL, 10);
              if (argc > 2)
                      flags |= MAP_HUGETLB;
      
              for (i = 0; i < 10; i++) {
                      base = mmap(NULL, mem_size, PROT_READ, flags, -1, 0);
                      if (base == MAP_FAILED) {
                              fprintf(stderr, "Map memory failed!\n");
                              return -1;
                      }
      
                      for (off = 0; off < mem_size; off += page_size)
                              *(volatile int *)(base + off);
      
                      munmap(base, mem_size);
              }
      
              return 0;
        }
      Signed-off-by: default avatarRui Wang <wangrui@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      a2a84e36
    • Xi Ruoyao's avatar
      LoongArch: Support R_LARCH_GOT_PC_{LO12,HI20} in modules · 59b3d4a9
      Xi Ruoyao authored
      GCC >= 13 and GNU assembler >= 2.40 use these relocations to address
      external symbols, so we need to add them.
      
      Let the module loader emit GOT entries for data symbols so we would be
      able to handle GOT relocations. The GOT entry is just the data's symbol
      address.
      
      In module.lds, emit a stub .got section for a section header entry. The
      actual content of the section entry will be filled at runtime by module_
      frob_arch_sections().
      Tested-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      59b3d4a9
    • Xi Ruoyao's avatar
      LoongArch: Support PC-relative relocations in modules · 9bd1e380
      Xi Ruoyao authored
      Binutils >= 2.40 uses R_LARCH_B26 instead of R_LARCH_SOP_PUSH_PLT_PCREL,
      and R_LARCH_PCALA* instead of R_LARCH_SOP_PUSH_PCREL.
      
      Handle R_LARCH_B26 and R_LARCH_PCALA* in the module loader. For R_LARCH_
      B26, also create a PLT entry as needed.
      Tested-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      9bd1e380
    • Xi Ruoyao's avatar
      LoongArch: Define ELF relocation types added in ABIv2.0 · 0a75e5d1
      Xi Ruoyao authored
      These relocation types are used by GNU binutils >= 2.40 and GCC >= 13.
      Add their definitions so we will be able to use them in later patches.
      
      Link: https://github.com/loongson/LoongArch-Documentation/pull/57Tested-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      0a75e5d1
    • Xi Ruoyao's avatar
      LoongArch: Adjust symbol addressing for AS_HAS_EXPLICIT_RELOCS · 11cd8a64
      Xi Ruoyao authored
      If explicit relocation hints are used by the toolchain, -Wa,-mla-*
      options will be useless for the C code. So only use them for the
      !CONFIG_AS_HAS_EXPLICIT_RELOCS case.
      
      Replace "la" with "la.pcrel" in head.S to keep the semantic consistent
      with new and old toolchains for the low level startup code.
      
      For per-CPU variables, the "address" of the symbol is actually an offset
      from $r21. The value is near the loading address of main kernel image,
      but far from the loading address of modules. So we use model("extreme")
      attibute to tell the compiler that a PC-relative addressing with 32-bit
      offset is not sufficient for local per-CPU variables.
      
      The behavior with different assemblers and compilers are summarized in
      the following table:
      
      AS has            CC has
      explicit relocs   explicit relocs * Behavior
      ==============================================================
      No                No                Use la.* macros.
                                          No change from Linux 6.0.
      --------------------------------------------------------------
      No                Yes               Disable explicit relocs.
                                          No change from Linux 6.0.
      --------------------------------------------------------------
      Yes               No                Not supported.
      --------------------------------------------------------------
      Yes               Yes               Enable explicit relocs.
                                          No -Wa,-mla* options used.
      ==============================================================
      *: We assume CC must have model attribute if it has explicit relocs.
         Both features are added in GCC 13 development cycle, so any GCC
         release >= 13 should be OK. Using early GCC 13 development snapshots
         may produce modules with unsupported relocations.
      
      Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f09482a
      Link: https://gcc.gnu.org/r13-1834
      Link: https://gcc.gnu.org/r13-2199Tested-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      11cd8a64
    • Xi Ruoyao's avatar
      LoongArch: Add Kconfig option AS_HAS_EXPLICIT_RELOCS · 0d8dad70
      Xi Ruoyao authored
      GNU as >= 2.40 and GCC >= 13 will support using explicit relocation
      hints in the assembly code, instead of la.* macros. The usage of
      explicit relocation hints can improve code generation so it's enabled
      by default by GCC >= 13.
      
      Introduce a Kconfig option AS_HAS_EXPLICIT_RELOCS as the switch for
      "use explicit relocation hints or not".
      Tested-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      0d8dad70
    • Colin Ian King's avatar
      LoongArch: Kconfig: Fix spelling mistake "delibrately" -> "deliberately" · 9550dfde
      Colin Ian King authored
      There is a spelling mistake in a commented section. Fix it.
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      9550dfde
    • Huacai Chen's avatar
      LoongArch: Mark __xchg() and __cmpxchg() as __always_inline · ddf50271
      Huacai Chen authored
      Commit ac7c3e4f ("compiler: enable CONFIG_OPTIMIZE_INLINING
      forcibly") allows compiler to uninline functions marked as 'inline'.
      In case of __xchg()/__cmpxchg() this would cause to reference
      BUILD_BUG(), which is an error case for catching bugs and will not
      happen for correct code, if __xchg()/__cmpxchg() is inlined.
      
      This bug can be produced with CONFIG_DEBUG_SECTION_MISMATCH enabled,
      and the solution is similar to below commits:
      46f16195 ("MIPS: include: Mark __xchg as __always_inline"),
      88356d09 ("MIPS: include: Mark __cmpxchg as __always_inline").
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      ddf50271
    • Huacai Chen's avatar
      LoongArch: Flush TLB earlier at initialization · 1299a129
      Huacai Chen authored
      Move local_flush_tlb_all() earlier (just after setup_ptwalker() and
      before page allocation). This can avoid stale TLB entries misguiding
      the later page allocation. Without this patch the second kernel of
      kexec/kdump fails to boot SMP.
      
      BTW, move output_pgtable_bits_defines() into tlb_init() since it has
      nothing to do with tlb handler setup.
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      1299a129
    • Tiezhu Yang's avatar
      LoongArch: Do not create sysfs control file for io master CPUs · a522b7ad
      Tiezhu Yang authored
      Now io master CPUs are not hotpluggable on LoongArch, but in the current
      code only /sys/devices/system/cpu/cpu0/online is not created. Let us set
      the hotpluggable field of all the io master CPUs as 0, then prevent to
      create sysfs control file for all the io master CPUs which confuses some
      user space tools. This is similar with commit 9cce844a ("MIPS: CPU#0
      is not hotpluggable").
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      a522b7ad
    • Jianmin Lv's avatar
      LoongArch: Fix cpu name after CPU-hotplug · 4b2edd38
      Jianmin Lv authored
      Don't overwrite the SMBIOS-provided CPU name on coming back from CPU-
      hotplug (including S3/S4) if it is already initialized.
      Reviewed-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarJianmin Lv <lvjianmin@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4b2edd38
    • Thomas Gleixner's avatar
      Merge tag 'irqchip-fixes-6.1-1' of... · b8d49bcd
      Thomas Gleixner authored
      Merge tag 'irqchip-fixes-6.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/core
      
      Pull irqchip fixes from Marc Zyngier:
      
        - Fix IMX-MU Kconfig, keeping it private to IMX
      
        - Fix a register offset for the same IMX-MU driver
      
        - Fix the ls-extirq irqchip driver that would use the wrong
          flavour of spinlocks
      
      Link: https://lore.kernel.org/r/20221012075125.1244143-1-maz@kernel.org
      b8d49bcd
    • Geert Uytterhoeven's avatar
      irqchip: IMX_MU_MSI should depend on ARCH_MXC · 6c9f7434
      Geert Uytterhoeven authored
      The Freescale/NXP i.MX Messaging Unit is only present on Freescale/NXP
      i.MX SoCs.  Hence add a dependency on ARCH_MXC, to prevent asking the
      user about this driver when configuring a kernel without Freescale/NXP
      i.MX SoC family support.
      
      While at it, expand "MU" to "Messaging Unit" in the help text.
      
      Fixes: 70afdab9 ("irqchip: Add IMX MU MSI controller driver")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/7f3bd932614ddbff46a1b750ef45b231130364ad.1664900434.git.geert+renesas@glider.be
      6c9f7434
    • Colin Ian King's avatar
      7880672b
    • Linus Torvalds's avatar
      Merge tag 'memblock-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock · 49da0700
      Linus Torvalds authored
      Pull memblock updates from Mike Rapoport:
       "Test suite improvements:
      
         - Added verification that memblock allocations zero the allocated
           memory
      
         - Added more test cases for memblock_add(), memblock_remove(),
           memblock_reserve() and memblock_free()
      
         - Added tests for memblock_*_raw() family
      
         - Added tests for NUMA-aware allocations in memblock_alloc_try_nid()
           and memblock_alloc_try_nid_raw()"
      
      * tag 'memblock-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
        memblock tests: add generic NUMA tests for memblock_alloc_try_nid*
        memblock tests: add bottom-up NUMA tests for memblock_alloc_try_nid*
        memblock tests: add top-down NUMA tests for memblock_alloc_try_nid*
        memblock tests: add simulation of physical memory with multiple NUMA nodes
        memblock_tests: move variable declarations to single block
        memblock tests: remove 'cleared' from comment blocks
        memblock tests: add tests for memblock_trim_memory
        memblock tests: add tests for memblock_*bottom_up functions
        memblock tests: update alloc_nid_api to test memblock_alloc_try_nid_raw
        memblock tests: update alloc_api to test memblock_alloc_raw
        memblock tests: add additional tests for basic api and memblock_alloc
        memblock tests: add labels to verbose output for generic alloc tests
        memblock tests: update zeroed memory check for memblock_alloc_* tests
        memblock tests: update tests to check if memblock_alloc zeroed memory
        memblock tests: update reference to obsolete build option in comments
        memblock tests: add command line help option
      49da0700