1. 04 Feb, 2020 40 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm · d60ddd24
      Linus Torvalds authored
      Pull ARM updates from Russell King:
      
       - decompressor updates
      
       - prevention of out-of-bounds access while stacktracing
      
       - fix a section mismatch warning with free_memmap()
      
       - make kexec depend on MMU to avoid some build errors
      
       - remove swapops stubs
      
      * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm:
        ARM: 8954/1: NOMMU: remove stubs for swapops
        ARM: 8952/1: Disable kmemleak on XIP kernels
        ARM: 8951/1: Fix Kexec compilation issue.
        ARM: 8949/1: mm: mark free_memmap as __init
        ARM: 8948/1: Prevent OOB access in stacktrace
        ARM: 8945/1: decompressor: use CONFIG option instead of cc-option
        ARM: 8942/1: Revert "8857/1: efi: enable CP15 DMB instructions before cleaning the cache"
        ARM: 8941/1: decompressor: enable CP15 barrier instructions in v7 cache setup code
      d60ddd24
    • Linus Torvalds's avatar
      Merge tag 'powerpc-5.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 71c3a888
      Linus Torvalds authored
      Pull powerpc updates from Michael Ellerman:
       "A pretty small batch for us, and apologies for it being a bit late, I
        wanted to sneak Christophe's user_access_begin() series in.
      
        Summary:
      
         - Implement user_access_begin() and friends for our platforms that
           support controlling kernel access to userspace.
      
         - Enable CONFIG_VMAP_STACK on 32-bit Book3S and 8xx.
      
         - Some tweaks to our pseries IOMMU code to allow SVMs ("secure"
           virtual machines) to use the IOMMU.
      
         - Add support for CLOCK_{REALTIME/MONOTONIC}_COARSE to the 32-bit
           VDSO, and some other improvements.
      
         - A series to use the PCI hotplug framework to control opencapi
           card's so that they can be reset and re-read after flashing a new
           FPGA image.
      
        As well as other minor fixes and improvements as usual.
      
        Thanks to: Alastair D'Silva, Alexandre Ghiti, Alexey Kardashevskiy,
        Andrew Donnellan, Aneesh Kumar K.V, Anju T Sudhakar, Bai Yingjie, Chen
        Zhou, Christophe Leroy, Frederic Barrat, Greg Kurz, Jason A.
        Donenfeld, Joel Stanley, Jordan Niethe, Julia Lawall, Krzysztof
        Kozlowski, Laurent Dufour, Laurentiu Tudor, Linus Walleij, Michael
        Bringmann, Nathan Chancellor, Nicholas Piggin, Nick Desaulniers,
        Oliver O'Halloran, Peter Ujfalusi, Pingfan Liu, Ram Pai, Randy Dunlap,
        Russell Currey, Sam Bobroff, Sebastian Andrzej Siewior, Shawn
        Anastasio, Stephen Rothwell, Steve Best, Sukadev Bhattiprolu, Thiago
        Jung Bauermann, Tyrel Datwyler, Vaibhav Jain"
      
      * tag 'powerpc-5.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (131 commits)
        powerpc: configs: Cleanup old Kconfig options
        powerpc/configs/skiroot: Enable some more hardening options
        powerpc/configs/skiroot: Disable xmon default & enable reboot on panic
        powerpc/configs/skiroot: Enable security features
        powerpc/configs/skiroot: Update for symbol movement only
        powerpc/configs/skiroot: Drop default n CONFIG_CRYPTO_ECHAINIV
        powerpc/configs/skiroot: Drop HID_LOGITECH
        powerpc/configs: Drop NET_VENDOR_HP which moved to staging
        powerpc/configs: NET_CADENCE became NET_VENDOR_CADENCE
        powerpc/configs: Drop CONFIG_QLGE which moved to staging
        powerpc: Do not consider weak unresolved symbol relocations as bad
        powerpc/32s: Fix kasan_early_hash_table() for CONFIG_VMAP_STACK
        powerpc: indent to improve Kconfig readability
        powerpc: Provide initial documentation for PAPR hcalls
        powerpc: Implement user_access_save() and user_access_restore()
        powerpc: Implement user_access_begin and friends
        powerpc/32s: Prepare prevent_user_access() for user_access_end()
        powerpc/32s: Drop NULL addr verification
        powerpc/kuap: Fix set direction in allow/prevent_user_access()
        powerpc/32s: Fix bad_kuap_fault()
        ...
      71c3a888
    • Linus Torvalds's avatar
      Merge tag 'microblaze-v5.6-rc1' of git://git.monstr.eu/linux-2.6-microblaze · 153b5c56
      Linus Torvalds authored
      Pull Microblaze update from Michal Simek:
      
       - enable CMA
      
       - add support for MB v11
      
       - defconfig updates
      
       - minor fixes
      
      * tag 'microblaze-v5.6-rc1' of git://git.monstr.eu/linux-2.6-microblaze:
        microblaze: Add ID for Microblaze v11
        microblaze: Prevent the overflow of the start
        microblaze: Wire CMA allocator
        asm-generic: Make dma-contiguous.h a mandatory include/asm header
        microblaze: Sync defconfig with latest Kconfig layout
        microblaze: defconfig: Disable EXT2 driver and Enable EXT3 & EXT4 drivers
        microblaze: Align comments with register usage
      153b5c56
    • Linus Torvalds's avatar
      Merge tag 'ovl-update-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs · 7f879e1a
      Linus Torvalds authored
      Pull overlayfs update from Miklos Szeredi:
      
       - Try to preserve holes in sparse files when copying up, thus saving
         disk space and improving performance.
      
       - Fix a performance regression introduced in v4.19 by preserving
         asynchronicity of IO when fowarding to underlying layers. Add VFS
         helpers to submit async iocbs.
      
       - Fix a regression in lseek(2) introduced in v4.19 that breaks >2G
         seeks on 32bit kernels.
      
       - Fix a corner case where st_ino/st_dev was not preserved across copy
         up.
      
       - Miscellaneous fixes and cleanups.
      
      * tag 'ovl-update-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
        ovl: fix lseek overflow on 32bit
        ovl: add splice file read write helper
        ovl: implement async IO routines
        vfs: add vfs_iocb_iter_[read|write] helper functions
        ovl: layer is const
        ovl: fix corner case of non-constant st_dev;st_ino
        ovl: fix corner case of conflicting lower layer uuid
        ovl: generalize the lower_fs[] array
        ovl: simplify ovl_same_sb() helper
        ovl: generalize the lower_layers[] array
        ovl: improving copy-up efficiency for big sparse file
        ovl: use ovl_inode_lock in ovl_llseek()
        ovl: use pr_fmt auto generate prefix
        ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
      7f879e1a
    • Michal Simek's avatar
      microblaze: Add ID for Microblaze v11 · 6aa71ef9
      Michal Simek authored
      List Microblaze v11 from PVR.
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      6aa71ef9
    • Shubhrajyoti Datta's avatar
      microblaze: Prevent the overflow of the start · 061d2c1d
      Shubhrajyoti Datta authored
      In case the start + cache size is more than the max int the
      start overflows.
      Prevent the same.
      Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      061d2c1d
    • Michal Simek's avatar
      microblaze: Wire CMA allocator · 2602276d
      Michal Simek authored
      Based on commit 04e3543e ("microblaze: use the generic dma coherent
      remap allocator")
      CMA can be easily enabled by calling dma_contiguous_reserve() at the end of
      mmu_init(). High limit is end of lowmem space which is completely unused at
      this point of time.
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      2602276d
    • Michal Simek's avatar
      asm-generic: Make dma-contiguous.h a mandatory include/asm header · def3f7ce
      Michal Simek authored
      dma-continuguous.h is generic for all architectures except arm32 which has
      its own version.
      
      Similar change was done for msi.h by commit a1b39bae
      ("asm-generic: Make msi.h a mandatory include/asm header")
      Suggested-by: default avatarChristoph Hellwig <hch@infradead.org>
      Link: https://lore.kernel.org/linux-arm-kernel/20200117080446.GA8980@lst.de/T/#m92bb56b04161057635d4142e1b3b9b6b0a70122eSigned-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: Paul Walmsley <paul.walmsley@sifive.com> # for arch/riscv
      def3f7ce
    • Michal Simek's avatar
      microblaze: Sync defconfig with latest Kconfig layout · 5fefd796
      Michal Simek authored
      Layout was changed by commit 6210b640
      ("kernel-hacking: group sysrq/kgdb/ubsan into 'Generic Kernel Debugging Instruments'")
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      5fefd796
    • Manish Narani's avatar
      microblaze: defconfig: Disable EXT2 driver and Enable EXT3 & EXT4 drivers · 6162cd2b
      Manish Narani authored
      As EXT4 filesystem driver is used for handling EXT2 file systems as
      well. There is no need to enable EXT2 driver. This patch disables EXT2
      and enables EXT3/EXT4 drivers.
      Signed-off-by: default avatarManish Narani <manish.narani@xilinx.com>
      Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
      6162cd2b
    • Linus Torvalds's avatar
      Merge tag 'rproc-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc · a45ad71e
      Linus Torvalds authored
      Pull remoteproc updates from Bjorn Andersson:
       "This adds support for the Mediatek MT8183 SCP, modem remoteproc on
        Qualcomm SC7180 platform, audio and sensor remoteprocs on Qualcomm
        MSM8998 and audio, compute, modem and sensor remoteprocs on Qualcomm
        SM8150.
      
        It adds votes for necessary power-domains for all Qualcomm TrustZone
        based remoteproc instances are held, fixes a bug related to remoteproc
        drivers registering before the core has been initialized and does
        clean up the Qualcomm modem remoteproc driver"
      
      * tag 'rproc-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc: (21 commits)
        remoteproc: qcom: q6v5-mss: Improve readability of reset_assert
        remoteproc: qcom: q6v5-mss: Use regmap_read_poll_timeout
        remoteproc: qcom: q6v5-mss: Rename boot status timeout
        remoteproc: qcom: q6v5-mss: Improve readability across clk handling
        remoteproc: use struct_size() helper
        remoteproc: Initialize rproc_class before use
        rpmsg: add rpmsg support for mt8183 SCP.
        remoteproc/mediatek: add SCP support for mt8183
        dt-bindings: Add a binding for Mediatek SCP
        remoteproc: mss: q6v5-mss: Add modem support on SC7180
        dt-bindings: remoteproc: qcom: Add Q6V5 Modem PIL binding for SC7180
        remoteproc: qcom: pas: Add MSM8998 ADSP and SLPI support
        dt-bindings: remoteproc: qcom: Add ADSP and SLPI support for MSM8998 SoC
        remoteproc: q6v5-mss: Remove mem clk from the active pool
        remoteproc: qcom: Remove unneeded semicolon
        remoteproc: qcom: pas: Add auto_boot flag
        remoteproc: qcom: pas: Add SM8150 ADSP, CDSP, Modem and SLPI support
        dt-bindings: remoteproc: qcom: SM8150 Add ADSP, CDSP, MPSS and SLPI support
        remoteproc: qcom: pas: Vote for active/proxy power domains
        dt-bindings: remoteproc: qcom: Add power-domain bindings for Q6V5 PAS
        ...
      a45ad71e
    • Linus Torvalds's avatar
      Merge tag 'hwlock-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc · 68509798
      Linus Torvalds authored
      Pull hwspinlock updates from Bjorn Andersson:
       "This continues the transition of drivers to device managed resources
        and removal of unnecessary PM runtime integration, with cleanups to
        the SIRF, OMAP and Qualcomm hwspinlock drivers.
      
        It also adds Baolin as reviewer in MAINTAINERS"
      
      * tag 'hwlock-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc:
        hwspinlock: sirf: Use devm_hwspin_lock_register() to register hwlock controller
        hwspinlock: sirf: Remove redundant PM runtime functions
        hwspinlock: sirf: Change to use devm_platform_ioremap_resource()
        hwspinlock: omap: Use devm_kzalloc() to allocate memory
        hwspinlock: omap: Change to use devm_platform_ioremap_resource()
        hwspinlock: qcom: Use devm_hwspin_lock_register() to register hwlock controller
        hwspinlock: qcom: Remove redundant PM runtime functions
        hwspinlock: stm32: convert to devm_platform_ioremap_resource
        MAINTAINERS: Add myself as reviewer for the hwspinlock subsystem
      68509798
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · cc12071f
      Linus Torvalds authored
      Merge more updates from Andrew Morton:
       "The rest of MM and the rest of everything else: hotfixes, ipc, misc,
        procfs, lib, cleanups, arm"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (67 commits)
        ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
        treewide: remove redundant IS_ERR() before error code check
        include/linux/cpumask.h: don't calculate length of the input string
        lib: new testcases for bitmap_parse{_user}
        lib: rework bitmap_parse()
        lib: make bitmap_parse_user a wrapper on bitmap_parse
        lib: add test for bitmap_parse()
        bitops: more BITS_TO_* macros
        lib/string: add strnchrnul()
        proc: convert everything to "struct proc_ops"
        proc: decouple proc from VFS with "struct proc_ops"
        asm-generic/tlb: provide MMU_GATHER_TABLE_FREE
        asm-generic/tlb: rename HAVE_MMU_GATHER_NO_GATHER
        asm-generic/tlb: rename HAVE_MMU_GATHER_PAGE_SIZE
        asm-generic/tlb: rename HAVE_RCU_TABLE_FREE
        asm-generic/tlb: add missing CONFIG symbol
        asm-gemeric/tlb: remove stray function declarations
        asm-generic/tlb: avoid potential double flush
        mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
        powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case
        ...
      cc12071f
    • Linus Torvalds's avatar
      Merge tag 'drm-next-2020-02-04' of git://anongit.freedesktop.org/drm/drm · 9717c1ce
      Linus Torvalds authored
      Pull drm ttm/mm updates from Dave Airlie:
       "Thomas Hellstrom has some more changes to the TTM layer that needed a
        patch to the mm subsystem.
      
        This adds a new mm API vmf_insert_mixed_prot to avoid an ugly hack
        that has limitations in the TTM layer"
      
      * tag 'drm-next-2020-02-04' of git://anongit.freedesktop.org/drm/drm:
        mm, drm/ttm: Fix vm page protection handling
        mm: Add a vmf_insert_mixed_prot() function
      9717c1ce
    • Linus Torvalds's avatar
      Merge tag 'tag-chrome-platform-for-v5.6' of... · 79703e01
      Linus Torvalds authored
      Merge tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux
      
      Pull chrome platform updates from Benson Leung:
       "CrOS EC:
      
         - Refactoring of some of cros_ec's headers:
      
           include/linux/mfd/cros_ec.h now removed, new cros_ec.h added to
           drivers/platform/chrome which contains shared operations of cros_ec
           transport drivers.
      
         - Response tracing in cros_ec_proto
      
        Wilco EC:
      
         - Fix unregistration order.
      
         - Fix keyboard backlight probing on systems without keyboard
           backlight
      
         - Minor cleanup (newlines in printks, COMPILE_TEST)
      
        Misc:
      
         - chromeos_laptop converted to use i2c_new_scanned_device instead of
           i2c_new_probed_device"
      
      * tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
        platform/chrome: cros_ec: Match implementation with headers
        platform/chrome: cros_ec: Drop unaligned.h include
        platform/chrome: wilco_ec: Allow wilco to be compiled in COMPILE_TEST
        platform/chrome: wilco_ec: Add newlines to printks
        platform/chrome: wilco_ec: Fix unregistration order
        cros_ec: treewide: Remove 'include/linux/mfd/cros_ec.h'
        platform/chrome: cros_ec_ishtp: Make init_lock static
        platform/chrome: chromeos_laptop: Convert to i2c_new_scanned_device
        platform/chrome: cros_ec_lpc: Use platform_get_irq_optional() for optional IRQs
        platform/chrome: cros_ec_proto: Add response tracing
        platform/chrome: cros_ec_trace: Match trace commands with EC commands
      79703e01
    • Linus Torvalds's avatar
      Merge tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux · eadc4e40
      Linus Torvalds authored
      Pull RTC updates from Alexandre Belloni:
       "The VL_READ and VL_CLR ioctls have been reworked to be more useful.
        This will not break userspace as there are very few users and they are
        using the integer value as a boolean.
      
        Apart from that, two drivers were reworked and a few fixes here and
        there for a net reduction of number of lines.
      
        Summary:
      
        Subsystem:
         - the VL_READ and VL_CLR ioctls are now documented and their behavior
           is unified across all the drivers.
         - RTC_I2C_AND_SPI Kconfig option rework to avoid selecting both
           REGMAP_I2C and REGMAP_SPI unecessarily.
      
        Drivers:
         - at91rm9200: remove deprecated procfs, add sam9x60, sama5d4 and
           sama5d2 compatibles.
         - cmos: solve lost interrupts issue on MS Surface 3
         - hym8563: return proper errno when time is invalid
         - rv3029: many fixes, nvram support"
      
      * tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (63 commits)
        dt-bindings: rtc: at91rm9200: document clocks property
        rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed
        rtc: Kconfig: select REGMAP_I2C when necessary
        rtc: Kconfig: properly indent sd3078 entry
        rtc: cmos: Refactor code by using the new dmi_get_bios_year() helper
        rtc: cmos: Use predefined value for RTC IRQ on legacy x86
        rtc: cmos: Stop using shared IRQ
        rtc: tps6586x: Use IRQ_NOAUTOEN flag
        rtc: at91rm9200: use FIELD_PREP/FIELD_GET
        rtc: at91rm9200: avoid time readout in at91_rtc_setalarm
        rtc: at91rm9200: move register definitions to C file
        rtc: at91rm9200: add sama5d4 and sama5d2 compatibles
        dt-bindings: rtc: at91rm9200: convert bindings to json-schema
        rtc: at91rm9200: remove procfs information
        dt-bindings: atmel, at91rm9200-rtc: add microchip, sam9x60-rtc
        rtc: pcf8563: Use BIT
        rtc: moxart: Convert to SPDX identifier
        rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv
        rtc: rx8025: Remove struct i2c_client from struct rx8025_data
        rtc: hym8563: Read the valid flag directly instead of caching it
        ...
      eadc4e40
    • Chen-Yu Tsai's avatar
      ARM: dma-api: fix max_pfn off-by-one error in __dma_supported() · f3cc4e1d
      Chen-Yu Tsai authored
      max_pfn, as set in arch/arm/mm/init.c:
      
          static void __init find_limits(unsigned long *min,
      				   unsigned long *max_low,
      				   unsigned long *max_high)
          {
      	    *max_low = PFN_DOWN(memblock_get_current_limit());
      	    *min = PFN_UP(memblock_start_of_DRAM());
      	    *max_high = PFN_DOWN(memblock_end_of_DRAM());
          }
      
      with memblock_end_of_DRAM() pointing to the next byte after DRAM.  As
      such, max_pfn points to the PFN after the end of DRAM.
      
      Thus when using max_pfn to check DMA masks, we should subtract one when
      checking DMA ranges against it.
      
      Commit 8bf1268f ("ARM: dma-api: fix off-by-one error in
      __dma_supported()") fixed the same issue, but missed this spot.
      
      This issue was found while working on the sun4i-csi v4l2 driver on the
      Allwinner R40 SoC.  On Allwinner SoCs, DRAM is offset at 0x40000000, and
      we are starting to use of_dma_configure() with the "dma-ranges" property
      in the device tree to have the DMA API handle the offset.
      
      In this particular instance, dma-ranges was set to the same range as the
      actual available (2 GiB) DRAM.  The following error appeared when the
      driver attempted to allocate a buffer:
      
          sun4i-csi 1c09000.csi: Coherent DMA mask 0x7fffffff (pfn 0x40000-0xc0000)
          covers a smaller range of system memory than the DMA zone pfn 0x0-0xc0001
          sun4i-csi 1c09000.csi: dma_alloc_coherent of size 307200 failed
      
      Fixing the off-by-one error makes things work.
      
      Link: http://lkml.kernel.org/r/20191224030239.5656-1-wens@kernel.org
      Fixes: 11a5aa32 ("ARM: dma-mapping: check DMA mask against available memory")
      Fixes: 9f28cde0 ("ARM: another fix for the DMA mapping checks")
      Fixes: ab746573 ("ARM: dma-mapping: allow larger DMA mask than supported")
      Signed-off-by: default avatarChen-Yu Tsai <wens@csie.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f3cc4e1d
    • Masahiro Yamada's avatar
      treewide: remove redundant IS_ERR() before error code check · 45586c70
      Masahiro Yamada authored
      'PTR_ERR(p) == -E*' is a stronger condition than IS_ERR(p).
      Hence, IS_ERR(p) is unneeded.
      
      The semantic patch that generates this commit is as follows:
      
      // <smpl>
      @@
      expression ptr;
      constant error_code;
      @@
      -IS_ERR(ptr) && (PTR_ERR(ptr) == - error_code)
      +PTR_ERR(ptr) == - error_code
      // </smpl>
      
      Link: http://lkml.kernel.org/r/20200106045833.1725-1-masahiroy@kernel.orgSigned-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Cc: Julia Lawall <julia.lawall@lip6.fr>
      Acked-by: Stephen Boyd <sboyd@kernel.org> [drivers/clk/clk.c]
      Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> [GPIO]
      Acked-by: Wolfram Sang <wsa@the-dreams.de> [drivers/i2c]
      Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> [acpi/scan.c]
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Cc: Eric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      45586c70
    • Yury Norov's avatar
      include/linux/cpumask.h: don't calculate length of the input string · 190535f7
      Yury Norov authored
      New design of inner bitmap_parse() allows to avoid calculating the size of
      a null-terminated string.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-8-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      190535f7
    • Yury Norov's avatar
      lib: new testcases for bitmap_parse{_user} · 809e308f
      Yury Norov authored
      New version of bitmap_parse() is unified with bitmap_parse_list(),
      and therefore:
      
      - weakens rules on whitespaces and commas between hex chunks;
      
      - in addition to
      
      - allows passing UINT_MAX or any other big number as the length of input
        string instead of actual string length.
      
      The patch covers the cases.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-7-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      809e308f
    • Yury Norov's avatar
      lib: rework bitmap_parse() · 2d626158
      Yury Norov authored
      bitmap_parse() is ineffective and full of opaque variables and opencoded
      parts.  It leads to hard understanding and usage of it.  This rework
      includes:
      
      - remove bitmap_shift_left() call from the cycle.  Now it makes the
        complexity of the algorithm as O(nbits^2).  In the suggested approach
        the input string is parsed in reverse direction, so no shifts needed;
      
      - relax requirement on a single comma and no white spaces between
        chunks.  It is considered useful in scripting, and it aligns with
        bitmap_parselist();
      
      - split bitmap_parse() to small readable helpers;
      
      - make an explicit calculation of the end of input line at the
        beginning, so users of the bitmap_parse() won't bother doing this.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-6-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2d626158
    • Yury Norov's avatar
      lib: make bitmap_parse_user a wrapper on bitmap_parse · e66eda06
      Yury Norov authored
      Currently we parse user data byte after byte which leads to
      overcomplicating of parsing algorithm.  There are no performance critical
      users of bitmap_parse_user(), and so we can duplicate user data to kernel
      buffer and simply call bitmap_parselist().  This rework lets us unify and
      simplify bitmap_parse() and bitmap_parse_user(), which is done in the
      following patch.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-5-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e66eda06
    • Yury Norov's avatar
      lib: add test for bitmap_parse() · 7eb2e94e
      Yury Norov authored
      The test is derived from bitmap_parselist() NO_LEN is reserved for use in
      following patches.
      
      [yury.norov@gmail.com: fix rebase issue]
        Link: http://lkml.kernel.org/r/20200102182659.6685-1-yury.norov@gmail.com
      [andriy.shevchenko@linux.intel.com: fix address space when test user buffer]
        Link: http://lkml.kernel.org/r/20200109103601.45929-2-andriy.shevchenko@linux.intel.com
      Link: http://lkml.kernel.org/r/20200102043031.30357-4-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7eb2e94e
    • Yury Norov's avatar
      bitops: more BITS_TO_* macros · 0bddc1bd
      Yury Norov authored
      Introduce BITS_TO_U64, BITS_TO_U32 and BITS_TO_BYTES as they are handy in
      the following patches (BITS_TO_U32 specifically).  Reimplement tools/
      version of the macros according to the kernel implementation.
      
      Also fix indentation for BITS_PER_TYPE definition.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-3-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0bddc1bd
    • Yury Norov's avatar
      lib/string: add strnchrnul() · 0bee0cec
      Yury Norov authored
      Patch series "lib: rework bitmap_parse", v5.
      
      Similarl to the recently revisited bitmap_parselist(), bitmap_parse() is
      ineffective and overcomplicated.  This series reworks it, aligns its
      interface with bitmap_parselist() and makes it simpler to use.
      
      The series also adds a test for the function and fixes usage of it in
      cpumask_parse() according to the new design - drops the calculating of
      length of an input string.
      
      bitmap_parse() takes the array of numbers to be put into the map in the BE
      order which is reversed to the natural LE order for bitmaps.  For example,
      to construct bitmap containing a bit on the position 42, we have to put a
      line '400,0'.  Current implementation reads chunk one by one from the
      beginning ('400' before '0') and makes bitmap shift after each successful
      parse.  It makes the complexity of the whole process as O(n^2).  We can do
      it in reverse direction ('0' before '400') and avoid shifting, but it
      requires reverse parsing helpers.
      
      This patch (of 7):
      
      New function works like strchrnul() with a length limited string.
      
      Link: http://lkml.kernel.org/r/20200102043031.30357-2-yury.norov@gmail.comSigned-off-by: default avatarYury Norov <yury.norov@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Amritha Nambiar <amritha.nambiar@intel.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: "Tobin C . Harding" <tobin@kernel.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0bee0cec
    • Alexey Dobriyan's avatar
      proc: convert everything to "struct proc_ops" · 97a32539
      Alexey Dobriyan authored
      The most notable change is DEFINE_SHOW_ATTRIBUTE macro split in
      seq_file.h.
      
      Conversion rule is:
      
      	llseek		=> proc_lseek
      	unlocked_ioctl	=> proc_ioctl
      
      	xxx		=> proc_xxx
      
      	delete ".owner = THIS_MODULE" line
      
      [akpm@linux-foundation.org: fix drivers/isdn/capi/kcapi_proc.c]
      [sfr@canb.auug.org.au: fix kernel/sched/psi.c]
        Link: http://lkml.kernel.org/r/20200122180545.36222f50@canb.auug.org.au
      Link: http://lkml.kernel.org/r/20191225172546.GB13378@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      97a32539
    • Alexey Dobriyan's avatar
      proc: decouple proc from VFS with "struct proc_ops" · d56c0d45
      Alexey Dobriyan authored
      Currently core /proc code uses "struct file_operations" for custom hooks,
      however, VFS doesn't directly call them.  Every time VFS expands
      file_operations hook set, /proc code bloats for no reason.
      
      Introduce "struct proc_ops" which contains only those hooks which /proc
      allows to call into (open, release, read, write, ioctl, mmap, poll).  It
      doesn't contain module pointer as well.
      
      Save ~184 bytes per usage:
      
      	add/remove: 26/26 grow/shrink: 1/4 up/down: 1922/-6674 (-4752)
      	Function                                     old     new   delta
      	sysvipc_proc_ops                               -      72     +72
      				...
      	config_gz_proc_ops                             -      72     +72
      	proc_get_inode                               289     339     +50
      	proc_reg_get_unmapped_area                   110     107      -3
      	close_pdeo                                   227     224      -3
      	proc_reg_open                                289     284      -5
      	proc_create_data                              60      53      -7
      	rt_cpu_seq_fops                              256       -    -256
      				...
      	default_affinity_proc_fops                   256       -    -256
      	Total: Before=5430095, After=5425343, chg -0.09%
      
      Link: http://lkml.kernel.org/r/20191225172228.GA13378@avx2Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d56c0d45
    • Peter Zijlstra's avatar
      asm-generic/tlb: provide MMU_GATHER_TABLE_FREE · 0d6e24d4
      Peter Zijlstra authored
      As described in the comment, the correct order for freeing pages is:
      
       1) unhook page
       2) TLB invalidate page
       3) free page
      
      This order equally applies to page directories.
      
      Currently there are two correct options:
      
       - use tlb_remove_page(), when all page directores are full pages and
         there are no futher contraints placed by things like software
         walkers (HAVE_FAST_GUP).
      
       - use MMU_GATHER_RCU_TABLE_FREE and tlb_remove_table() when the
         architecture does not do IPI based TLB invalidate and has
         HAVE_FAST_GUP (or software TLB fill).
      
      This however leaves architectures that don't have page based directories
      but don't need RCU in a bind.  For those, provide MMU_GATHER_TABLE_FREE,
      which provides the independent batching for directories without the
      additional RCU freeing.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-10-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0d6e24d4
    • Peter Zijlstra's avatar
      asm-generic/tlb: rename HAVE_MMU_GATHER_NO_GATHER · 580a586c
      Peter Zijlstra authored
      Towards a more consistent naming scheme.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-9-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      580a586c
    • Peter Zijlstra's avatar
      asm-generic/tlb: rename HAVE_MMU_GATHER_PAGE_SIZE · 3af4bd03
      Peter Zijlstra authored
      Towards a more consistent naming scheme.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-8-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3af4bd03
    • Peter Zijlstra's avatar
      asm-generic/tlb: rename HAVE_RCU_TABLE_FREE · ff2e6d72
      Peter Zijlstra authored
      Towards a more consistent naming scheme.
      
      [akpm@linux-foundation.org: fix sparc64 Kconfig]
      Link: http://lkml.kernel.org/r/20200116064531.483522-7-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ff2e6d72
    • Peter Zijlstra's avatar
      asm-generic/tlb: add missing CONFIG symbol · 27796d03
      Peter Zijlstra authored
      Without this the symbol will not actually end up in .config files.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-6-aneesh.kumar@linux.ibm.com
      Fixes: a30e32bd ("asm-generic/tlb: Provide generic tlb_flush() based on flush_tlb_mm()")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      27796d03
    • Peter Zijlstra's avatar
      asm-gemeric/tlb: remove stray function declarations · 491a49ff
      Peter Zijlstra authored
      We removed the actual functions a while ago.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-5-aneesh.kumar@linux.ibm.com
      Fixes: 1808d65b ("asm-generic/tlb: Remove arch_tlb*_mmu()")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      491a49ff
    • Peter Zijlstra's avatar
      asm-generic/tlb: avoid potential double flush · 0758cd83
      Peter Zijlstra authored
      Aneesh reported that:
      
      	tlb_flush_mmu()
      	  tlb_flush_mmu_tlbonly()
      	    tlb_flush()			<-- #1
      	  tlb_flush_mmu_free()
      	    tlb_table_flush()
      	      tlb_table_invalidate()
      		tlb_flush_mmu_tlbonly()
      		  tlb_flush()		<-- #2
      
      does two TLBIs when tlb->fullmm, because __tlb_reset_range() will not
      clear tlb->end in that case.
      
      Observe that any caller to __tlb_adjust_range() also sets at least one of
      the tlb->freed_tables || tlb->cleared_p* bits, and those are
      unconditionally cleared by __tlb_reset_range().
      
      Change the condition for actually issuing TLBI to having one of those bits
      set, as opposed to having tlb->end != 0.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-4-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Reported-by: default avatar"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0758cd83
    • Peter Zijlstra's avatar
      mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush · 0ed13259
      Peter Zijlstra authored
      Architectures for which we have hardware walkers of Linux page table
      should flush TLB on mmu gather batch allocation failures and batch flush.
      Some architectures like POWER supports multiple translation modes (hash
      and radix) and in the case of POWER only radix translation mode needs the
      above TLBI.  This is because for hash translation mode kernel wants to
      avoid this extra flush since there are no hardware walkers of linux page
      table.  With radix translation, the hardware also walks linux page table
      and with that, kernel needs to make sure to TLB invalidate page walk cache
      before page table pages are freed.
      
      More details in commit d86564a2 ("mm/tlb, x86/mm: Support invalidating
      TLB caches for RCU_TABLE_FREE")
      
      The changes to sparc are to make sure we keep the old behavior since we
      are now removing HAVE_RCU_TABLE_NO_INVALIDATE.  The default value for
      tlb_needs_table_invalidate is to always force an invalidate and sparc can
      avoid the table invalidate.  Hence we define tlb_needs_table_invalidate to
      false for sparc architecture.
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-3-aneesh.kumar@linux.ibm.com
      Fixes: a46cc7a9 ("powerpc/mm/radix: Improve TLB/PWC flushes")
      Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au>	[powerpc]
      Cc: <stable@vger.kernel.org>	[4.14+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0ed13259
    • Aneesh Kumar K.V's avatar
      powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case · 12e4d53f
      Aneesh Kumar K.V authored
      Patch series "Fixup page directory freeing", v4.
      
      This is a repost of patch series from Peter with the arch specific changes
      except ppc64 dropped.  ppc64 changes are added here because we are redoing
      the patch series on top of ppc64 changes.  This makes it easy to backport
      these changes.  Only the first 2 patches need to be backported to stable.
      
      The thing is, on anything SMP, freeing page directories should observe the
      exact same order as normal page freeing:
      
       1) unhook page/directory
       2) TLB invalidate
       3) free page/directory
      
      Without this, any concurrent page-table walk could end up with a
      Use-after-Free.  This is esp.  trivial for anything that has software
      page-table walkers (HAVE_FAST_GUP / software TLB fill) or the hardware
      caches partial page-walks (ie.  caches page directories).
      
      Even on UP this might give issues since mmu_gather is preemptible these
      days.  An interrupt or preempted task accessing user pages might stumble
      into the free page if the hardware caches page directories.
      
      This patch series fixes ppc64 and add generic MMU_GATHER changes to
      support the conversion of other architectures.  I haven't added patches
      w.r.t other architecture because they are yet to be acked.
      
      This patch (of 9):
      
      A followup patch is going to make sure we correctly invalidate page walk
      cache before we free page table pages.  In order to keep things simple
      enable RCU_TABLE_FREE even for !SMP so that we don't have to fixup the
      !SMP case differently in the followup patch
      
      !SMP case is right now broken for radix translation w.r.t page walk
      cache flush.  We can get interrupted in between page table free and
      that would imply we have page walk cache entries pointing to tables
      which got freed already.  Michael said "both our platforms that run on
      Power9 force SMP on in Kconfig, so the !SMP case is unlikely to be a
      problem for anyone in practice, unless they've hacked their kernel to
      build it !SMP."
      
      Link: http://lkml.kernel.org/r/20200116064531.483522-2-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      12e4d53f
    • Steven Price's avatar
      x86: mm: avoid allocating struct mm_struct on the stack · e47690d7
      Steven Price authored
      struct mm_struct is quite large (~1664 bytes) and so allocating on the
      stack may cause problems as the kernel stack size is small.
      
      Since ptdump_walk_pgd_level_core() was only allocating the structure so
      that it could modify the pgd argument we can instead introduce a pgd
      override in struct mm_walk and pass this down the call stack to where it
      is needed.
      
      Since the correct mm_struct is now being passed down, it is now also
      unnecessary to take the mmap_sem semaphore because ptdump_walk_pgd() will
      now take the semaphore on the real mm.
      
      [steven.price@arm.com: restore missed arm64 changes]
        Link: http://lkml.kernel.org/r/20200108145710.34314-1-steven.price@arm.com
      Link: http://lkml.kernel.org/r/20200108145710.34314-1-steven.price@arm.comSigned-off-by: default avatarSteven Price <steven.price@arm.com>
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexandre Ghiti <alex@ghiti.fr>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: "Liang, Kan" <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e47690d7
    • Steven Price's avatar
      mm: ptdump: reduce level numbers by 1 in note_page() · f8f0d0b6
      Steven Price authored
      Rather than having to increment the 'depth' number by 1 in ptdump_hole(),
      let's change the meaning of 'level' in note_page() since that makes the
      code simplier.
      
      Note that for x86, the level numbers were previously increased by 1 in
      commit 45dcd209 ("x86/mm/dump_pagetables: Fix printout of p4d level")
      and the comment "Bit 7 has a different meaning" was not updated, so this
      change also makes the code match the comment again.
      
      Link: http://lkml.kernel.org/r/20191218162402.45610-24-steven.price@arm.comSigned-off-by: default avatarSteven Price <steven.price@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexandre Ghiti <alex@ghiti.fr>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: "Liang, Kan" <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f8f0d0b6
    • Steven Price's avatar
      arm64: mm: display non-present entries in ptdump · 9c7869c7
      Steven Price authored
      Previously the /sys/kernel/debug/kernel_page_tables file would only show
      lines for entries present in the page tables.  However it is useful to
      also show non-present entries as this makes the size and level of the
      holes more visible.  This aligns the behaviour with x86 which also shows
      holes.
      
      Link: http://lkml.kernel.org/r/20191218162402.45610-23-steven.price@arm.comSigned-off-by: default avatarSteven Price <steven.price@arm.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexandre Ghiti <alex@ghiti.fr>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: "Liang, Kan" <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c7869c7
    • Steven Price's avatar
      arm64: mm: convert mm/dump.c to use walk_page_range() · 102f45fd
      Steven Price authored
      Now walk_page_range() can walk kernel page tables, we can switch the arm64
      ptdump code over to using it, simplifying the code.
      
      Link: http://lkml.kernel.org/r/20191218162402.45610-22-steven.price@arm.comSigned-off-by: default avatarSteven Price <steven.price@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexandre Ghiti <alex@ghiti.fr>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Jerome Glisse <jglisse@redhat.com>
      Cc: "Liang, Kan" <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      102f45fd