Skip to content
  1. Mar 16, 2022
    • Jarkko Sakkinen's avatar
      x86/sgx: Free backing memory after faulting the enclave page · 248c6347
      Jarkko Sakkinen authored
      commit 08999b24 upstream.
      
      There is a limited amount of SGX memory (EPC) on each system.  When that
      memory is used up, SGX has its own swapping mechanism which is similar
      in concept but totally separate from the core mm/* code.  Instead of
      swapping to disk, SGX swaps from EPC to normal RAM.  That normal RAM
      comes from a shared memory pseudo-file and can itself be swapped by the
      core mm code.  There is a hierarchy like this:
      
      	EPC <-> shmem <-> disk
      
      After data is swapped back in from shmem to EPC, the shmem backing
      storage needs to be freed.  Currently, the backing shmem is not freed.
      This effectively wastes the shmem while the enclave is running.  The
      memory is recovered when the enclave is destroyed and the backing
      storage freed.
      
      Sort this out by freeing memory with shmem_truncate_range(), as soon as
      a page is faulted back to the EPC.  In addition, free the memory for
      PCMD pages as soon as all PCMD's in a page have been marked as unused
      by zeroing its contents.
      
      Cc: stable@vger.kernel.org
      Fixes: 1728ab54
      
       ("x86/sgx: Add a page reclaimer")
      Reported-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20220303223859.273187-1-jarkko@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      248c6347
    • Peter Zijlstra's avatar
      x86/module: Fix the paravirt vs alternative order · 173dc5ec
      Peter Zijlstra authored
      commit 5adf3494 upstream.
      
      Ever since commit
      
        4e629211 ("x86/paravirt: Add new features for paravirt patching")
      
      there is an ordering dependency between patching paravirt ops and
      patching alternatives, the module loader still violates this.
      
      Fixes: 4e629211
      
       ("x86/paravirt: Add new features for paravirt patching")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220303112825.068773913@infradead.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      173dc5ec
    • Ross Philipson's avatar
      x86/boot: Add setup_indirect support in early_memremap_is_setup_data() · ba4b13aa
      Ross Philipson authored
      commit 445c1470 upstream.
      
      The x86 boot documentation describes the setup_indirect structures and
      how they are used. Only one of the two functions in ioremap.c that needed
      to be modified to be aware of the introduction of setup_indirect
      functionality was updated. Adds comparable support to the other function
      where it was missing.
      
      Fixes: b3c72fc9
      
       ("x86/boot: Introduce setup_indirect")
      Signed-off-by: default avatarRoss Philipson <ross.philipson@oracle.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/1645668456-22036-3-git-send-email-ross.philipson@oracle.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba4b13aa
    • Ross Philipson's avatar
      x86/boot: Fix memremap of setup_indirect structures · b46bfa5c
      Ross Philipson authored
      commit 7228918b upstream.
      
      As documented, the setup_indirect structure is nested inside
      the setup_data structures in the setup_data list. The code currently
      accesses the fields inside the setup_indirect structure but only
      the sizeof(struct setup_data) is being memremapped. No crash
      occurred but this is just due to how the area is remapped under the
      covers.
      
      Properly memremap both the setup_data and setup_indirect structures
      in these cases before accessing them.
      
      Fixes: b3c72fc9
      
       ("x86/boot: Introduce setup_indirect")
      Signed-off-by: default avatarRoss Philipson <ross.philipson@oracle.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarDaniel Kiper <daniel.kiper@oracle.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/1645668456-22036-2-git-send-email-ross.philipson@oracle.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b46bfa5c
    • David Howells's avatar
      watch_queue: Make comment about setting ->defunct more accurate · ab36cca5
      David Howells authored
      commit 4edc0760 upstream.
      
      watch_queue_clear() has a comment stating that setting ->defunct to true
      preventing new additions as well as preventing notifications.  Whilst
      the latter is true, the first bit is superfluous since at the time this
      function is called, the pipe cannot be accessed to add new event
      sources.
      
      Remove the "new additions" bit from the comment.
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab36cca5
    • David Howells's avatar
      watch_queue: Fix lack of barrier/sync/lock between post and read · 36198e39
      David Howells authored
      commit 2ed147f0 upstream.
      
      There's nothing to synchronise post_one_notification() versus
      pipe_read().  Whilst posting is done under pipe->rd_wait.lock, the
      reader only takes pipe->mutex which cannot bar notification posting as
      that may need to be made from contexts that cannot sleep.
      
      Fix this by setting pipe->head with a barrier in post_one_notification()
      and reading pipe->head with a barrier in pipe_read().
      
      If that's not sufficient, the rd_wait.lock will need to be taken,
      possibly in a ->confirm() op so that it only applies to notifications.
      The lock would, however, have to be dropped before copy_page_to_iter()
      is invoked.
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      36198e39
    • David Howells's avatar
      watch_queue: Free the alloc bitmap when the watch_queue is torn down · d7e05190
      David Howells authored
      commit 7ea1a012 upstream.
      
      Free the watch_queue note allocation bitmap when the watch_queue is
      destroyed.
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7e05190
    • David Howells's avatar
      watch_queue: Fix the alloc bitmap size to reflect notes allocated · 6cb5c7e1
      David Howells authored
      commit 3b4c0371 upstream.
      
      Currently, watch_queue_set_size() sets the number of notes available in
      wqueue->nr_notes according to the number of notes allocated, but sets
      the size of the bitmap to the unrounded number of notes originally asked
      for.
      
      Fix this by setting the bitmap size to the number of notes we're
      actually going to make available (ie. the number allocated).
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6cb5c7e1
    • David Howells's avatar
      watch_queue: Fix to always request a pow-of-2 pipe ring size · 2f331b8d
      David Howells authored
      commit 96a4d891 upstream.
      
      The pipe ring size must always be a power of 2 as the head and tail
      pointers are masked off by AND'ing with the size of the ring - 1.
      watch_queue_set_size(), however, lets you specify any number of notes
      between 1 and 511.  This number is passed through to pipe_resize_ring()
      without checking/forcing its alignment.
      
      Fix this by rounding the number of slots required up to the nearest
      power of two.  The request is meant to guarantee that at least that many
      notifications can be generated before the queue is full, so rounding
      down isn't an option, but, alternatively, it may be better to give an
      error if we aren't allowed to allocate that much ring space.
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f331b8d
    • David Howells's avatar
      watch_queue: Fix to release page in ->release() · 70bbc085
      David Howells authored
      commit c1853fba upstream.
      
      When a pipe ring descriptor points to a notification message, the
      refcount on the backing page is incremented by the generic get function,
      but the release function, which marks the bitmap, doesn't drop the page
      ref.
      
      Fix this by calling generic_pipe_buf_release() at the end of
      watch_queue_pipe_buf_release().
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70bbc085
    • David Howells's avatar
      watch_queue, pipe: Free watchqueue state after clearing pipe ring · eef9afda
      David Howells authored
      commit db8facfc upstream.
      
      In free_pipe_info(), free the watchqueue state after clearing the pipe
      ring as each pipe ring descriptor has a release function, and in the
      case of a notification message, this is watch_queue_pipe_buf_release()
      which tries to mark the allocation bitmap that was previously released.
      
      Fix this by moving the put of the pipe's ref on the watch queue to after
      the ring has been cleared.  We still need to call watch_queue_clear()
      before doing that to make sure that the pipe is disconnected from any
      notification sources first.
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eef9afda
    • David Howells's avatar
      watch_queue: Fix filter limit check · b36588eb
      David Howells authored
      commit c993ee0f upstream.
      
      In watch_queue_set_filter(), there are a couple of places where we check
      that the filter type value does not exceed what the type_filter bitmap
      can hold.  One place calculates the number of bits by:
      
         if (tf[i].type >= sizeof(wfilter->type_filter) * 8)
      
      which is fine, but the second does:
      
         if (tf[i].type >= sizeof(wfilter->type_filter) * BITS_PER_LONG)
      
      which is not.  This can lead to a couple of out-of-bounds writes due to
      a too-large type:
      
       (1) __set_bit() on wfilter->type_filter
       (2) Writing more elements in wfilter->filters[] than we allocated.
      
      Fix this by just using the proper WATCH_TYPE__NR instead, which is the
      number of types we actually know about.
      
      The bug may cause an oops looking something like:
      
        BUG: KASAN: slab-out-of-bounds in watch_queue_set_filter+0x659/0x740
        Write of size 4 at addr ffff88800d2c66bc by task watch_queue_oob/611
        ...
        Call Trace:
         <TASK>
         dump_stack_lvl+0x45/0x59
         print_address_description.constprop.0+0x1f/0x150
         ...
         kasan_report.cold+0x7f/0x11b
         ...
         watch_queue_set_filter+0x659/0x740
         ...
         __x64_sys_ioctl+0x127/0x190
         do_syscall_64+0x43/0x90
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
        Allocated by task 611:
         kasan_save_stack+0x1e/0x40
         __kasan_kmalloc+0x81/0xa0
         watch_queue_set_filter+0x23a/0x740
         __x64_sys_ioctl+0x127/0x190
         do_syscall_64+0x43/0x90
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
        The buggy address belongs to the object at ffff88800d2c66a0
         which belongs to the cache kmalloc-32 of size 32
        The buggy address is located 28 bytes inside of
         32-byte region [ffff88800d2c66a0, ffff88800d2c66c0)
      
      Fixes: c73be61c
      
       ("pipe: Add general notification queue support")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b36588eb
    • Russell King (Oracle)'s avatar
      ARM: fix Thumb2 regression with Spectre BHB · c21b0de7
      Russell King (Oracle) authored
      commit 6c7cb60b upstream.
      
      When building for Thumb2, the vectors make use of a local label. Sadly,
      the Spectre BHB code also uses a local label with the same number which
      results in the Thumb2 reference pointing at the wrong place. Fix this
      by changing the number used for the Spectre BHB local label.
      
      Fixes: b9baf5c8
      
       ("ARM: Spectre-BHB workaround")
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c21b0de7
    • Dima Chumak's avatar
      net/mlx5: Fix offloading with ESWITCH_IPV4_TTL_MODIFY_ENABLE · a0347a63
      Dima Chumak authored
      commit 39bab83b upstream.
      
      Only prio 1 is supported for nic mode when there is no ignore flow level
      support in firmware. But for switchdev mode, which supports fixed number
      of statically pre-allocated prios, this restriction is not relevant so
      it can be relaxed.
      
      Fixes: d671e109
      
       ("net/mlx5: Fix tc max supported prio for nic mode")
      Signed-off-by: default avatarDima Chumak <dchumak@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0347a63
    • Michael S. Tsirkin's avatar
      virtio: acknowledge all features before access · 290902a5
      Michael S. Tsirkin authored
      commit 4fa59ede upstream.
      
      The feature negotiation was designed in a way that
      makes it possible for devices to know which config
      fields will be accessed by drivers.
      
      This is broken since commit 404123c2 ("virtio: allow drivers to
      validate features") with fallout in at least block and net.  We have a
      partial work-around in commit 2f9a174f
      
       ("virtio: write back
      F_VERSION_1 before validate") which at least lets devices find out which
      format should config space have, but this is a partial fix: guests
      should not access config space without acknowledging features since
      otherwise we'll never be able to change the config space format.
      
      To fix, split finalize_features from virtio_finalize_features and
      call finalize_features with all feature bits before validation,
      and then - if validation changed any bits - once again after.
      
      Since virtio_finalize_features no longer writes out features
      rename it to virtio_features_ok - since that is what it does:
      checks that features are ok with the device.
      
      As a side effect, this also reduces the amount of hypervisor accesses -
      we now only acknowledge features once unless we are clearing any
      features when validating (which is uncommon).
      
      IRC I think that this was more or less always the intent in the spec but
      unfortunately the way the spec is worded does not say this explicitly, I
      plan to address this at the spec level, too.
      
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 404123c2 ("virtio: allow drivers to validate features")
      Fixes: 2f9a174f
      
       ("virtio: write back F_VERSION_1 before validate")
      Cc: "Halil Pasic" <pasic@linux.ibm.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      290902a5
    • Michael S. Tsirkin's avatar
      virtio: unexport virtio_finalize_features · c6b1706d
      Michael S. Tsirkin authored
      commit 838d6d34
      
       upstream.
      
      virtio_finalize_features is only used internally within virtio.
      No reason to export it.
      
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6b1706d
    • Halil Pasic's avatar
      swiotlb: rework "fix info leak with DMA_FROM_DEVICE" · 62b27d92
      Halil Pasic authored
      commit aa6f8dcb
      
       upstream.
      
      Unfortunately, we ended up merging an old version of the patch "fix info
      leak with DMA_FROM_DEVICE" instead of merging the latest one. Christoph
      (the swiotlb maintainer), he asked me to create an incremental fix
      (after I have pointed this out the mix up, and asked him for guidance).
      So here we go.
      
      The main differences between what we got and what was agreed are:
      * swiotlb_sync_single_for_device is also required to do an extra bounce
      * We decided not to introduce DMA_ATTR_OVERWRITE until we have exploiters
      * The implantation of DMA_ATTR_OVERWRITE is flawed: DMA_ATTR_OVERWRITE
        must take precedence over DMA_ATTR_SKIP_CPU_SYNC
      
      Thus this patch removes DMA_ATTR_OVERWRITE, and makes
      swiotlb_sync_single_for_device() bounce unconditionally (that is, also
      when dir == DMA_TO_DEVICE) in order do avoid synchronising back stale
      data from the swiotlb buffer.
      
      Let me note, that if the size used with dma_sync_* API is less than the
      size used with dma_[un]map_*, under certain circumstances we may still
      end up with swiotlb not being transparent. In that sense, this is no
      perfect fix either.
      
      To get this bullet proof, we would have to bounce the entire
      mapping/bounce buffer. For that we would have to figure out the starting
      address, and the size of the mapping in
      swiotlb_sync_single_for_device(). While this does seem possible, there
      seems to be no firm consensus on how things are supposed to work.
      
      Signed-off-by: default avatarHalil Pasic <pasic@linux.ibm.com>
      Fixes: ddbd89de
      
       ("swiotlb: fix info leak with DMA_FROM_DEVICE")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62b27d92
    • Paul Semel's avatar
      arm64: kasan: fix include error in MTE functions · cf04a86d
      Paul Semel authored
      commit b859ebed
      
       upstream.
      
      Fix `error: expected string literal in 'asm'`.
      This happens when compiling an ebpf object file that includes
      `net/net_namespace.h` from linux kernel headers.
      
      Include trace:
           include/net/net_namespace.h:10
           include/linux/workqueue.h:9
           include/linux/timer.h:8
           include/linux/debugobjects.h:6
           include/linux/spinlock.h:90
           include/linux/workqueue.h:9
           arch/arm64/include/asm/spinlock.h:9
           arch/arm64/include/generated/asm/qrwlock.h:1
           include/asm-generic/qrwlock.h:14
           arch/arm64/include/asm/processor.h:33
           arch/arm64/include/asm/kasan.h:9
           arch/arm64/include/asm/mte-kasan.h:45
           arch/arm64/include/asm/mte-def.h:14
      
      Signed-off-by: default avatarPaul Semel <paul.semel@datadoghq.com>
      Fixes: 2cb34276
      
       ("arm64: kasan: simplify and inline MTE functions")
      Cc: <stable@vger.kernel.org> # 5.12.x
      Link: https://lore.kernel.org/r/bacb5387-2992-97e4-0c48-1ed925905bee@gmail.com
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf04a86d
    • Catalin Marinas's avatar
      arm64: Ensure execute-only permissions are not allowed without EPAN · 8b2dc214
      Catalin Marinas authored
      commit 6e2edd63 upstream.
      
      Commit 18107f8a
      
       ("arm64: Support execute-only permissions with
      Enhanced PAN") re-introduced execute-only permissions when EPAN is
      available. When EPAN is not available, arch_filter_pgprot() is supposed
      to change a PAGE_EXECONLY permission into PAGE_READONLY_EXEC. However,
      if BTI or MTE are present, such check does not detect the execute-only
      pgprot in the presence of PTE_GP (BTI) or MT_NORMAL_TAGGED (MTE),
      allowing the user to request PROT_EXEC with PROT_BTI or PROT_MTE.
      
      Remove the arch_filter_pgprot() function, change the default VM_EXEC
      permissions to PAGE_READONLY_EXEC and update the protection_map[] array
      at core_initcall() if EPAN is detected.
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Fixes: 18107f8a
      
       ("arm64: Support execute-only permissions with Enhanced PAN")
      Cc: <stable@vger.kernel.org> # 5.13.x
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Reviewed-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Tested-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b2dc214
    • Pali Rohár's avatar
      arm64: dts: marvell: armada-37xx: Remap IO space to bus address 0x0 · 92258a35
      Pali Rohár authored
      commit a1cc1697 upstream.
      
      Legacy and old PCI I/O based cards do not support 32-bit I/O addressing.
      
      Since commit 64f160e1
      
       ("PCI: aardvark: Configure PCIe resources from
      'ranges' DT property") kernel can set different PCIe address on CPU and
      different on the bus for the one A37xx address mapping without any firmware
      support in case the bus address does not conflict with other A37xx mapping.
      
      So remap I/O space to the bus address 0x0 to enable support for old legacy
      I/O port based cards which have hardcoded I/O ports in low address space.
      
      Note that DDR on A37xx is mapped to bus address 0x0. And mapping of I/O
      space can be set to address 0x0 too because MEM space and I/O space are
      separate and so do not conflict.
      
      Remapping IO space on Turris Mox to different address is not possible to
      due bootloader bug.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: 76f6386b ("arm64: dts: marvell: Add Aardvark PCIe support for Armada 3700")
      Cc: stable@vger.kernel.org # 64f160e1 ("PCI: aardvark: Configure PCIe resources from 'ranges' DT property")
      Cc: stable@vger.kernel.org # 514ef1e6
      
       ("arm64: dts: marvell: armada-37xx: Extend PCIe MEM space")
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      92258a35
    • Daniel Bristot de Oliveira's avatar
      tracing/osnoise: Do not unregister events twice · 4e10787d
      Daniel Bristot de Oliveira authored
      commit f0cfe17b upstream.
      
      Nicolas reported that using:
      
       # trace-cmd record -e all -M 10 -p osnoise --poll
      
      Resulted in the following kernel warning:
      
       ------------[ cut here ]------------
       WARNING: CPU: 0 PID: 1217 at kernel/tracepoint.c:404 tracepoint_probe_unregister+0x280/0x370
       [...]
       CPU: 0 PID: 1217 Comm: trace-cmd Not tainted 5.17.0-rc6-next-20220307-nico+ #19
       RIP: 0010:tracepoint_probe_unregister+0x280/0x370
       [...]
       CR2: 00007ff919b29497 CR3: 0000000109da4005 CR4: 0000000000170ef0
       Call Trace:
        <TASK>
        osnoise_workload_stop+0x36/0x90
        tracing_set_tracer+0x108/0x260
        tracing_set_trace_write+0x94/0xd0
        ? __check_object_size.part.0+0x10a/0x150
        ? selinux_file_permission+0x104/0x150
        vfs_write+0xb5/0x290
        ksys_write+0x5f/0xe0
        do_syscall_64+0x3b/0x90
        entry_SYSCALL_64_after_hwframe+0x44/0xae
       RIP: 0033:0x7ff919a18127
       [...]
       ---[ end trace 0000000000000000 ]---
      
      The warning complains about an attempt to unregister an
      unregistered tracepoint.
      
      This happens on trace-cmd because it first stops tracing, and
      then switches the tracer to nop. Which is equivalent to:
      
        # cd /sys/kernel/tracing/
        # echo osnoise > current_tracer
        # echo 0 > tracing_on
        # echo nop > current_tracer
      
      The osnoise tracer stops the workload when no trace instance
      is actually collecting data. This can be caused both by
      disabling tracing or disabling the tracer itself.
      
      To avoid unregistering events twice, use the existing
      trace_osnoise_callback_enabled variable to check if the events
      (and the workload) are actually active before trying to
      deactivate them.
      
      Link: https://lore.kernel.org/all/c898d1911f7f9303b7e14726e7cc9678fbfb4a0e.camel@redhat.com/
      Link: https://lkml.kernel.org/r/938765e17d5a781c2df429a98f0b2e7cc317b022.1646823913.git.bristot@kernel.org
      
      Cc: stable@vger.kernel.org
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Fixes: 2fac8d64
      
       ("tracing/osnoise: Allow multiple instances of the same tracer")
      Reported-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e10787d
    • Nicolas Saenz Julienne's avatar
      tracing/osnoise: Force quiescent states while tracing · d76e7558
      Nicolas Saenz Julienne authored
      commit caf4c86b upstream.
      
      At the moment running osnoise on a nohz_full CPU or uncontested FIFO
      priority and a PREEMPT_RCU kernel might have the side effect of
      extending grace periods too much. This will entice RCU to force a
      context switch on the wayward CPU to end the grace period, all while
      introducing unwarranted noise into the tracer. This behaviour is
      unavoidable as overly extending grace periods might exhaust the system's
      memory.
      
      This same exact problem is what extended quiescent states (EQS) were
      created for, conversely, rcu_momentary_dyntick_idle() emulates them by
      performing a zero duration EQS. So let's make use of it.
      
      In the common case rcu_momentary_dyntick_idle() is fairly inexpensive:
      atomically incrementing a local per-CPU counter and doing a store. So it
      shouldn't affect osnoise's measurements (which has a 1us granularity),
      so we'll call it unanimously.
      
      The uncommon case involve calling rcu_momentary_dyntick_idle() after
      having the osnoise process:
      
       - Receive an expedited quiescent state IPI with preemption disabled or
         during an RCU critical section. (activates rdp->cpu_no_qs.b.exp
         code-path).
      
       - Being preempted within in an RCU critical section and having the
         subsequent outermost rcu_read_unlock() called with interrupts
         disabled. (t->rcu_read_unlock_special.b.blocked code-path).
      
      Neither of those are possible at the moment, and are unlikely to be in
      the future given the osnoise's loop design. On top of this, the noise
      generated by the situations described above is unavoidable, and if not
      exposed by rcu_momentary_dyntick_idle() will be eventually seen in
      subsequent rcu_read_unlock() calls or schedule operations.
      
      Link: https://lkml.kernel.org/r/20220307180740.577607-1-nsaenzju@redhat.com
      
      Cc: stable@vger.kernel.org
      Fixes: bce29ac9
      
       ("trace: Add osnoise tracer")
      Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Acked-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Acked-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d76e7558
    • Emil Renner Berthing's avatar
      riscv: Fix auipc+jalr relocation range checks · 4f46ec48
      Emil Renner Berthing authored
      commit 0966d385
      
       upstream.
      
      RISC-V can do PC-relative jumps with a 32bit range using the following
      two instructions:
      
      	auipc	t0, imm20	; t0 = PC + imm20 * 2^12
      	jalr	ra, t0, imm12	; ra = PC + 4, PC = t0 + imm12
      
      Crucially both the 20bit immediate imm20 and the 12bit immediate imm12
      are treated as two's-complement signed values. For this reason the
      immediates are usually calculated like this:
      
      	imm20 = (offset + 0x800) >> 12
      	imm12 = offset & 0xfff
      
      ..where offset is the signed offset from the auipc instruction. When
      the 11th bit of offset is 0 the addition of 0x800 doesn't change the top
      20 bits and imm12 considered positive. When the 11th bit is 1 the carry
      of the addition by 0x800 means imm20 is one higher, but since imm12 is
      then considered negative the two's complement representation means it
      all cancels out nicely.
      
      However, this addition by 0x800 (2^11) means an offset greater than or
      equal to 2^31 - 2^11 would overflow so imm20 is considered negative and
      result in a backwards jump. Similarly the lower range of offset is also
      moved down by 2^11 and hence the true 32bit range is
      
      	[-2^31 - 2^11, 2^31 - 2^11)
      
      Signed-off-by: default avatarEmil Renner Berthing <kernel@esmil.dk>
      Fixes: e2c0cdfb
      
       ("RISC-V: User-facing API")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f46ec48
    • Rong Chen's avatar
      mmc: meson: Fix usage of meson_mmc_post_req() · 700b81b8
      Rong Chen authored
      commit f0d2f153
      
       upstream.
      
      Currently meson_mmc_post_req() is called in meson_mmc_request() right
      after meson_mmc_start_cmd(). This could lead to DMA unmapping before the request
      is actually finished.
      
      To fix, don't call meson_mmc_post_req() until meson_mmc_request_done().
      
      Signed-off-by: default avatarRong Chen <rong.chen@amlogic.com>
      Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
      Fixes: 79ed05e3
      
       ("mmc: meson-gx: add support for descriptor chain mode")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220216124239.4007667-1-rong.chen@amlogic.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      700b81b8
    • Jisheng Zhang's avatar
      riscv: alternative only works on !XIP_KERNEL · f10316c1
      Jisheng Zhang authored
      commit c80ee64a
      
       upstream.
      
      The alternative mechanism needs runtime code patching, it can't work
      on XIP_KERNEL. And the errata workarounds are implemented via the
      alternative mechanism. So add !XIP_KERNEL dependency for alternative
      and erratas.
      
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Fixes: 44c92257
      
       ("RISC-V: enable XIP")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f10316c1
    • Robert Hancock's avatar
      net: macb: Fix lost RX packet wakeup race in NAPI receive · c049b0b7
      Robert Hancock authored
      commit 0bf476fc upstream.
      
      There is an oddity in the way the RSR register flags propagate to the
      ISR register (and the actual interrupt output) on this hardware: it
      appears that RSR register bits only result in ISR being asserted if the
      interrupt was actually enabled at the time, so enabling interrupts with
      RSR bits already set doesn't trigger an interrupt to be raised. There
      was already a partial fix for this race in the macb_poll function where
      it checked for RSR bits being set and re-triggered NAPI receive.
      However, there was a still a race window between checking RSR and
      actually enabling interrupts, where a lost wakeup could happen. It's
      necessary to check again after enabling interrupts to see if RSR was set
      just prior to the interrupt being enabled, and re-trigger receive in that
      case.
      
      This issue was noticed in a point-to-point UDP request-response protocol
      which periodically saw timeouts or abnormally high response times due to
      received packets not being processed in a timely fashion. In many
      applications, more packets arriving, including TCP retransmissions, would
      cause the original packet to be processed, thus masking the issue.
      
      Fixes: 02f7a34f
      
       ("net: macb: Re-enable RX interrupt only when RX is done")
      Cc: stable@vger.kernel.org
      Co-developed-by: default avatarScott McNutt <scott.mcnutt@siriusxm.com>
      Signed-off-by: default avatarScott McNutt <scott.mcnutt@siriusxm.com>
      Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
      Tested-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c049b0b7
    • Dan Carpenter's avatar
      staging: gdm724x: fix use after free in gdm_lte_rx() · d39dc795
      Dan Carpenter authored
      commit fc7f750d upstream.
      
      The netif_rx_ni() function frees the skb so we can't dereference it to
      save the skb->len.
      
      Fixes: 61e12104
      
       ("staging: gdm7240: adding LTE USB driver")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20220228074331.GA13685@kili
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d39dc795
    • Hans de Goede's avatar
      staging: rtl8723bs: Fix access-point mode deadlock · eaa3d087
      Hans de Goede authored
      commit 8f434708 upstream.
      
      Commit 54659ca0 ("staging: rtl8723bs: remove possible deadlock when
      disconnect (v2)") split the locking of pxmitpriv->lock vs sleep_q/lock
      into 2 locks in attempt to fix a lockdep reported issue with the locking
      order of the sta_hash_lock vs pxmitpriv->lock.
      
      But in the end this turned out to not fully solve the sta_hash_lock issue
      so commit a7ac783c ("staging: rtl8723bs: remove a second possible
      deadlock") was added to fix this in another way.
      
      The original fix was kept as it was still seen as a good thing to have,
      but now it turns out that it creates a deadlock in access-point mode:
      
      [Feb20 23:47] ======================================================
      [  +0.074085] WARNING: possible circular locking dependency detected
      [  +0.074077] 5.16.0-1-amd64 #1 Tainted: G         C  E
      [  +0.064710] ------------------------------------------------------
      [  +0.074075] ksoftirqd/3/29 is trying to acquire lock:
      [  +0.060542] ffffb8b30062ab00 (&pxmitpriv->lock){+.-.}-{2:2}, at: rtw_xmit_classifier+0x8a/0x140 [r8723bs]
      [  +0.114921]
                    but task is already holding lock:
      [  +0.069908] ffffb8b3007ab704 (&psta->sleep_q.lock){+.-.}-{2:2}, at: wakeup_sta_to_xmit+0x3b/0x300 [r8723bs]
      [  +0.116976]
                    which lock already depends on the new lock.
      
      [  +0.098037]
                    the existing dependency chain (in reverse order) is:
      [  +0.089704]
                    -> #1 (&psta->sleep_q.lock){+.-.}-{2:2}:
      [  +0.077232]        _raw_spin_lock_bh+0x34/0x40
      [  +0.053261]        xmitframe_enqueue_for_sleeping_sta+0xc1/0x2f0 [r8723bs]
      [  +0.082572]        rtw_xmit+0x58b/0x940 [r8723bs]
      [  +0.056528]        _rtw_xmit_entry+0xba/0x350 [r8723bs]
      [  +0.062755]        dev_hard_start_xmit+0xf1/0x320
      [  +0.056381]        sch_direct_xmit+0x9e/0x360
      [  +0.052212]        __dev_queue_xmit+0xce4/0x1080
      [  +0.055334]        ip6_finish_output2+0x18f/0x6e0
      [  +0.056378]        ndisc_send_skb+0x2c8/0x870
      [  +0.052209]        ndisc_send_ns+0xd3/0x210
      [  +0.050130]        addrconf_dad_work+0x3df/0x5a0
      [  +0.055338]        process_one_work+0x274/0x5a0
      [  +0.054296]        worker_thread+0x52/0x3b0
      [  +0.050124]        kthread+0x16c/0x1a0
      [  +0.044925]        ret_from_fork+0x1f/0x30
      [  +0.049092]
                    -> #0 (&pxmitpriv->lock){+.-.}-{2:2}:
      [  +0.074101]        __lock_acquire+0x10f5/0x1d80
      [  +0.054298]        lock_acquire+0xd7/0x300
      [  +0.049088]        _raw_spin_lock_bh+0x34/0x40
      [  +0.053248]        rtw_xmit_classifier+0x8a/0x140 [r8723bs]
      [  +0.066949]        rtw_xmitframe_enqueue+0xa/0x20 [r8723bs]
      [  +0.066946]        rtl8723bs_hal_xmitframe_enqueue+0x14/0x50 [r8723bs]
      [  +0.078386]        wakeup_sta_to_xmit+0xa6/0x300 [r8723bs]
      [  +0.065903]        rtw_recv_entry+0xe36/0x1160 [r8723bs]
      [  +0.063809]        rtl8723bs_recv_tasklet+0x349/0x6c0 [r8723bs]
      [  +0.071093]        tasklet_action_common.constprop.0+0xe5/0x110
      [  +0.070966]        __do_softirq+0x16f/0x50a
      [  +0.050134]        __irq_exit_rcu+0xeb/0x140
      [  +0.051172]        irq_exit_rcu+0xa/0x20
      [  +0.047006]        common_interrupt+0xb8/0xd0
      [  +0.052214]        asm_common_interrupt+0x1e/0x40
      [  +0.056381]        finish_task_switch.isra.0+0x100/0x3a0
      [  +0.063670]        __schedule+0x3ad/0xd20
      [  +0.048047]        schedule+0x4e/0xc0
      [  +0.043880]        smpboot_thread_fn+0xc4/0x220
      [  +0.054298]        kthread+0x16c/0x1a0
      [  +0.044922]        ret_from_fork+0x1f/0x30
      [  +0.049088]
                    other info that might help us debug this:
      
      [  +0.095950]  Possible unsafe locking scenario:
      
      [  +0.070952]        CPU0                    CPU1
      [  +0.054282]        ----                    ----
      [  +0.054285]   lock(&psta->sleep_q.lock);
      [  +0.047004]                                lock(&pxmitpriv->lock);
      [  +0.074082]                                lock(&psta->sleep_q.lock);
      [  +0.077209]   lock(&pxmitpriv->lock);
      [  +0.043873]
                     *** DEADLOCK ***
      
      [  +0.070950] 1 lock held by ksoftirqd/3/29:
      [  +0.049082]  #0: ffffb8b3007ab704 (&psta->sleep_q.lock){+.-.}-{2:2}, at: wakeup_sta_to_xmit+0x3b/0x300 [r8723bs]
      
      Analysis shows that in hindsight the splitting of the lock was not
      a good idea, so revert this to fix the access-point mode deadlock.
      
      Note this is a straight-forward revert done with git revert, the commented
      out "/* spin_lock_bh(&psta_bmc->sleep_q.lock); */" lines were part of the
      code before the reverted changes.
      
      Fixes: 54659ca0
      
       ("staging: rtl8723bs: remove possible deadlock when disconnect (v2)")
      Cc: stable <stable@vger.kernel.org>
      Cc: Fabio Aiuto <fabioaiuto83@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215542
      Link: https://lore.kernel.org/r/20220302101637.26542-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eaa3d087
    • Miklos Szeredi's avatar
      fuse: fix pipe buffer lifetime for direct_io · 58a9bdff
      Miklos Szeredi authored
      commit 0c4bcfde
      
       upstream.
      
      In FOPEN_DIRECT_IO mode, fuse_file_write_iter() calls
      fuse_direct_write_iter(), which normally calls fuse_direct_io(), which then
      imports the write buffer with fuse_get_user_pages(), which uses
      iov_iter_get_pages() to grab references to userspace pages instead of
      actually copying memory.
      
      On the filesystem device side, these pages can then either be read to
      userspace (via fuse_dev_read()), or splice()d over into a pipe using
      fuse_dev_splice_read() as pipe buffers with &nosteal_pipe_buf_ops.
      
      This is wrong because after fuse_dev_do_read() unlocks the FUSE request,
      the userspace filesystem can mark the request as completed, causing write()
      to return. At that point, the userspace filesystem should no longer have
      access to the pipe buffer.
      
      Fix by copying pages coming from the user address space to new pipe
      buffers.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Fixes: c3021629
      
       ("fuse: support splice() reading from fuse device")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58a9bdff
    • Miklos Szeredi's avatar
      fuse: fix fileattr op failure · d71d62b6
      Miklos Szeredi authored
      commit a679a615
      
       upstream.
      
      The fileattr API conversion broke lsattr on ntfs3g.
      
      Previously the ioctl(... FS_IOC_GETFLAGS) returned an EINVAL error, but
      after the conversion the error returned by the fuse filesystem was not
      propagated back to the ioctl() system call, resulting in success being
      returned with bogus values.
      
      Fix by checking for outarg.result in fuse_priv_ioctl(), just as generic
      ioctl code does.
      
      Reported-by: default avatarJean-Pierre André <jean-pierre.andre@wanadoo.fr>
      Fixes: 72227eac
      
       ("fuse: convert to fileattr")
      Cc: <stable@vger.kernel.org> # v5.13
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d71d62b6
    • Randy Dunlap's avatar
      ARM: Spectre-BHB: provide empty stub for non-config · 34b6fde1
      Randy Dunlap authored
      commit 68453767 upstream.
      
      When CONFIG_GENERIC_CPU_VULNERABILITIES is not set, references
      to spectre_v2_update_state() cause a build error, so provide an
      empty stub for that function when the Kconfig option is not set.
      
      Fixes this build error:
      
        arm-linux-gnueabi-ld: arch/arm/mm/proc-v7-bugs.o: in function `cpu_v7_bugs_init':
        proc-v7-bugs.c:(.text+0x52): undefined reference to `spectre_v2_update_state'
        arm-linux-gnueabi-ld: proc-v7-bugs.c:(.text+0x82): undefined reference to `spectre_v2_update_state'
      
      Fixes: b9baf5c8
      
       ("ARM: Spectre-BHB workaround")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: patches@armlinux.org.uk
      Acked-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34b6fde1
    • Mike Kravetz's avatar
      selftests/memfd: clean up mapping in mfd_fail_write · 7e4bd0cd
      Mike Kravetz authored
      [ Upstream commit fda153c8
      
       ]
      
      Running the memfd script ./run_hugetlbfs_test.sh will often end in error
      as follows:
      
          memfd-hugetlb: CREATE
          memfd-hugetlb: BASIC
          memfd-hugetlb: SEAL-WRITE
          memfd-hugetlb: SEAL-FUTURE-WRITE
          memfd-hugetlb: SEAL-SHRINK
          fallocate(ALLOC) failed: No space left on device
          ./run_hugetlbfs_test.sh: line 60: 166855 Aborted                 (core dumped) ./memfd_test hugetlbfs
          opening: ./mnt/memfd
          fuse: DONE
      
      If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will
      allocate 'just enough' pages to run the test.  In the SEAL-FUTURE-WRITE
      test the mfd_fail_write routine maps the file, but does not unmap.  As a
      result, two hugetlb pages remain reserved for the mapping.  When the
      fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb
      pages, it is short by the two reserved pages.
      
      Fix by making sure to unmap in mfd_fail_write.
      
      Link: https://lkml.kernel.org/r/20220219004340.56478-1-mike.kravetz@oracle.com
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: Joel Fernandes <joel@joelfernandes.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7e4bd0cd
    • Aneesh Kumar K.V's avatar
      selftest/vm: fix map_fixed_noreplace test failure · 2246b5eb
      Aneesh Kumar K.V authored
      [ Upstream commit f39c5800
      
       ]
      
      On the latest RHEL the test fails due to executable mapped at 256MB
      address
      
           # ./map_fixed_noreplace
          mmap() @ 0x10000000-0x10050000 p=0xffffffffffffffff result=File exists
          10000000-10010000 r-xp 00000000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10010000-10020000 r--p 00000000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10020000-10030000 rw-p 00010000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10029b90000-10029bc0000 rw-p 00000000 00:00 0                            [heap]
          7fffbb510000-7fffbb750000 r-xp 00000000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb750000-7fffbb760000 r--p 00230000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb760000-7fffbb770000 rw-p 00240000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb780000-7fffbb7a0000 r--p 00000000 00:00 0                          [vvar]
          7fffbb7a0000-7fffbb7b0000 r-xp 00000000 00:00 0                          [vdso]
          7fffbb7b0000-7fffbb800000 r-xp 00000000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffbb800000-7fffbb810000 r--p 00040000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffbb810000-7fffbb820000 rw-p 00050000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffd93f0000-7fffd9420000 rw-p 00000000 00:00 0                          [stack]
          Error: couldn't map the space we need for the test
      
      Fix this by finding a free address using mmap instead of hardcoding
      BASE_ADDRESS.
      
      Link: https://lkml.kernel.org/r/20220217083417.373823-1-aneesh.kumar@linux.ibm.com
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Jann Horn <jannh@google.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2246b5eb
    • Christophe Leroy's avatar
      tracing: Fix selftest config check for function graph start up test · eefb9def
      Christophe Leroy authored
      [ Upstream commit c5229a0b
      
       ]
      
      CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS is required to test
      direct tramp.
      
      Link: https://lkml.kernel.org/r/bdc7e594e13b0891c1d61bc8d56c94b1890eaed7.1640017960.git.christophe.leroy@csgroup.eu
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eefb9def
    • Daniel Bristot de Oliveira's avatar
      tracing/osnoise: Make osnoise_main to sleep for microseconds · 3237183c
      Daniel Bristot de Oliveira authored
      [ Upstream commit dd990352
      
       ]
      
      osnoise's runtime and period are in the microseconds scale, but it is
      currently sleeping in the millisecond's scale. This behavior roots in the
      usage of hwlat as the skeleton for osnoise.
      
      Make osnoise to sleep in the microseconds scale. Also, move the sleep to
      a specialized function.
      
      Link: https://lkml.kernel.org/r/302aa6c7bdf2d131719b22901905e9da122a11b2.1645197336.git.bristot@kernel.org
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3237183c
    • Sven Schnelle's avatar
      tracing: Ensure trace buffer is at least 4096 bytes large · 2a44a82a
      Sven Schnelle authored
      [ Upstream commit 7acf3a12
      
       ]
      
      Booting the kernel with 'trace_buf_size=1' give a warning at
      boot during the ftrace selftests:
      
      [    0.892809] Running postponed tracer tests:
      [    0.892893] Testing tracer function:
      [    0.901899] Callback from call_rcu_tasks_trace() invoked.
      [    0.983829] Callback from call_rcu_tasks_rude() invoked.
      [    1.072003] .. bad ring buffer .. corrupted trace buffer ..
      [    1.091944] Callback from call_rcu_tasks() invoked.
      [    1.097695] PASSED
      [    1.097701] Testing dynamic ftrace: .. filter failed count=0 ..FAILED!
      [    1.353474] ------------[ cut here ]------------
      [    1.353478] WARNING: CPU: 0 PID: 1 at kernel/trace/trace.c:1951 run_tracer_selftest+0x13c/0x1b0
      
      Therefore enforce a minimum of 4096 bytes to make the selftest pass.
      
      Link: https://lkml.kernel.org/r/20220214134456.1751749-1-svens@linux.ibm.com
      
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2a44a82a
    • Niels Dossche's avatar
      ipv6: prevent a possible race condition with lifetimes · ee89f39c
      Niels Dossche authored
      [ Upstream commit 6c0d8833
      
       ]
      
      valid_lft, prefered_lft and tstamp are always accessed under the lock
      "lock" in other places. Reading these without taking the lock may result
      in inconsistencies regarding the calculation of the valid and preferred
      variables since decisions are taken on these fields for those variables.
      
      Signed-off-by: default avatarNiels Dossche <dossche.niels@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarNiels Dossche <niels.dossche@ugent.be>
      Link: https://lore.kernel.org/r/20220223131954.6570-1-niels.dossche@ugent.be
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee89f39c
    • Marek Marczykowski-Górecki's avatar
      Revert "xen-netback: Check for hotplug-status existence before watching" · 728d6b52
      Marek Marczykowski-Górecki authored
      [ Upstream commit e8240add ]
      
      This reverts commit 2afeec08
      
      .
      
      The reasoning in the commit was wrong - the code expected to setup the
      watch even if 'hotplug-status' didn't exist. In fact, it relied on the
      watch being fired the first time - to check if maybe 'hotplug-status' is
      already set to 'connected'. Not registering a watch for non-existing
      path (which is the case if hotplug script hasn't been executed yet),
      made the backend not waiting for the hotplug script to execute. This in
      turns, made the netfront think the interface is fully operational, while
      in fact it was not (the vif interface on xen-netback side might not be
      configured yet).
      
      This was a workaround for 'hotplug-status' erroneously being removed.
      But since that is reverted now, the workaround is not necessary either.
      
      More discussion at
      https://lore.kernel.org/xen-devel/afedd7cb-a291-e773-8b0d-4db9b291fa98@ipxe.org/T/#u
      
      Signed-off-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Reviewed-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      Link: https://lore.kernel.org/r/20220222001817.2264967-2-marmarek@invisiblethingslab.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      728d6b52
    • Marek Marczykowski-Górecki's avatar
      Revert "xen-netback: remove 'hotplug-status' once it has served its purpose" · 5f469346
      Marek Marczykowski-Górecki authored
      [ Upstream commit 0f4558ae ]
      
      This reverts commit 1f256578
      
      .
      
      The 'hotplug-status' node should not be removed as long as the vif
      device remains configured. Otherwise the xen-netback would wait for
      re-running the network script even if it was already called (in case of
      the frontent re-connecting). But also, it _should_ be removed when the
      vif device is destroyed (for example when unbinding the driver) -
      otherwise hotplug script would not configure the device whenever it
      re-appear.
      
      Moving removal of the 'hotplug-status' node was a workaround for nothing
      calling network script after xen-netback module is reloaded. But when
      vif interface is re-created (on xen-netback unbind/bind for example),
      the script should be called, regardless of who does that - currently
      this case is not handled by the toolstack, and requires manual
      script call. Keeping hotplug-status=connected to skip the call is wrong
      and leads to not configured interface.
      
      More discussion at
      https://lore.kernel.org/xen-devel/afedd7cb-a291-e773-8b0d-4db9b291fa98@ipxe.org/T/#u
      
      Signed-off-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Link: https://lore.kernel.org/r/20220222001817.2264967-1-marmarek@invisiblethingslab.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f469346
    • Guchun Chen's avatar
      drm/amdgpu: bypass tiling flag check in virtual display case (v2) · cb29021b
      Guchun Chen authored
      [ Upstream commit e2b99330
      
       ]
      
      vkms leverages common amdgpu framebuffer creation, and
      also as it does not support FB modifier, there is no need
      to check tiling flags when initing framebuffer when virtual
      display is enabled.
      
      This can fix below calltrace:
      
      amdgpu 0000:00:08.0: GFX9+ requires FB check based on format modifier
      WARNING: CPU: 0 PID: 1023 at drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:1150 amdgpu_display_framebuffer_init+0x8e7/0xb40 [amdgpu]
      
      v2: check adev->enable_virtual_display instead as vkms can be
      	enabled in bare metal as well.
      
      Signed-off-by: default avatarLeslie Shi <Yuliang.Shi@amd.com>
      Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb29021b