commit f428e49b8cb1fbd9b4b4b29ea31b6991d2ff7de1
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Aug 18 09:07:08 2021 +0200

    Linux 5.13.12
    
    Link: https://lore.kernel.org/r/20210816125444.082226187@linuxfoundation.org
    Tested-by: Fox Chen <foxhlchen@gmail.com>
    Link: https://lore.kernel.org/r/20210816171414.653076979@linuxfoundation.org
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Fox Chen <foxhlchen@gmail.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>

commit 639a033fd765ed473dfee27028df5ccbe1038a2e
Author: Maxim Levitsky <mlevitsk@redhat.com>
Date:   Mon Jul 19 16:05:00 2021 +0300

    KVM: nSVM: always intercept VMLOAD/VMSAVE when nested (CVE-2021-3656)
    
    commit c7dfa4009965a9b2d7b329ee970eb8da0d32f0bc upstream.
    
    If L1 disables VMLOAD/VMSAVE intercepts, and doesn't enable
    Virtual VMLOAD/VMSAVE (currently not supported for the nested hypervisor),
    then VMLOAD/VMSAVE must operate on the L1 physical memory, which is only
    possible by making L0 intercept these instructions.
    
    Failure to do so allowed the nested guest to run VMLOAD/VMSAVE unintercepted,
    and thus read/write portions of the host physical memory.
    
    Fixes: 89c8a4984fc9 ("KVM: SVM: Enable Virtual VMLOAD VMSAVE feature")
    
    Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a0949ee63cf95408870a564ccad163018b1a9e6b
Author: Maxim Levitsky <mlevitsk@redhat.com>
Date:   Thu Jul 15 01:56:24 2021 +0300

    KVM: nSVM: avoid picking up unsupported bits from L2 in int_ctl (CVE-2021-3653)
    
    commit 0f923e07124df069ba68d8bb12324398f4b6b709 upstream.
    
    * Invert the mask of bits that we pick from L2 in
      nested_vmcb02_prepare_control
    
    * Invert and explicitly use VIRQ related bits bitmask in svm_clear_vintr
    
    This fixes a security issue that allowed a malicious L1 to run L2 with
    AVIC enabled, which allowed the L2 to exploit the uninitialized and enabled
    AVIC to read/write the host physical memory at some offsets.
    
    Fixes: 3d6368ef580a ("KVM: SVM: Add VMRUN handler")
    Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 87421314435244676ce66ee799c54d21c942fb55
Author: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Date:   Fri Aug 13 16:54:27 2021 -0700

    kasan, slub: reset tag when printing address
    
    commit 340caf178ddc2efb0294afaf54c715f7928c258e upstream.
    
    The address still includes the tags when it is printed.  With hardware
    tag-based kasan enabled, we will get a false positive KASAN issue when
    we access metadata.
    
    Reset the tag before we access the metadata.
    
    Link: https://lkml.kernel.org/r/20210804090957.12393-3-Kuan-Ying.Lee@mediatek.com
    Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing metadata")
    Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
    Reviewed-by: Marco Elver <elver@google.com>
    Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Chinwen Chang <chinwen.chang@mediatek.com>
    Cc: Nicholas Tang <nicholas.tang@mediatek.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ac0e79584d4156d3c5c496f3d8d6c746637ef1ad
Author: Jeff Layton <jlayton@kernel.org>
Date:   Tue Aug 3 12:47:34 2021 -0400

    ceph: take snap_empty_lock atomically with snaprealm refcount change
    
    commit 8434ffe71c874b9c4e184b88d25de98c2bf5fe3f upstream.
    
    There is a race in ceph_put_snap_realm. The change to the nref and the
    spinlock acquisition are not done atomically, so you could decrement
    nref, and before you take the spinlock, the nref is incremented again.
    At that point, you end up putting it on the empty list when it
    shouldn't be there. Eventually __cleanup_empty_realms runs and frees
    it when it's still in-use.
    
    Fix this by protecting the 1->0 transition with atomic_dec_and_lock,
    and just drop the spinlock if we can get the rwsem.
    
    Because these objects can also undergo a 0->1 refcount transition, we
    must protect that change as well with the spinlock. Increment locklessly
    unless the value is at 0, in which case we take the spinlock, increment
    and then take it off the empty list if it did the 0->1 transition.
    
    With these changes, I'm removing the dout() messages from these
    functions, as well as in __put_snap_realm. They've always been racy, and
    it's better to not print values that may be misleading.
    
    Cc: stable@vger.kernel.org
    URL: https://tracker.ceph.com/issues/46419
    Reported-by: Mark Nelson <mnelson@redhat.com>
    Signed-off-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Luis Henriques <lhenriques@suse.de>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dcd02a1248cc4a6a889a1ea00734c201d14f5f1a
Author: Jeff Layton <jlayton@kernel.org>
Date:   Tue Jun 1 09:24:38 2021 -0400

    ceph: clean up locking annotation for ceph_get_snap_realm and __lookup_snap_realm
    
    commit df2c0cb7f8e8c83e495260ad86df8c5da947f2a7 upstream.
    
    They both say that the snap_rwsem must be held for write, but I don't
    see any real reason for it, and it's not currently always called that
    way.
    
    The lookup is just walking the rbtree, so holding it for read should be
    fine there. The "get" is bumping the refcount and (possibly) removing
    it from the empty list. I see no need to hold the snap_rwsem for write
    for that.
    
    Signed-off-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 36b361cb1966dea56408c2f9214def2199d13c29
Author: Jeff Layton <jlayton@kernel.org>
Date:   Tue Jun 1 08:13:38 2021 -0400

    ceph: add some lockdep assertions around snaprealm handling
    
    commit a6862e6708c15995bc10614b2ef34ca35b4b9078 upstream.
    
    Turn some comments into lockdep asserts.
    
    Signed-off-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90d21536715696df9cd0ea0f030d8551fccfede7
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Aug 12 11:18:15 2021 -0700

    KVM: x86/mmu: Protect marking SPs unsync when using TDP MMU with spinlock
    
    commit ce25681d59ffc4303321e555a2d71b1946af07da upstream.
    
    Add yet another spinlock for the TDP MMU and take it when marking indirect
    shadow pages unsync.  When using the TDP MMU and L1 is running L2(s) with
    nested TDP, KVM may encounter shadow pages for the TDP entries managed by
    L1 (controlling L2) when handling a TDP MMU page fault.  The unsync logic
    is not thread safe, e.g. the kvm_mmu_page fields are not atomic, and
    misbehaves when a shadow page is marked unsync via a TDP MMU page fault,
    which runs with mmu_lock held for read, not write.
    
    Lack of a critical section manifests most visibly as an underflow of
    unsync_children in clear_unsync_child_bit() due to unsync_children being
    corrupted when multiple CPUs write it without a critical section and
    without atomic operations.  But underflow is the best case scenario.  The
    worst case scenario is that unsync_children prematurely hits '0' and
    leads to guest memory corruption due to KVM neglecting to properly sync
    shadow pages.
    
    Use an entirely new spinlock even though piggybacking tdp_mmu_pages_lock
    would functionally be ok.  Usurping the lock could degrade performance when
    building upper level page tables on different vCPUs, especially since the
    unsync flow could hold the lock for a comparatively long time depending on
    the number of indirect shadow pages and the depth of the paging tree.
    
    For simplicity, take the lock for all MMUs, even though KVM could fairly
    easily know that mmu_lock is held for write.  If mmu_lock is held for
    write, there cannot be contention for the inner spinlock, and marking
    shadow pages unsync across multiple vCPUs will be slow enough that
    bouncing the kvm_arch cacheline should be in the noise.
    
    Note, even though L2 could theoretically be given access to its own EPT
    entries, a nested MMU must hold mmu_lock for write and thus cannot race
    against a TDP MMU page fault.  I.e. the additional spinlock only _needs_ to
    be taken by the TDP MMU, as opposed to being taken by any MMU for a VM
    that is running with the TDP MMU enabled.  Holding mmu_lock for read also
    prevents the indirect shadow page from being freed.  But as above, keep
    it simple and always take the lock.
    
    Alternative #1, the TDP MMU could simply pass "false" for can_unsync and
    effectively disable unsync behavior for nested TDP.  Write protecting leaf
    shadow pages is unlikely to noticeably impact traditional L1 VMMs, as such
    VMMs typically don't modify TDP entries, but the same may not hold true for
    non-standard use cases and/or VMMs that are migrating physical pages (from
    L1's perspective).
    
    Alternative #2, the unsync logic could be made thread safe.  In theory,
    simply converting all relevant kvm_mmu_page fields to atomics and using
    atomic bitops for the bitmap would suffice.  However, (a) an in-depth audit
    would be required, (b) the code churn would be substantial, and (c) legacy
    shadow paging would incur additional atomic operations in performance
    sensitive paths for no benefit (to legacy shadow paging).
    
    Fixes: a2855afc7ee8 ("KVM: x86/mmu: Allow parallel page faults for the TDP MMU")
    Cc: stable@vger.kernel.org
    Cc: Ben Gardon <bgardon@google.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20210812181815.3378104-1-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0f4bf029494de53c0eb7ca1a39e7d3360f638a8a
Author: Sean Christopherson <seanjc@google.com>
Date:   Thu Aug 12 11:14:13 2021 -0700

    KVM: x86/mmu: Don't leak non-leaf SPTEs when zapping all SPTEs
    
    commit 524a1e4e381fc5e7781008d5bd420fd1357c0113 upstream.
    
    Pass "all ones" as the end GFN to signal "zap all" for the TDP MMU and
    really zap all SPTEs in this case.  As is, zap_gfn_range() skips non-leaf
    SPTEs whose range exceeds the range to be zapped.  If shadow_phys_bits is
    not aligned to the range size of top-level SPTEs, e.g. 512gb with 4-level
    paging, the "zap all" flows will skip top-level SPTEs whose range extends
    beyond shadow_phys_bits and leak their SPs when the VM is destroyed.
    
    Use the current upper bound (based on host.MAXPHYADDR) to detect that the
    caller wants to zap all SPTEs, e.g. instead of using the max theoretical
    gfn, 1 << (52 - 12).  The more precise upper bound allows the TDP iterator
    to terminate its walk earlier when running on hosts with MAXPHYADDR < 52.
    
    Add a WARN on kmv->arch.tdp_mmu_pages when the TDP MMU is destroyed to
    help future debuggers should KVM decide to leak SPTEs again.
    
    The bug is most easily reproduced by running (and unloading!) KVM in a
    VM whose host.MAXPHYADDR < 39, as the SPTE for gfn=0 will be skipped.
    
      =============================================================================
      BUG kvm_mmu_page_header (Not tainted): Objects remaining in kvm_mmu_page_header on __kmem_cache_shutdown()
      -----------------------------------------------------------------------------
      Slab 0x000000004d8f7af1 objects=22 used=2 fp=0x00000000624d29ac flags=0x4000000000000200(slab|zone=1)
      CPU: 0 PID: 1582 Comm: rmmod Not tainted 5.14.0-rc2+ #420
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
      Call Trace:
       dump_stack_lvl+0x45/0x59
       slab_err+0x95/0xc9
       __kmem_cache_shutdown.cold+0x3c/0x158
       kmem_cache_destroy+0x3d/0xf0
       kvm_mmu_module_exit+0xa/0x30 [kvm]
       kvm_arch_exit+0x5d/0x90 [kvm]
       kvm_exit+0x78/0x90 [kvm]
       vmx_exit+0x1a/0x50 [kvm_intel]
       __x64_sys_delete_module+0x13f/0x220
       do_syscall_64+0x3b/0xc0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    Fixes: faaf05b00aec ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU")
    Cc: stable@vger.kernel.org
    Cc: Ben Gardon <bgardon@google.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20210812181414.3376143-2-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd043e754f4d7347cac6d78f7259b68aefb8b1a9
Author: Sean Christopherson <seanjc@google.com>
Date:   Wed Aug 11 21:56:15 2021 -0700

    KVM: nVMX: Use vmx_need_pf_intercept() when deciding if L0 wants a #PF
    
    commit 18712c13709d2de9516c5d3414f707c4f0a9c190 upstream.
    
    Use vmx_need_pf_intercept() when determining if L0 wants to handle a #PF
    in L2 or if the VM-Exit should be forwarded to L1.  The current logic fails
    to account for the case where #PF is intercepted to handle
    guest.MAXPHYADDR < host.MAXPHYADDR and ends up reflecting all #PFs into
    L1.  At best, L1 will complain and inject the #PF back into L2.  At
    worst, L1 will eat the unexpected fault and cause L2 to hang on infinite
    page faults.
    
    Note, while the bug was technically introduced by the commit that added
    support for the MAXPHYADDR madness, the shame is all on commit
    a0c134347baf ("KVM: VMX: introduce vmx_need_pf_intercept").
    
    Fixes: 1dbf5d68af6f ("KVM: VMX: Add guest physical address check in EPT violation and misconfig")
    Cc: stable@vger.kernel.org
    Cc: Peter Shier <pshier@google.com>
    Cc: Oliver Upton <oupton@google.com>
    Cc: Jim Mattson <jmattson@google.com>
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20210812045615.3167686-1-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1163cd462e1f42a2c58ab7cc097ad9543d9f152c
Author: Sean Christopherson <seanjc@google.com>
Date:   Tue Aug 10 10:19:49 2021 -0700

    KVM: VMX: Use current VMCS to query WAITPKG support for MSR emulation
    
    commit 7b9cae027ba3aaac295ae23a62f47876ed97da73 upstream.
    
    Use the secondary_exec_controls_get() accessor in vmx_has_waitpkg() to
    effectively get the controls for the current VMCS, as opposed to using
    vmx->secondary_exec_controls, which is the cached value of KVM's desired
    controls for vmcs01 and truly not reflective of any particular VMCS.
    
    While the waitpkg control is not dynamic, i.e. vmcs01 will always hold
    the same waitpkg configuration as vmx->secondary_exec_controls, the same
    does not hold true for vmcs02 if the L1 VMM hides the feature from L2.
    If L1 hides the feature _and_ does not intercept MSR_IA32_UMWAIT_CONTROL,
    L2 could incorrectly read/write L1's virtual MSR instead of taking a #GP.
    
    Fixes: 6e3ba4abcea5 ("KVM: vmx: Emulate MSR IA32_UMWAIT_CONTROL")
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20210810171952.2758100-2-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a3040e7e9ff2105dced876410f1578e96e801ae3
Author: Zhen Lei <thunder.leizhen@huawei.com>
Date:   Sat Jul 31 20:30:11 2021 +0800

    locking/rtmutex: Use the correct rtmutex debugging config option
    
    commit 07d25971b220e477eb019fcb520a9f2e3ac966af upstream.
    
    It's CONFIG_DEBUG_RT_MUTEXES not CONFIG_DEBUG_RT_MUTEX.
    
    Fixes: f7efc4799f81 ("locking/rtmutex: Inline chainwalk depth check")
    Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Will Deacon <will@kernel.org>
    Acked-by: Boqun Feng <boqun.feng@gmail.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210731123011.4555-1-thunder.leizhen@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b636a0d1e5c8431b2a7d284f415835c917d1ee2d
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Mon Jul 26 16:31:44 2021 +0200

    efi/libstub: arm64: Double check image alignment at entry
    
    commit c32ac11da3f83bb42b986702a9b92f0a14ed4182 upstream.
    
    On arm64, the stub only moves the kernel image around in memory if
    needed, which is typically only for KASLR, given that relocatable
    kernels (which is the default) can run from any 64k aligned address,
    which is also the minimum alignment communicated to EFI via the PE/COFF
    header.
    
    Unfortunately, some loaders appear to ignore this header, and load the
    kernel at some arbitrary offset in memory. We can deal with this, but
    let's check for this condition anyway, so non-compliant code can be
    spotted and fixed.
    
    Cc: <stable@vger.kernel.org> # v5.10+
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e1d1392f381ffd95a6b099e399ca621f53f7857
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Wed Jul 7 05:55:07 2021 +0000

    powerpc/32: Fix critical and debug interrupts on BOOKE
    
    commit b5cfc9cd7b0426e94ffd9e9ed79d1b00ace7780a upstream.
    
    32 bits BOOKE have special interrupts for debug and other
    critical events.
    
    When handling those interrupts, dedicated registers are saved
    in the stack frame in addition to the standard registers, leading
    to a shift of the pt_regs struct.
    
    Since commit db297c3b07af ("powerpc/32: Don't save thread.regs on
    interrupt entry"), the pt_regs struct is expected to be at the
    same place all the time.
    
    Instead of handling a special struct in addition to pt_regs, just
    add those special registers to struct pt_regs.
    
    Fixes: db297c3b07af ("powerpc/32: Don't save thread.regs on interrupt entry")
    Cc: stable@vger.kernel.org
    Reported-by: Radu Rendec <radu.rendec@gmail.com>
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/028d5483b4851b01ea4334d0751e7f260419092b.1625637264.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4ce6f022df438afc409c19d0c9e7f65e7c78c956
Author: Cédric Le Goater <clg@kaod.org>
Date:   Sat Aug 7 09:20:57 2021 +0200

    powerpc/xive: Do not skip CPU-less nodes when creating the IPIs
    
    commit cbc06f051c524dcfe52ef0d1f30647828e226d30 upstream.
    
    On PowerVM, CPU-less nodes can be populated with hot-plugged CPUs at
    runtime. Today, the IPI is not created for such nodes, and hot-plugged
    CPUs use a bogus IPI, which leads to soft lockups.
    
    We can not directly allocate and request the IPI on demand because
    bringup_up() is called under the IRQ sparse lock. The alternative is
    to allocate the IPIs for all possible nodes at startup and to request
    the mapping on demand when the first CPU of a node is brought up.
    
    Fixes: 7dcc37b3eff9 ("powerpc/xive: Map one IPI interrupt per node")
    Cc: stable@vger.kernel.org # v5.13
    Reported-by: Geetika Moolchandani <Geetika.Moolchandani1@ibm.com>
    Signed-off-by: Cédric Le Goater <clg@kaod.org>
    Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Tested-by: Laurent Vivier <lvivier@redhat.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210807072057.184698-1-clg@kaod.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3b1700551dee65b55e1c7dd6db4df1c844954827
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Wed Aug 4 18:24:10 2021 +0000

    powerpc/smp: Fix OOPS in topology_init()
    
    commit 8241461536f21bbe51308a6916d1c9fb2e6b75a7 upstream.
    
    Running an SMP kernel on an UP platform not prepared for it,
    I encountered the following OOPS:
    
            BUG: Kernel NULL pointer dereference on read at 0x00000034
            Faulting instruction address: 0xc0a04110
            Oops: Kernel access of bad area, sig: 11 [#1]
            BE PAGE_SIZE=4K SMP NR_CPUS=2 CMPCPRO
            Modules linked in:
            CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.13.0-pmac-00001-g230fedfaad21 #5234
            NIP:  c0a04110 LR: c0a040d8 CTR: c0a04084
            REGS: e100dda0 TRAP: 0300   Not tainted  (5.13.0-pmac-00001-g230fedfaad21)
            MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 84000284  XER: 00000000
            DAR: 00000034 DSISR: 20000000
            GPR00: c0006bd4 e100de60 c1033320 00000000 00000000 c0942274 00000000 00000000
            GPR08: 00000000 00000000 00000001 00000063 00000007 00000000 c0006f30 00000000
            GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000005
            GPR24: c0c67d74 c0c67f1c c0c60000 c0c67d70 c0c0c558 1efdf000 c0c00020 00000000
            NIP [c0a04110] topology_init+0x8c/0x138
            LR [c0a040d8] topology_init+0x54/0x138
            Call Trace:
            [e100de60] [80808080] 0x80808080 (unreliable)
            [e100de90] [c0006bd4] do_one_initcall+0x48/0x1bc
            [e100def0] [c0a0150c] kernel_init_freeable+0x1c8/0x278
            [e100df20] [c0006f44] kernel_init+0x14/0x10c
            [e100df30] [c00190fc] ret_from_kernel_thread+0x14/0x1c
            Instruction dump:
            7c692e70 7d290194 7c035040 7c7f1b78 5529103a 546706fe 5468103a 39400001
            7c641b78 40800054 80c690b4 7fb9402e <81060034> 7fbeea14 2c080000 7fa3eb78
            ---[ end trace b246ffbc6bbbb6fb ]---
    
    Fix it by checking smp_ops before using it, as already done in
    several other places in the arch/powerpc/kernel/smp.c
    
    Fixes: 39f87561454d ("powerpc/smp: Move ppc_md.cpu_die() to smp_ops.cpu_offline_self()")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/75287841cbb8740edd44880fe60be66d489160d9.1628097995.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 115ff78c3a03695f6bda5dd87a1b85b10c3566c0
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Tue Aug 3 15:14:27 2021 +0000

    powerpc/32s: Fix napping restore in data storage interrupt (DSI)
    
    commit 62376365048878f770d8b7d11b89b8b3e18018f1 upstream.
    
    When a DSI (Data Storage Interrupt) is taken while in NAP mode,
    r11 doesn't survive the call to power_save_ppc32_restore().
    
    So use r1 instead of r11 as they both contain the virtual stack
    pointer at that point.
    
    Fixes: 4c0104a83fc3 ("powerpc/32: Dismantle EXC_XFER_STD/LITE/TEMPLATE")
    Cc: stable@vger.kernel.org # v5.13+
    Reported-by: Finn Thain <fthain@linux-m68k.org>
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/731694e0885271f6ee9ffc179eb4bcee78313682.1628003562.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3eda59bcee6eb49b73e634ea32f7b1dbdbfcb086
Author: Laurent Dufour <ldufour@linux.ibm.com>
Date:   Thu Aug 5 17:23:08 2021 +0200

    powerpc/pseries: Fix update of LPAR security flavor after LPM
    
    commit c18956e6e0b95f78dad2773ecc8c61a9e41f6405 upstream.
    
    After LPM, when migrating from a system with security mitigation enabled
    to a system with mitigation disabled, the security flavor exposed in
    /proc is not correctly set back to 0.
    
    Do not assume the value of the security flavor is set to 0 when entering
    init_cpu_char_feature_flags(), so when called after a LPM, the value is
    set correctly even if the mitigation are not turned off.
    
    Fixes: 6ce56e1ac380 ("powerpc/pseries: export LPAR security flavor in lparcfg")
    Cc: stable@vger.kernel.org # v5.13+
    Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210805152308.33988-1-ldufour@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33971cedf1d9e8ca3a4eb5ca3e7577abfe333034
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Tue Aug 10 16:13:17 2021 +0000

    powerpc/interrupt: Do not call single_step_exception() from other exceptions
    
    commit 01fcac8e4dfc112f420dcaeb70056a74e326cacf upstream.
    
    single_step_exception() is called by emulate_single_step() which
    is called from (at least) alignment exception() handler and
    program_check_exception() handler.
    
    Redefine it as a regular __single_step_exception() which is called
    by both single_step_exception() handler and emulate_single_step()
    function.
    
    Fixes: 3a96570ffceb ("powerpc: convert interrupt handlers to use wrappers")
    Cc: stable@vger.kernel.org # v5.12+
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/aed174f5cbc06f2cf95233c071d8aac948e46043.1628611921.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 11aa5db61e9b42c4b928ab2ef89ff398a337dcbe
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:47 2021 +0200

    PCI/MSI: Protect msi_desc::masked for multi-MSI
    
    commit 77e89afc25f30abd56e76a809ee2884d7c1b63ce upstream.
    
    Multi-MSI uses a single MSI descriptor and there is a single mask register
    when the device supports per vector masking. To avoid reading back the mask
    register the value is cached in the MSI descriptor and updates are done by
    clearing and setting bits in the cache and writing it to the device.
    
    But nothing protects msi_desc::masked and the mask register from being
    modified concurrently on two different CPUs for two different Linux
    interrupts which belong to the same multi-MSI descriptor.
    
    Add a lock to struct device and protect any operation on the mask and the
    mask register with it.
    
    This makes the update of msi_desc::masked unconditional, but there is no
    place which requires a modification of the hardware register without
    updating the masked cache.
    
    msi_mask_irq() is now an empty wrapper which will be cleaned up in follow
    up changes.
    
    The problem goes way back to the initial support of multi-MSI, but picking
    the commit which introduced the mask cache is a valid cut off point
    (2.6.30).
    
    Fixes: f2440d9acbe8 ("PCI MSI: Refactor interrupt masking code")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.726833414@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b82047e5d80798fb1317687b5d3faf2c2df9cc79
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:46 2021 +0200

    PCI/MSI: Use msi_mask_irq() in pci_msi_shutdown()
    
    commit d28d4ad2a1aef27458b3383725bb179beb8d015c upstream.
    
    No point in using the raw write function from shutdown. Preparatory change
    to introduce proper serialization for the msi_desc::masked cache.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.674391354@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 849b6a5bde32c8fd8217efe7b11777f9028d4aa3
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:45 2021 +0200

    PCI/MSI: Correct misleading comments
    
    commit 689e6b5351573c38ccf92a0dd8b3e2c2241e4aff upstream.
    
    The comments about preserving the cached state in pci_msi[x]_shutdown() are
    misleading as the MSI descriptors are freed right after those functions
    return. So there is nothing to restore. Preparatory change.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.621609423@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea6cc94e8807f80e4f4c0ba2e1ad4e9989cb9901
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:44 2021 +0200

    PCI/MSI: Do not set invalid bits in MSI mask
    
    commit 361fd37397f77578735907341579397d5bed0a2d upstream.
    
    msi_mask_irq() takes a mask and a flags argument. The mask argument is used
    to mask out bits from the cached mask and the flags argument to set bits.
    
    Some places invoke it with a flags argument which sets bits which are not
    used by the device, i.e. when the device supports up to 8 vectors a full
    unmask in some places sets the mask to 0xFFFFFF00. While devices probably
    do not care, it's still bad practice.
    
    Fixes: 7ba1930db02f ("PCI MSI: Unmask MSI if setup failed")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.568173099@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78225ed700dfa3d90841cf27554e01b15b850114
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:43 2021 +0200

    PCI/MSI: Enforce MSI[X] entry updates to be visible
    
    commit b9255a7cb51754e8d2645b65dd31805e282b4f3e upstream.
    
    Nothing enforces the posted writes to be visible when the function
    returns. Flush them even if the flush might be redundant when the entry is
    masked already as the unmask will flush as well. This is either setup or a
    rare affinity change event so the extra flush is not the end of the world.
    
    While this is more a theoretical issue especially the logic in the X86
    specific msi_set_affinity() function relies on the assumption that the
    update has reached the hardware when the function returns.
    
    Again, as this never has been enforced the Fixes tag refers to a commit in:
       git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
    
    Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Acked-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.515188147@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0b51d4c16a274b1f5eea7bd572236ba481ae6019
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:42 2021 +0200

    PCI/MSI: Enforce that MSI-X table entry is masked for update
    
    commit da181dc974ad667579baece33c2c8d2d1e4558d5 upstream.
    
    The specification (PCIe r5.0, sec 6.1.4.5) states:
    
        For MSI-X, a function is permitted to cache Address and Data values
        from unmasked MSI-X Table entries. However, anytime software unmasks a
        currently masked MSI-X Table entry either by clearing its Mask bit or
        by clearing the Function Mask bit, the function must update any Address
        or Data values that it cached from that entry. If software changes the
        Address or Data value of an entry while the entry is unmasked, the
        result is undefined.
    
    The Linux kernel's MSI-X support never enforced that the entry is masked
    before the entry is modified hence the Fixes tag refers to a commit in:
          git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
    
    Enforce the entry to be masked across the update.
    
    There is no point in enforcing this to be handled at all possible call
    sites as this is just pointless code duplication and the common update
    function is the obvious place to enforce this.
    
    Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
    Reported-by: Kevin Tian <kevin.tian@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Acked-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.462096385@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c971252f09040af40d20851cf4e14018e6710d9
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:41 2021 +0200

    PCI/MSI: Mask all unused MSI-X entries
    
    commit 7d5ec3d3612396dc6d4b76366d20ab9fc06f399f upstream.
    
    When MSI-X is enabled the ordering of calls is:
    
      msix_map_region();
      msix_setup_entries();
      pci_msi_setup_msi_irqs();
      msix_program_entries();
    
    This has a few interesting issues:
    
     1) msix_setup_entries() allocates the MSI descriptors and initializes them
        except for the msi_desc:masked member which is left zero initialized.
    
     2) pci_msi_setup_msi_irqs() allocates the interrupt descriptors and sets
        up the MSI interrupts which ends up in pci_write_msi_msg() unless the
        interrupt chip provides its own irq_write_msi_msg() function.
    
     3) msix_program_entries() does not do what the name suggests. It solely
        updates the entries array (if not NULL) and initializes the masked
        member for each MSI descriptor by reading the hardware state and then
        masks the entry.
    
    Obviously this has some issues:
    
     1) The uninitialized masked member of msi_desc prevents the enforcement
        of masking the entry in pci_write_msi_msg() depending on the cached
        masked bit. Aside of that half initialized data is a NONO in general
    
     2) msix_program_entries() only ensures that the actually allocated entries
        are masked. This is wrong as experimentation with crash testing and
        crash kernel kexec has shown.
    
        This limited testing unearthed that when the production kernel had more
        entries in use and unmasked when it crashed and the crash kernel
        allocated a smaller amount of entries, then a full scan of all entries
        found unmasked entries which were in use in the production kernel.
    
        This is obviously a device or emulation issue as the device reset
        should mask all MSI-X table entries, but obviously that's just part
        of the paper specification.
    
    Cure this by:
    
     1) Masking all table entries in hardware
     2) Initializing msi_desc::masked in msix_setup_entries()
     3) Removing the mask dance in msix_program_entries()
     4) Renaming msix_program_entries() to msix_update_entries() to
        reflect the purpose of that function.
    
    As the masking of unused entries has never been done the Fixes tag refers
    to a commit in:
       git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
    
    Fixes: f036d4ea5fa7 ("[PATCH] ia32 Message Signalled Interrupt support")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Acked-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.403833459@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f800bb380fea8c6b3d2b2d14c29ef3dfb0291e61
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:40 2021 +0200

    PCI/MSI: Enable and mask MSI-X early
    
    commit 438553958ba19296663c6d6583d208dfb6792830 upstream.
    
    The ordering of MSI-X enable in hardware is dysfunctional:
    
     1) MSI-X is disabled in the control register
     2) Various setup functions
     3) pci_msi_setup_msi_irqs() is invoked which ends up accessing
        the MSI-X table entries
     4) MSI-X is enabled and masked in the control register with the
        comment that enabling is required for some hardware to access
        the MSI-X table
    
    Step #4 obviously contradicts #3. The history of this is an issue with the
    NIU hardware. When #4 was introduced the table access actually happened in
    msix_program_entries() which was invoked after enabling and masking MSI-X.
    
    This was changed in commit d71d6432e105 ("PCI/MSI: Kill redundant call of
    irq_set_msi_desc() for MSI-X interrupts") which removed the table write
    from msix_program_entries().
    
    Interestingly enough nobody noticed and either NIU still works or it did
    not get any testing with a kernel 3.19 or later.
    
    Nevertheless this is inconsistent and there is no reason why MSI-X can't be
    enabled and masked in the control register early on, i.e. move step #4
    above to step #1. This preserves the NIU workaround and has no side effects
    on other hardware.
    
    Fixes: d71d6432e105 ("PCI/MSI: Kill redundant call of irq_set_msi_desc() for MSI-X interrupts")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Acked-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.344136412@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 73d8b5769514551490ec111c606bbab29c508f1a
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Tue Aug 10 16:13:16 2021 +0000

    powerpc/interrupt: Fix OOPS by not calling do_IRQ() from timer_interrupt()
    
    commit 98694166c27d473c36b434bd3572934c2f2a16ab upstream.
    
    An interrupt handler shall not be called from another interrupt
    handler otherwise this leads to problems like the following:
    
      Kernel attempted to write user page (afd4fa84) - exploit attempt? (uid: 1000)
      ------------[ cut here ]------------
      Bug: Write fault blocked by KUAP!
      WARNING: CPU: 0 PID: 1617 at arch/powerpc/mm/fault.c:230 do_page_fault+0x484/0x720
      Modules linked in:
      CPU: 0 PID: 1617 Comm: sshd Tainted: G        W         5.13.0-pmac-00010-g8393422eb77 #7
      NIP:  c001b77c LR: c001b77c CTR: 00000000
      REGS: cb9e5bc0 TRAP: 0700   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
      MSR:  00021032 <ME,IR,DR,RI>  CR: 24942424  XER: 00000000
    
      GPR00: c001b77c cb9e5c80 c1582c00 00000021 3ffffbff 085b0000 00000027 c8eb644c
      GPR08: 00000023 00000000 00000000 00000000 24942424 0063f8c8 00000000 000186a0
      GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 c07640c4 cb9e5e98 cb9e5e90
      GPR24: 00000040 afd4fa96 00000040 02000000 c1fda6c0 afd4fa84 00000300 cb9e5cc0
      NIP [c001b77c] do_page_fault+0x484/0x720
      LR [c001b77c] do_page_fault+0x484/0x720
      Call Trace:
      [cb9e5c80] [c001b77c] do_page_fault+0x484/0x720 (unreliable)
      [cb9e5cb0] [c000424c] DataAccess_virt+0xd4/0xe4
      --- interrupt: 300 at __copy_tofrom_user+0x110/0x20c
      NIP:  c001f9b4 LR: c03250a0 CTR: 00000004
      REGS: cb9e5cc0 TRAP: 0300   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
      MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 48028468  XER: 20000000
      DAR: afd4fa84 DSISR: 0a000000
      GPR00: 20726f6f cb9e5d80 c1582c00 00000004 cb9e5e3a 00000016 afd4fa80 00000000
      GPR08: 3835202d 72777872 2d78722d 00000004 28028464 0063f8c8 00000000 000186a0
      GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 c07640c4 cb9e5e98 cb9e5e90
      GPR24: 00000040 afd4fa96 00000040 cb9e5e0c 00000daa a0000000 cb9e5e98 afd4fa56
      NIP [c001f9b4] __copy_tofrom_user+0x110/0x20c
      LR [c03250a0] _copy_to_iter+0x144/0x990
      --- interrupt: 300
      [cb9e5d80] [c03e89c0] n_tty_read+0xa4/0x598 (unreliable)
      [cb9e5df0] [c03e2a0c] tty_read+0xdc/0x2b4
      [cb9e5e80] [c0156bf8] vfs_read+0x274/0x340
      [cb9e5f00] [c01571ac] ksys_read+0x70/0x118
      [cb9e5f30] [c0016048] ret_from_syscall+0x0/0x28
      --- interrupt: c00 at 0xa7855c88
      NIP:  a7855c88 LR: a7855c5c CTR: 00000000
      REGS: cb9e5f40 TRAP: 0c00   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
      MSR:  0000d032 <EE,PR,ME,IR,DR,RI>  CR: 2402446c  XER: 00000000
    
      GPR00: 00000003 afd4ec70 a72137d0 0000000b afd4ecac 00004000 0065a990 00000800
      GPR08: 00000000 a7947930 00000000 00000004 c15831b0 0063f8c8 00000000 000186a0
      GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 0065a9e0 00000001 0065fac0
      GPR24: 00000000 00000089 00664050 00000000 00668e30 a720c8dc a7943ff4 0065f9b0
      NIP [a7855c88] 0xa7855c88
      LR [a7855c5c] 0xa7855c5c
      --- interrupt: c00
      Instruction dump:
      3884aa88 38630178 48076861 807f0080 48042e45 2f830000 419e0148 3c80c079
      3c60c076 38841be4 386301c0 4801f705 <0fe00000> 3860000b 4bfffe30 3c80c06b
      ---[ end trace fd69b91a8046c2e5 ]---
    
    Here the problem is that by re-enterring an exception handler,
    kuap_save_and_lock() is called a second time with this time KUAP
    access locked, leading to regs->kuap being overwritten hence
    KUAP not being unlocked at exception exit as expected.
    
    Do not call do_IRQ() from timer_interrupt() directly. Instead,
    redefine do_IRQ() as a standard function named __do_IRQ(), and
    call it from both do_IRQ() and time_interrupt() handlers.
    
    Fixes: 3a96570ffceb ("powerpc: convert interrupt handlers to use wrappers")
    Cc: stable@vger.kernel.org # v5.12+
    Reported-by: Stan Johnson <userm57@yahoo.com>
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/c17d234f4927d39a1d7100864a8e1145323d33a0.1628611927.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9dac5f65caaf53545d4475c57a5f30edaa2a6ece
Author: Ben Dai <ben.dai@unisoc.com>
Date:   Sun Apr 25 23:09:03 2021 +0800

    genirq/timings: Prevent potential array overflow in __irq_timings_store()
    
    commit b9cc7d8a4656a6e815852c27ab50365009cb69c1 upstream.
    
    When the interrupt interval is greater than 2 ^ PREDICTION_BUFFER_SIZE *
    PREDICTION_FACTOR us and less than 1s, the calculated index will be greater
    than the length of irqs->ema_time[]. Check the calculated index before
    using it to prevent array overflow.
    
    Fixes: 23aa3b9a6b7d ("genirq/timings: Encapsulate storing function")
    Signed-off-by: Ben Dai <ben.dai@unisoc.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210425150903.25456-1-ben.dai9703@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c081d4a6a138b05c591cc674f49da9bde682e94
Author: Bixuan Cui <cuibixuan@huawei.com>
Date:   Tue May 18 11:31:17 2021 +0800

    genirq/msi: Ensure deactivation on teardown
    
    commit dbbc93576e03fbe24b365fab0e901eb442237a8a upstream.
    
    msi_domain_alloc_irqs() invokes irq_domain_activate_irq(), but
    msi_domain_free_irqs() does not enforce deactivation before tearing down
    the interrupts.
    
    This happens when PCI/MSI interrupts are set up and never used before being
    torn down again, e.g. in error handling pathes. The only place which cleans
    that up is the error handling path in msi_domain_alloc_irqs().
    
    Move the cleanup from msi_domain_alloc_irqs() into msi_domain_free_irqs()
    to cure that.
    
    Fixes: f3b0946d629c ("genirq/msi: Make sure PCI MSIs are activated early")
    Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210518033117.78104-1-cuibixuan@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0abb63311246068e347986b6b8270a197c576f64
Author: Babu Moger <Babu.Moger@amd.com>
Date:   Mon Aug 2 14:38:58 2021 -0500

    x86/resctrl: Fix default monitoring groups reporting
    
    commit 064855a69003c24bd6b473b367d364e418c57625 upstream.
    
    Creating a new sub monitoring group in the root /sys/fs/resctrl leads to
    getting the "Unavailable" value for mbm_total_bytes and mbm_local_bytes
    on the entire filesystem.
    
    Steps to reproduce:
    
      1. mount -t resctrl resctrl /sys/fs/resctrl/
    
      2. cd /sys/fs/resctrl/
    
      3. cat mon_data/mon_L3_00/mbm_total_bytes
         23189832
    
      4. Create sub monitor group:
      mkdir mon_groups/test1
    
      5. cat mon_data/mon_L3_00/mbm_total_bytes
         Unavailable
    
    When a new monitoring group is created, a new RMID is assigned to the
    new group. But the RMID is not active yet. When the events are read on
    the new RMID, it is expected to report the status as "Unavailable".
    
    When the user reads the events on the default monitoring group with
    multiple subgroups, the events on all subgroups are consolidated
    together. Currently, if any of the RMID reads report as "Unavailable",
    then everything will be reported as "Unavailable".
    
    Fix the issue by discarding the "Unavailable" reads and reporting all
    the successful RMID reads. This is not a problem on Intel systems as
    Intel reports 0 on Inactive RMIDs.
    
    Fixes: d89b7379015f ("x86/intel_rdt/cqm: Add mon_data")
    Reported-by: Paweł Szulik <pawel.szulik@intel.com>
    Signed-off-by: Babu Moger <Babu.Moger@amd.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Acked-by: Reinette Chatre <reinette.chatre@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=213311
    Link: https://lkml.kernel.org/r/162793309296.9224.15871659871696482080.stgit@bmoger-ubuntu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 55cd80f4928cc6db9bfbe6f41d7071a82962d8ab
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:49 2021 +0200

    x86/ioapic: Force affinity setup before startup
    
    commit 0c0e37dc11671384e53ba6ede53a4d91162a2cc5 upstream.
    
    The IO/APIC cannot handle interrupt affinity changes safely after startup
    other than from an interrupt handler. The startup sequence in the generic
    interrupt code violates that assumption.
    
    Mark the irq chip with the new IRQCHIP_AFFINITY_PRE_STARTUP flag so that
    the default interrupt setting happens before the interrupt is started up
    for the first time.
    
    Fixes: 18404756765c ("genirq: Expose default irq affinity mask (take 3)")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.832143400@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 067ef02048801350d4bd5438893b165f3ae63817
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:50 2021 +0200

    x86/msi: Force affinity setup before startup
    
    commit ff363f480e5997051dd1de949121ffda3b753741 upstream.
    
    The X86 MSI mechanism cannot handle interrupt affinity changes safely after
    startup other than from an interrupt handler, unless interrupt remapping is
    enabled. The startup sequence in the generic interrupt code violates that
    assumption.
    
    Mark the irq chips with the new IRQCHIP_AFFINITY_PRE_STARTUP flag so that
    the default interrupt setting happens before the interrupt is started up
    for the first time.
    
    While the interrupt remapping MSI chip does not require this, there is no
    point in treating it differently as this might spare an interrupt to a CPU
    which is not in the default affinity mask.
    
    For the non-remapping case go to the direct write path when the interrupt
    is not yet started similar to the not yet activated case.
    
    Fixes: 18404756765c ("genirq: Expose default irq affinity mask (take 3)")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.886722080@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24ed8f291d599f5629909d3db5f961035e7f32e7
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Jul 29 23:51:48 2021 +0200

    genirq: Provide IRQCHIP_AFFINITY_PRE_STARTUP
    
    commit 826da771291fc25a428e871f9e7fb465e390f852 upstream.
    
    X86 IO/APIC and MSI interrupts (when used without interrupts remapping)
    require that the affinity setup on startup is done before the interrupt is
    enabled for the first time as the non-remapped operation mode cannot safely
    migrate enabled interrupts from arbitrary contexts. Provide a new irq chip
    flag which allows affected hardware to request this.
    
    This has to be opt-in because there have been reports in the past that some
    interrupt chips cannot handle affinity setting before startup.
    
    Fixes: 18404756765c ("genirq: Expose default irq affinity mask (take 3)")
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Marc Zyngier <maz@kernel.org>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20210729222542.779791738@linutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 560051d8f4391d4b1c609085f13b54f925ac2813
Author: Randy Dunlap <rdunlap@infradead.org>
Date:   Fri Jul 30 17:01:46 2021 -0700

    x86/tools: Fix objdump version check again
    
    [ Upstream commit 839ad22f755132838f406751439363c07272ad87 ]
    
    Skip (omit) any version string info that is parenthesized.
    
    Warning: objdump version 15) is older than 2.19
    Warning: Skipping posttest.
    
    where 'objdump -v' says:
    GNU objdump (GNU Binutils; SUSE Linux Enterprise 15) 2.35.1.20201123-7.18
    
    Fixes: 8bee738bb1979 ("x86: Fix objdump version check in chkobjdump.awk for different formats.")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
    Link: https://lore.kernel.org/r/20210731000146.2720-1-rdunlap@infradead.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d8f9d8c4be6e7279bbb1c20c98ff3646a5419096
Author: Dhananjay Phadke <dphadke@linux.microsoft.com>
Date:   Thu Aug 5 14:49:05 2021 -0700

    i2c: iproc: fix race between client unreg and tasklet
    
    [ Upstream commit bba676cc0b6122a74fa2e246f38a6b05c6f95b36 ]
    
    Similar NULL deref was originally fixed by graceful teardown sequence -
    
    https://lore.kernel.org/linux-i2c/1597106560-79693-1-git-send-email-dphadke@linux.microsoft.com
    
    After this, a tasklet was added to take care of FIFO full condition for large i2c
    transaction.
    
    https://lore.kernel.org/linux-arm-kernel/20201102035433.6774-1-rayagonda.kokatanur@broadcom.com/
    
    This introduced regression, a new race condition between tasklet enabling
    interrupts and client unreg teardown sequence.
    
    Kill tasklet before unreg_slave() masks bits in IE_OFFSET.
    Updated teardown sequence -
    (1) disable_irq()
    (2) Kill tasklet
    (3) Mask event enable bits in control reg
    (4) Erase slave address (avoid further writes to rx fifo)
    (5) Flush tx and rx FIFOs
    (6) Clear pending event (interrupt) bits in status reg
    (7) Set client pointer to NULL
    (8) enable_irq()
    
     --
    
     Unable to handle kernel read from unreadable memory at virtual address 0000000000000320
     Mem abort info:
       ESR = 0x96000004
       EC = 0x25: DABT (current EL), IL = 32 bits
       SET = 0, FnV = 0
       EA = 0, S1PTW = 0
     Data abort info:
       ISV = 0, ISS = 0x00000004
       CM = 0, WnR = 0
     user pgtable: 4k pages, 48-bit VAs, pgdp=000000009212a000
     [0000000000000320] pgd=0000000000000000, p4d=0000000000000000
     Internal error: Oops: 96000004 [#1] SMP
     CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           O
     Hardware name: Overlake (DT)
     pstate: 40400085 (nZcv daIf +PAN -UAO -TCO BTYPE=--)
     pc : bcm_iproc_i2c_slave_isr+0x2b8/0x8e4
     lr : bcm_iproc_i2c_slave_isr+0x1c8/0x8e4
     sp : ffff800010003e70
     x29: ffff800010003e80 x28: ffffda017acdc000
     x27: ffffda017b0ae000 x26: ffff800010004000
     x25: ffff800010000000 x24: ffffda017af4a168
     x23: 0000000000000073 x22: 0000000000000000
     x21: 0000000001400000 x20: 0000000001000000
     x19: ffff06f09583f880 x18: 00000000fa83b2da
     x17: 000000000000b67e x16: 0000000002edb2f3
     x15: 00000000000002c7 x14: 00000000000002c7
     x13: 0000000000000006 x12: 0000000000000033
     x11: 0000000000000000 x10: 0000000001000000
     x9 : 0000000003289312 x8 : 0000000003289311
     x7 : 02d0cd03a303adbc x6 : 02d18e7f0a4dfc6c
     x5 : 02edb2f33f76ea68 x4 : 00000000fa83b2da
     x3 : ffffda017af43cd0 x2 : ffff800010003e74
     x1 : 0000000001400000 x0 : 0000000000000000
     Call trace:
      bcm_iproc_i2c_slave_isr+0x2b8/0x8e4
      bcm_iproc_i2c_isr+0x178/0x290
      __handle_irq_event_percpu+0xd0/0x200
      handle_irq_event+0x60/0x1a0
      handle_fasteoi_irq+0x130/0x220
      __handle_domain_irq+0x8c/0xcc
      gic_handle_irq+0xc0/0x120
      el1_irq+0xcc/0x180
      finish_task_switch+0x100/0x1d8
      __schedule+0x61c/0x7a0
      schedule_idle+0x28/0x44
      do_idle+0x254/0x28c
      cpu_startup_entry+0x28/0x2c
      rest_init+0xc4/0xd0
      arch_call_rest_init+0x14/0x1c
      start_kernel+0x33c/0x3b8
     Code: f9423260 910013e2 11000509 b9047a69 (f9419009)
     ---[ end trace 4781455b2a7bec15 ]---
    
    Fixes: 4d658451c9d6 ("i2c: iproc: handle rx fifo full interrupt")
    
    Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
    Acked-by: Ray Jui <ray.jui@broadcom.com>
    Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit daf371e74d3645f1d7cce7b3c1c9cd3bc072dd76
Author: Pu Lehui <pulehui@huawei.com>
Date:   Mon Aug 9 10:36:58 2021 +0800

    powerpc/kprobes: Fix kprobe Oops happens in booke
    
    [ Upstream commit 43e8f76006592cb1573a959aa287c45421066f9c ]
    
    When using kprobe on powerpc booke series processor, Oops happens
    as show bellow:
    
    / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events
    / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable
    / # sleep 1
    [   50.076730] Oops: Exception in kernel mode, sig: 5 [#1]
    [   50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500
    [   50.077221] Modules linked in:
    [   50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524293d #21
    [   50.077887] NIP:  c0b9c4e0 LR: c00ebecc CTR: 00000000
    [   50.078067] REGS: c3883de0 TRAP: 0700   Not tainted (5.14.0-rc4-00022-g251a1524293d)
    [   50.078349] MSR:  00029000 <CE,EE,ME>  CR: 24000228  XER: 20000000
    [   50.078675]
    [   50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 00000001 00000000 c3883ecc 00000001
    [   50.078675] GPR08: c100598c c00ea250 00000004 00000000 24000222 102490c2 bff4180c 101e60d4
    [   50.078675] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
    [   50.078675] GPR24: 00000002 00000000 c3883ea0 00000001 00000000 0000c350 3b9b8d50 00000000
    [   50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190
    [   50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0
    [   50.080638] Call Trace:
    [   50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable)
    [   50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110
    [   50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28
    [   50.081541] --- interrupt: c00 at 0x100a4d08
    [   50.081749] NIP:  100a4d08 LR: 101b5234 CTR: 00000003
    [   50.081931] REGS: c3883f50 TRAP: 0c00   Not tainted (5.14.0-rc4-00022-g251a1524293d)
    [   50.082183] MSR:  0002f902 <CE,EE,PR,FP,ME>  CR: 24000222  XER: 00000000
    [   50.082457]
    [   50.082457] GPR00: 000000a2 bf980040 1024b4d0 bf980084 bf980084 64000000 00555345 fefefeff
    [   50.082457] GPR08: 7f7f7f7f 101e0000 00000069 00000003 28000422 102490c2 bff4180c 101e60d4
    [   50.082457] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
    [   50.082457] GPR24: 00000002 bf9803f4 10240000 00000000 00000000 100039e0 00000000 102444e8
    [   50.083789] NIP [100a4d08] 0x100a4d08
    [   50.083917] LR [101b5234] 0x101b5234
    [   50.084042] --- interrupt: c00
    [   50.084238] Instruction dump:
    [   50.084483] 4bfffc40 60000000 60000000 60000000 9421fff0 39400402 914200c0 38210010
    [   50.084841] 4bfffc20 00000000 00000000 00000000 <7fe00008> 7c0802a6 7c892378 93c10048
    [   50.085487] ---[ end trace f6fffe98e2fa8f3e ]---
    [   50.085678]
    Trace/breakpoint trap
    
    There is no real mode for booke arch and the MMU translation is
    always on. The corresponding MSR_IS/MSR_DS bit in booke is used
    to switch the address space, but not for real mode judgment.
    
    Fixes: 21f8b2fa3ca5 ("powerpc/kprobes: Ignore traps that happened in real mode")
    Signed-off-by: Pu Lehui <pulehui@huawei.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210809023658.218915-1-pulehui@huawei.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2bfb303470e0500aee5f332fcbcae5c462d31987
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Thu Jul 22 12:10:31 2021 +0200

    efi/libstub: arm64: Relax 2M alignment again for relocatable kernels
    
    [ Upstream commit 3a262423755b83a5f85009ace415d6e7f572dfe8 ]
    
    Commit 82046702e288 ("efi/libstub/arm64: Replace 'preferred' offset with
    alignment check") simplified the way the stub moves the kernel image
    around in memory before booting it, given that a relocatable image does
    not need to be copied to a 2M aligned offset if it was loaded on a 64k
    boundary by EFI.
    
    Commit d32de9130f6c ("efi/arm64: libstub: Deal gracefully with
    EFI_RNG_PROTOCOL failure") inadvertently defeated this logic by
    overriding the value of efi_nokaslr if EFI_RNG_PROTOCOL is not
    available, which was mistaken by the loader logic as an explicit request
    on the part of the user to disable KASLR and any associated relocation
    of an Image not loaded on a 2M boundary.
    
    So let's reinstate this functionality, by capturing the value of
    efi_nokaslr at function entry to choose the minimum alignment.
    
    Fixes: d32de9130f6c ("efi/arm64: libstub: Deal gracefully with EFI_RNG_PROTOCOL failure")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bfc48d02d9155c3b2aac7fecbefdd6c89dc1e01f
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Mon Jul 26 11:38:41 2021 +0200

    efi/libstub: arm64: Force Image reallocation if BSS was not reserved
    
    [ Upstream commit 5b94046efb4706b3429c9c8e7377bd8d1621d588 ]
    
    Distro versions of GRUB replace the usual LoadImage/StartImage calls
    used to load the kernel image with some local code that fails to honor
    the allocation requirements described in the PE/COFF header, as it
    does not account for the image's BSS section at all: it fails to
    allocate space for it, and fails to zero initialize it.
    
    Since the EFI stub itself is allocated in the .init segment, which is
    in the middle of the image, its BSS section is not impacted by this,
    and the main consequence of this omission is that the BSS section may
    overlap with memory regions that are already used by the firmware.
    
    So let's warn about this condition, and force image reallocation to
    occur in this case, which works around the problem.
    
    Fixes: 82046702e288 ("efi/libstub/arm64: Replace 'preferred' offset with alignment check")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Tested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f3409e925da2315c298d7b5966de7b383e4633db
Author: David Brazdil <dbrazdil@google.com>
Date:   Wed Jul 28 15:32:31 2021 +0000

    KVM: arm64: Fix off-by-one in range_is_memory
    
    [ Upstream commit facee1be7689f8cf573b9ffee6a5c28ee193615e ]
    
    Hyp checks whether an address range only covers RAM by checking the
    start/endpoints against a list of memblock_region structs. However,
    the endpoint here is exclusive but internally is treated as inclusive.
    Fix the off-by-one error that caused valid address ranges to be
    rejected.
    
    Cc: Quentin Perret <qperret@google.com>
    Fixes: 90134ac9cabb6 ("KVM: arm64: Protect the .hyp sections from the host")
    Signed-off-by: David Brazdil <dbrazdil@google.com>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20210728153232.1018911-2-dbrazdil@google.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 14034883d0587b4e2f63f6386d34bacd22cf1740
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Tue Jul 20 21:14:05 2021 +1000

    arm64: efi: kaslr: Fix occasional random alloc (and boot) failure
    
    [ Upstream commit 4152433c397697acc4b02c4a10d17d5859c2730d ]
    
    The EFI stub random allocator used for kaslr on arm64 has a subtle
    bug. In function get_entry_num_slots() which counts the number of
    possible allocation "slots" for the image in a given chunk of free
    EFI memory, "last_slot" can become negative if the chunk is smaller
    than the requested allocation size.
    
    The test "if (first_slot > last_slot)" doesn't catch it because
    both first_slot and last_slot are unsigned.
    
    I chose not to make them signed to avoid problems if this is ever
    used on architectures where there are meaningful addresses with the
    top bit set. Instead, fix it with an additional test against the
    allocation size.
    
    This can cause a boot failure in addition to a loss of randomisation
    due to another bug in the arm64 stub fixed separately.
    
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Fixes: 2ddbfc81eac8 ("efi: stub: add implementation of efi_random_alloc()")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 98f73989055fb91f5febea2b69c6059b1b0d2547
Author: Xie Yongji <xieyongji@bytedance.com>
Date:   Fri Aug 13 23:13:30 2021 +0800

    nbd: Aovid double completion of a request
    
    [ Upstream commit cddce01160582a5f52ada3da9626c052d852ec42 ]
    
    There is a race between iterating over requests in
    nbd_clear_que() and completing requests in recv_work(),
    which can lead to double completion of a request.
    
    To fix it, flush the recv worker before iterating over
    the requests and don't abort the completed request
    while iterating.
    
    Fixes: 96d97e17828f ("nbd: clear_sock on netlink disconnect")
    Reported-by: Jiang Yadong <jiangyadong@bytedance.com>
    Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20210813151330.96-1-xieyongji@bytedance.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 09625c5badd23a2eeaee252dc81f7dbc7082e7ed
Author: Longpeng(Mike) <longpeng2@huawei.com>
Date:   Thu Aug 12 13:30:56 2021 +0800

    vsock/virtio: avoid potential deadlock when vsock device remove
    
    [ Upstream commit 49b0b6ffe20c5344f4173f3436298782a08da4f2 ]
    
    There's a potential deadlock case when remove the vsock device or
    process the RESET event:
    
      vsock_for_each_connected_socket:
          spin_lock_bh(&vsock_table_lock) ----------- (1)
          ...
              virtio_vsock_reset_sock:
                  lock_sock(sk) --------------------- (2)
          ...
          spin_unlock_bh(&vsock_table_lock)
    
    lock_sock() may do initiative schedule when the 'sk' is owned by
    other thread at the same time, we would receivce a warning message
    that "scheduling while atomic".
    
    Even worse, if the next task (selected by the scheduler) try to
    release a 'sk', it need to request vsock_table_lock and the deadlock
    occur, cause the system into softlockup state.
      Call trace:
       queued_spin_lock_slowpath
       vsock_remove_bound
       vsock_remove_sock
       virtio_transport_release
       __vsock_release
       vsock_release
       __sock_release
       sock_close
       __fput
       ____fput
    
    So we should not require sk_lock in this case, just like the behavior
    in vhost_vsock or vmci.
    
    Fixes: 0ea9e1d3a9e3 ("VSOCK: Introduce virtio_transport.ko")
    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
    Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
    Link: https://lore.kernel.org/r/20210812053056.1699-1-longpeng2@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 128e480afe783b50151124f31deb0ca0cf431d61
Author: Maximilian Heyne <mheyne@amazon.de>
Date:   Thu Aug 12 13:09:27 2021 +0000

    xen/events: Fix race in set_evtchn_to_irq
    
    [ Upstream commit 88ca2521bd5b4e8b83743c01a2d4cb09325b51e9 ]
    
    There is a TOCTOU issue in set_evtchn_to_irq. Rows in the evtchn_to_irq
    mapping are lazily allocated in this function. The check whether the row
    is already present and the row initialization is not synchronized. Two
    threads can at the same time allocate a new row for evtchn_to_irq and
    add the irq mapping to the their newly allocated row. One thread will
    overwrite what the other has set for evtchn_to_irq[row] and therefore
    the irq mapping is lost. This will trigger a BUG_ON later in
    bind_evtchn_to_cpu:
    
      INFO: pci 0000:1a:15.4: [1d0f:8061] type 00 class 0x010802
      INFO: nvme 0000:1a:12.1: enabling device (0000 -> 0002)
      INFO: nvme nvme77: 1/0/0 default/read/poll queues
      CRIT: kernel BUG at drivers/xen/events/events_base.c:427!
      WARN: invalid opcode: 0000 [#1] SMP NOPTI
      WARN: Workqueue: nvme-reset-wq nvme_reset_work [nvme]
      WARN: RIP: e030:bind_evtchn_to_cpu+0xc2/0xd0
      WARN: Call Trace:
      WARN:  set_affinity_irq+0x121/0x150
      WARN:  irq_do_set_affinity+0x37/0xe0
      WARN:  irq_setup_affinity+0xf6/0x170
      WARN:  irq_startup+0x64/0xe0
      WARN:  __setup_irq+0x69e/0x740
      WARN:  ? request_threaded_irq+0xad/0x160
      WARN:  request_threaded_irq+0xf5/0x160
      WARN:  ? nvme_timeout+0x2f0/0x2f0 [nvme]
      WARN:  pci_request_irq+0xa9/0xf0
      WARN:  ? pci_alloc_irq_vectors_affinity+0xbb/0x130
      WARN:  queue_request_irq+0x4c/0x70 [nvme]
      WARN:  nvme_reset_work+0x82d/0x1550 [nvme]
      WARN:  ? check_preempt_wakeup+0x14f/0x230
      WARN:  ? check_preempt_curr+0x29/0x80
      WARN:  ? nvme_irq_check+0x30/0x30 [nvme]
      WARN:  process_one_work+0x18e/0x3c0
      WARN:  worker_thread+0x30/0x3a0
      WARN:  ? process_one_work+0x3c0/0x3c0
      WARN:  kthread+0x113/0x130
      WARN:  ? kthread_park+0x90/0x90
      WARN:  ret_from_fork+0x3a/0x50
    
    This patch sets evtchn_to_irq rows via a cmpxchg operation so that they
    will be set only once. The row is now cleared before writing it to
    evtchn_to_irq in order to not create a race once the row is visible for
    other threads.
    
    While at it, do not require the page to be zeroed, because it will be
    overwritten with -1's in clear_evtchn_to_irq_row anyway.
    
    Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
    Fixes: d0b075ffeede ("xen/events: Refactor evtchn_to_irq array to be dynamically allocated")
    Link: https://lore.kernel.org/r/20210812130930.127134-1-mheyne@amazon.de
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 950429a4d346460ff95dd572f29326db60f42267
Author: Matt Roper <matthew.d.roper@intel.com>
Date:   Fri Aug 6 10:41:30 2021 -0700

    drm/i915: Only access SFC_DONE when media domain is not fused off
    
    [ Upstream commit 24d032e2359e3abc926b3d423f49a7c33e0b7836 ]
    
    The SFC_DONE register lives within the corresponding VD0/VD2/VD4/VD6
    forcewake domain and is not accessible if the vdbox in that domain is
    fused off and the forcewake is not initialized.
    
    This mistake went unnoticed because until recently we were using the
    wrong register offset for the SFC_DONE register; once the register
    offset was corrected, we started hitting errors like
    
      <4> [544.989065] i915 0000:cc:00.0: Uninitialized forcewake domain(s) 0x80 accessed at 0x1ce000
    
    on parts with fused-off vdbox engines.
    
    Fixes: e50dbdbfd9fb ("drm/i915/tgl: Add SFC instdone to error state")
    Fixes: 9c9c6d0ab08a ("drm/i915: Correct SFC_DONE register offset")
    Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
    Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210806174130.1058960-1-matthew.d.roper@intel.com
    Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
    (cherry picked from commit c5589bb5dccb0c5cb74910da93663f489589f3ce)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    [Changed Fixes tag to match the cherry-picked 82929a2140eb]
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9977d0baadc842110e7a0cb44a765dfa56f8be88
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Aug 11 12:57:15 2021 -0700

    net: igmp: increase size of mr_ifc_count
    
    [ Upstream commit b69dd5b3780a7298bd893816a09da751bc0636f7 ]
    
    Some arches support cmpxchg() on 4-byte and 8-byte only.
    Increase mr_ifc_count width to 32bit to fix this problem.
    
    Fixes: 4a2b285e7e10 ("net: igmp: fix data-race in igmp_ifc_timer_expire()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20210811195715.3684218-1-eric.dumazet@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4391389526a14f5e0a5cf0a8df22d7f5a3b5cc8e
Author: Neal Cardwell <ncardwell@google.com>
Date:   Tue Aug 10 22:40:56 2021 -0400

    tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets
    
    [ Upstream commit 6de035fec045f8ae5ee5f3a02373a18b939e91fb ]
    
    Currently if BBR congestion control is initialized after more than 2B
    packets have been delivered, depending on the phase of the
    tp->delivered counter the tracking of BBR round trips can get stuck.
    
    The bug arises because if tp->delivered is between 2^31 and 2^32 at
    the time the BBR congestion control module is initialized, then the
    initialization of bbr->next_rtt_delivered to 0 will cause the logic to
    believe that the end of the round trip is still billions of packets in
    the future. More specifically, the following check will fail
    repeatedly:
    
      !before(rs->prior_delivered, bbr->next_rtt_delivered)
    
    and thus the connection will take up to 2B packets delivered before
    that check will pass and the connection will set:
    
      bbr->round_start = 1;
    
    This could cause many mechanisms in BBR to fail to trigger, for
    example bbr_check_full_bw_reached() would likely never exit STARTUP.
    
    This bug is 5 years old and has not been observed, and as a practical
    matter this would likely rarely trigger, since it would require
    transferring at least 2B packets, or likely more than 3 terabytes of
    data, before switching congestion control algorithms to BBR.
    
    This patch is a stable candidate for kernels as far back as v4.9,
    when tcp_bbr.c was added.
    
    Fixes: 0f8782ea1497 ("tcp_bbr: add BBR congestion control")
    Signed-off-by: Neal Cardwell <ncardwell@google.com>
    Reviewed-by: Yuchung Cheng <ycheng@google.com>
    Reviewed-by: Kevin Yang <yyd@google.com>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Link: https://lore.kernel.org/r/20210811024056.235161-1-ncardwell@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 53201f2902eea6286c4ca6dec79cda40e8ee9cd3
Author: Willy Tarreau <w@1wt.eu>
Date:   Mon Aug 9 18:06:28 2021 +0200

    net: linkwatch: fix failure to restore device state across suspend/resume
    
    [ Upstream commit 6922110d152e56d7569616b45a1f02876cf3eb9f ]
    
    After migrating my laptop from 4.19-LTS to 5.4-LTS a while ago I noticed
    that my Ethernet port to which a bond and a VLAN interface are attached
    appeared to remain up after resuming from suspend with the cable unplugged
    (and that problem still persists with 5.10-LTS).
    
    It happens that the following happens:
    
      - the network driver (e1000e here) prepares to suspend, calls e1000e_down()
        which calls netif_carrier_off() to signal that the link is going down.
      - netif_carrier_off() adds a link_watch event to the list of events for
        this device
      - the device is completely stopped.
      - the machine suspends
      - the cable is unplugged and the machine brought to another location
      - the machine is resumed
      - the queued linkwatch events are processed for the device
      - the device doesn't yet have the __LINK_STATE_PRESENT bit and its events
        are silently dropped
      - the device is resumed with its link down
      - the upper VLAN and bond interfaces are never notified that the link had
        been turned down and remain up
      - the only way to provoke a change is to physically connect the machine
        to a port and possibly unplug it.
    
    The state after resume looks like this:
      $ ip -br li | egrep 'bond|eth'
      bond0            UP             e8:6a:64:64:64:64 <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP>
      eth0             DOWN           e8:6a:64:64:64:64 <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP>
      eth0.2@eth0      UP             e8:6a:64:64:64:64 <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP>
    
    Placing an explicit call to netdev_state_change() either in the suspend
    or the resume code in the NIC driver worked around this but the solution
    is not satisfying.
    
    The issue in fact really is in link_watch that loses events while it
    ought not to. It happens that the test for the device being present was
    added by commit 124eee3f6955 ("net: linkwatch: add check for netdevice
    being present to linkwatch_do_dev") in 4.20 to avoid an access to
    devices that are not present.
    
    Instead of dropping events, this patch proceeds slightly differently by
    postponing their handling so that they happen after the device is fully
    resumed.
    
    Fixes: 124eee3f6955 ("net: linkwatch: add check for netdevice being present to linkwatch_do_dev")
    Link: https://lists.openwall.net/netdev/2018/03/15/62
    Cc: Heiner Kallweit <hkallweit1@gmail.com>
    Cc: Geert Uytterhoeven <geert+renesas@glider.be>
    Cc: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: Willy Tarreau <w@1wt.eu>
    Link: https://lore.kernel.org/r/20210809160628.22623-1-w@1wt.eu
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 59cabc513b8a9a3e8d324ed61fa39a2d773cc24d
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Mon Aug 9 21:20:23 2021 +0800

    net: bridge: fix memleak in br_add_if()
    
    [ Upstream commit 519133debcc19f5c834e7e28480b60bdc234fe02 ]
    
    I got a memleak report:
    
    BUG: memory leak
    unreferenced object 0x607ee521a658 (size 240):
    comm "syz-executor.0", pid 955, jiffies 4294780569 (age 16.449s)
    hex dump (first 32 bytes, cpu 1):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    backtrace:
    [<00000000d830ea5a>] br_multicast_add_port+0x1c2/0x300 net/bridge/br_multicast.c:1693
    [<00000000274d9a71>] new_nbp net/bridge/br_if.c:435 [inline]
    [<00000000274d9a71>] br_add_if+0x670/0x1740 net/bridge/br_if.c:611
    [<0000000012ce888e>] do_set_master net/core/rtnetlink.c:2513 [inline]
    [<0000000012ce888e>] do_set_master+0x1aa/0x210 net/core/rtnetlink.c:2487
    [<0000000099d1cafc>] __rtnl_newlink+0x1095/0x13e0 net/core/rtnetlink.c:3457
    [<00000000a01facc0>] rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3488
    [<00000000acc9186c>] rtnetlink_rcv_msg+0x369/0xa10 net/core/rtnetlink.c:5550
    [<00000000d4aabb9c>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504
    [<00000000bc2e12a3>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
    [<00000000bc2e12a3>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340
    [<00000000e4dc2d0e>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929
    [<000000000d22c8b3>] sock_sendmsg_nosec net/socket.c:654 [inline]
    [<000000000d22c8b3>] sock_sendmsg+0x139/0x170 net/socket.c:674
    [<00000000e281417a>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350
    [<00000000237aa2ab>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404
    [<000000004f2dc381>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433
    [<0000000005feca6c>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47
    [<000000007304477d>] entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    On error path of br_add_if(), p->mcast_stats allocated in
    new_nbp() need be freed, or it will be leaked.
    
    Fixes: 1080ab95e3c7 ("net: bridge: add support for IGMP/MLD stats and export them via netlink")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
    Link: https://lore.kernel.org/r/20210809132023.978546-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ff6c9aad35996f2941fcec21cf289e31de2afc16
Author: Nikolay Aleksandrov <nikolay@nvidia.com>
Date:   Tue Aug 10 14:00:10 2021 +0300

    net: bridge: fix flags interpretation for extern learn fdb entries
    
    [ Upstream commit 45a687879b31caae4032abd1c2402e289d2b8083 ]
    
    Ignore fdb flags when adding port extern learn entries and always set
    BR_FDB_LOCAL flag when adding bridge extern learn entries. This is
    closest to the behaviour we had before and avoids breaking any use cases
    which were allowed.
    
    This patch fixes iproute2 calls which assume NUD_PERMANENT and were
    allowed before, example:
    $ bridge fdb add 00:11:22:33:44:55 dev swp1 extern_learn
    
    Extern learn entries are allowed to roam, but do not expire, so static
    or dynamic flags make no sense for them.
    
    Also add a comment for future reference.
    
    Fixes: eb100e0e24a2 ("net: bridge: allow to add externally learned entries from user-space")
    Fixes: 0541a6293298 ("net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry")
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Tested-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
    Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20210810110010.43859-1-razor@blackwall.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c7c9cc4a601612bc03eab92ab4926fc9e3917b3a
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Thu Jul 22 14:25:48 2021 +0100

    pinctrl: sunxi: Don't underestimate number of functions
    
    [ Upstream commit d1dee814168538eba166ae4150b37f0d88257884 ]
    
    When we are building all the various pinctrl structures for the
    Allwinner pinctrl devices, we do some estimation about the maximum
    number of distinct function (names) that we will need.
    
    So far we take the number of pins as an upper bound, even though we
    can actually have up to four special functions per pin. This wasn't a
    problem until now, since we indeed have typically far more pins than
    functions, and most pins share common functions.
    
    However the H616 "-r" pin controller has only two pins, but four
    functions, so we run over the end of the array when we are looking for
    a matching function name in sunxi_pinctrl_add_function - there is no
    NULL sentinel left that would terminate the loop:
    
    [    8.200648] Unable to handle kernel paging request at virtual address fffdff7efbefaff5
    [    8.209179] Mem abort info:
    ....
    [    8.368456] Call trace:
    [    8.370925]  __pi_strcmp+0x90/0xf0
    [    8.374559]  sun50i_h616_r_pinctrl_probe+0x1c/0x28
    [    8.379557]  platform_probe+0x68/0xd8
    
    Do an actual worst case allocation (4 functions per pin, three common
    functions and the sentinel) for the initial array allocation. This is
    now heavily overestimating the number of functions in the common case,
    but we will reallocate this array later with the actual number of
    functions, so it's only temporarily.
    
    Fixes: 561c1cf17c46 ("pinctrl: sunxi: Add support for the Allwinner H616-R pin controller")
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Acked-by: Maxime Ripard <maxime@cerno.tech>
    Link: https://lore.kernel.org/r/20210722132548.22121-1-andre.przywara@arm.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 735e90f3efa6141b92b446f32419edf0bcc26ed6
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Aug 10 14:19:56 2021 +0300

    net: dsa: sja1105: fix broken backpressure in .port_fdb_dump
    
    [ Upstream commit 21b52fed928e96d2f75d2f6aa9eac7a4b0b55d22 ]
    
    rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into
    multiple netlink skbs if the buffer provided by user space is too small
    (one buffer will typically handle a few hundred FDB entries).
    
    When the current buffer becomes full, nlmsg_put() in
    dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index
    of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that
    point, and then the dump resumes on the same port with a new skb, and
    FDB entries up to the saved index are simply skipped.
    
    Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to
    drivers, then drivers must check for the -EMSGSIZE error code returned
    by it. Otherwise, when a netlink skb becomes full, DSA will no longer
    save newly dumped FDB entries to it, but the driver will continue
    dumping. So FDB entries will be missing from the dump.
    
    Fix the broken backpressure by propagating the "cb" return code and
    allow rtnl_fdb_dump() to restart the FDB dump with a new skb.
    
    Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8398aab49ba33057a3c931baa1f78c65dc6f47c6
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Aug 10 14:19:55 2021 +0300

    net: dsa: lantiq: fix broken backpressure in .port_fdb_dump
    
    [ Upstream commit 871a73a1c8f55da0a3db234e9dd816ea4fd546f2 ]
    
    rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into
    multiple netlink skbs if the buffer provided by user space is too small
    (one buffer will typically handle a few hundred FDB entries).
    
    When the current buffer becomes full, nlmsg_put() in
    dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index
    of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that
    point, and then the dump resumes on the same port with a new skb, and
    FDB entries up to the saved index are simply skipped.
    
    Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to
    drivers, then drivers must check for the -EMSGSIZE error code returned
    by it. Otherwise, when a netlink skb becomes full, DSA will no longer
    save newly dumped FDB entries to it, but the driver will continue
    dumping. So FDB entries will be missing from the dump.
    
    Fix the broken backpressure by propagating the "cb" return code and
    allow rtnl_fdb_dump() to restart the FDB dump with a new skb.
    
    Fixes: 58c59ef9e930 ("net: dsa: lantiq: Add Forwarding Database access")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c6cbf5672cc0130b342cfedf73dcdd1cc23a5e85
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Aug 10 14:19:54 2021 +0300

    net: dsa: lan9303: fix broken backpressure in .port_fdb_dump
    
    [ Upstream commit ada2fee185d8145afb89056558bb59545b9dbdd0 ]
    
    rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into
    multiple netlink skbs if the buffer provided by user space is too small
    (one buffer will typically handle a few hundred FDB entries).
    
    When the current buffer becomes full, nlmsg_put() in
    dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index
    of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that
    point, and then the dump resumes on the same port with a new skb, and
    FDB entries up to the saved index are simply skipped.
    
    Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to
    drivers, then drivers must check for the -EMSGSIZE error code returned
    by it. Otherwise, when a netlink skb becomes full, DSA will no longer
    save newly dumped FDB entries to it, but the driver will continue
    dumping. So FDB entries will be missing from the dump.
    
    Fix the broken backpressure by propagating the "cb" return code and
    allow rtnl_fdb_dump() to restart the FDB dump with a new skb.
    
    Fixes: ab335349b852 ("net: dsa: lan9303: Add port_fast_age and port_fdb_dump methods")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 22ecb3423f9c0fa9ebcf164175cab59b4b6bf334
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Tue Aug 10 14:19:53 2021 +0300

    net: dsa: hellcreek: fix broken backpressure in .port_fdb_dump
    
    [ Upstream commit cd391280bf4693ceddca8f19042cff42f98c1a89 ]
    
    rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into
    multiple netlink skbs if the buffer provided by user space is too small
    (one buffer will typically handle a few hundred FDB entries).
    
    When the current buffer becomes full, nlmsg_put() in
    dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index
    of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that
    point, and then the dump resumes on the same port with a new skb, and
    FDB entries up to the saved index are simply skipped.
    
    Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to
    drivers, then drivers must check for the -EMSGSIZE error code returned
    by it. Otherwise, when a netlink skb becomes full, DSA will no longer
    save newly dumped FDB entries to it, but the driver will continue
    dumping. So FDB entries will be missing from the dump.
    
    Fix the broken backpressure by propagating the "cb" return code and
    allow rtnl_fdb_dump() to restart the FDB dump with a new skb.
    
    Fixes: e4b27ebc780f ("net: dsa: Add DSA driver for Hirschmann Hellcreek switches")
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 52133524d807bfa46a794807421c531bd18471fc
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Aug 10 02:45:47 2021 -0700

    net: igmp: fix data-race in igmp_ifc_timer_expire()
    
    [ Upstream commit 4a2b285e7e103d4d6c6ed3e5052a0ff74a5d7f15 ]
    
    Fix the data-race reported by syzbot [1]
    Issue here is that igmp_ifc_timer_expire() can update in_dev->mr_ifc_count
    while another change just occured from another context.
    
    in_dev->mr_ifc_count is only 8bit wide, so the race had little
    consequences.
    
    [1]
    BUG: KCSAN: data-race in igmp_ifc_event / igmp_ifc_timer_expire
    
    write to 0xffff8881051e3062 of 1 bytes by task 12547 on cpu 0:
     igmp_ifc_event+0x1d5/0x290 net/ipv4/igmp.c:821
     igmp_group_added+0x462/0x490 net/ipv4/igmp.c:1356
     ____ip_mc_inc_group+0x3ff/0x500 net/ipv4/igmp.c:1461
     __ip_mc_join_group+0x24d/0x2c0 net/ipv4/igmp.c:2199
     ip_mc_join_group_ssm+0x20/0x30 net/ipv4/igmp.c:2218
     do_ip_setsockopt net/ipv4/ip_sockglue.c:1285 [inline]
     ip_setsockopt+0x1827/0x2a80 net/ipv4/ip_sockglue.c:1423
     tcp_setsockopt+0x8c/0xa0 net/ipv4/tcp.c:3657
     sock_common_setsockopt+0x5d/0x70 net/core/sock.c:3362
     __sys_setsockopt+0x18f/0x200 net/socket.c:2159
     __do_sys_setsockopt net/socket.c:2170 [inline]
     __se_sys_setsockopt net/socket.c:2167 [inline]
     __x64_sys_setsockopt+0x62/0x70 net/socket.c:2167
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    read to 0xffff8881051e3062 of 1 bytes by interrupt on cpu 1:
     igmp_ifc_timer_expire+0x706/0xa30 net/ipv4/igmp.c:808
     call_timer_fn+0x2e/0x1d0 kernel/time/timer.c:1419
     expire_timers+0x135/0x250 kernel/time/timer.c:1464
     __run_timers+0x358/0x420 kernel/time/timer.c:1732
     run_timer_softirq+0x19/0x30 kernel/time/timer.c:1745
     __do_softirq+0x12c/0x26e kernel/softirq.c:558
     invoke_softirq kernel/softirq.c:432 [inline]
     __irq_exit_rcu+0x9a/0xb0 kernel/softirq.c:636
     sysvec_apic_timer_interrupt+0x69/0x80 arch/x86/kernel/apic/apic.c:1100
     asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638
     console_unlock+0x8e8/0xb30 kernel/printk/printk.c:2646
     vprintk_emit+0x125/0x3d0 kernel/printk/printk.c:2174
     vprintk_default+0x22/0x30 kernel/printk/printk.c:2185
     vprintk+0x15a/0x170 kernel/printk/printk_safe.c:392
     printk+0x62/0x87 kernel/printk/printk.c:2216
     selinux_netlink_send+0x399/0x400 security/selinux/hooks.c:6041
     security_netlink_send+0x42/0x90 security/security.c:2070
     netlink_sendmsg+0x59e/0x7c0 net/netlink/af_netlink.c:1919
     sock_sendmsg_nosec net/socket.c:703 [inline]
     sock_sendmsg net/socket.c:723 [inline]
     ____sys_sendmsg+0x360/0x4d0 net/socket.c:2392
     ___sys_sendmsg net/socket.c:2446 [inline]
     __sys_sendmsg+0x1ed/0x270 net/socket.c:2475
     __do_sys_sendmsg net/socket.c:2484 [inline]
     __se_sys_sendmsg net/socket.c:2482 [inline]
     __x64_sys_sendmsg+0x42/0x50 net/socket.c:2482
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x3d/0x90 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    value changed: 0x01 -> 0x02
    
    Reported by Kernel Concurrency Sanitizer on:
    CPU: 1 PID: 12539 Comm: syz-executor.1 Not tainted 5.14.0-rc4-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 44c8aa99691174b990469b319197940f7995ddd2
Author: Takeshi Misawa <jeliantsurux@gmail.com>
Date:   Thu Aug 5 16:54:14 2021 +0900

    net: Fix memory leak in ieee802154_raw_deliver
    
    [ Upstream commit 1090340f7ee53e824fd4eef66a4855d548110c5b ]
    
    If IEEE-802.15.4-RAW is closed before receive skb, skb is leaked.
    Fix this, by freeing sk_receive_queue in sk->sk_destruct().
    
    syzbot report:
    BUG: memory leak
    unreferenced object 0xffff88810f644600 (size 232):
      comm "softirq", pid 0, jiffies 4294967032 (age 81.270s)
      hex dump (first 32 bytes):
        10 7d 4b 12 81 88 ff ff 10 7d 4b 12 81 88 ff ff  .}K......}K.....
        00 00 00 00 00 00 00 00 40 7c 4b 12 81 88 ff ff  ........@|K.....
      backtrace:
        [<ffffffff83651d4a>] skb_clone+0xaa/0x2b0 net/core/skbuff.c:1496
        [<ffffffff83fe1b80>] ieee802154_raw_deliver net/ieee802154/socket.c:369 [inline]
        [<ffffffff83fe1b80>] ieee802154_rcv+0x100/0x340 net/ieee802154/socket.c:1070
        [<ffffffff8367cc7a>] __netif_receive_skb_one_core+0x6a/0xa0 net/core/dev.c:5384
        [<ffffffff8367cd07>] __netif_receive_skb+0x27/0xa0 net/core/dev.c:5498
        [<ffffffff8367cdd9>] netif_receive_skb_internal net/core/dev.c:5603 [inline]
        [<ffffffff8367cdd9>] netif_receive_skb+0x59/0x260 net/core/dev.c:5662
        [<ffffffff83fe6302>] ieee802154_deliver_skb net/mac802154/rx.c:29 [inline]
        [<ffffffff83fe6302>] ieee802154_subif_frame net/mac802154/rx.c:102 [inline]
        [<ffffffff83fe6302>] __ieee802154_rx_handle_packet net/mac802154/rx.c:212 [inline]
        [<ffffffff83fe6302>] ieee802154_rx+0x612/0x620 net/mac802154/rx.c:284
        [<ffffffff83fe59a6>] ieee802154_tasklet_handler+0x86/0xa0 net/mac802154/main.c:35
        [<ffffffff81232aab>] tasklet_action_common.constprop.0+0x5b/0x100 kernel/softirq.c:557
        [<ffffffff846000bf>] __do_softirq+0xbf/0x2ab kernel/softirq.c:345
        [<ffffffff81232f4c>] do_softirq kernel/softirq.c:248 [inline]
        [<ffffffff81232f4c>] do_softirq+0x5c/0x80 kernel/softirq.c:235
        [<ffffffff81232fc1>] __local_bh_enable_ip+0x51/0x60 kernel/softirq.c:198
        [<ffffffff8367a9a4>] local_bh_enable include/linux/bottom_half.h:32 [inline]
        [<ffffffff8367a9a4>] rcu_read_unlock_bh include/linux/rcupdate.h:745 [inline]
        [<ffffffff8367a9a4>] __dev_queue_xmit+0x7f4/0xf60 net/core/dev.c:4221
        [<ffffffff83fe2db4>] raw_sendmsg+0x1f4/0x2b0 net/ieee802154/socket.c:295
        [<ffffffff8363af16>] sock_sendmsg_nosec net/socket.c:654 [inline]
        [<ffffffff8363af16>] sock_sendmsg+0x56/0x80 net/socket.c:674
        [<ffffffff8363deec>] __sys_sendto+0x15c/0x200 net/socket.c:1977
        [<ffffffff8363dfb6>] __do_sys_sendto net/socket.c:1989 [inline]
        [<ffffffff8363dfb6>] __se_sys_sendto net/socket.c:1985 [inline]
        [<ffffffff8363dfb6>] __x64_sys_sendto+0x26/0x30 net/socket.c:1985
    
    Fixes: 9ec767160357 ("net: add IEEE 802.15.4 socket family implementation")
    Reported-and-tested-by: syzbot+1f68113fa907bf0695a8@syzkaller.appspotmail.com
    Signed-off-by: Takeshi Misawa <jeliantsurux@gmail.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20210805075414.GA15796@DESKTOP
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 74b264b342a5d0d8900fad60247b0313aae0add5
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 01:00:15 2021 +0200

    net: dsa: microchip: ksz8795: Don't use phy_port_cnt in VLAN table lookup
    
    [ Upstream commit 411d466d94a6b16a20c8b552e403b7e8ce2397a2 ]
    
    The magic number 4 in VLAN table lookup was the number of entries we
    can read and write at once.  Using phy_port_cnt here doesn't make
    sense and presumably broke VLAN filtering for 3-port switches.  Change
    it back to 4.
    
    Fixes: 4ce2a984abd8 ("net: dsa: microchip: ksz8795: use phy_port_cnt ...")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1c4f28207fabd032bde9fb9f11ef0e3f19d4198d
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 01:00:06 2021 +0200

    net: dsa: microchip: ksz8795: Fix VLAN filtering
    
    [ Upstream commit 164844135a3f215d3018ee9d6875336beb942413 ]
    
    Currently ksz8_port_vlan_filtering() sets or clears the VLAN Enable
    hardware flag.  That controls discarding of packets with a VID that
    has not been enabled for any port on the switch.
    
    Since it is a global flag, set the dsa_switch::vlan_filtering_is_global
    flag so that the DSA core understands this can't be controlled per
    port.
    
    When VLAN filtering is enabled, the switch should also discard packets
    with a VID that's not enabled on the ingress port.  Set or clear each
    external port's VLAN Ingress Filter flag in ksz8_port_vlan_filtering()
    to make that happen.
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3cc015794dab78b1ae12fe9ab76718c37576f6b3
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 00:59:57 2021 +0200

    net: dsa: microchip: ksz8795: Use software untagging on CPU port
    
    [ Upstream commit 9130c2d30c17846287b803a9803106318cbe5266 ]
    
    On the CPU port, we can support both tagged and untagged VLANs at the
    same time by doing any necessary untagging in software rather than
    hardware.  To enable that, keep the CPU port's Remove Tag flag cleared
    and set the dsa_switch::untag_bridge_pvid flag.
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9674dc6724c5e86fc34562d7e7498deaa347e97c
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 00:59:47 2021 +0200

    net: dsa: microchip: ksz8795: Fix VLAN untagged flag change on deletion
    
    [ Upstream commit af01754f9e3c553a2ee63b4693c79a3956e230ab ]
    
    When a VLAN is deleted from a port, the flags in struct
    switchdev_obj_port_vlan are always 0.  ksz8_port_vlan_del() copies the
    BRIDGE_VLAN_INFO_UNTAGGED flag to the port's Tag Removal flag, and
    therefore always clears it.
    
    In case there are multiple VLANs configured as untagged on this port -
    which seems useless, but is allowed - deleting one of them changes the
    remaining VLANs to be tagged.
    
    It's only ever necessary to change this flag when a VLAN is added to
    the port, so leave it unchanged in ksz8_port_vlan_del().
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 159948c423aa726d62c2ee36068ff2fa6dfbae2c
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 00:59:37 2021 +0200

    net: dsa: microchip: ksz8795: Reject unsupported VLAN configuration
    
    [ Upstream commit 8f4f58f88fe0d9bd591f21f53de7dbd42baeb3fa ]
    
    The switches supported by ksz8795 only have a per-port flag for Tag
    Removal.  This means it is not possible to support both tagged and
    untagged VLANs on the same port.  Reject attempts to add a VLAN that
    requires the flag to be changed, unless there are no VLANs currently
    configured.
    
    VID 0 is excluded from this check since it is untagged regardless of
    the state of the flag.
    
    On the CPU port we could support tagged and untagged VLANs at the same
    time.  This will be enabled by a later patch.
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3149f9edddf9187e5f8a283faf4a4a8d544179cb
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 00:59:28 2021 +0200

    net: dsa: microchip: ksz8795: Fix PVID tag insertion
    
    [ Upstream commit ef3b02a1d79b691f9a354c4903cf1e6917e315f9 ]
    
    ksz8795 has never actually enabled PVID tag insertion, and it also
    programmed the PVID incorrectly.  To fix this:
    
    * Allow tag insertion to be controlled per ingress port.  On most
      chips, set bit 2 in Global Control 19.  On KSZ88x3 this control
      flag doesn't exist.
    
    * When adding a PVID:
      - Set the appropriate register bits to enable tag insertion on
        egress at every other port if this was the packet's ingress port.
      - Mask *out* the VID from the default tag, before or-ing in the new
        PVID.
    
    * When removing a PVID:
      - Clear the same control bits to disable tag insertion.
      - Don't update the default tag.  This wasn't doing anything useful.
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8154453a4be5d917b9f5d86914c87aa61a668af1
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Tue Aug 10 00:59:12 2021 +0200

    net: dsa: microchip: Fix ksz_read64()
    
    [ Upstream commit c34f674c8875235725c3ef86147a627f165d23b4 ]
    
    ksz_read64() currently does some dubious byte-swapping on the two
    halves of a 64-bit register, and then only returns the high bits.
    Replace this with a straightforward expression.
    
    Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 037570c9adab40513bc35777eba597e425cbd3f5
Author: Yonghong Song <yhs@fb.com>
Date:   Mon Aug 9 18:04:13 2021 -0700

    bpf: Fix potentially incorrect results with bpf_get_local_storage()
    
    [ Upstream commit a2baf4e8bb0f306fbed7b5e6197c02896a638ab5 ]
    
    Commit b910eaaaa4b8 ("bpf: Fix NULL pointer dereference in bpf_get_local_storage()
    helper") fixed a bug for bpf_get_local_storage() helper so different tasks
    won't mess up with each other's percpu local storage.
    
    The percpu data contains 8 slots so it can hold up to 8 contexts (same or
    different tasks), for 8 different program runs, at the same time. This in
    general is sufficient. But our internal testing showed the following warning
    multiple times:
    
      [...]
      warning: WARNING: CPU: 13 PID: 41661 at include/linux/bpf-cgroup.h:193
         __cgroup_bpf_run_filter_sock_ops+0x13e/0x180
      RIP: 0010:__cgroup_bpf_run_filter_sock_ops+0x13e/0x180
      <IRQ>
       tcp_call_bpf.constprop.99+0x93/0xc0
       tcp_conn_request+0x41e/0xa50
       ? tcp_rcv_state_process+0x203/0xe00
       tcp_rcv_state_process+0x203/0xe00
       ? sk_filter_trim_cap+0xbc/0x210
       ? tcp_v6_inbound_md5_hash.constprop.41+0x44/0x160
       tcp_v6_do_rcv+0x181/0x3e0
       tcp_v6_rcv+0xc65/0xcb0
       ip6_protocol_deliver_rcu+0xbd/0x450
       ip6_input_finish+0x11/0x20
       ip6_input+0xb5/0xc0
       ip6_sublist_rcv_finish+0x37/0x50
       ip6_sublist_rcv+0x1dc/0x270
       ipv6_list_rcv+0x113/0x140
       __netif_receive_skb_list_core+0x1a0/0x210
       netif_receive_skb_list_internal+0x186/0x2a0
       gro_normal_list.part.170+0x19/0x40
       napi_complete_done+0x65/0x150
       mlx5e_napi_poll+0x1ae/0x680
       __napi_poll+0x25/0x120
       net_rx_action+0x11e/0x280
       __do_softirq+0xbb/0x271
       irq_exit_rcu+0x97/0xa0
       common_interrupt+0x7f/0xa0
       </IRQ>
       asm_common_interrupt+0x1e/0x40
      RIP: 0010:bpf_prog_1835a9241238291a_tw_egress+0x5/0xbac
       ? __cgroup_bpf_run_filter_skb+0x378/0x4e0
       ? do_softirq+0x34/0x70
       ? ip6_finish_output2+0x266/0x590
       ? ip6_finish_output+0x66/0xa0
       ? ip6_output+0x6c/0x130
       ? ip6_xmit+0x279/0x550
       ? ip6_dst_check+0x61/0xd0
      [...]
    
    Using drgn [0] to dump the percpu buffer contents showed that on this CPU
    slot 0 is still available, but slots 1-7 are occupied and those tasks in
    slots 1-7 mostly don't exist any more. So we might have issues in
    bpf_cgroup_storage_unset().
    
    Further debugging confirmed that there is a bug in bpf_cgroup_storage_unset().
    Currently, it tries to unset "current" slot with searching from the start.
    So the following sequence is possible:
    
      1. A task is running and claims slot 0
      2. Running BPF program is done, and it checked slot 0 has the "task"
         and ready to reset it to NULL (not yet).
      3. An interrupt happens, another BPF program runs and it claims slot 1
         with the *same* task.
      4. The unset() in interrupt context releases slot 0 since it matches "task".
      5. Interrupt is done, the task in process context reset slot 0.
    
    At the end, slot 1 is not reset and the same process can continue to occupy
    slots 2-7 and finally, when the above step 1-5 is repeated again, step 3 BPF
    program won't be able to claim an empty slot and a warning will be issued.
    
    To fix the issue, for unset() function, we should traverse from the last slot
    to the first. This way, the above issue can be avoided.
    
    The same reverse traversal should also be done in bpf_get_local_storage() helper
    itself. Otherwise, incorrect local storage may be returned to BPF program.
    
      [0] https://github.com/osandov/drgn
    
    Fixes: b910eaaaa4b8 ("bpf: Fix NULL pointer dereference in bpf_get_local_storage() helper")
    Signed-off-by: Yonghong Song <yhs@fb.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20210810010413.1976277-1-yhs@fb.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1d1808fae2e085228da8577f1bf7f4cbe25fef2a
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Wed Jul 28 10:38:43 2021 +0200

    ovl: fix deadlock in splice write
    
    [ Upstream commit 9b91b6b019fda817eb52f728eb9c79b3579760bc ]
    
    There's possibility of an ABBA deadlock in case of a splice write to an
    overlayfs file and a concurrent splice write to a corresponding real file.
    
    The call chain for splice to an overlay file:
    
     -> do_splice                     [takes sb_writers on overlay file]
       -> do_splice_from
         -> iter_file_splice_write    [takes pipe->mutex]
           -> vfs_iter_write
             ...
             -> ovl_write_iter        [takes sb_writers on real file]
    
    And the call chain for splice to a real file:
    
     -> do_splice                     [takes sb_writers on real file]
       -> do_splice_from
         -> iter_file_splice_write    [takes pipe->mutex]
    
    Syzbot successfully bisected this to commit 82a763e61e2b ("ovl: simplify
    file splice").
    
    Fix by reverting the write part of the above commit and by adding missing
    bits from ovl_write_iter() into ovl_splice_write().
    
    Fixes: 82a763e61e2b ("ovl: simplify file splice")
    Reported-and-tested-by: syzbot+579885d1a9a833336209@syzkaller.appspotmail.com
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 75004b47fba41ffba1c779350d9e457ace11cc6b
Author: Christian Hewitt <christianshewitt@gmail.com>
Date:   Fri Aug 6 09:40:05 2021 +0000

    drm/meson: fix colour distortion from HDR set during vendor u-boot
    
    [ Upstream commit bf33677a3c394bb8fddd48d3bbc97adf0262e045 ]
    
    Add support for the OSD1 HDR registers so meson DRM can handle the HDR
    properties set by Amlogic u-boot on G12A and newer devices which result
    in blue/green/pink colour distortion to display output.
    
    This takes the original patch submissions from Mathias [0] and [1] with
    corrections for formatting and the missing description and attribution
    needed for merge.
    
    [0] https://lore.kernel.org/linux-amlogic/59dfd7e6-fc91-3d61-04c4-94e078a3188c@baylibre.com/T/
    [1] https://lore.kernel.org/linux-amlogic/CAOKfEHBx_fboUqkENEMd-OC-NSrf46nto+vDLgvgttzPe99kXg@mail.gmail.com/T/#u
    
    Fixes: 728883948b0d ("drm/meson: Add G12A Support for VIU setup")
    Suggested-by: Mathias Steiger <mathias.steiger@googlemail.com>
    Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
    Tested-by: Neil Armstrong <narmstrong@baylibre.com>
    Tested-by: Philip Milev <milev.philip@gmail.com>
    [narmsrong: adding missing space on second tested-by tag]
    Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210806094005.7136-1-christianshewitt@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 11e249ce5e3e8b124bdcc2a9f546869ee9f5e004
Author: Aya Levin <ayal@nvidia.com>
Date:   Tue Jun 8 16:38:30 2021 +0300

    net/mlx5: Fix return value from tracer initialization
    
    [ Upstream commit bd37c2888ccaa5ceb9895718f6909b247cc372e0 ]
    
    Check return value of mlx5_fw_tracer_start(), set error path and fix
    return value of mlx5_fw_tracer_init() accordingly.
    
    Fixes: c71ad41ccb0c ("net/mlx5: FW tracer, events handling")
    Signed-off-by: Aya Levin <ayal@nvidia.com>
    Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 436f4a1c6d17efddbdbbb121ee7e2c9690737673
Author: Shay Drory <shayd@nvidia.com>
Date:   Sun Apr 11 15:32:55 2021 +0300

    net/mlx5: Synchronize correct IRQ when destroying CQ
    
    [ Upstream commit 563476ae0c5e48a028cbfa38fa9d2fc0418eb88f ]
    
    The CQ destroy is performed based on the IRQ number that is stored in
    cq->irqn. That number wasn't set explicitly during CQ creation and as
    expected some of the API users of mlx5_core_create_cq() forgot to update
    it.
    
    This caused to wrong synchronization call of the wrong IRQ with a number
    0 instead of the real one.
    
    As a fix, set the IRQ number directly in the mlx5_core_create_cq() and
    update all users accordingly.
    
    Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
    Fixes: ef1659ade359 ("IB/mlx5: Add DEVX support for CQ events")
    Signed-off-by: Shay Drory <shayd@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9b0b9c9da81082c097e42f85fc1d17ef48d9968b
Author: Chris Mi <cmi@nvidia.com>
Date:   Thu May 6 11:40:34 2021 +0800

    net/mlx5e: TC, Fix error handling memory leak
    
    [ Upstream commit 88bbd7b2369aca4598eb8f38c5f16be98c3bb5d4 ]
    
    Free the offload sample action on error.
    
    Fixes: f94d6389f6a8 ("net/mlx5e: TC, Add support to offload sample action")
    Signed-off-by: Chris Mi <cmi@nvidia.com>
    Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 89163e392e5717a65875179b956fda7e7d7c7a45
Author: Aya Levin <ayal@nvidia.com>
Date:   Wed Jul 28 18:18:59 2021 +0300

    net/mlx5: Block switchdev mode while devlink traps are active
    
    [ Upstream commit c85a6b8feb16c0cdbbc8d9f581c7861c4a9ac351 ]
    
    Since switchdev mode can't support  devlink traps, verify there are
    no active devlink traps before moving eswitch to switchdev mode. If
    there are active traps, prevent the switchdev mode configuration.
    
    Fixes: eb3862a0525d ("net/mlx5e: Enable traps according to link state")
    Signed-off-by: Aya Levin <ayal@nvidia.com>
    Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 09ab613d4996774a942a50fa5ff0c4c392557c3f
Author: Maxim Mikityanskiy <maximmi@nvidia.com>
Date:   Mon May 24 16:15:22 2021 +0300

    net/mlx5e: Destroy page pool after XDP SQ to fix use-after-free
    
    [ Upstream commit 8ba3e4c85825c8801a2c298dcadac650a40d7137 ]
    
    mlx5e_close_xdpsq does the cleanup: it calls mlx5e_free_xdpsq_descs to
    free the outstanding descriptors, which relies on
    mlx5e_page_release_dynamic and page_pool_release_page. However,
    page_pool_destroy is already called by this point, because
    mlx5e_close_rq runs before mlx5e_close_xdpsq.
    
    This commit fixes the use-after-free by swapping mlx5e_close_xdpsq and
    mlx5e_close_rq.
    
    The commit cited below started calling page_pool_destroy directly from
    the driver. Previously, the page pool was destroyed under a call_rcu
    from xdp_rxq_info_unreg_mem_model, which would defer the deallocation
    until after the XDPSQ is cleaned up.
    
    Fixes: 1da4bbeffe41 ("net: core: page_pool: add user refcnt and reintroduce page_pool_destroy")
    Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c0cb7d8be945b63a609a725b1c55d895accfca77
Author: Roi Dayan <roid@nvidia.com>
Date:   Sun Aug 1 15:47:46 2021 +0300

    net/mlx5e: Avoid creating tunnel headers for local route
    
    [ Upstream commit c623c95afa56bf4bf64e4f58742dc94616ef83db ]
    
    It could be local and remote are on the same machine and the route
    result will be a local route which will result in creating encap id
    with src/dst mac address of 0.
    
    Fixes: a54e20b4fcae ("net/mlx5e: Add basic TC tunnel set action for SRIOV offloads")
    Signed-off-by: Roi Dayan <roid@nvidia.com>
    Reviewed-by: Maor Dickman <maord@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3f20768c9fdc0be92dac34502dcc8e4ca93ceb79
Author: Alex Vesker <valex@nvidia.com>
Date:   Tue Jun 22 16:51:58 2021 +0300

    net/mlx5: DR, Add fail on error check on decap
    
    [ Upstream commit d3875924dae632d5edd908d285fffc5f07c835a3 ]
    
    While processing encapsulated packet on RX, one of the fields that is
    checked is the inner packet length. If the length as specified in the header
    doesn't match the actual inner packet length, the packet is invalid
    and should be dropped. However, such packet caused the NIC to hang.
    
    This patch turns on a 'fail_on_error' HW bit which allows HW to drop
    such an invalid packet while processing RX packet and trying to decap it.
    
    Fixes: ad17dc8cf910 ("net/mlx5: DR, Move STEv0 action apply logic")
    Signed-off-by: Alex Vesker <valex@nvidia.com>
    Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit df712c5d591aa6eb1f4eb3c91e2dff4aa0423a05
Author: Leon Romanovsky <leon@kernel.org>
Date:   Mon Aug 2 16:39:54 2021 +0300

    net/mlx5: Don't skip subfunction cleanup in case of error in module init
    
    [ Upstream commit c633e799641cf13960bd83189b4d5b1b2adb0d4e ]
    
    Clean SF resources if mlx5 eth failed to initialize.
    
    Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: Parav Pandit <parav@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f49d457950b99901f6d63a55cf2167a4889d8509
Author: Hao Xu <haoxu@linux.alibaba.com>
Date:   Sun Aug 8 21:54:34 2021 +0800

    io-wq: fix IO_WORKER_F_FIXED issue in create_io_worker()
    
    [ Upstream commit 47cae0c71f7a126903f930191e6e9f103674aca1 ]
    
    There may be cases like:
            A                                 B
    spin_lock(wqe->lock)
    nr_workers is 0
    nr_workers++
    spin_unlock(wqe->lock)
                                         spin_lock(wqe->lock)
                                         nr_wokers is 1
                                         nr_workers++
                                         spin_unlock(wqe->lock)
    create_io_worker()
      acct->worker is 1
                                         create_io_worker()
                                           acct->worker is 1
    
    There should be one worker marked IO_WORKER_F_FIXED, but no one is.
    Fix this by introduce a new agrument for create_io_worker() to indicate
    if it is the first worker.
    
    Fixes: 3d4e4face9c1 ("io-wq: fix no lock protection of acct->nr_worker")
    Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20210808135434.68667-3-haoxu@linux.alibaba.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 815a0fe3f415e78ae8678fc1b8864e2dc34b9091
Author: Hao Xu <haoxu@linux.alibaba.com>
Date:   Sun Aug 8 21:54:33 2021 +0800

    io-wq: fix bug of creating io-wokers unconditionally
    
    [ Upstream commit 49e7f0c789add1330b111af0b7caeb0e87df063e ]
    
    The former patch to add check between nr_workers and max_workers has a
    bug, which will cause unconditionally creating io-workers. That's
    because the result of the check doesn't affect the call of
    create_io_worker(), fix it by bringing in a boolean value for it.
    
    Fixes: 21698274da5b ("io-wq: fix lack of acct->nr_workers < acct->max_workers judgement")
    Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
    Link: https://lore.kernel.org/r/20210808135434.68667-2-haoxu@linux.alibaba.com
    [axboe: drop hunk that isn't strictly needed]
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3cedeb691b74c1c0d85a7241727ad5e62ba53b4e
Author: Guillaume Nault <gnault@redhat.com>
Date:   Fri Aug 6 17:52:06 2021 +0200

    bareudp: Fix invalid read beyond skb's linear data
    
    [ Upstream commit 143a8526ab5fd4f8a0c4fe2a9cb28c181dc5a95f ]
    
    Data beyond the UDP header might not be part of the skb's linear data.
    Use skb_copy_bits() instead of direct access to skb->data+X, so that
    we read the correct bytes even on a fragmented skb.
    
    Fixes: 4b5f67232d95 ("net: Special handling for IP & MPLS.")
    Signed-off-by: Guillaume Nault <gnault@redhat.com>
    Link: https://lore.kernel.org/r/7741c46545c6ef02e70c80a9b32814b22d9616b3.1628264975.git.gnault@redhat.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ed277fbd30536028afee2505cd04e30551a05c18
Author: Roi Dayan <roid@nvidia.com>
Date:   Sun Aug 8 09:52:42 2021 +0300

    psample: Add a fwd declaration for skbuff
    
    [ Upstream commit beb7f2de5728b0bd2140a652fa51f6ad85d159f7 ]
    
    Without this there is a warning if source files include psample.h
    before skbuff.h or doesn't include it at all.
    
    Fixes: 6ae0a6286171 ("net: Introduce psample, a new genetlink channel for packet sampling")
    Signed-off-by: Roi Dayan <roid@nvidia.com>
    Link: https://lore.kernel.org/r/20210808065242.1522535-1-roid@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 792e7591d3084ce0d473d6df137afbf45bb4bcbb
Author: Md Fahad Iqbal Polash <md.fahad.iqbal.polash@intel.com>
Date:   Fri Jun 4 09:53:33 2021 -0700

    iavf: Set RSS LUT and key in reset handle path
    
    [ Upstream commit a7550f8b1c9712894f9e98d6caf5f49451ebd058 ]
    
    iavf driver should set RSS LUT and key unconditionally in reset
    path. Currently, the driver does not do that. This patch fixes
    this issue.
    
    Fixes: 2c86ac3c7079 ("i40evf: create a generic config RSS function")
    Signed-off-by: Md Fahad Iqbal Polash <md.fahad.iqbal.polash@intel.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f2b15898012a805e96fa1e7458e6e52ae48e450f
Author: Brett Creeley <brett.creeley@intel.com>
Date:   Fri Aug 6 09:51:27 2021 -0700

    ice: don't remove netdev->dev_addr from uc sync list
    
    [ Upstream commit 3ba7f53f8bf1fb862e36c7f74434ac3aceb60158 ]
    
    In some circumstances, such as with bridging, it's possible that the
    stack will add the device's own MAC address to its unicast address list.
    
    If, later, the stack deletes this address, the driver will receive a
    request to remove this address.
    
    The driver stores its current MAC address as part of the VSI MAC filter
    list instead of separately. So, this causes a problem when the device's
    MAC address is deleted unexpectedly, which results in traffic failure in
    some cases.
    
    The following configuration steps will reproduce the previously
    mentioned problem:
    
    > ip link set eth0 up
    > ip link add dev br0 type bridge
    > ip link set br0 up
    > ip addr flush dev eth0
    > ip link set eth0 master br0
    > echo 1 > /sys/class/net/br0/bridge/vlan_filtering
    > modprobe -r veth
    > modprobe -r bridge
    > ip addr add 192.168.1.100/24 dev eth0
    
    The following ping command fails due to the netdev->dev_addr being
    deleted when removing the bridge module.
    > ping <link partner>
    
    Fix this by making sure to not delete the netdev->dev_addr during MAC
    address sync. After fixing this issue it was noticed that the
    netdev_warn() in .set_mac was overly verbose, so make it at
    netdev_dbg().
    
    Also, there is a possibility of a race condition between .set_mac and
    .set_rx_mode. Fix this by calling netif_addr_lock_bh() and
    netif_addr_unlock_bh() on the device's netdev when the netdev->dev_addr
    is going to be updated in .set_mac.
    
    Fixes: e94d44786693 ("ice: Implement filter sync, NDO operations and bump version")
    Signed-off-by: Brett Creeley <brett.creeley@intel.com>
    Tested-by: Liang Li <liali@redhat.com>
    Tested-by: Gurucharan G <gurucharanx.g@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8a08142433624fd1088bc8c13639408cf4e1707c
Author: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Date:   Wed Aug 4 12:12:42 2021 -0700

    ice: Stop processing VF messages during teardown
    
    [ Upstream commit c503e63200c679e362afca7aca9d3dc63a0f45ed ]
    
    When VFs are setup and torn down in quick succession, it is possible
    that a VF is torn down by the PF while the VF's virtchnl requests are
    still in the PF's mailbox ring. Processing the VF's virtchnl request
    when the VF itself doesn't exist results in undefined behavior. Fix
    this by adding a check to stop processing virtchnl requests when VF
    teardown is in progress.
    
    Fixes: ddf30f7ff840 ("ice: Add handler to configure SR-IOV")
    Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e266d4c43b95a13d04e78069d1efdb14d1c4b589
Author: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Date:   Wed Jul 28 12:39:10 2021 -0700

    ice: Prevent probing virtual functions
    
    [ Upstream commit 50ac7479846053ca8054be833c1594e64de496bb ]
    
    The userspace utility "driverctl" can be used to change/override the
    system's default driver choices. This is useful in some situations
    (buggy driver, old driver missing a device ID, trying a workaround,
    etc.) where the user needs to load a different driver.
    
    However, this is also prone to user error, where a driver is mapped
    to a device it's not designed to drive. For example, if the ice driver
    is mapped to driver iavf devices, the ice driver crashes.
    
    Add a check to return an error if the ice driver is being used to
    probe a virtual function.
    
    Fixes: 837f08fdecbe ("ice: Add basic driver framework for Intel(R) E800 Series")
    Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
    Tested-by: Gurucharan G <gurucharanx.g@intel.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 00735401c91830e08ac524b4fd0109f1238161a6
Author: Hangbin Liu <liuhangbin@gmail.com>
Date:   Mon Aug 9 15:04:55 2021 +0800

    net: sched: act_mirred: Reset ct info when mirror/redirect skb
    
    [ Upstream commit d09c548dbf3b31cb07bba562e0f452edfa01efe3 ]
    
    When mirror/redirect a skb to a different port, the ct info should be reset
    for reclassification. Or the pkts will match unexpected rules. For example,
    with following topology and commands:
    
        -----------
                  |
           veth0 -+-------
                  |
           veth1 -+-------
                  |
       ------------
    
     tc qdisc add dev veth0 clsact
     # The same with "action mirred egress mirror dev veth1" or "action mirred ingress redirect dev veth1"
     tc filter add dev veth0 egress chain 1 protocol ip flower ct_state +trk action mirred ingress mirror dev veth1
     tc filter add dev veth0 egress chain 0 protocol ip flower ct_state -inv action ct commit action goto chain 1
     tc qdisc add dev veth1 clsact
     tc filter add dev veth1 ingress chain 0 protocol ip flower ct_state +trk action drop
    
     ping <remove ip via veth0> &
     tc -s filter show dev veth1 ingress
    
    With command 'tc -s filter show', we can find the pkts were dropped on
    veth1.
    
    Fixes: b57dc7c13ea9 ("net/sched: Introduce action ct")
    Signed-off-by: Roi Dayan <roid@nvidia.com>
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e04669e14c5a3a8d6009ecad3dba98bd4a9bb56c
Author: Guvenc Gulce <guvenc@linux.ibm.com>
Date:   Mon Aug 9 11:05:57 2021 +0200

    net/smc: Correct smc link connection counter in case of smc client
    
    [ Upstream commit 64513d269e8971aabb7e787955a1b320e3031306 ]
    
    SMC clients may be assigned to a different link after the initial
    connection between two peers was established. In such a case,
    the connection counter was not correctly set.
    
    Update the connection counter correctly when a smc client connection
    is assigned to a different smc link.
    
    Fixes: 07d51580ff65 ("net/smc: Add connection counters for links")
    Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
    Tested-by: Karsten Graul <kgraul@linux.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9b8f136b88f342d5b9a53bce7795fb0df9591748
Author: Karsten Graul <kgraul@linux.ibm.com>
Date:   Mon Aug 9 11:05:56 2021 +0200

    net/smc: fix wait on already cleared link
    
    [ Upstream commit 8f3d65c166797746455553f4eaf74a5f89f996d4 ]
    
    There can be a race between the waiters for a tx work request buffer
    and the link down processing that finally clears the link. Although
    all waiters are woken up before the link is cleared there might be
    waiters which did not yet get back control and are still waiting.
    This results in an access to a cleared wait queue head.
    
    Fix this by introducing atomic reference counting around the wait calls,
    and wait with the link clear processing until all waiters have finished.
    Move the work request layer related calls into smc_wr.c and set the
    link state to INACTIVE before calling smcr_link_clear() in
    smc_llc_srv_add_link().
    
    Fixes: 15e1b99aadfb ("net/smc: no WR buffer wait for terminating link group")
    Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
    Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6a4b92821135940de9790e135f28bff3d8b7b5eb
Author: Nadav Amit <namit@vmware.com>
Date:   Sat Aug 7 17:13:41 2021 -0700

    io_uring: clear TIF_NOTIFY_SIGNAL when running task work
    
    [ Upstream commit ef98eb0409c31c39ab55ff46b2721c3b4f84c122 ]
    
    When using SQPOLL, the submission queue polling thread calls
    task_work_run() to run queued work. However, when work is added with
    TWA_SIGNAL - as done by io_uring itself - the TIF_NOTIFY_SIGNAL remains
    set afterwards and is never cleared.
    
    Consequently, when the submission queue polling thread checks whether
    signal_pending(), it may always find a pending signal, if
    task_work_add() was ever called before.
    
    The impact of this bug might be different on different kernel versions.
    It appears that on 5.14 it would only cause unnecessary calculation and
    prevent the polling thread from sleeping. On 5.13, where the bug was
    found, it stops the polling thread from finding newly submitted work.
    
    Instead of task_work_run(), use tracehook_notify_signal() that clears
    TIF_NOTIFY_SIGNAL. Test for TIF_NOTIFY_SIGNAL in addition to
    current->task_works to avoid a race in which task_works is cleared but
    the TIF_NOTIFY_SIGNAL is set.
    
    Fixes: 685fe7feedb96 ("io-wq: eliminate the need for a manager thread")
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Pavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: Nadav Amit <namit@vmware.com>
    Link: https://lore.kernel.org/r/20210808001342.964634-2-namit@vmware.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1e19d18189fe1aeebbf41551109bb674af01ed87
Author: Pali Rohár <pali@kernel.org>
Date:   Sat Aug 7 15:27:03 2021 +0200

    ppp: Fix generating ifname when empty IFLA_IFNAME is specified
    
    [ Upstream commit 2459dcb96bcba94c08d6861f8a050185ff301672 ]
    
    IFLA_IFNAME is nul-term string which means that IFLA_IFNAME buffer can be
    larger than length of string which contains.
    
    Function __rtnl_newlink() generates new own ifname if either IFLA_IFNAME
    was not specified at all or userspace passed empty nul-term string.
    
    It is expected that if userspace does not specify ifname for new ppp netdev
    then kernel generates one in format "ppp<id>" where id matches to the ppp
    unit id which can be later obtained by PPPIOCGUNIT ioctl.
    
    And it works in this way if IFLA_IFNAME is not specified at all. But it
    does not work when IFLA_IFNAME is specified with empty string.
    
    So fix this logic also for empty IFLA_IFNAME in ppp_nl_newlink() function
    and correctly generates ifname based on ppp unit identifier if userspace
    did not provided preferred ifname.
    
    Without this patch when IFLA_IFNAME was specified with empty string then
    kernel created a new ppp interface in format "ppp<id>" but id did not
    match ppp unit id returned by PPPIOCGUNIT ioctl. In this case id was some
    number generated by __rtnl_newlink() function.
    
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Fixes: bb8082f69138 ("ppp: build ifname using unit identifier for rtnl based devices")
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2a4a96afa7b58243c87e6afa609ab419d930d883
Author: Ben Hutchings <ben.hutchings@mind.be>
Date:   Sat Aug 7 02:06:18 2021 +0200

    net: phy: micrel: Fix link detection on ksz87xx switch"
    
    [ Upstream commit 2383cb9497d113360137a2be308b390faa80632d ]
    
    Commit a5e63c7d38d5 "net: phy: micrel: Fix detection of ksz87xx
    switch" broke link detection on the external ports of the KSZ8795.
    
    The previously unused phy_driver structure for these devices specifies
    config_aneg and read_status functions that appear to be designed for a
    fixed link and do not work with the embedded PHYs in the KSZ8795.
    
    Delete the use of these functions in favour of the generic PHY
    implementations which were used previously.
    
    Fixes: a5e63c7d38d5 ("net: phy: micrel: Fix detection of ksz87xx switch")
    Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d8431e3fa7b39de0596d346d747b8b02b09620ee
Author: Oleksij Rempel <linux@rempel-privat.de>
Date:   Fri Aug 6 11:47:23 2021 +0200

    net: dsa: qca: ar9331: make proper initial port defaults
    
    [ Upstream commit 47fac45600aafc5939d9620055c3c46f7135d316 ]
    
    Make sure that all external port are actually isolated from each other,
    so no packets are leaked.
    
    Fixes: ec6698c272de ("net: dsa: add support for Atheros AR9331 built-in switch")
    Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ada7135e6d998030de0d166aa6a2438031f70fe3
Author: Tatsuhiko Yasumatsu <th.yasumatsu@gmail.com>
Date:   Sat Aug 7 00:04:18 2021 +0900

    bpf: Fix integer overflow involving bucket_size
    
    [ Upstream commit c4eb1f403243fc7bbb7de644db8587c03de36da6 ]
    
    In __htab_map_lookup_and_delete_batch(), hash buckets are iterated
    over to count the number of elements in each bucket (bucket_size).
    If bucket_size is large enough, the multiplication to calculate
    kvmalloc() size could overflow, resulting in out-of-bounds write
    as reported by KASAN:
    
      [...]
      [  104.986052] BUG: KASAN: vmalloc-out-of-bounds in __htab_map_lookup_and_delete_batch+0x5ce/0xb60
      [  104.986489] Write of size 4194224 at addr ffffc9010503be70 by task crash/112
      [  104.986889]
      [  104.987193] CPU: 0 PID: 112 Comm: crash Not tainted 5.14.0-rc4 #13
      [  104.987552] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      [  104.988104] Call Trace:
      [  104.988410]  dump_stack_lvl+0x34/0x44
      [  104.988706]  print_address_description.constprop.0+0x21/0x140
      [  104.988991]  ? __htab_map_lookup_and_delete_batch+0x5ce/0xb60
      [  104.989327]  ? __htab_map_lookup_and_delete_batch+0x5ce/0xb60
      [  104.989622]  kasan_report.cold+0x7f/0x11b
      [  104.989881]  ? __htab_map_lookup_and_delete_batch+0x5ce/0xb60
      [  104.990239]  kasan_check_range+0x17c/0x1e0
      [  104.990467]  memcpy+0x39/0x60
      [  104.990670]  __htab_map_lookup_and_delete_batch+0x5ce/0xb60
      [  104.990982]  ? __wake_up_common+0x4d/0x230
      [  104.991256]  ? htab_of_map_free+0x130/0x130
      [  104.991541]  bpf_map_do_batch+0x1fb/0x220
      [...]
    
    In hashtable, if the elements' keys have the same jhash() value, the
    elements will be put into the same bucket. By putting a lot of elements
    into a single bucket, the value of bucket_size can be increased to
    trigger the integer overflow.
    
    Triggering the overflow is possible for both callers with CAP_SYS_ADMIN
    and callers without CAP_SYS_ADMIN.
    
    It will be trivial for a caller with CAP_SYS_ADMIN to intentionally
    reach this overflow by enabling BPF_F_ZERO_SEED. As this flag will set
    the random seed passed to jhash() to 0, it will be easy for the caller
    to prepare keys which will be hashed into the same value, and thus put
    all the elements into the same bucket.
    
    If the caller does not have CAP_SYS_ADMIN, BPF_F_ZERO_SEED cannot be
    used. However, it will be still technically possible to trigger the
    overflow, by guessing the random seed value passed to jhash() (32bit)
    and repeating the attempt to trigger the overflow. In this case,
    the probability to trigger the overflow will be low and will take
    a very long time.
    
    Fix the integer overflow by calling kvmalloc_array() instead of
    kvmalloc() to allocate memory.
    
    Fixes: 057996380a42 ("bpf: Add batch ops to all htab bpf map")
    Signed-off-by: Tatsuhiko Yasumatsu <th.yasumatsu@gmail.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20210806150419.109658-1-th.yasumatsu@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 621d81cfbb0c4c9fdc2f55245abc323b0ade437e
Author: Daniel Xu <dxu@dxuuu.xyz>
Date:   Wed Jul 28 16:09:21 2021 -0700

    libbpf: Do not close un-owned FD 0 on errors
    
    [ Upstream commit c34c338a40e4f3b6f80889cd17fd9281784d1c32 ]
    
    Before this patch, btf_new() was liable to close an arbitrary FD 0 if
    BTF parsing failed. This was because:
    
    * btf->fd was initialized to 0 through the calloc()
    * btf__free() (in the `done` label) closed any FDs >= 0
    * btf->fd is left at 0 if parsing fails
    
    This issue was discovered on a system using libbpf v0.3 (without
    BTF_KIND_FLOAT support) but with a kernel that had BTF_KIND_FLOAT types
    in BTF. Thus, parsing fails.
    
    While this patch technically doesn't fix any issues b/c upstream libbpf
    has BTF_KIND_FLOAT support, it'll help prevent issues in the future if
    more BTF types are added. It also allow the fix to be backported to
    older libbpf's.
    
    Fixes: 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
    Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Yonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/5969bb991adedb03c6ae93e051fd2a00d293cf25.1627513670.git.dxu@dxuuu.xyz
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 51f19580f5f4f2393b2a0220dc2495e9abb0efbd
Author: Robin Gögge <r.goegge@googlemail.com>
Date:   Thu Jul 29 00:58:25 2021 +0200

    libbpf: Fix probe for BPF_PROG_TYPE_CGROUP_SOCKOPT
    
    [ Upstream commit 78d14bda861dd2729f15bb438fe355b48514bfe0 ]
    
    This patch fixes the probe for BPF_PROG_TYPE_CGROUP_SOCKOPT,
    so the probe reports accurate results when used by e.g.
    bpftool.
    
    Fixes: 4cdbfb59c44a ("libbpf: support sockopt hooks")
    Signed-off-by: Robin Gögge <r.goegge@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Quentin Monnet <quentin@isovalent.com>
    Link: https://lore.kernel.org/bpf/20210728225825.2357586-1-r.goegge@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 466f5509f62ae464b8c0ae9590442c104866c9f4
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Thu Aug 5 20:37:14 2021 +0200

    drm/amd/pm: Fix a memory leak in an error handling path in 'vangogh_tables_init()'
    
    [ Upstream commit 5126da7d99cf6396c929f3b577ba3aed1e74acd7 ]
    
    'watermarks_table' must be freed instead 'clocks_table', because
    'clocks_table' is known to be NULL at this point and 'watermarks_table' is
    never freed if the last kzalloc fails.
    
    Fixes: c98ee89736b8 ("drm/amd/pm: add the fine grain tuning function for vangogh")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fd0b94e6b1c73cc37142091b56d76460bd8300b5
Author: Kan Liang <kan.liang@linux.intel.com>
Date:   Tue Aug 3 06:25:28 2021 -0700

    perf/x86/intel: Apply mid ACK for small core
    
    [ Upstream commit acade6379930dfa7987f4bd9b26d1a701cc1b542 ]
    
    A warning as below may be occasionally triggered in an ADL machine when
    these conditions occur:
    
     - Two perf record commands run one by one. Both record a PEBS event.
     - Both runs on small cores.
     - They have different adaptive PEBS configuration (PEBS_DATA_CFG).
    
      [ ] WARNING: CPU: 4 PID: 9874 at arch/x86/events/intel/ds.c:1743 setup_pebs_adaptive_sample_data+0x55e/0x5b0
      [ ] RIP: 0010:setup_pebs_adaptive_sample_data+0x55e/0x5b0
      [ ] Call Trace:
      [ ]  <NMI>
      [ ]  intel_pmu_drain_pebs_icl+0x48b/0x810
      [ ]  perf_event_nmi_handler+0x41/0x80
      [ ]  </NMI>
      [ ]  __perf_event_task_sched_in+0x2c2/0x3a0
    
    Different from the big core, the small core requires the ACK right
    before re-enabling counters in the NMI handler, otherwise a stale PEBS
    record may be dumped into the later NMI handler, which trigger the
    warning.
    
    Add a new mid_ack flag to track the case. Add all PMI handler bits in
    the struct x86_hybrid_pmu to track the bits for different types of
    PMUs.  Apply mid ACK for the small cores on an Alder Lake machine.
    
    The existing hybrid() macro has a compile error when taking address of
    a bit-field variable. Add a new macro hybrid_bit() to get the
    bit-field value of a given PMU.
    
    Fixes: f83d2f91d259 ("perf/x86/intel: Add Alder Lake Hybrid support")
    Reported-by: Ammy Yi <ammy.yi@intel.com>
    Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Andi Kleen <ak@linux.intel.com>
    Tested-by: Ammy Yi <ammy.yi@intel.com>
    Link: https://lkml.kernel.org/r/1627997128-57891-1-git-send-email-kan.liang@linux.intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 736e0445f921ef00f323e09dde008c0b3351b7df
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Fri Aug 6 13:55:15 2021 +0200

    platform/x86: pcengines-apuv2: Add missing terminating entries to gpio-lookup tables
    
    [ Upstream commit 9d7b132e62e41b7d49bf157aeaf9147c27492e0f ]
    
    The gpiod_lookup_table.table passed to gpiod_add_lookup_table() must
    be terminated with an empty entry, add this.
    
    Note we have likely been getting away with this not being present because
    the GPIO lookup code first matches on the dev_id, causing most lookups to
    skip checking the table and the lookups which do check the table will
    find a matching entry before reaching the end. With that said, terminating
    these tables properly still is obviously the correct thing to do.
    
    Fixes: f8eb0235f659 ("x86: pcengines apuv2 gpio/leds/keys platform driver")
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20210806115515.12184-1-hdegoede@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a4de486958ffcd90f2b0e8e27aaeaf9f1eb751b5
Author: John Hubbard <jhubbard@nvidia.com>
Date:   Thu Aug 5 23:53:30 2021 -0700

    net: mvvp2: fix short frame size on s390
    
    [ Upstream commit 704e624f7b3e8a4fc1ce43fb564746d1d07b20c0 ]
    
    On s390, the following build warning occurs:
    
    drivers/net/ethernet/marvell/mvpp2/mvpp2.h:844:2: warning: overflow in
    conversion from 'long unsigned int' to 'int' changes value from
    '18446744073709551584' to '-32' [-Woverflow]
    844 |  ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE)
    
    This happens because MVPP2_SKB_SHINFO_SIZE, which is 320 bytes (which is
    already 64-byte aligned) on some architectures, actually gets ALIGN'd up
    to 512 bytes in the s390 case.
    
    So then, when this is invoked:
    
        MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE)
    
    ...that turns into:
    
         704 - 224 - 512 == -32
    
    ...which is not a good frame size to end up with! The warning above is a
    bit lucky: it notices a signed/unsigned bad behavior here, which leads
    to the real problem of a frame that is too short for its contents.
    
    Increase MVPP2_BM_SHORT_FRAME_SIZE by 32 (from 704 to 736), which is
    just exactly big enough. (The other values can't readily be changed
    without causing a lot of other problems.)
    
    Fixes: 07dd0a7aae7f ("mvpp2: add basic XDP support")
    Cc: Sven Auhagen <sven.auhagen@voleatech.de>
    Cc: Matteo Croce <mcroce@microsoft.com>
    Cc: David S. Miller <davem@davemloft.net>
    Signed-off-by: John Hubbard <jhubbard@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f67f34a8637528ee7dbbaf0e8389855f156a7e94
Author: DENG Qingfang <dqfext@gmail.com>
Date:   Fri Aug 6 12:05:27 2021 +0800

    net: dsa: mt7530: add the missing RxUnicast MIB counter
    
    [ Upstream commit aff51c5da3208bd164381e1488998667269c6cf4 ]
    
    Add the missing RxUnicast counter.
    
    Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
    Signed-off-by: DENG Qingfang <dqfext@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 141af64cf7684461a5cd9eb1e239afe849441aac
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Aug 5 17:11:07 2021 +0100

    ASoC: cs42l42: Fix mono playback
    
    [ Upstream commit e5ada3f6787a4d6234adc6f2f3ae35c6d5b71ba0 ]
    
    I2S always has two LRCLK phases and both CH1 and CH2 of the RX
    must be enabled (corresponding to the low and high phases of LRCLK.)
    The selection of the valid data channels is done by setting the DAC
    CHA_SEL and CHB_SEL. CHA_SEL is always the first (left) channel,
    CHB_SEL depends on the number of active channels.
    
    Previously for mono ASP CH2 was not enabled, the result was playing
    mono data would not produce any audio output.
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 621d65f3b868 ("ASoC: cs42l42: Provide finer control on playback path")
    Link: https://lore.kernel.org/r/20210805161111.10410-4-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d57b00645556a537cd2875418884ed05775c8204
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Aug 5 17:11:05 2021 +0100

    ASoC: cs42l42: Fix LRCLK frame start edge
    
    [ Upstream commit 0c2f2ad4f16a58879463d0979a54293f8f296d6f ]
    
    An I2S frame starts on the falling edge of LRCLK so ASP_STP must
    be 0.
    
    At the same time, move other format settings in the same register
    from cs42l42_pll_config() to cs42l42_set_dai_fmt() where you'd
    expect to find them, and merge into a single write.
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
    Link: https://lore.kernel.org/r/20210805161111.10410-2-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6e61f4d51d3802d7902de490ba0a298673fb3e1e
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Aug 5 17:11:04 2021 +0100

    ASoC: cs42l42: PLL must be running when changing MCLK_SRC_SEL
    
    [ Upstream commit f1040e86f83b0f7d5f45724500a6a441731ff4b7 ]
    
    Both SCLK and PLL clocks must be running to drive the glitch-free mux
    behind MCLK_SRC_SEL and complete the switchover.
    
    This patch moves the writing of MCLK_SRC_SEL to when the PLL is started
    and stopped, so that it only transitions while the PLL is running.
    The unconditional write MCLK_SRC_SEL=0 in cs42l42_mute_stream() is safe
    because if the PLL is not running MCLK_SRC_SEL is already 0.
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 43fc357199f9 ("ASoC: cs42l42: Set clock source for both ways of stream")
    Link: https://lore.kernel.org/r/20210805161111.10410-1-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 22af0d2a5e5e770be36ce2f16e4dd9cc90cbc1ce
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Wed Aug 4 14:21:41 2021 +0300

    pinctrl: tigerlake: Fix GPIO mapping for newer version of software
    
    [ Upstream commit 2f658f7a3953f6d70bab90e117aff8d0ad44e200 ]
    
    The software mapping for GPIO, which initially comes from Microsoft,
    is subject to change by respective Windows and firmware developers.
    Due to the above the driver had been written and published way ahead
    of the schedule, and thus the numbering schema used in it is outdated.
    
    Fix the numbering schema in accordance with the real products on market.
    
    Fixes: 653d96455e1e ("pinctrl: tigerlake: Add support for Tiger Lake-H")
    Reported-and-tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Reported-by: Riccardo Mori <patacca@autistici.org>
    Reported-and-tested-by: Lovesh <lovesh.bond@gmail.com>
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213463
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213579
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213857
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit deff14bdcc5454da691ab589d6aaeb56d42f8a1c
Author: Yajun Deng <yajun.deng@linux.dev>
Date:   Thu Jul 29 16:20:21 2021 +0800

    netfilter: nf_conntrack_bridge: Fix memory leak when error
    
    [ Upstream commit 38ea9def5b62f9193f6bad96c5d108e2830ecbde ]
    
    It should be added kfree_skb_list() when err is not equal to zero
    in nf_br_ip_fragment().
    
    v2: keep this aligned with IPv6.
    v3: modify iter.frag_list to iter.frag.
    
    Fixes: 3c171f496ef5 ("netfilter: bridge: add connection tracking system")
    Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 71805c36336af0a71f8f04db09c1ada2d15ad1a3
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Tue Aug 3 17:08:34 2021 +0100

    ASoC: cs42l42: Remove duplicate control for WNF filter frequency
    
    [ Upstream commit 8b353bbeae20e2214c9d9d88bcb2fda4ba145d83 ]
    
    The driver was defining two ALSA controls that both change the same
    register field for the wind noise filter corner frequency. The filter
    response has two corners, at different frequencies, and the duplicate
    controls most likely were an attempt to be able to set the value using
    either of the frequencies.
    
    However, having two controls changing the same field can be problematic
    and it is unnecessary. Both frequencies are related to each other so
    setting one implies exactly what the other would be.
    
    Removing a control affects user-side code, but there is currently no
    known use of the removed control so it would be best to remove it now
    before it becomes a problem.
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
    Link: https://lore.kernel.org/r/20210803160834.9005-2-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9c272596189cb8a999146cfe14e93bf09219f9ce
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Tue Aug 3 17:08:33 2021 +0100

    ASoC: cs42l42: Fix inversion of ADC Notch Switch control
    
    [ Upstream commit 30615bd21b4cc3c3bb5ae8bd70e2a915cc5f75c7 ]
    
    The underlying register field has inverted sense (0 = enabled) so
    the control definition must be marked as inverted.
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
    Link: https://lore.kernel.org/r/20210803160834.9005-1-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 710490222c6973e62f9ee7edfb4985c9432f7e6f
Author: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Date:   Mon Aug 2 10:17:49 2021 -0500

    ASoC: SOF: Intel: hda-ipc: fix reply size checking
    
    [ Upstream commit 973b393fdf073a4ebd8d82ef6edea99fedc74af9 ]
    
    Checking that two values don't have common bits makes no sense,
    strict equality is meant.
    
    Fixes: f3b433e4699f  ("ASoC: SOF: Implement Probe IPC API")
    Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
    Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Link: https://lore.kernel.org/r/20210802151749.15417-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ba216b210f26c4533e7bf7b972fbf862418b0dff
Author: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date:   Mon Aug 2 10:16:28 2021 -0500

    ASoC: SOF: Intel: Kconfig: fix SoundWire dependencies
    
    [ Upstream commit 6b994c554ebc4c065427f510db333081cbd7228d ]
    
    The previous Kconfig cleanup added simplifications but also introduced
    a new one by moving a boolean to a tristate. This leads to randconfig
    problems.
    
    This patch moves the select operations in the SOUNDWIRE_LINK_BASELINE
    option. The INTEL_SOUNDWIRE config remains a tristate for backwards
    compatibility with older configurations but is essentially an on/off
    switch.
    
    Fixes: cf5807f5f814f ('ASoC: SOF: Intel: SoundWire: simplify Kconfig')
    Reported-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Reviewed-by: Rander Wang <rander.wang@intel.com>
    Reviewed-by: Bard Liao <bard.liao@intel.com>
    Tested-by: Arnd Bergmann <arnd@arndb.de>
    Link: https://lore.kernel.org/r/20210802151628.15291-1-pierre-louis.bossart@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d82c88a44bb6d259ab1ec5f1f6a2b9463ea8f48a
Author: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Date:   Mon Jul 5 08:09:21 2021 +0300

    selftests/sgx: Fix Q1 and Q2 calculation in sigstruct.c
    
    [ Upstream commit 567c39047dbee341244fe3bf79fea24ee0897ff9 ]
    
    Q1 and Q2 are numbers with *maximum* length of 384 bytes. If the
    calculated length of Q1 and Q2 is less than 384 bytes, things will
    go wrong.
    
    E.g. if Q2 is 383 bytes, then
    
    1. The bytes of q2 are copied to sigstruct->q2 in calc_q1q2().
    2. The entire sigstruct->q2 is reversed, which results it being
       256 * Q2, given that the last byte of sigstruct->q2 is added
       to before the bytes given by calc_q1q2().
    
    Either change in key or measurement can trigger the bug. E.g. an
    unmeasured heap could cause a devastating change in Q1 or Q2.
    
    Reverse exactly the bytes of Q1 and Q2 in calc_q1q2() before returning
    to the caller.
    
    Fixes: 2adcba79e69d ("selftests/x86: Add a selftest for SGX")
    Link: https://lore.kernel.org/linux-sgx/20210301051836.30738-1-tianjia.zhang@linux.alibaba.com/
    Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
    Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 67488f5c9613a1142b25d9365dc6f7ea9773150e
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Jul 29 18:09:29 2021 +0100

    ASoC: cs42l42: Fix bclk calculation for mono
    
    [ Upstream commit 926ef1a4c245c093acc07807e466ad2ef0ff6ccb ]
    
    An I2S frame always has a left and right channel slot even if mono
    data is being sent. So if channels==1 the actual bitclock frequency
    is 2 * snd_soc_params_to_bclk(params).
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2cdba9b045c7 ("ASoC: cs42l42: Use bclk from hw_params if set_sysclk was not called")
    Link: https://lore.kernel.org/r/20210729170929.6589-3-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b4f870447de18a2998284248d7b72e1c02c4c981
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Jul 29 18:09:28 2021 +0100

    ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
    
    [ Upstream commit 64324bac750b84ca54711fb7d332132fcdb87293 ]
    
    The driver has no support for left-justified protocol so it should
    not have been allowing this to be passed to cs42l42_set_dai_fmt().
    
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
    Link: https://lore.kernel.org/r/20210729170929.6589-2-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 918bbb32c8236a78b6f148fdc4bcee7d966db24a
Author: Richard Fitzgerald <rf@opensource.cirrus.com>
Date:   Thu Jul 29 18:09:27 2021 +0100

    ASoC: cs42l42: Correct definition of ADC Volume control
    
    [ Upstream commit ee86f680ff4c9b406d49d4e22ddf10805b8a2137 ]
    
    The ADC volume is a signed 8-bit number with range -97 to +12,
    with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
    and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
    mute flag.
    
    Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
    Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
    Link: https://lore.kernel.org/r/20210729170929.6589-1-rf@opensource.cirrus.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 676b964835765a6aea293fa1b277441a9e1b120a
Author: Hsin-Yi Wang <hsinyi@chromium.org>
Date:   Thu Jul 1 16:09:55 2021 +0800

    pinctrl: mediatek: Fix fallback behavior for bias_set_combo
    
    [ Upstream commit 798a315fc359aa6dbe48e09d802aa59b7e158ffc ]
    
    Some pin doesn't support PUPD register, if it fails and fallbacks with
    bias_set_combo case, it will call mtk_pinconf_bias_set_pupd_r1_r0() to
    modify the PUPD pin again.
    
    Since the general bias set are either PU/PD or PULLSEL/PULLEN, try
    bias_set or bias_set_rev1 for the other fallback case. If the pin
    doesn't support neither PU/PD nor PULLSEL/PULLEN, it will return
    -ENOTSUPP.
    
    Fixes: 81bd1579b43e ("pinctrl: mediatek: Fix fallback call path")
    Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
    Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
    Reviewed-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
    Link: https://lore.kernel.org/r/20210701080955.2660294-1-hsinyi@chromium.org
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 73e81f7219aa582d8e55a7b6552f607a8e5a9724
Author: jason-jh.lin <jason-jh.lin@mediatek.com>
Date:   Thu Jul 22 09:47:43 2021 +0800

    drm/mediatek: Fix cursor plane no update
    
    [ Upstream commit 1a64a7aff8da352c9419de3d5c34343682916411 ]
    
    The cursor plane should use the current plane state in atomic_async_update
    because it would not be the new plane state in the global atomic state
    since _swap_state happened when those hook are run.
    
    Fix cursor plane issue by below modification:
    1. Remove plane_helper_funcs->atomic_update(plane, state) in
       mtk_drm_crtc_async_update.
    2. Add mtk_drm_update_new_state in to mtk_plane_atomic_async_update to
       update the cursor plane by current plane state hook and update
       others plane by the new_state.
    
    Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state pointer")
    Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
    Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
    Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 30df59b45cac203b86c0c35400c60147afe429e9
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Wed Jul 7 23:56:32 2021 +0800

    ieee802154: hwsim: fix GPF in hwsim_new_edge_nl
    
    [ Upstream commit 889d0e7dc68314a273627d89cbb60c09e1cc1c25 ]
    
    Both MAC802154_HWSIM_ATTR_RADIO_ID and MAC802154_HWSIM_ATTR_RADIO_EDGE
    must be present to fix GPF.
    
    Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20210707155633.1486603-1-mudongliangabcd@gmail.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bb0c87658dd135d70c7e2bb795abe23b9daad212
Author: Dongliang Mu <mudongliangabcd@gmail.com>
Date:   Mon Jul 5 21:13:20 2021 +0800

    ieee802154: hwsim: fix GPF in hwsim_set_edge_lqi
    
    [ Upstream commit e9faf53c5a5d01f6f2a09ae28ec63a3bbd6f64fd ]
    
    Both MAC802154_HWSIM_ATTR_RADIO_ID and MAC802154_HWSIM_ATTR_RADIO_EDGE,
    MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID and MAC802154_HWSIM_EDGE_ATTR_LQI
    must be present to fix GPF.
    
    Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
    Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
    Acked-by: Alexander Aring <aahringo@redhat.com>
    Link: https://lore.kernel.org/r/20210705131321.217111-1-mudongliangabcd@gmail.com
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 73248a01ae1494af7dd2f688dc5dba3e6b812e5e
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Mon Aug 9 11:22:20 2021 -0400

    drm/amdgpu: handle VCN instances when harvesting (v2)
    
    commit 7cbe08a930a132d84b4cf79953b00b074ec7a2a7 upstream.
    
    There may be multiple instances and only one is harvested.
    
    v2: fix typo in commit message
    
    Fixes: 83a0b8639185 ("drm/amdgpu: add judgement when add ip blocks (v2)")
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1673
    Reviewed-by: Guchun Chen <guchun.chen@amd.com>
    Reviewed-by: James Zhu <James.Zhu@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e73eac2bd907e0e7325b27bb13797761373c15e
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Mon Aug 2 10:03:30 2021 -0400

    drm/amdgpu: don't enable baco on boco platforms in runpm
    
    commit 202ead5a3c589b0594a75cb99f080174f6851fed upstream.
    
    If the platform uses BOCO, don't use BACO in runtime suspend.
    We could end up executing the BACO path if the platform supports
    both.
    
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1669
    Reviewed-by: Evan Quan <evan.quan@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fcd957aa8b321c3ee7adf2f4446f476c217c16d9
Author: Solomon Chiu <solomon.chiu@amd.com>
Date:   Wed Jul 28 00:20:30 2021 +0800

    drm/amdgpu: Add preferred mode in modeset when freesync video mode's enabled.
    
    commit 46dd2965bdd1c5a4f6499c73ff32e636fa8f9769 upstream.
    
    [Why]
    With kernel module parameter "freesync_video" is enabled, if the mode
    is changed to preferred mode(the mode with highest rate), then Freesync
    fails because the preferred mode is treated as one of freesync video
    mode, and then be configurated as freesync video mode(fixed refresh
    rate).
    
    [How]
    Skip freesync fixed rate configurating when modeset to preferred mode.
    
    Signed-off-by: Solomon Chiu <solomon.chiu@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7b69bee4817cdbdb9a0a7a6db595301c6349d7b7
Author: Anson Jacob <Anson.Jacob@amd.com>
Date:   Fri Jul 30 19:46:20 2021 -0400

    drm/amd/display: use GFP_ATOMIC in amdgpu_dm_irq_schedule_work
    
    commit 0cde63a8fc4d9f9f580c297211fd05f91c0fd66d upstream.
    
    Replace GFP_KERNEL with GFP_ATOMIC as amdgpu_dm_irq_schedule_work
    can't sleep.
    
    BUG: sleeping function called from invalid context at include/linux/sched/mm.h:196
    in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 253, name: kworker/6:1H
    CPU: 6 PID: 253 Comm: kworker/6:1H Tainted: G        W  OE     5.11.0-promotion_2021_06_07-18_36_28_prelim_revert_retrain #8
    Hardware name: System manufacturer System Product Name/PRIME X570-PRO, BIOS 3405 02/01/2021
    Workqueue: events_highpri dm_irq_work_func [amdgpu]
    Call Trace:
     <IRQ>
     dump_stack+0x5e/0x74
     ___might_sleep.cold+0x87/0x98
     __might_sleep+0x4b/0x80
     kmem_cache_alloc_trace+0x390/0x4f0
     amdgpu_dm_irq_handler+0x171/0x230 [amdgpu]
     amdgpu_irq_dispatch+0xc0/0x1e0 [amdgpu]
     amdgpu_ih_process+0x81/0x100 [amdgpu]
     amdgpu_irq_handler+0x26/0xa0 [amdgpu]
     __handle_irq_event_percpu+0x49/0x190
     ? __hrtimer_get_next_event+0x4d/0x80
     handle_irq_event_percpu+0x33/0x80
     handle_irq_event+0x33/0x60
     handle_edge_irq+0x82/0x190
     asm_call_irq_on_stack+0x12/0x20
     </IRQ>
     common_interrupt+0xbb/0x140
     asm_common_interrupt+0x1e/0x40
    RIP: 0010:amdgpu_device_rreg.part.0+0x44/0xf0 [amdgpu]
    Code: 53 48 89 fb 4c 3b af c8 08 00 00 73 6d 83 e2 02 75 0d f6 87 40 62 01 00 10 0f 85 83 00 00 00 4c 03 ab d0 08 00 00 45 8b 6d 00 <8b> 05 3e b6 52 00 85 c0 7e 62 48 8b 43 08 0f b7 70 3e 65 8b 05 e3
    RSP: 0018:ffffae7740fff9e8 EFLAGS: 00000286
    RAX: ffffffffc05ee610 RBX: ffff8aaf8f620000 RCX: 0000000000000006
    RDX: 0000000000000000 RSI: 0000000000005430 RDI: ffff8aaf8f620000
    RBP: ffffae7740fffa08 R08: 0000000000000001 R09: 000000000000000a
    R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000005430
    R13: 0000000071000000 R14: 0000000000000001 R15: 0000000000005430
     ? amdgpu_cgs_write_register+0x20/0x20 [amdgpu]
     amdgpu_device_rreg+0x17/0x20 [amdgpu]
     amdgpu_cgs_read_register+0x14/0x20 [amdgpu]
     dm_read_reg_func+0x38/0xb0 [amdgpu]
     generic_reg_wait+0x80/0x160 [amdgpu]
     dce_aux_transfer_raw+0x324/0x7c0 [amdgpu]
     dc_link_aux_transfer_raw+0x43/0x50 [amdgpu]
     dm_dp_aux_transfer+0x87/0x110 [amdgpu]
     drm_dp_dpcd_access+0x72/0x110 [drm_kms_helper]
     drm_dp_dpcd_read+0xb7/0xf0 [drm_kms_helper]
     drm_dp_get_one_sb_msg+0x349/0x480 [drm_kms_helper]
     drm_dp_mst_hpd_irq+0xc5/0xe40 [drm_kms_helper]
     ? drm_dp_mst_hpd_irq+0xc5/0xe40 [drm_kms_helper]
     dm_handle_hpd_rx_irq+0x184/0x1a0 [amdgpu]
     ? dm_handle_hpd_rx_irq+0x184/0x1a0 [amdgpu]
     handle_hpd_rx_irq+0x195/0x240 [amdgpu]
     ? __switch_to_asm+0x42/0x70
     ? __switch_to+0x131/0x450
     dm_irq_work_func+0x19/0x20 [amdgpu]
     process_one_work+0x209/0x400
     worker_thread+0x4d/0x3e0
     ? cancel_delayed_work+0xa0/0xa0
     kthread+0x124/0x160
     ? kthread_park+0x90/0x90
     ret_from_fork+0x22/0x30
    
    Reviewed-by: Aurabindo Jayamohanan Pillai <Aurabindo.Pillai@amd.com>
    Acked-by: Anson Jacob <Anson.Jacob@amd.com>
    Signed-off-by: Anson Jacob <Anson.Jacob@amd.com>
    Cc: stable@vger.kernel.org
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 164759f4070e22a2233ecec5bf6ab6dd22277730
Author: Eric Bernstein <eric.bernstein@amd.com>
Date:   Mon Jul 26 15:53:18 2021 -0400

    drm/amd/display: Remove invalid assert for ODM + MPC case
    
    commit c90f6263f58a28c3d97b83679d6fd693b33dfd4e upstream.
    
    Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
    Acked-by: Anson Jacob <Anson.Jacob@amd.com>
    Signed-off-by: Eric Bernstein <eric.bernstein@amd.com>
    Cc: stable@vger.kernel.org
    Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3565f42dc8e2d8235fc18668da503497161b19e5
Author: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Date:   Wed Aug 11 10:48:57 2021 +0530

    drm/i915/display: Fix the 12 BPC bits for PIPE_MISC reg
    
    commit abd9d66a055722393d33685214c08386694871d7 upstream.
    
    Till DISPLAY12 the PIPE_MISC bits 5-7 are used to set the
    Dithering BPC, with valid values of 6, 8, 10 BPC.
    For ADLP+ these bits are used to set the PORT OUTPUT BPC, with valid
    values of: 6, 8, 10, 12 BPC, and need to be programmed whether
    dithering is enabled or not.
    
    This patch:
    -corrects the bits 5-7 for PIPE MISC register for 12 BPC.
    -renames the bits and mask to have generic names for these bits for
    dithering bpc and port output bpc.
    
    v3: Added a note for MIPI DSI which uses the PIPE_MISC for readout
    for pipe_bpp. (Uma Shankar)
    
    v2: Added 'display' to the subject and fixes tag. (Uma Shankar)
    
    Fixes: 756f85cffef2 ("drm/i915/bdw: Broadwell has PIPEMISC")
    Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> (v1)
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Jani Nikula <jani.nikula@linux.intel.com>
    Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Cc: intel-gfx@lists.freedesktop.org
    Cc: <stable@vger.kernel.org> # v3.13+
    
    Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
    Reviewed-by: Uma Shankar <uma.shankar@intel.com>
    Signed-off-by: Uma Shankar <uma.shankar@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210811051857.109723-1-ankit.k.nautiyal@intel.com
    (cherry picked from commit 70418a68713c13da3f36c388087d0220b456a430)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 01478e2517320f40c84b04ef2ed8787a1818f423
Author: Zhenyu Wang <zhenyuw@linux.intel.com>
Date:   Fri Aug 6 12:40:56 2021 +0800

    drm/i915/gvt: Fix cached atomics setting for Windows VM
    
    commit 699aa57b35672c3b2f230e2b7e5d0ab8c2bde80a upstream.
    
    We've seen recent regression with host and windows VM running
    simultaneously that cause gpu hang or even crash. Finally bisect to
    commit 58586680ffad ("drm/i915: Disable atomics in L3 for gen9"),
    which seems cached atomics behavior difference caused regression
    issue.
    
    This tries to add new scratch register handler and add those in mmio
    save/restore list for context switch. No gpu hang produced with this one.
    
    Cc: stable@vger.kernel.org # 5.12+
    Cc: "Xu, Terrence" <terrence.xu@intel.com>
    Cc: "Bloomfield, Jon" <jon.bloomfield@intel.com>
    Cc: "Ekstrand, Jason" <jason.ekstrand@intel.com>
    Reviewed-by: Colin Xu <colin.xu@intel.com>
    Fixes: 58586680ffad ("drm/i915: Disable atomics in L3 for gen9")
    Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
    Link: http://patchwork.freedesktop.org/patch/msgid/20210806044056.648016-1-zhenyuw@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 21fcf2f1ced428f54bd79a3ead034a95b7610964
Author: Nathan Chancellor <nathan@kernel.org>
Date:   Fri Jul 30 19:31:08 2021 -0700

    vmlinux.lds.h: Handle clang's module.{c,d}tor sections
    
    commit 848378812e40152abe9b9baf58ce2004f76fb988 upstream.
    
    A recent change in LLVM causes module_{c,d}tor sections to appear when
    CONFIG_K{A,C}SAN are enabled, which results in orphan section warnings
    because these are not handled anywhere:
    
    ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_ctor) is being placed in '.text.asan.module_ctor'
    ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_dtor) is being placed in '.text.asan.module_dtor'
    ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.tsan.module_ctor) is being placed in '.text.tsan.module_ctor'
    
    Fangrui explains: "the function asan.module_ctor has the SHF_GNU_RETAIN
    flag, so it is in a separate section even with -fno-function-sections
    (default)".
    
    Place them in the TEXT_TEXT section so that these technologies continue
    to work with the newer compiler versions. All of the KASAN and KCSAN
    KUnit tests continue to pass after this change.
    
    Cc: stable@vger.kernel.org
    Link: https://github.com/ClangBuiltLinux/linux/issues/1432
    Link: https://github.com/llvm/llvm-project/commit/7b789562244ee941b7bf2cefeb3fc08a59a01865
    Signed-off-by: Nathan Chancellor <nathan@kernel.org>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Fangrui Song <maskray@google.com>
    Acked-by: Marco Elver <elver@google.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20210731023107.1932981-1-nathan@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33d2301ad61b388b9341938b9ada1be87868893c
Author: Changbin Du <changbin.du@intel.com>
Date:   Thu Jul 22 10:17:15 2021 +0800

    riscv: kexec: do not add '-mno-relax' flag if compiler doesn't support it
    
    commit 030d6dbf0c2e5fdf23ad29557f0c87a882993e26 upstream.
    
    The RISC-V special option '-mno-relax' which to disable linker relaxations
    is supported by GCC8+. For GCC7 and lower versions do not support this
    option.
    
    Fixes: fba8a8674f68 ("RISC-V: Add kexec support")
    Signed-off-by: Changbin Du <changbin.du@gmail.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1579656b0141c5886070ad41eebe149ad4e68554
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Fri Jul 30 09:46:04 2021 -0700

    libnvdimm/region: Fix label activation vs errors
    
    commit d9cee9f85b22fab88d2b76d2e92b18e3d0e6aa8c upstream.
    
    There are a few scenarios where init_active_labels() can return without
    registering deactivate_labels() to run when the region is disabled. In
    particular label error injection creates scenarios where a DIMM is
    disabled, but labels on other DIMMs in the region become activated.
    
    Arrange for init_active_labels() to always register deactivate_labels().
    
    Reported-by: Krzysztof Kensicki <krzysztof.kensicki@intel.com>
    Cc: <stable@vger.kernel.org>
    Fixes: bf9bccc14c05 ("libnvdimm: pmem label sets and namespace instantiation.")
    Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
    Link: https://lore.kernel.org/r/162766356450.3223041.1183118139023841447.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4debaa9f577af93595a31f3357c87580c383e12b
Author: Dan Williams <dan.j.williams@intel.com>
Date:   Wed Aug 11 11:53:37 2021 -0700

    ACPI: NFIT: Fix support for virtual SPA ranges
    
    commit b93dfa6bda4d4e88e5386490f2b277a26958f9d3 upstream.
    
    Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as
    a special case and not match Region Mapping Structures that use 0 to
    indicate that they are not mapped. Without this fix some platform BIOS
    descriptions of "virtual disk" ranges do not result in the pmem driver
    attaching to the range.
    
    Details:
    In addition to typical persistent memory ranges, the ACPI NFIT may also
    convey "virtual" ranges. These ranges are indicated by a UUID in the SPA
    Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD,
    UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The
    critical difference between virtual ranges and UUID_PERSISTENT_MEMORY,
    is that virtual do not support associations with Region Mapping
    Structures.  For this reason the "index" value of virtual SPA Range
    Structures is allowed to be 0. If a platform BIOS decides to represent
    NVDIMMs with disconnected "Region Mapping Structures" (range-index ==
    0), the kernel may falsely associate them with standalone ranges where
    the "SPA Range Structure Index" is also zero. When this happens the
    driver may falsely require labels where "virtual disks" are expected to
    be label-less. I.e. "label-less" is where the namespace-range ==
    region-range and the pmem driver attaches with no user action to create
    a namespace.
    
    Cc: Jacek Zloch <jacek.zloch@intel.com>
    Cc: Lukasz Sobieraj <lukasz.sobieraj@intel.com>
    Cc: "Lee, Chun-Yi" <jlee@suse.com>
    Cc: <stable@vger.kernel.org>
    Fixes: c2f32acdf848 ("acpi, nfit: treat virtual ramdisk SPA as pmem region")
    Reported-by: Krzysztof Rusocki <krzysztof.rusocki@intel.com>
    Reported-by: Damian Bassa <damian.bassa@intel.com>
    Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
    Link: https://lore.kernel.org/r/162870796589.2521182.1240403310175570220.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbe28d4afbdaa61ea794f1674f8fcc3417a268e3
Author: Damien Le Moal <damien.lemoal@wdc.com>
Date:   Fri Aug 6 09:43:11 2021 +0900

    pinctrl: k210: Fix k210_fpioa_probe()
    
    commit 31697ef7f3f45293bba3da87bcc710953e97fc3e upstream.
    
    In k210_fpioa_probe(), add missing calls to clk_disable_unprepare() in
    case of error after cenabling the clk and pclk clocks. Also add missing
    error handling when enabling pclk.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Fixes: d4c34d09ab03 ("pinctrl: Add RISC-V Canaan Kendryte K210 FPIOA driver")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
    Link: https://lore.kernel.org/r/20210806004311.52859-1-damien.lemoal@wdc.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3d33960c8d663dbbf98f2cbcda49b198e0fc2918
Author: Luis Henriques <lhenriques@suse.de>
Date:   Tue Jul 6 14:52:41 2021 +0100

    ceph: reduce contention in ceph_check_delayed_caps()
    
    commit bf2ba432213fade50dd39f2e348085b758c0726e upstream.
    
    Function ceph_check_delayed_caps() is called from the mdsc->delayed_work
    workqueue and it can be kept looping for quite some time if caps keep
    being added back to the mdsc->cap_delay_list.  This may result in the
    watchdog tainting the kernel with the softlockup flag.
    
    This patch breaks this loop if the caps have been recently (i.e. during
    the loop execution).  Any new caps added to the list will be handled in
    the next run.
    
    Also, allow schedule_delayed() callers to explicitly set the delay value
    instead of defaulting to 5s, so we can ensure that it runs soon
    afterward if it looks like there is more work.
    
    Cc: stable@vger.kernel.org
    URL: https://tracker.ceph.com/issues/46284
    Signed-off-by: Luis Henriques <lhenriques@suse.de>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 01b2ec534d387608904ae7bd9b3ecd1b8bd56745
Author: Vineet Gupta <vgupta@synopsys.com>
Date:   Thu Jul 8 17:13:48 2021 -0700

    ARC: fp: set FPU_STATUS.FWE to enable FPU_STATUS update on context switch
    
    commit 3a715e80400f452b247caa55344f4f60250ffbcf upstream.
    
    FPU_STATUS register contains FP exception flags bits which are updated
    by core as side-effect of FP instructions but can also be manually
    wiggled such as by glibc C99 functions fe{raise,clear,test}except() etc.
    To effect the update, the programming model requires OR'ing FWE
    bit (31). This bit is write-only and RAZ, meaning it is effectively
    auto-cleared after write and thus needs to be set everytime: which
    is how glibc implements this.
    
    However there's another usecase of FPU_STATUS update, at the time of
    Linux task switch when incoming task value needs to be programmed into
    the register. This was added as part of f45ba2bd6da0dc ("ARCv2:
    fpu: preserve userspace fpu state") which missed OR'ing FWE bit,
    meaning the new value is effectively not being written at all.
    This patch remedies that.
    
    Interestingly, this snafu was not caught in interm glibc testing as the
    race window which relies on a specific exception bit to be set/clear is
    really small specially when it nvolves context switch.
    Fortunately this was caught by glibc's math/test-fenv-tls test which
    repeatedly set/clear exception flags in a big loop, concurrently in main
    program and also in a thread.
    
    Fixes: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/54
    Fixes: f45ba2bd6da0dc ("ARCv2: fpu: preserve userspace fpu state")
    Cc: stable@vger.kernel.org      #5.6+
    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 30a5d06dc3dd1b01c2491fee1642d3060288b094
Author: Grygorii Strashko <grygorii.strashko@ti.com>
Date:   Thu Aug 5 17:55:11 2021 +0300

    net: ethernet: ti: cpsw: fix min eth packet size for non-switch use-cases
    
    commit acc68b8d2a1196c4db806947606f162dbeed2274 upstream.
    
    The CPSW switchdev driver inherited fix from commit 9421c9015047 ("net:
    ethernet: ti: cpsw: fix min eth packet size") which changes min TX packet
    size to 64bytes (VLAN_ETH_ZLEN, excluding ETH_FCS). It was done to fix HW
    packed drop issue when packets are sent from Host to the port with PVID and
    un-tagging enabled. Unfortunately this breaks some other non-switch
    specific use-cases, like:
    - [1] CPSW port as DSA CPU port with DSA-tag applied at the end of the
    packet
    - [2] Some industrial protocols, which expects min TX packet size 60Bytes
    (excluding FCS).
    
    Fix it by configuring min TX packet size depending on driver mode
     - 60Bytes (ETH_ZLEN) for multi mac (dual-mac) mode
     - 64Bytes (VLAN_ETH_ZLEN) for switch mode
    and update it during driver mode change and annotate with
    READ_ONCE()/WRITE_ONCE() as it can be read by napi while writing.
    
    [1] https://lore.kernel.org/netdev/20210531124051.GA15218@cephalopod/
    [2] https://e2e.ti.com/support/arm/sitara_arm/f/791/t/701669
    
    Cc: stable@vger.kernel.org
    Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac")
    Reported-by: Ben Hutchings <ben.hutchings@essensium.com>
    Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2bb154128d145a8231fb8a26c5effbd8a2154f11
Author: Loic Poulain <loic.poulain@linaro.org>
Date:   Fri Aug 6 12:35:09 2021 +0200

    net: wwan: mhi_wwan_ctrl: Fix possible deadlock
    
    commit 34737e1320db6d51f0d140d5c684b9eb32f0da76 upstream.
    
    Lockdep detected possible interrupt unsafe locking scenario:
    
            CPU0                    CPU1
            ----                    ----
       lock(&mhiwwan->rx_lock);
                                   local_irq_disable();
                                   lock(&mhi_cntrl->pm_lock);
                                   lock(&mhiwwan->rx_lock);
       <Interrupt>
         lock(&mhi_cntrl->pm_lock);
    
      *** DEADLOCK ***
    
    To prevent this we need to disable the soft-interrupts when taking
    the rx_lock.
    
    Cc: stable@vger.kernel.org
    Fixes: fa588eba632d ("net: Add Qcom WWAN control driver")
    Reported-by: Thomas Perrot <thomas.perrot@bootlin.com>
    Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
    Reviewed-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8610d75c4db614346bba3d14443810240fb2c955
Author: Hsuan-Chi Kuo <hsuanchikuo@gmail.com>
Date:   Thu Mar 4 17:37:08 2021 -0600

    seccomp: Fix setting loaded filter count during TSYNC
    
    commit b4d8a58f8dcfcc890f296696cadb76e77be44b5f upstream.
    
    The desired behavior is to set the caller's filter count to thread's.
    This value is reported via /proc, so this fixes the inaccurate count
    exposed to userspace; it is not used for reference counting, etc.
    
    Signed-off-by: Hsuan-Chi Kuo <hsuanchikuo@gmail.com>
    Link: https://lore.kernel.org/r/20210304233708.420597-1-hsuanchikuo@gmail.com
    Co-developed-by: Wiktor Garbacz <wiktorg@google.com>
    Signed-off-by: Wiktor Garbacz <wiktorg@google.com>
    Link: https://lore.kernel.org/lkml/20210810125158.329849-1-wiktorg@google.com
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Cc: stable@vger.kernel.org
    Fixes: c818c03b661c ("seccomp: Report number of loaded filters in /proc/$pid/status")
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bf77f479cd4cfd7f0b3d80a13b05e56223becc97
Author: Tejun Heo <tj@kernel.org>
Date:   Tue Jul 27 13:12:20 2021 -1000

    cgroup: rstat: fix A-A deadlock on 32bit around u64_stats_sync
    
    commit c3df5fb57fe8756d67fd56ed29da65cdfde839f9 upstream.
    
    0fa294fb1985 ("cgroup: Replace cgroup_rstat_mutex with a spinlock") added
    cgroup_rstat_flush_irqsafe() allowing flushing to happen from the irq
    context. However, rstat paths use u64_stats_sync to synchronize access to
    64bit stat counters on 32bit machines. u64_stats_sync is implemented using
    seq_lock and trying to read from an irq context can lead to A-A deadlock if
    the irq happens to interrupt the stat update.
    
    Fix it by using the irqsafe variants - u64_stats_update_begin_irqsave() and
    u64_stats_update_end_irqrestore() - in the update paths. Note that none of
    this matters on 64bit machines. All these are just for 32bit SMP setups.
    
    Note that the interface was introduced way back, its first and currently
    only use was recently added by 2d146aa3aa84 ("mm: memcontrol: switch to
    rstat"). Stable tagging targets this commit.
    
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Reported-by: Rik van Riel <riel@surriel.com>
    Fixes: 2d146aa3aa84 ("mm: memcontrol: switch to rstat")
    Cc: stable@vger.kernel.org # v5.13+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5028bdb679c4e504f0b0d70bc7122538f2bdb5da
Author: Ewan D. Milne <emilne@redhat.com>
Date:   Mon Aug 9 11:09:47 2021 -0400

    scsi: lpfc: Move initialization of phba->poll_list earlier to avoid crash
    
    commit 9977d880f7a3c233db9165a75a3a14defc2a4aee upstream.
    
    The phba->poll_list is traversed in case of an error in
    lpfc_sli4_hba_setup(), so it must be initialized earlier in case the error
    path is taken.
    
    [  490.030738] lpfc 0000:65:00.0: 0:1413 Failed to init iocb list.
    [  490.036661] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    [  490.044485] PGD 0 P4D 0
    [  490.047027] Oops: 0000 [#1] SMP PTI
    [  490.050518] CPU: 0 PID: 7 Comm: kworker/0:1 Kdump: loaded Tainted: G          I      --------- -  - 4.18.
    [  490.060511] Hardware name: Dell Inc. PowerEdge R440/0WKGTH, BIOS 1.4.8 05/22/2018
    [  490.067994] Workqueue: events work_for_cpu_fn
    [  490.072371] RIP: 0010:lpfc_sli4_cleanup_poll_list+0x20/0xb0 [lpfc]
    [  490.078546] Code: cf e9 04 f7 fe ff 0f 1f 40 00 0f 1f 44 00 00 41 57 49 89 ff 41 56 41 55 41 54 4d 8d a79
    [  490.097291] RSP: 0018:ffffbd1a463dbcc8 EFLAGS: 00010246
    [  490.102518] RAX: 0000000000008200 RBX: ffff945cdb8c0000 RCX: 0000000000000000
    [  490.109649] RDX: 0000000000018200 RSI: ffff9468d0e16818 RDI: 0000000000000000
    [  490.116783] RBP: ffff945cdb8c1740 R08: 00000000000015c5 R09: 0000000000000042
    [  490.123915] R10: 0000000000000000 R11: ffffbd1a463dbab0 R12: ffff945cdb8c25c0
    [  490.131049] R13: 00000000fffffff4 R14: 0000000000001800 R15: ffff945cdb8c0000
    [  490.138182] FS:  0000000000000000(0000) GS:ffff9468d0e00000(0000) knlGS:0000000000000000
    [  490.146267] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  490.152013] CR2: 0000000000000000 CR3: 000000042ca10002 CR4: 00000000007706f0
    [  490.159146] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [  490.166277] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [  490.173409] PKRU: 55555554
    [  490.176123] Call Trace:
    [  490.178598]  lpfc_sli4_queue_destroy+0x7f/0x3c0 [lpfc]
    [  490.183745]  lpfc_sli4_hba_setup+0x1bc7/0x23e0 [lpfc]
    [  490.188797]  ? kernfs_activate+0x63/0x80
    [  490.192721]  ? kernfs_add_one+0xe7/0x130
    [  490.196647]  ? __kernfs_create_file+0x80/0xb0
    [  490.201020]  ? lpfc_pci_probe_one_s4.isra.48+0x46f/0x9e0 [lpfc]
    [  490.206944]  lpfc_pci_probe_one_s4.isra.48+0x46f/0x9e0 [lpfc]
    [  490.212697]  lpfc_pci_probe_one+0x179/0xb70 [lpfc]
    [  490.217492]  local_pci_probe+0x41/0x90
    [  490.221246]  work_for_cpu_fn+0x16/0x20
    [  490.224994]  process_one_work+0x1a7/0x360
    [  490.229009]  ? create_worker+0x1a0/0x1a0
    [  490.232933]  worker_thread+0x1cf/0x390
    [  490.236687]  ? create_worker+0x1a0/0x1a0
    [  490.240612]  kthread+0x116/0x130
    [  490.243846]  ? kthread_flush_work_fn+0x10/0x10
    [  490.248293]  ret_from_fork+0x35/0x40
    [  490.251869] Modules linked in: lpfc(+) xt_CHECKSUM ipt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4i
    [  490.332609] CR2: 0000000000000000
    
    Link: https://lore.kernel.org/r/20210809150947.18104-1-emilne@redhat.com
    Fixes: 93a4d6f40198 ("scsi: lpfc: Add registration for CPU Offline/Online events")
    Cc: stable@vger.kernel.org
    Reviewed-by: James Smart <jsmart2021@gmail.com>
    Signed-off-by: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3e35c7dbf7064bde4c92b4637f719d6cbd9e21b7
Author: Pavel Begunkov <asml.silence@gmail.com>
Date:   Tue Aug 10 02:44:23 2021 +0100

    io_uring: fix ctx-exit io_rsrc_put_work() deadlock
    
    commit 43597aac1f87230cb565ab354d331682f13d3c7a upstream.
    
    __io_rsrc_put_work() might need ->uring_lock, so nobody should wait for
    rsrc nodes holding the mutex. However, that's exactly what
    io_ring_ctx_free() does with io_wait_rsrc_data().
    
    Split it into rsrc wait + dealloc, and move the first one out of the
    lock.
    
    Cc: stable@vger.kernel.org
    Fixes: b60c8dce33895 ("io_uring: preparation for rsrc tagging")
    Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
    Link: https://lore.kernel.org/r/0130c5c2693468173ec1afab714e0885d2c9c363.1628559783.git.asml.silence@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e1c5046e341dbd1cb1a331210645253993414d6b
Author: Jens Axboe <axboe@kernel.dk>
Date:   Mon Aug 9 08:15:50 2021 -0600

    io_uring: drop ctx->uring_lock before flushing work item
    
    commit c018db4a57f3e31a9cb24d528e9f094eda89a499 upstream.
    
    Ammar reports that he's seeing a lockdep splat on running test/rsrc_tags
    from the regression suite:
    
    ======================================================
    WARNING: possible circular locking dependency detected
    5.14.0-rc3-bluetea-test-00249-gc7d102232649 #5 Tainted: G           OE
    ------------------------------------------------------
    kworker/2:4/2684 is trying to acquire lock:
    ffff88814bb1c0a8 (&ctx->uring_lock){+.+.}-{3:3}, at: io_rsrc_put_work+0x13d/0x1a0
    
    but task is already holding lock:
    ffffc90001c6be70 ((work_completion)(&(&ctx->rsrc_put_work)->work)){+.+.}-{0:0}, at: process_one_work+0x1bc/0x530
    
    which lock already depends on the new lock.
    
    the existing dependency chain (in reverse order) is:
    
    -> #1 ((work_completion)(&(&ctx->rsrc_put_work)->work)){+.+.}-{0:0}:
           __flush_work+0x31b/0x490
           io_rsrc_ref_quiesce.part.0.constprop.0+0x35/0xb0
           __do_sys_io_uring_register+0x45b/0x1060
           do_syscall_64+0x35/0xb0
           entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    -> #0 (&ctx->uring_lock){+.+.}-{3:3}:
           __lock_acquire+0x119a/0x1e10
           lock_acquire+0xc8/0x2f0
           __mutex_lock+0x86/0x740
           io_rsrc_put_work+0x13d/0x1a0
           process_one_work+0x236/0x530
           worker_thread+0x52/0x3b0
           kthread+0x135/0x160
           ret_from_fork+0x1f/0x30
    
    other info that might help us debug this:
    
     Possible unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock((work_completion)(&(&ctx->rsrc_put_work)->work));
                                   lock(&ctx->uring_lock);
                                   lock((work_completion)(&(&ctx->rsrc_put_work)->work));
      lock(&ctx->uring_lock);
    
     *** DEADLOCK ***
    
    2 locks held by kworker/2:4/2684:
     #0: ffff88810004d938 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1bc/0x530
     #1: ffffc90001c6be70 ((work_completion)(&(&ctx->rsrc_put_work)->work)){+.+.}-{0:0}, at: process_one_work+0x1bc/0x530
    
    stack backtrace:
    CPU: 2 PID: 2684 Comm: kworker/2:4 Tainted: G           OE     5.14.0-rc3-bluetea-test-00249-gc7d102232649 #5
    Hardware name: Acer Aspire ES1-421/OLVIA_BE, BIOS V1.05 07/02/2015
    Workqueue: events io_rsrc_put_work
    Call Trace:
     dump_stack_lvl+0x6a/0x9a
     check_noncircular+0xfe/0x110
     __lock_acquire+0x119a/0x1e10
     lock_acquire+0xc8/0x2f0
     ? io_rsrc_put_work+0x13d/0x1a0
     __mutex_lock+0x86/0x740
     ? io_rsrc_put_work+0x13d/0x1a0
     ? io_rsrc_put_work+0x13d/0x1a0
     ? io_rsrc_put_work+0x13d/0x1a0
     ? process_one_work+0x1ce/0x530
     io_rsrc_put_work+0x13d/0x1a0
     process_one_work+0x236/0x530
     worker_thread+0x52/0x3b0
     ? process_one_work+0x530/0x530
     kthread+0x135/0x160
     ? set_kthread_struct+0x40/0x40
     ret_from_fork+0x1f/0x30
    
    which is due to holding the ctx->uring_lock when flushing existing
    pending work, while the pending work flushing may need to grab the uring
    lock if we're using IOPOLL.
    
    Fix this by dropping the uring_lock a bit earlier as part of the flush.
    
    Cc: stable@vger.kernel.org
    Link: https://github.com/axboe/liburing/issues/404
    Tested-by: Ammar Faizi <ammarfaizi2@gmail.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 000cb600dabf180358ccbff900c0f1ba366bc7bc
Author: Ronnie Sahlberg <lsahlber@redhat.com>
Date:   Tue Aug 10 16:33:55 2021 +1000

    cifs: use the correct max-length for dentry_path_raw()
    
    commit 981567bd965329df7e64b13e92a54da816c1e0a4 upstream.
    
    RHBZ: 1972502
    
    PATH_MAX is 4096 but PAGE_SIZE can be >4096 on some architectures
    such as ppc and would thus write beyond the end of the actual object.
    
    Cc: <stable@vger.kernel.org>
    Reported-by: Xiaoli Feng <xifeng@redhat.com>
    Suggested-by: Brian foster <bfoster@redhat.com>
    Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
    Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0ca6ac8a2691762307beaa4841255d1cfe6b2684
Author: Rohith Surabattula <rohiths@microsoft.com>
Date:   Mon Aug 9 09:32:46 2021 +0000

    cifs: Call close synchronously during unlink/rename/lease break.
    
    commit 9e992755be8f2d458a0bcbefd19e493483c1dba2 upstream.
    
    During unlink/rename/lease break, deferred work for close is
    scheduled immediately but in an asynchronous manner which might
    lead to race with actual(unlink/rename) commands.
    
    This change will schedule close synchronously which will avoid
    the race conditions with other commands.
    
    Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
    Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
    Cc: stable@vger.kernel.org # 5.13
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 10290043f377c51e998bf6afb11500601a53cb99
Author: Shyam Prasad N <sprasad@microsoft.com>
Date:   Wed Aug 4 18:37:22 2021 +0000

    cifs: create sd context must be a multiple of 8
    
    commit 7d3fc01796fc895e5fcce45c994c5a8db8120a8d upstream.
    
    We used to follow the rule earlier that the create SD context
    always be a multiple of 8. However, with the change:
    cifs: refactor create_sd_buf() and and avoid corrupting the buffer
    ...we recompute the length, and we failed that rule.
    Fixing that with this change.
    
    Cc: <stable@vger.kernel.org> # v5.10+
    Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3c420ec439715616dfe189d38169f71df612a086
Author: Rohith Surabattula <rohiths@microsoft.com>
Date:   Thu Jul 29 07:45:29 2021 +0000

    cifs: Handle race conditions during rename
    
    commit 41535701da3324b80029cabb501e86c4fafe339d upstream.
    
    When rename is executed on directory which has files for which
    close is deferred, then rename will fail with EACCES.
    
    This patch will try to close all deferred files when EACCES is received
    and retry rename on a directory.
    
    Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
    Cc: stable@vger.kernel.org # 5.13
    Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cc3a5a27e8111af0e8e243b8db358248eb5bc9cd
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Jul 29 16:35:32 2021 +0200

    i2c: dev: zero out array used for i2c reads from userspace
    
    commit 86ff25ed6cd8240d18df58930bd8848b19fce308 upstream.
    
    If an i2c driver happens to not provide the full amount of data that a
    user asks for, it is possible that some uninitialized data could be sent
    to userspace.  While all in-kernel drivers look to be safe, just be sure
    by initializing the buffer to zero before it is passed to the i2c driver
    so that any future drivers will not have this issue.
    
    Also properly copy the amount of data recvieved to the userspace buffer,
    as pointed out by Dan Carpenter.
    
    Reported-by: Eric Dumazet <edumazet@google.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2693a747960bb9b988a7561518dd8d35522d962b
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jul 28 13:23:50 2021 +0200

    ASoC: intel: atom: Fix reference to PCM buffer address
    
    commit 2e6b836312a477d647a7920b56810a5a25f6c856 upstream.
    
    PCM buffers might be allocated dynamically when the buffer
    preallocation failed or a larger buffer is requested, and it's not
    guaranteed that substream->dma_buffer points to the actually used
    buffer.  The address should be retrieved from runtime->dma_addr,
    instead of substream->dma_buffer (and shouldn't use virt_to_phys).
    
    Also, remove the line overriding runtime->dma_area superfluously,
    which was already set up at the PCM buffer allocation.
    
    Cc: Cezary Rojewski <cezary.rojewski@intel.com>
    Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20210728112353.6675-3-tiwai@suse.de
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 145951900b763dc32bf31bd770f3f036a8348424
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jul 28 13:23:53 2021 +0200

    ASoC: kirkwood: Fix reference to PCM buffer address
    
    commit bb6a40fc5a830cae45ddd5cd6cfa151b008522ed upstream.
    
    The transition to the managed PCM buffers allowed the dynamically
    buffer allocation, while the driver code still assumes the fixed
    preallocation buffer and sets up the DMA stuff at the open call.
    This needs to be moved to hw_params after the buffer allocation and
    setup.  Also, the reference to the buffer address has to be corrected
    to runtime->dma_addr.
    
    Fixes: b3c0ae75f5d3 ("ASoC: kirkwood: Use managed DMA buffer allocation")
    Cc: Lars-Peter Clausen <lars@metafoo.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20210728112353.6675-6-tiwai@suse.de
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8e4a0581e288781f2752fec5f241b962f5809fc6
Author: Mark Brown <broonie@kernel.org>
Date:   Fri Jul 23 19:02:00 2021 +0100

    ASoC: tlv320aic31xx: Fix jack detection after suspend
    
    commit 2c39ca6885a2ec03e5c9e7c12a4da2aa8926605a upstream.
    
    The tlv320aic31xx driver relies on regcache_sync() to restore the register
    contents after going to _BIAS_OFF, for example during system suspend. This
    does not work for the jack detection configuration since that is configured
    via the same register that status is read back from so the register is
    volatile and not cached. This can also cause issues during init if the jack
    detection ends up getting set up before the CODEC is initially brought out
    of _BIAS_OFF, we will reset the CODEC and resync the cache as part of that
    process.
    
    Fix this by explicitly reapplying the jack detection configuration after
    resyncing the register cache during power on.
    
    This issue was found by an engineer working off-list on a product
    kernel, I just wrote up the upstream fix.
    
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Link: https://lore.kernel.org/r/20210723180200.25105-1-broonie@kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3380a37484eb74447e15941939a1ffa8701da620
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jul 28 13:23:52 2021 +0200

    ASoC: uniphier: Fix reference to PCM buffer address
    
    commit 827f3164aaa579eee6fd50c6654861d54f282a11 upstream.
    
    Along with the transition to the managed PCM buffers, the driver now
    accepts the dynamically allocated buffer, while it still kept the
    reference to the old preallocated buffer address.  This patch corrects
    to the right reference via runtime->dma_addr.
    
    (Although this might have been already buggy before the cleanup with
    the managed buffer, let's put Fixes tag to point that; it's a corner
    case, after all.)
    
    Fixes: d55894bc2763 ("ASoC: uniphier: Use managed buffer allocation")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20210728112353.6675-5-tiwai@suse.de
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4cf1b08e6889edc666266f551ff3f8a5c2fae88c
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jul 28 13:23:51 2021 +0200

    ASoC: xilinx: Fix reference to PCM buffer address
    
    commit 42bc62c9f1d3d4880bdc27acb5ab4784209bb0b0 upstream.
    
    PCM buffers might be allocated dynamically when the buffer
    preallocation failed or a larger buffer is requested, and it's not
    guaranteed that substream->dma_buffer points to the actually used
    buffer.  The driver needs to refer to substream->runtime->dma_addr
    instead for the buffer address.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20210728112353.6675-4-tiwai@suse.de
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c43e0f97f5fcf8b19c28f97a15aaa86322fef31e
Author: Takashi Iwai <tiwai@suse.de>
Date:   Sat Jul 31 10:43:31 2021 +0200

    ASoC: amd: Fix reference to PCM buffer address
    
    commit 8b5d95313b6d30f642e4ed0125891984c446604e upstream.
    
    PCM buffers might be allocated dynamically when the buffer
    preallocation failed or a larger buffer is requested, and it's not
    guaranteed that substream->dma_buffer points to the actually used
    buffer.  The driver needs to refer to substream->runtime->dma_addr
    instead for the buffer address.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Link: https://lore.kernel.org/r/20210731084331.32225-1-tiwai@suse.de
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b37adfb2c760c3c1061849b1fbc930dde222d316
Author: Colin Ian King <colin.king@canonical.com>
Date:   Fri Jul 30 08:16:51 2021 +0100

    iio: adc: Fix incorrect exit of for-loop
    
    commit 5afc1540f13804a31bb704b763308e17688369c5 upstream.
    
    Currently the for-loop that scans for the optimial adc_period iterates
    through all the possible adc_period levels because the exit logic in
    the loop is inverted. I believe the comparison should be swapped and
    the continue replaced with a break to exit the loop at the correct
    point.
    
    Addresses-Coverity: ("Continue has no effect")
    Fixes: e08e19c331fb ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Link: https://lore.kernel.org/r/20210730071651.17394-1-colin.king@canonical.com
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 88f5acc1f2aff01654f337650cff2a89cf4dbd82
Author: Chris Lesiak <chris.lesiak@licor.com>
Date:   Mon Jun 14 09:18:20 2021 -0500

    iio: humidity: hdc100x: Add margin to the conversion time
    
    commit 84edec86f449adea9ee0b4912a79ab8d9d65abb7 upstream.
    
    The datasheets have the following note for the conversion time
    specification: "This parameter is specified by design and/or
    characterization and it is not tested in production."
    
    Parts have been seen that require more time to do 14-bit conversions for
    the relative humidity channel.  The result is ENXIO due to the address
    phase of a transfer not getting an ACK.
    
    Delay an additional 1 ms per conversion to allow for additional margin.
    
    Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
    Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
    Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
    Link: https://lore.kernel.org/r/20210614141820.2034827-1-chris.lesiak@licor.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29ccbb4684e95d034604f950f454d61f769c85aa
Author: Antti Keränen <detegr@rbx.email>
Date:   Thu Jul 8 12:54:29 2021 +0300

    iio: adis: set GPIO reset pin direction
    
    commit 7e77ef8b8d600cf8448a2bbd32f682c28884551f upstream.
    
    Set reset pin direction to output as the reset pin needs to be an active
    low output pin.
    
    Co-developed-by: Hannu Hartikainen <hannu@hrtk.in>
    Signed-off-by: Hannu Hartikainen <hannu@hrtk.in>
    Signed-off-by: Antti Keränen <detegr@rbx.email>
    Reviewed-by: Nuno Sá <nuno.sa@analog.com>
    Fixes: ecb010d44108 ("iio: imu: adis: Refactor adis_initial_startup")
    Link: https://lore.kernel.org/r/20210708095425.13295-1-detegr@rbx.email
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 51289a499dd1281a31d53432fad9863bbfb2b88c
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Fri Jul 9 12:11:10 2021 +0200

    iio: adc: ti-ads7950: Ensure CS is deasserted after reading channels
    
    commit 9898cb24e454602beb6e17bacf9f97b26c85c955 upstream.
    
    The ADS7950 requires that CS is deasserted after each SPI word. Before
    commit e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce
    CPU usage") the driver used a message with one spi transfer per channel
    where each but the last one had .cs_change set to enforce a CS toggle.
    This was wrongly translated into a message with a single transfer and
    .cs_change set which results in a CS toggle after each word but the
    last which corrupts the first adc conversion of all readouts after the
    first readout.
    
    Fixes: e2540da86ef8 ("iio: adc: ti-ads7950: use SPI_CS_WORD to reduce CPU usage")
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Reviewed-by: David Lechner <david@lechnology.com>
    Tested-by: David Lechner <david@lechnology.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20210709101110.1814294-1-u.kleine-koenig@pengutronix.de
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c7ee0c9854fda85afdc3a9130c1e9b64ef47e1a7
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Aug 10 09:10:15 2021 +0200

    Revert "usb: dwc3: gadget: Use list_replace_init() before traversing lists"
    
    commit 664cc971fb259007e49cc8a3ac43b0787d89443f upstream.
    
    This reverts commit d25d85061bd856d6be221626605319154f9b5043 as it is
    reported to cause problems on many different types of boards.
    
    Reported-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Reported-by: John Stultz <john.stultz@linaro.org>
    Cc: Ray Chi <raychi@google.com>
    Link: https://lore.kernel.org/r/CANcMJZCEVxVLyFgLwK98hqBEdc0_n4P0x_K6Gih8zNH3ouzbJQ@mail.gmail.com
    Fixes: d25d85061bd8 ("usb: dwc3: gadget: Use list_replace_init() before traversing lists")
    Cc: stable <stable@vger.kernel.org>
    Cc: Felipe Balbi <balbi@kernel.org>
    Cc: Wesley Cheng <wcheng@codeaurora.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 95f4fb3ef0b9b7f9b0261f35c029729de0e451da
Author: Liang Wang <wangliang101@huawei.com>
Date:   Fri Aug 13 16:54:45 2021 -0700

    lib: use PFN_PHYS() in devmem_is_allowed()
    
    commit 854f32648b8a5e424d682953b1a9f3b7c3322701 upstream.
    
    The physical address may exceed 32 bits on 32-bit systems with more than
    32 bits of physcial address.  Use PFN_PHYS() in devmem_is_allowed(), or
    the physical address may overflow and be truncated.
    
    We found this bug when mapping a high addresses through devmem tool,
    when CONFIG_STRICT_DEVMEM is enabled on the ARM with ARM_LPAE and devmem
    is used to map a high address that is not in the iomem address range, an
    unexpected error indicating no permission is returned.
    
    This bug was initially introduced from v2.6.37, and the function was
    moved to lib in v5.11.
    
    Link: https://lkml.kernel.org/r/20210731025057.78825-1-wangliang101@huawei.com
    Fixes: 087aaffcdf9c ("ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem")
    Fixes: 527701eda5f1 ("lib: Add a generic version of devmem_is_allowed()")
    Signed-off-by: Liang Wang <wangliang101@huawei.com>
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    Cc: Palmer Dabbelt <palmerdabbelt@google.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Russell King <linux@armlinux.org.uk>
    Cc: Liang Wang <wangliang101@huawei.com>
    Cc: Xiaoming Ni <nixiaoming@huawei.com>
    Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
    Cc: <stable@vger.kernel.org>    [2.6.37+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>