commit dafd634415a7f9892a6fcc99c540fe567ab42c92
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Fri Oct 11 18:21:44 2019 +0200

    Linux 4.19.79

commit 1bd17a737c9e7e91483d9a603528b0e6d4c772f8
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Sep 20 21:54:17 2019 +0200

    nl80211: validate beacon head
    
    commit f88eb7c0d002a67ef31aeb7850b42ff69abc46dc upstream.
    
    We currently don't validate the beacon head, i.e. the header,
    fixed part and elements that are to go in front of the TIM
    element. This means that the variable elements there can be
    malformed, e.g. have a length exceeding the buffer size, but
    most downstream code from this assumes that this has already
    been checked.
    
    Add the necessary checks to the netlink policy.
    
    Cc: stable@vger.kernel.org
    Fixes: ed1b6cc7f80f ("cfg80211/nl80211: add beacon settings")
    Link: https://lore.kernel.org/r/1569009255-I7ac7fbe9436e9d8733439eab8acbbd35e55c74ef@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 527ba5d7634b230448c133b6eea304146ec0aa5e
Author: Jouni Malinen <j@w1.fi>
Date:   Mon Feb 11 16:29:04 2019 +0200

    cfg80211: Use const more consistently in for_each_element macros
    
    commit 7388afe09143210f555bdd6c75035e9acc1fab96 upstream.
    
    Enforce the first argument to be a correct type of a pointer to struct
    element and avoid unnecessary typecasts from const to non-const pointers
    (the change in validate_ie_attr() is needed to make this part work). In
    addition, avoid signed/unsigned comparison within for_each_element() and
    mark struct element packed just in case.
    
    Signed-off-by: Jouni Malinen <j@w1.fi>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad180cace853e60532d118cce17565e4138eb596
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Feb 7 21:44:41 2019 +0100

    cfg80211: add and use strongly typed element iteration macros
    
    commit 0f3b07f027f87a38ebe5c436490095df762819be upstream.
    
    Rather than always iterating elements from frames with pure
    u8 pointers, add a type "struct element" that encapsulates
    the id/datalen/data format of them.
    
    Then, add the element iteration macros
     * for_each_element
     * for_each_element_id
     * for_each_element_extid
    
    which take, as their first 'argument', such a structure and
    iterate through a given u8 array interpreting it as elements.
    
    While at it and since we'll need it, also add
     * for_each_subelement
     * for_each_subelement_id
     * for_each_subelement_extid
    
    which instead of taking data/length just take an outer element
    and use its data/datalen.
    
    Also add for_each_element_completed() to determine if any of
    the loops above completed, i.e. it was able to parse all of
    the elements successfully and no data remained.
    
    Use for_each_element_id() in cfg80211_find_ie_match() as the
    first user of this.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3dab5ba6d7ae8ab5dfcaa61127d92cf07ceca016
Author: Gao Xiang <gaoxiang25@huawei.com>
Date:   Wed Oct 9 18:12:39 2019 +0800

    staging: erofs: detect potential multiref due to corrupted images
    
    commit e12a0ce2fa69798194f3a8628baf6edfbd5c548f upstream.
    
    As reported by erofs-utils fuzzer, currently, multiref
    (ondisk deduplication) hasn't been supported for now,
    we should forbid it properly.
    
    Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
    Cc: <stable@vger.kernel.org> # 4.19+
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Link: https://lore.kernel.org/r/20190821140152.229648-1-gaoxiang25@huawei.com
    [ Gao Xiang: Since earlier kernels don't define EFSCORRUPTED,
                 let's use EIO instead. ]
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8b4341f9b80bb8a7aefedce50b0305696083a830
Author: Gao Xiang <gaoxiang25@huawei.com>
Date:   Wed Oct 9 18:12:38 2019 +0800

    staging: erofs: add two missing erofs_workgroup_put for corrupted images
    
    commit 138e1a0990e80db486ab9f6c06bd5c01f9a97999 upstream.
    
    As reported by erofs-utils fuzzer, these error handling
    path will be entered to handle corrupted images.
    
    Lack of erofs_workgroup_puts will cause unmounting
    unsuccessfully.
    
    Fix these return values to EFSCORRUPTED as well.
    
    Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
    Cc: <stable@vger.kernel.org> # 4.19+
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Link: https://lore.kernel.org/r/20190819103426.87579-4-gaoxiang25@huawei.com
    [ Gao Xiang: Older kernel versions don't have length validity check
                 and EFSCORRUPTED, thus backport pageofs check for now. ]
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 596bbc4e0edfab05efc69313e09107caf5096a5c
Author: Gao Xiang <gaoxiang25@huawei.com>
Date:   Wed Oct 9 18:12:37 2019 +0800

    staging: erofs: some compressed cluster should be submitted for corrupted images
    
    commit ee45197c807895e156b2be0abcaebdfc116487c8 upstream.
    
    As reported by erofs_utils fuzzer, a logical page can belong
    to at most 2 compressed clusters, if one compressed cluster
    is corrupted, but the other has been ready in submitting chain.
    
    The chain needs to submit anyway in order to keep the page
    working properly (page unlocked with PG_error set, PG_uptodate
    not set).
    
    Let's fix it now.
    
    Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
    Cc: <stable@vger.kernel.org> # 4.19+
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Link: https://lore.kernel.org/r/20190819103426.87579-2-gaoxiang25@huawei.com
    [ Gao Xiang: Manually backport to v4.19.y stable. ]
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7c44410387c99039df28ffcbdaa5ff85ab5e857
Author: Gao Xiang <gaoxiang25@huawei.com>
Date:   Wed Oct 9 18:12:36 2019 +0800

    staging: erofs: fix an error handling in erofs_readdir()
    
    commit acb383f1dcb4f1e79b66d4be3a0b6f519a957b0d upstream.
    
    Richard observed a forever loop of erofs_read_raw_page() [1]
    which can be generated by forcely setting ->u.i_blkaddr
    to 0xdeadbeef (as my understanding block layer can
    handle access beyond end of device correctly).
    
    After digging into that, it seems the problem is highly
    related with directories and then I found the root cause
    is an improper error handling in erofs_readdir().
    
    Let's fix it now.
    
    [1] https://lore.kernel.org/r/1163995781.68824.1566084358245.JavaMail.zimbra@nod.at/
    
    Reported-by: Richard Weinberger <richard@nod.at>
    Fixes: 3aa8ec716e52 ("staging: erofs: add directory operations")
    Cc: <stable@vger.kernel.org> # 4.19+
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Link: https://lore.kernel.org/r/20190818125457.25906-1-hsiangkao@aol.com
    [ Gao Xiang: Since earlier kernels don't define EFSCORRUPTED,
                 let's use original error code instead. ]
    Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1b94c1e80ca8e22a09451fa495ffa234dbb29ca7
Author: Andrew Murray <andrew.murray@arm.com>
Date:   Thu Aug 29 14:28:35 2019 -0600

    coresight: etm4x: Use explicit barriers on enable/disable
    
    commit 1004ce4c255fc3eb3ad9145ddd53547d1b7ce327 upstream.
    
    Synchronization is recommended before disabling the trace registers
    to prevent any start or stop points being speculative at the point
    of disabling the unit (section 7.3.77 of ARM IHI 0064D).
    
    Synchronization is also recommended after programming the trace
    registers to ensure all updates are committed prior to normal code
    resuming (section 4.3.7 of ARM IHI 0064D).
    
    Let's ensure these syncronization points are present in the code
    and clearly commented.
    
    Note that we could rely on the barriers in CS_LOCK and
    coresight_disclaim_device_unlocked or the context switch to user
    space - however coresight may be of use in the kernel.
    
    On armv8 the mb macro is defined as dsb(sy) - Given that the etm4x is
    only used on armv8 let's directly use dsb(sy) instead of mb(). This
    removes some ambiguity and makes it easier to correlate the code with
    the TRM.
    
    Signed-off-by: Andrew Murray <andrew.murray@arm.com>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    [Fixed capital letter for "use" in title]
    Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Link: https://lore.kernel.org/r/20190829202842.580-11-mathieu.poirier@linaro.org
    Cc: stable@vger.kernel.org # 4.9+
    Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit effad578c23f97547cb6155111f77b22e7c0119b
Author: Eric Sandeen <sandeen@redhat.com>
Date:   Wed Oct 2 16:17:54 2019 -0500

    vfs: Fix EOVERFLOW testing in put_compat_statfs64
    
    commit cc3a7bfe62b947b423fcb2cfe89fcba92bf48fa3 upstream.
    
    Today, put_compat_statfs64() disallows nearly any field value over
    2^32 if f_bsize is only 32 bits, but that makes no sense.
    compat_statfs64 is there for the explicit purpose of providing 64-bit
    fields for f_files, f_ffree, etc.  And f_bsize is always only 32 bits.
    
    As a result, 32-bit userspace gets -EOVERFLOW for i.e.  large file
    counts even with -D_FILE_OFFSET_BITS=64 set.
    
    In reality, only f_bsize and f_frsize can legitimately overflow
    (fields like f_type and f_namelen should never be large), so test
    only those fields.
    
    This bug was discussed at length some time ago, and this is the proposal
    Al suggested at https://lkml.org/lkml/2018/8/6/640.  It seemed to get
    dropped amid the discussion of other related changes, but this
    part seems obviously correct on its own, so I've picked it up and
    sent it, for expediency.
    
    Fixes: 64d2ab32efe3 ("vfs: fix put_compat_statfs64() does not handle errors")
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d976344d27f7bfef87703035768e51893ce2bd21
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date:   Fri Apr 12 15:39:32 2019 -0500

    arm64/speculation: Support 'mitigations=' cmdline option
    
    commit a111b7c0f20e13b54df2fa959b3dc0bdf1925ae6 upstream.
    
    Configure arm64 runtime CPU speculation bug mitigations in accordance
    with the 'mitigations=' cmdline option.  This affects Meltdown, Spectre
    v2, and Speculative Store Bypass.
    
    The default behavior is unchanged.
    
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    [will: reorder checks so KASLR implies KPTI and SSBS is affected by cmdline]
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit af33d746286c1209fc0026877371d03c8f52606f
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Mon Apr 15 16:21:24 2019 -0500

    arm64: Use firmware to detect CPUs that are not affected by Spectre-v2
    
    commit 517953c2c47f9c00a002f588ac856a5bc70cede3 upstream.
    
    The SMCCC ARCH_WORKAROUND_1 service can indicate that although the
    firmware knows about the Spectre-v2 mitigation, this particular
    CPU is not vulnerable, and it is thus not necessary to call
    the firmware on this CPU.
    
    Let's use this information to our benefit.
    
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 17d1acc4c61ded6b61f65e5904d9758ddc75ae15
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Tue Oct 8 17:39:30 2019 +0200

    arm64: Force SSBS on context switch
    
    [ Upstream commit cbdf8a189a66001c36007bf0f5c975d0376c5c3a ]
    
    On a CPU that doesn't support SSBS, PSTATE[12] is RES0.  In a system
    where only some of the CPUs implement SSBS, we end-up losing track of
    the SSBS bit across task migration.
    
    To address this issue, let's force the SSBS bit on context switch.
    
    Fixes: 8f04e8e6e29c ("arm64: ssbd: Add support for PSTATE.SSBS rather than trapping to EL3")
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    [will: inverted logic and added comments]
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fe22ea561ce0c4d78f4e8305c852ad6f4a432b6a
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Oct 8 17:39:29 2019 +0200

    arm64: ssbs: Don't treat CPUs with SSBS as unaffected by SSB
    
    [ Upstream commit eb337cdfcd5dd3b10522c2f34140a73a4c285c30 ]
    
    SSBS provides a relatively cheap mitigation for SSB, but it is still a
    mitigation and its presence does not indicate that the CPU is unaffected
    by the vulnerability.
    
    Tweak the mitigation logic so that we report the correct string in sysfs.
    
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dada3a4abb43fcffe63d11047209752f1698669b
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:28 2019 +0200

    arm64: add sysfs vulnerability show for speculative store bypass
    
    [ Upstream commit 526e065dbca6df0b5a130b84b836b8b3c9f54e21 ]
    
    Return status based on ssbd_state and __ssb_safe. If the
    mitigation is disabled, or the firmware isn't responding then
    return the expected machine state based on a whitelist of known
    good cores.
    
    Given a heterogeneous machine, the overall machine vulnerability
    defaults to safe but is reset to unsafe when we miss the whitelist
    and the firmware doesn't explicitly tell us the core is safe.
    In order to make that work we delay transitioning to vulnerable
    until we know the firmware isn't responding to avoid a case
    where we miss the whitelist, but the firmware goes ahead and
    reports the core is not vulnerable. If all the cores in the
    machine have SSBS, then __ssb_safe will remain true.
    
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f41df38898ecb5a0a9b5efb863d999d27393c907
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:27 2019 +0200

    arm64: add sysfs vulnerability show for spectre-v2
    
    [ Upstream commit d2532e27b5638bb2e2dd52b80b7ea2ec65135377 ]
    
    Track whether all the cores in the machine are vulnerable to Spectre-v2,
    and whether all the vulnerable cores have been mitigated. We then expose
    this information to userspace via sysfs.
    
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9d1bb39cdd9629d1a6127bd085d3ecc7009789e0
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:26 2019 +0200

    arm64: Always enable spectre-v2 vulnerability detection
    
    [ Upstream commit 8c1e3d2bb44cbb998cb28ff9a18f105fee7f1eb3 ]
    
    Ensure we are always able to detect whether or not the CPU is affected
    by Spectre-v2, so that we can later advertise this to userspace.
    
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b1a33cfd8034dd45cd90a19bdda0b3293c92401e
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Tue Oct 8 17:39:25 2019 +0200

    arm64: Advertise mitigation of Spectre-v2, or lack thereof
    
    [ Upstream commit 73f38166095947f3b86b02fbed6bd592223a7ac8 ]
    
    We currently have a list of CPUs affected by Spectre-v2, for which
    we check that the firmware implements ARCH_WORKAROUND_1. It turns
    out that not all firmwares do implement the required mitigation,
    and that we fail to let the user know about it.
    
    Instead, let's slightly revamp our checks, and rely on a whitelist
    of cores that are known to be non-vulnerable, and let the user know
    the status of the mitigation in the kernel log.
    
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 59a6dc262c8500c6e5fb9f234c6078fd72ddc20f
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:24 2019 +0200

    arm64: Provide a command line to disable spectre_v2 mitigation
    
    [ Upstream commit e5ce5e7267ddcbe13ab9ead2542524e1b7993e5a ]
    
    There are various reasons, such as benchmarking, to disable spectrev2
    mitigation on a machine. Provide a command-line option to do so.
    
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: linux-doc@vger.kernel.org
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c131623b1e9d94c11e2db4635c4572a85fd8b3ce
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:23 2019 +0200

    arm64: Always enable ssb vulnerability detection
    
    [ Upstream commit d42281b6e49510f078ace15a8ea10f71e6262581 ]
    
    Ensure we are always able to detect whether or not the CPU is affected
    by SSB, so that we can later advertise this to userspace.
    
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    [will: Use IS_ENABLED instead of #ifdef]
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 47a11f2eafcc08f7515d141b49f0f889c203b480
Author: Mian Yousaf Kaukab <ykaukab@suse.de>
Date:   Tue Oct 8 17:39:22 2019 +0200

    arm64: enable generic CPU vulnerabilites support
    
    [ Upstream commit 61ae1321f06c4489c724c803e9b8363dea576da3 ]
    
    Enable CPU vulnerabilty show functions for spectre_v1, spectre_v2,
    meltdown and store-bypass.
    
    Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 512158d0c67e4667fa165efc67ddd0bb96295bf4
Author: Jeremy Linton <jeremy.linton@arm.com>
Date:   Tue Oct 8 17:39:21 2019 +0200

    arm64: add sysfs vulnerability show for meltdown
    
    [ Upstream commit 1b3ccf4be0e7be8c4bd8522066b6cbc92591e912 ]
    
    We implement page table isolation as a mitigation for meltdown.
    Report this to userspace via sysfs.
    
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 047aac35fd1a3822987ce2b6239da6058b8525a6
Author: Mian Yousaf Kaukab <ykaukab@suse.de>
Date:   Tue Oct 8 17:39:20 2019 +0200

    arm64: Add sysfs vulnerability show for spectre-v1
    
    [ Upstream commit 3891ebccace188af075ce143d8b072b65e90f695 ]
    
    spectre-v1 has been mitigated and the mitigation is always active.
    Report this to userspace via sysfs
    
    Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
    Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
    Reviewed-by: Andre Przywara <andre.przywara@arm.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
    Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit edfc026626d6339499b3ee126cad9a1a82171a51
Author: Mark Rutland <mark.rutland@arm.com>
Date:   Tue Oct 8 17:39:19 2019 +0200

    arm64: fix SSBS sanitization
    
    [ Upstream commit f54dada8274643e3ff4436df0ea124aeedc43cae ]
    
    In valid_user_regs() we treat SSBS as a RES0 bit, and consequently it is
    unexpectedly cleared when we restore a sigframe or fiddle with GPRs via
    ptrace.
    
    This patch fixes valid_user_regs() to account for this, updating the
    function to refer to the latest ARM ARM (ARM DDI 0487D.a). For AArch32
    tasks, SSBS appears in bit 23 of SPSR_EL1, matching its position in the
    AArch32-native PSR format, and we don't need to translate it as we have
    to for DIT.
    
    There are no other bit assignments that we need to account for today.
    As the recent documentation describes the DIT bit, we can drop our
    comment regarding DIT.
    
    While removing SSBS from the RES0 masks, existing inconsistent
    whitespace is corrected.
    
    Fixes: d71be2b6c0e19180 ("arm64: cpufeature: Detect SSBS and advertise to userspace")
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
    Cc: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 09c22781dd2c641c1ed58fc95605fc36ca4fe50f
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Oct 8 17:39:18 2019 +0200

    arm64: docs: Document SSBS HWCAP
    
    [ Upstream commit ee91176120bd584aa10c564e7e9fdcaf397190a1 ]
    
    We advertise the MRS/MSR instructions for toggling SSBS at EL0 using an
    HWCAP, so document it along with the others.
    
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a59d42ac50a1e74a12c8b4b448318834a10cb887
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Oct 8 17:39:17 2019 +0200

    KVM: arm64: Set SCTLR_EL2.DSSBS if SSBD is forcefully disabled and !vhe
    
    [ Upstream commit 7c36447ae5a090729e7b129f24705bb231a07e0b ]
    
    When running without VHE, it is necessary to set SCTLR_EL2.DSSBS if SSBD
    has been forcefully disabled on the kernel command-line.
    
    Acked-by: Christoffer Dall <christoffer.dall@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1eaff33e24414d1b29083fb4cde53555f5f1d259
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Oct 8 17:39:16 2019 +0200

    arm64: ssbd: Add support for PSTATE.SSBS rather than trapping to EL3
    
    [ Upstream commit 8f04e8e6e29c93421a95b61cad62e3918425eac7 ]
    
    On CPUs with support for PSTATE.SSBS, the kernel can toggle the SSBD
    state without needing to call into firmware.
    
    This patch hooks into the existing SSBD infrastructure so that SSBS is
    used on CPUs that support it, but it's all made horribly complicated by
    the very real possibility of big/little systems that don't uniformly
    provide the new capability.
    
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d286a37471b6a72908d1a0214c79fb16e958a28e
Author: Vincent Chen <vincent.chen@sifive.com>
Date:   Mon Sep 16 16:47:41 2019 +0800

    riscv: Avoid interrupts being erroneously enabled in handle_exception()
    
    [ Upstream commit c82dd6d078a2bb29d41eda032bb96d05699a524d ]
    
    When the handle_exception function addresses an exception, the interrupts
    will be unconditionally enabled after finishing the context save. However,
    It may erroneously enable the interrupts if the interrupts are disabled
    before entering the handle_exception.
    
    For example, one of the WARN_ON() condition is satisfied in the scheduling
    where the interrupt is disabled and rq.lock is locked. The WARN_ON will
    trigger a break exception and the handle_exception function will enable the
    interrupts before entering do_trap_break function. During the procedure, if
    a timer interrupt is pending, it will be taken when interrupts are enabled.
    In this case, it may cause a deadlock problem if the rq.lock is locked
    again in the timer ISR.
    
    Hence, the handle_exception() can only enable interrupts when the state of
    sstatus.SPIE is 1.
    
    This patch is tested on HiFive Unleashed board.
    
    Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
    Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
    [paul.walmsley@sifive.com: updated to apply]
    Fixes: bcae803a21317 ("RISC-V: Enable IRQ during exception handling")
    Cc: David Abdurachmanov <david.abdurachmanov@sifive.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5b67a4721ddd816e81439dc869e3d8b964d86f42
Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Date:   Wed Sep 4 15:17:37 2019 +0530

    perf stat: Reset previous counts on repeat with interval
    
    [ Upstream commit b63fd11cced17fcb8e133def29001b0f6aaa5e06 ]
    
    When using 'perf stat' with repeat and interval option, it shows wrong
    values for events.
    
    The wrong values will be shown for the first interval on the second and
    subsequent repetitions.
    
    Without the fix:
    
      # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
    
         2.000282489                 53      faults
         2.000282489                513      sched:sched_switch
         4.005478208              3,721      faults
         4.005478208              2,666      sched:sched_switch
         5.025470933                395      faults
         5.025470933              1,307      sched:sched_switch
         2.009602825 1,84,46,74,40,73,70,95,47,520      faults              <------
         2.009602825 1,84,46,74,40,73,70,95,49,568      sched:sched_switch  <------
         4.019612206              4,730      faults
         4.019612206              2,746      sched:sched_switch
         5.039615484              3,953      faults
         5.039615484              1,496      sched:sched_switch
         2.000274620 1,84,46,74,40,73,70,95,47,520      faults              <------
         2.000274620 1,84,46,74,40,73,70,95,47,520      sched:sched_switch  <------
         4.000480342              4,282      faults
         4.000480342              2,303      sched:sched_switch
         5.000916811              1,322      faults
         5.000916811              1,064      sched:sched_switch
      #
    
    prev_raw_counts is allocated when using intervals. This is used when
    calculating the difference in the counts of events when using interval.
    
    The current counts are stored in prev_raw_counts to calculate the
    differences in the next iteration.
    
    On the first interval of the second and subsequent repetitions,
    prev_raw_counts would be the values stored in the last interval of the
    previous repetitions, while the current counts will only be for the
    first interval of the current repetition.
    
    Hence there is a possibility of events showing up as big number.
    
    Fix this by resetting prev_raw_counts whenever perf stat repeats the
    command.
    
    With the fix:
    
      # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
    
         2.019349347              2,597      faults
         2.019349347              2,753      sched:sched_switch
         4.019577372              3,098      faults
         4.019577372              2,532      sched:sched_switch
         5.019415481              1,879      faults
         5.019415481              1,356      sched:sched_switch
         2.000178813              8,468      faults
         2.000178813              2,254      sched:sched_switch
         4.000404621              7,440      faults
         4.000404621              1,266      sched:sched_switch
         5.040196079              2,458      faults
         5.040196079                556      sched:sched_switch
         2.000191939              6,870      faults
         2.000191939              1,170      sched:sched_switch
         4.000414103                541      faults
         4.000414103                902      sched:sched_switch
         5.000809863                450      faults
         5.000809863                364      sched:sched_switch
      #
    
    Committer notes:
    
    This was broken since the cset introducing the --interval feature, i.e.
    --repeat + --interval wasn't tested at that point, add the Fixes tag so
    that automatic scripts can pick this up.
    
    Fixes: 13370a9b5bb8 ("perf stat: Add interval printing")
    Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: stable@vger.kernel.org # v3.9+
    Link: http://lore.kernel.org/lkml/20190904094738.9558-2-srikar@linux.vnet.ibm.com
    [ Fixed up conflicts with libperf, i.e. some perf_{evsel,evlist} lost the 'perf' prefix ]
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 15c57bf9dcf8281a54721000f22804c1c0df5299
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Thu Sep 12 12:52:35 2019 +0200

    perf tools: Fix segfault in cpu_cache_level__read()
    
    [ Upstream commit 0216234c2eed1367a318daeb9f4a97d8217412a0 ]
    
    We release wrong pointer on error path in cpu_cache_level__read
    function, leading to segfault:
    
      (gdb) r record ls
      Starting program: /root/perf/tools/perf/perf record ls
      ...
      [ perf record: Woken up 1 times to write data ]
      double free or corruption (out)
    
      Thread 1 "perf" received signal SIGABRT, Aborted.
      0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
      (gdb) bt
      #0  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
      #1  0x00007ffff7443bac in abort () from /lib64/power9/libc.so.6
      #2  0x00007ffff74af8bc in __libc_message () from /lib64/power9/libc.so.6
      #3  0x00007ffff74b92b8 in malloc_printerr () from /lib64/power9/libc.so.6
      #4  0x00007ffff74bb874 in _int_free () from /lib64/power9/libc.so.6
      #5  0x0000000010271260 in __zfree (ptr=0x7fffffffa0b0) at ../../lib/zalloc..
      #6  0x0000000010139340 in cpu_cache_level__read (cache=0x7fffffffa090, cac..
      #7  0x0000000010143c90 in build_caches (cntp=0x7fffffffa118, size=<optimiz..
      ...
    
    Releasing the proper pointer.
    
    Fixes: 720e98b5faf1 ("perf tools: Add perf data cache feature")
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Michael Petlan <mpetlan@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: stable@vger.kernel.org: # v4.6+
    Link: http://lore.kernel.org/lkml/20190912105235.10689-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e5331c37c08baa21e6a1caa7c3ae30156596573c
Author: Balasubramani Vivekanandan <balasubramani_vivekanandan@mentor.com>
Date:   Thu Sep 26 15:51:01 2019 +0200

    tick: broadcast-hrtimer: Fix a race in bc_set_next
    
    [ Upstream commit b9023b91dd020ad7e093baa5122b6968c48cc9e0 ]
    
    When a cpu requests broadcasting, before starting the tick broadcast
    hrtimer, bc_set_next() checks if the timer callback (bc_handler) is active
    using hrtimer_try_to_cancel(). But hrtimer_try_to_cancel() does not provide
    the required synchronization when the callback is active on other core.
    
    The callback could have already executed tick_handle_oneshot_broadcast()
    and could have also returned. But still there is a small time window where
    the hrtimer_try_to_cancel() returns -1. In that case bc_set_next() returns
    without doing anything, but the next_event of the tick broadcast clock
    device is already set to a timeout value.
    
    In the race condition diagram below, CPU #1 is running the timer callback
    and CPU #2 is entering idle state and so calls bc_set_next().
    
    In the worst case, the next_event will contain an expiry time, but the
    hrtimer will not be started which happens when the racing callback returns
    HRTIMER_NORESTART. The hrtimer might never recover if all further requests
    from the CPUs to subscribe to tick broadcast have timeout greater than the
    next_event of tick broadcast clock device. This leads to cascading of
    failures and finally noticed as rcu stall warnings
    
    Here is a depiction of the race condition
    
    CPU #1 (Running timer callback)                   CPU #2 (Enter idle
                                                      and subscribe to
                                                      tick broadcast)
    ---------------------                             ---------------------
    
    __run_hrtimer()                                   tick_broadcast_enter()
    
      bc_handler()                                      __tick_broadcast_oneshot_control()
    
        tick_handle_oneshot_broadcast()
    
          raw_spin_lock(&tick_broadcast_lock);
    
          dev->next_event = KTIME_MAX;                  //wait for tick_broadcast_lock
          //next_event for tick broadcast clock
          set to KTIME_MAX since no other cores
          subscribed to tick broadcasting
    
          raw_spin_unlock(&tick_broadcast_lock);
    
        if (dev->next_event == KTIME_MAX)
          return HRTIMER_NORESTART
        // callback function exits without
           restarting the hrtimer                      //tick_broadcast_lock acquired
                                                       raw_spin_lock(&tick_broadcast_lock);
    
                                                       tick_broadcast_set_event()
    
                                                         clockevents_program_event()
    
                                                           dev->next_event = expires;
    
                                                           bc_set_next()
    
                                                             hrtimer_try_to_cancel()
                                                             //returns -1 since the timer
                                                             callback is active. Exits without
                                                             restarting the timer
      cpu_base->running = NULL;
    
    The comment that hrtimer cannot be armed from within the callback is
    wrong. It is fine to start the hrtimer from within the callback. Also it is
    safe to start the hrtimer from the enter/exit idle code while the broadcast
    handler is active. The enter/exit idle code and the broadcast handler are
    synchronized using tick_broadcast_lock. So there is no need for the
    existing try to cancel logic. All this can be removed which will eliminate
    the race condition as well.
    
    Fixes: 5d1638acb9f6 ("tick: Introduce hrtimer based broadcast")
    Originally-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Balasubramani Vivekanandan <balasubramani_vivekanandan@mentor.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190926135101.12102-2-balasubramani_vivekanandan@mentor.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 140acbb093844308f693ce2e3b53b3f2c61ca16c
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Wed Aug 28 15:05:28 2019 -0400

    tools lib traceevent: Do not free tep->cmdlines in add_new_comm() on failure
    
    [ Upstream commit e0d2615856b2046c2e8d5bfd6933f37f69703b0b ]
    
    If the re-allocation of tep->cmdlines succeeds, then the previous
    allocation of tep->cmdlines will be freed. If we later fail in
    add_new_comm(), we must not free cmdlines, and also should assign
    tep->cmdlines to the new allocation. Otherwise when freeing tep, the
    tep->cmdlines will be pointing to garbage.
    
    Fixes: a6d2a61ac653a ("tools lib traceevent: Remove some die() calls")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: linux-trace-devel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/20190828191819.970121417@goodmis.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d1e4b4cc3bba1059caafacfab57a558d4ba4df51
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Tue Sep 24 09:22:52 2019 +0530

    powerpc/book3s64/radix: Rename CPU_FTR_P9_TLBIE_BUG feature flag
    
    commit 09ce98cacd51fcd0fa0af2f79d1e1d3192f4cbb0 upstream.
    
    Rename the #define to indicate this is related to store vs tlbie
    ordering issue. In the next patch, we will be adding another feature
    flag that is used to handles ERAT flush vs tlbie ordering issue.
    
    Fixes: a5d4b5891c2f ("powerpc/mm: Fixup tlbie vs store ordering issue on POWER9")
    Cc: stable@vger.kernel.org # v4.16+
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190924035254.24612-2-aneesh.kumar@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5f31a6ea55813fc0dd5d1c596287455746431d7
Author: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Date:   Wed May 15 13:15:52 2019 +0530

    powerpc/pseries: Fix cpu_hotplug_lock acquisition in resize_hpt()
    
    [ Upstream commit c784be435d5dae28d3b03db31753dd7a18733f0c ]
    
    The calls to arch_add_memory()/arch_remove_memory() are always made
    with the read-side cpu_hotplug_lock acquired via memory_hotplug_begin().
    On pSeries, arch_add_memory()/arch_remove_memory() eventually call
    resize_hpt() which in turn calls stop_machine() which acquires the
    read-side cpu_hotplug_lock again, thereby resulting in the recursive
    acquisition of this lock.
    
    In the absence of CONFIG_PROVE_LOCKING, we hadn't observed a system
    lockup during a memory hotplug operation because cpus_read_lock() is a
    per-cpu rwsem read, which, in the fast-path (in the absence of the
    writer, which in our case is a CPU-hotplug operation) simply
    increments the read_count on the semaphore. Thus a recursive read in
    the fast-path doesn't cause any problems.
    
    However, we can hit this problem in practice if there is a concurrent
    CPU-Hotplug operation in progress which is waiting to acquire the
    write-side of the lock. This will cause the second recursive read to
    block until the writer finishes. While the writer is blocked since the
    first read holds the lock. Thus both the reader as well as the writers
    fail to make any progress thereby blocking both CPU-Hotplug as well as
    Memory Hotplug operations.
    
    Memory-Hotplug                          CPU-Hotplug
    CPU 0                                   CPU 1
    ------                                  ------
    
    1. down_read(cpu_hotplug_lock.rw_sem)
       [memory_hotplug_begin]
                                            2. down_write(cpu_hotplug_lock.rw_sem)
                                            [cpu_up/cpu_down]
    3. down_read(cpu_hotplug_lock.rw_sem)
       [stop_machine()]
    
    Lockdep complains as follows in these code-paths.
    
     swapper/0/1 is trying to acquire lock:
     (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: stop_machine+0x2c/0x60
    
    but task is already holding lock:
    (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: mem_hotplug_begin+0x20/0x50
    
     other info that might help us debug this:
      Possible unsafe locking scenario:
    
            CPU0
            ----
       lock(cpu_hotplug_lock.rw_sem);
       lock(cpu_hotplug_lock.rw_sem);
    
      *** DEADLOCK ***
    
      May be due to missing lock nesting notation
    
     3 locks held by swapper/0/1:
      #0: (____ptrval____) (&dev->mutex){....}, at: __driver_attach+0x12c/0x1b0
      #1: (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: mem_hotplug_begin+0x20/0x50
      #2: (____ptrval____) (mem_hotplug_lock.rw_sem){++++}, at: percpu_down_write+0x54/0x1a0
    
    stack backtrace:
     CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc5-58373-gbc99402235f3-dirty #166
     Call Trace:
       dump_stack+0xe8/0x164 (unreliable)
       __lock_acquire+0x1110/0x1c70
       lock_acquire+0x240/0x290
       cpus_read_lock+0x64/0xf0
       stop_machine+0x2c/0x60
       pseries_lpar_resize_hpt+0x19c/0x2c0
       resize_hpt_for_hotplug+0x70/0xd0
       arch_add_memory+0x58/0xfc
       devm_memremap_pages+0x5e8/0x8f0
       pmem_attach_disk+0x764/0x830
       nvdimm_bus_probe+0x118/0x240
       really_probe+0x230/0x4b0
       driver_probe_device+0x16c/0x1e0
       __driver_attach+0x148/0x1b0
       bus_for_each_dev+0x90/0x130
       driver_attach+0x34/0x50
       bus_add_driver+0x1a8/0x360
       driver_register+0x108/0x170
       __nd_driver_register+0xd0/0xf0
       nd_pmem_driver_init+0x34/0x48
       do_one_initcall+0x1e0/0x45c
       kernel_init_freeable+0x540/0x64c
       kernel_init+0x2c/0x160
       ret_from_kernel_thread+0x5c/0x68
    
    Fix this issue by
      1) Requiring all the calls to pseries_lpar_resize_hpt() be made
         with cpu_hotplug_lock held.
    
      2) In pseries_lpar_resize_hpt() invoke stop_machine_cpuslocked()
         as a consequence of 1)
    
      3) To satisfy 1), in hpt_order_set(), call mmu_hash_ops.resize_hpt()
         with cpu_hotplug_lock held.
    
    Fixes: dbcf929c0062 ("powerpc/pseries: Add support for hash table resizing")
    Cc: stable@vger.kernel.org # v4.11+
    Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/1557906352-29048-1-git-send-email-ego@linux.vnet.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c688982ffaeb71cbf0c6a16a232d037baf21e472
Author: Xiubo Li <xiubli@redhat.com>
Date:   Wed May 29 15:16:05 2019 -0500

    nbd: fix crash when the blksize is zero
    
    [ Upstream commit 553768d1169a48c0cd87c4eb4ab57534ee663415 ]
    
    This will allow the blksize to be set zero and then use 1024 as
    default.
    
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Xiubo Li <xiubli@redhat.com>
    [fix to use goto out instead of return in genl_connect]
    Signed-off-by: Mike Christie <mchristi@redhat.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 63bb8b76ed62e4075a6bd805132fd9647b0c0e47
Author: Sean Christopherson <sean.j.christopherson@intel.com>
Date:   Tue Oct 1 09:21:23 2019 -0700

    KVM: nVMX: Fix consistency check on injected exception error code
    
    [ Upstream commit 567926cca99ba1750be8aae9c4178796bf9bb90b ]
    
    Current versions of Intel's SDM incorrectly state that "bits 31:15 of
    the VM-Entry exception error-code field" must be zero.  In reality, bits
    31:16 must be zero, i.e. error codes are 16-bit values.
    
    The bogus error code check manifests as an unexpected VM-Entry failure
    due to an invalid code field (error number 7) in L1, e.g. when injecting
    a #GP with error_code=0x9f00.
    
    Nadav previously reported the bug[*], both to KVM and Intel, and fixed
    the associated kvm-unit-test.
    
    [*] https://patchwork.kernel.org/patch/11124749/
    
    Reported-by: Nadav Amit <namit@vmware.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
    Reviewed-by: Jim Mattson <jmattson@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 34b13ff69668d6e8534719f096dd15987f46efaf
Author: Cédric Le Goater <clg@kaod.org>
Date:   Tue Aug 6 19:25:38 2019 +0200

    KVM: PPC: Book3S HV: XIVE: Free escalation interrupts before disabling the VP
    
    [ Upstream commit 237aed48c642328ff0ab19b63423634340224a06 ]
    
    When a vCPU is brought done, the XIVE VP (Virtual Processor) is first
    disabled and then the event notification queues are freed. When freeing
    the queues, we check for possible escalation interrupts and free them
    also.
    
    But when a XIVE VP is disabled, the underlying XIVE ENDs also are
    disabled in OPAL. When an END (Event Notification Descriptor) is
    disabled, its ESB pages (ESn and ESe) are disabled and loads return all
    1s. Which means that any access on the ESB page of the escalation
    interrupt will return invalid values.
    
    When an interrupt is freed, the shutdown handler computes a 'saved_p'
    field from the value returned by a load in xive_do_source_set_mask().
    This value is incorrect for escalation interrupts for the reason
    described above.
    
    This has no impact on Linux/KVM today because we don't make use of it
    but we will introduce in future changes a xive_get_irqchip_state()
    handler. This handler will use the 'saved_p' field to return the state
    of an interrupt and 'saved_p' being incorrect, softlockup will occur.
    
    Fix the vCPU cleanup sequence by first freeing the escalation interrupts
    if any, then disable the XIVE VP and last free the queues.
    
    Fixes: 90c73795afa2 ("KVM: PPC: Book3S HV: Add a new KVM device for the XIVE native exploitation mode")
    Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
    Cc: stable@vger.kernel.org # v4.12+
    Signed-off-by: Cédric Le Goater <clg@kaod.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190806172538.5087-1-clg@kaod.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1b155b4fe8b4b581d70221642be63c9fc6da4f6e
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sat Sep 7 22:32:38 2019 +0200

    drm/radeon: Bail earlier when radeon.cik_/si_support=0 is passed
    
    [ Upstream commit 9dbc88d013b79c62bd845cb9e7c0256e660967c5 ]
    
    Bail from the pci_driver probe function instead of from the drm_driver
    load function.
    
    This avoid /dev/dri/card0 temporarily getting registered and then
    unregistered again, sending unwanted add / remove udev events to
    userspace.
    
    Specifically this avoids triggering the (userspace) bug fixed by this
    plymouth merge-request:
    https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/59
    
    Note that despite that being an userspace bug, not sending unnecessary
    udev events is a good idea in general.
    
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1490490
    Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 04e0c84f137dd07aa931c00db1a2ac80f3be4be5
Author: Navid Emamdoost <navid.emamdoost@gmail.com>
Date:   Wed Sep 25 14:05:09 2019 -0500

    nfp: flower: fix memory leak in nfp_flower_spawn_vnic_reprs
    
    [ Upstream commit 8ce39eb5a67aee25d9f05b40b673c95b23502e3e ]
    
    In nfp_flower_spawn_vnic_reprs in the loop if initialization or the
    allocations fail memory is leaked. Appropriate releases are added.
    
    Fixes: b94524529741 ("nfp: flower: add per repr private data for LAG offload")
    Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
    Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 575a5bb3d37254c620f3a9e68bb61cd8ba81397e
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Thu Sep 26 14:36:48 2019 -0300

    perf unwind: Fix libunwind build failure on i386 systems
    
    [ Upstream commit 26acf400d2dcc72c7e713e1f55db47ad92010cc2 ]
    
    Naresh Kamboju reported, that on the i386 build pr_err()
    doesn't get defined properly due to header ordering:
    
      perf-in.o: In function `libunwind__x86_reg_id':
      tools/perf/util/libunwind/../../arch/x86/util/unwind-libunwind.c:109:
      undefined reference to `pr_err'
    
    Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b0aaf65bb16ab92d1d09c99ad2779aa1bcf4062b
Author: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Date:   Wed Sep 25 16:45:59 2019 -0700

    kernel/elfcore.c: include proper prototypes
    
    [ Upstream commit 0f74914071ab7e7b78731ed62bf350e3a344e0a5 ]
    
    When building with W=1, gcc properly complains that there's no prototypes:
    
      CC      kernel/elfcore.o
    kernel/elfcore.c:7:17: warning: no previous prototype for 'elf_core_extra_phdrs' [-Wmissing-prototypes]
        7 | Elf_Half __weak elf_core_extra_phdrs(void)
          |                 ^~~~~~~~~~~~~~~~~~~~
    kernel/elfcore.c:12:12: warning: no previous prototype for 'elf_core_write_extra_phdrs' [-Wmissing-prototypes]
       12 | int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
    kernel/elfcore.c:17:12: warning: no previous prototype for 'elf_core_write_extra_data' [-Wmissing-prototypes]
       17 | int __weak elf_core_write_extra_data(struct coredump_params *cprm)
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    kernel/elfcore.c:22:15: warning: no previous prototype for 'elf_core_extra_data_size' [-Wmissing-prototypes]
       22 | size_t __weak elf_core_extra_data_size(void)
          |               ^~~~~~~~~~~~~~~~~~~~~~~~
    
    Provide the include file so gcc is happy, and we don't have potential code drift
    
    Link: http://lkml.kernel.org/r/29875.1565224705@turing-police
    Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bab46480e6f918bc4bcb1b6c30629ccbcae455b7
Author: Thomas Richter <tmricht@linux.ibm.com>
Date:   Mon Sep 9 13:41:16 2019 +0200

    perf build: Add detection of java-11-openjdk-devel package
    
    [ Upstream commit 815c1560bf8fd522b8d93a1d727868b910c1cc24 ]
    
    With Java 11 there is no seperate JRE anymore.
    
    Details:
    
      https://coderanch.com/t/701603/java/JRE-JDK
    
    Therefore the detection of the JRE needs to be adapted.
    
    This change works for s390 and x86.  I have not tested other platforms.
    
    Committer testing:
    
    Continues to work with the OpenJDK 8:
    
      $ rm -f ~acme/lib64/libperf-jvmti.so
      $ rpm -qa | grep jdk-devel
      java-1.8.0-openjdk-devel-1.8.0.222.b10-0.fc30.x86_64
      $ git log --oneline -1
      a51937170f33 (HEAD -> perf/core) perf build: Add detection of java-11-openjdk-devel package
      $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make -C tools/perf O=/tmp/build/perf install > /dev/null 2>1
      $ ls -la ~acme/lib64/libperf-jvmti.so
      -rwxr-xr-x. 1 acme acme 230744 Sep 24 16:46 /home/acme/lib64/libperf-jvmti.so
      $
    
    Suggested-by: Andreas Krebbel <krebbel@linux.ibm.com>
    Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
    Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Link: http://lore.kernel.org/lkml/20190909114116.50469-4-tmricht@linux.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 46ff0e2f869f785ca3f60d3fa33e24e707ae847d
Author: KeMeng Shi <shikemeng@huawei.com>
Date:   Mon Sep 16 06:53:28 2019 +0000

    sched/core: Fix migration to invalid CPU in __set_cpus_allowed_ptr()
    
    [ Upstream commit 714e501e16cd473538b609b3e351b2cc9f7f09ed ]
    
    An oops can be triggered in the scheduler when running qemu on arm64:
    
     Unable to handle kernel paging request at virtual address ffff000008effe40
     Internal error: Oops: 96000007 [#1] SMP
     Process migration/0 (pid: 12, stack limit = 0x00000000084e3736)
     pstate: 20000085 (nzCv daIf -PAN -UAO)
     pc : __ll_sc___cmpxchg_case_acq_4+0x4/0x20
     lr : move_queued_task.isra.21+0x124/0x298
     ...
     Call trace:
      __ll_sc___cmpxchg_case_acq_4+0x4/0x20
      __migrate_task+0xc8/0xe0
      migration_cpu_stop+0x170/0x180
      cpu_stopper_thread+0xec/0x178
      smpboot_thread_fn+0x1ac/0x1e8
      kthread+0x134/0x138
      ret_from_fork+0x10/0x18
    
    __set_cpus_allowed_ptr() will choose an active dest_cpu in affinity mask to
    migrage the process if process is not currently running on any one of the
    CPUs specified in affinity mask. __set_cpus_allowed_ptr() will choose an
    invalid dest_cpu (dest_cpu >= nr_cpu_ids, 1024 in my virtual machine) if
    CPUS in an affinity mask are deactived by cpu_down after cpumask_intersects
    check. cpumask_test_cpu() of dest_cpu afterwards is overflown and may pass if
    corresponding bit is coincidentally set. As a consequence, kernel will
    access an invalid rq address associate with the invalid CPU in
    migration_cpu_stop->__migrate_task->move_queued_task and the Oops occurs.
    
    The reproduce the crash:
    
      1) A process repeatedly binds itself to cpu0 and cpu1 in turn by calling
      sched_setaffinity.
    
      2) A shell script repeatedly does "echo 0 > /sys/devices/system/cpu/cpu1/online"
      and "echo 1 > /sys/devices/system/cpu/cpu1/online" in turn.
    
      3) Oops appears if the invalid CPU is set in memory after tested cpumask.
    
    Signed-off-by: KeMeng Shi <shikemeng@huawei.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lkml.kernel.org/r/1568616808-16808-1-git-send-email-shikemeng@huawei.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6cb7aa1b4f94410369bc80f88d7a89bb8a65397a
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date:   Thu Sep 19 13:36:59 2019 -0400

    sched/membarrier: Fix private expedited registration check
    
    [ Upstream commit fc0d77387cb5ae883fd774fc559e056a8dde024c ]
    
    Fix a logic flaw in the way membarrier_register_private_expedited()
    handles ready state checks for private expedited sync core and private
    expedited registrations.
    
    If a private expedited membarrier registration is first performed, and
    then a private expedited sync_core registration is performed, the ready
    state check will skip the second registration when it really should not.
    
    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Chris Metcalf <cmetcalf@ezchip.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Kirill Tkhai <tkhai@yandex.ru>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Paul E. McKenney <paulmck@linux.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lkml.kernel.org/r/20190919173705.2181-2-mathieu.desnoyers@efficios.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e250f2b6aa9ef9cef4f239b15975867c4902f968
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date:   Thu Sep 19 13:37:01 2019 -0400

    sched/membarrier: Call sync_core only before usermode for same mm
    
    [ Upstream commit 2840cf02fae627860156737e83326df354ee4ec6 ]
    
    When the prev and next task's mm change, switch_mm() provides the core
    serializing guarantees before returning to usermode. The only case
    where an explicit core serialization is needed is when the scheduler
    keeps the same mm for prev and next.
    
    Suggested-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Chris Metcalf <cmetcalf@ezchip.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Kirill Tkhai <tkhai@yandex.ru>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Paul E. McKenney <paulmck@linux.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lkml.kernel.org/r/20190919173705.2181-4-mathieu.desnoyers@efficios.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9f33b178cbb2f6b1fd45c6e7b69bd9900971f554
Author: Nathan Chancellor <natechancellor@gmail.com>
Date:   Tue Sep 17 21:21:49 2019 -0700

    libnvdimm/nfit_test: Fix acpi_handle redefinition
    
    [ Upstream commit 59f08896f058a92f03a0041b397a1a227c5e8529 ]
    
    After commit 62974fc389b3 ("libnvdimm: Enable unit test infrastructure
    compile checks"), clang warns:
    
    In file included from
    ../drivers/nvdimm/../../tools/testing/nvdimm/test/iomap.c:15:
    ../drivers/nvdimm/../../tools/testing/nvdimm/test/nfit_test.h:206:15:
    warning: redefinition of typedef 'acpi_handle' is a C11 feature
    [-Wtypedef-redefinition]
    typedef void *acpi_handle;
                  ^
    ../include/acpi/actypes.h:424:15: note: previous definition is here
    typedef void *acpi_handle;      /* Actually a ptr to a NS Node */
                  ^
    1 warning generated.
    
    The include chain:
    
    iomap.c ->
        linux/acpi.h ->
            acpi/acpi.h ->
                acpi/actypes.h
        nfit_test.h
    
    Avoid this by including linux/acpi.h in nfit_test.h, which allows us to
    remove both the typedef and the forward declaration of acpi_object.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/660
    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Reviewed-by: Ira Weiny <ira.weiny@intel.com>
    Link: https://lore.kernel.org/r/20190918042148.77553-1-natechancellor@gmail.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7b4f541fcd1cf5e1a10f6c4e7d59d7e80907fe7d
Author: zhengbin <zhengbin13@huawei.com>
Date:   Wed Aug 14 15:59:09 2019 +0800

    fuse: fix memleak in cuse_channel_open
    
    [ Upstream commit 9ad09b1976c562061636ff1e01bfc3a57aebe56b ]
    
    If cuse_send_init fails, need to fuse_conn_put cc->fc.
    
    cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
                     ->fuse_dev_alloc->fuse_conn_get
                     ->fuse_dev_free->fuse_conn_put
    
    Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: zhengbin <zhengbin13@huawei.com>
    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2e93d24ac75efddc855be4719f7271325f06496c
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Thu Sep 19 14:03:55 2019 +0530

    libnvdimm/region: Initialize bad block for volatile namespaces
    
    [ Upstream commit c42adf87e4e7ed77f6ffe288dc90f980d07d68df ]
    
    We do check for a bad block during namespace init and that use
    region bad block list. We need to initialize the bad block
    for volatile regions for this to work. We also observe a lockdep
    warning as below because the lock is not initialized correctly
    since we skip bad block init for volatile regions.
    
     INFO: trying to register non-static key.
     the code is fine but needs lockdep annotation.
     turning off the locking correctness validator.
     CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc1-15699-g3dee241c937e #149
     Call Trace:
     [c0000000f95cb250] [c00000000147dd84] dump_stack+0xe8/0x164 (unreliable)
     [c0000000f95cb2a0] [c00000000022ccd8] register_lock_class+0x308/0xa60
     [c0000000f95cb3a0] [c000000000229cc0] __lock_acquire+0x170/0x1ff0
     [c0000000f95cb4c0] [c00000000022c740] lock_acquire+0x220/0x270
     [c0000000f95cb580] [c000000000a93230] badblocks_check+0xc0/0x290
     [c0000000f95cb5f0] [c000000000d97540] nd_pfn_validate+0x5c0/0x7f0
     [c0000000f95cb6d0] [c000000000d98300] nd_dax_probe+0xd0/0x1f0
     [c0000000f95cb760] [c000000000d9b66c] nd_pmem_probe+0x10c/0x160
     [c0000000f95cb790] [c000000000d7f5ec] nvdimm_bus_probe+0x10c/0x240
     [c0000000f95cb820] [c000000000d0f844] really_probe+0x254/0x4e0
     [c0000000f95cb8b0] [c000000000d0fdfc] driver_probe_device+0x16c/0x1e0
     [c0000000f95cb930] [c000000000d10238] device_driver_attach+0x68/0xa0
     [c0000000f95cb970] [c000000000d1040c] __driver_attach+0x19c/0x1c0
     [c0000000f95cb9f0] [c000000000d0c4c4] bus_for_each_dev+0x94/0x130
     [c0000000f95cba50] [c000000000d0f014] driver_attach+0x34/0x50
     [c0000000f95cba70] [c000000000d0e208] bus_add_driver+0x178/0x2f0
     [c0000000f95cbb00] [c000000000d117c8] driver_register+0x108/0x170
     [c0000000f95cbb70] [c000000000d7edb0] __nd_driver_register+0xe0/0x100
     [c0000000f95cbbd0] [c000000001a6baa4] nd_pmem_driver_init+0x34/0x48
     [c0000000f95cbbf0] [c0000000000106f4] do_one_initcall+0x1d4/0x4b0
     [c0000000f95cbcd0] [c0000000019f499c] kernel_init_freeable+0x544/0x65c
     [c0000000f95cbdb0] [c000000000010d6c] kernel_init+0x2c/0x180
     [c0000000f95cbe20] [c00000000000b954] ret_from_kernel_thread+0x5c/0x68
    
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Link: https://lore.kernel.org/r/20190919083355.26340-1-aneesh.kumar@linux.ibm.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9025adf37ee8d9511756e5d3a1bee54f6cbd72e6
Author: Stefan Mavrodiev <stefan@olimex.com>
Date:   Fri Jul 26 16:32:36 2019 +0300

    thermal_hwmon: Sanitize thermal_zone type
    
    [ Upstream commit 8c7aa184281c01fc26f319059efb94725012921d ]
    
    When calling thermal_add_hwmon_sysfs(), the device type is sanitized by
    replacing '-' with '_'. However tz->type remains unsanitized. Thus
    calling thermal_hwmon_lookup_by_type() returns no device. And if there is
    no device, thermal_remove_hwmon_sysfs() fails with "hwmon device lookup
    failed!".
    
    The result is unregisted hwmon devices in the sysfs.
    
    Fixes: 409ef0bacacf ("thermal_hwmon: Sanitize attribute name passed to hwmon")
    
    Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c01a9dbec18af8dbbe6dc75c033003427de68ed8
Author: Ido Schimmel <idosch@mellanox.com>
Date:   Wed Jul 10 13:14:52 2019 +0300

    thermal: Fix use-after-free when unregistering thermal zone device
    
    [ Upstream commit 1851799e1d2978f68eea5d9dff322e121dcf59c1 ]
    
    thermal_zone_device_unregister() cancels the delayed work that polls the
    thermal zone, but it does not wait for it to finish. This is racy with
    respect to the freeing of the thermal zone device, which can result in a
    use-after-free [1].
    
    Fix this by waiting for the delayed work to finish before freeing the
    thermal zone device. Note that thermal_zone_device_set_polling() is
    never invoked from an atomic context, so it is safe to call
    cancel_delayed_work_sync() that can block.
    
    [1]
    [  +0.002221] ==================================================================
    [  +0.000064] BUG: KASAN: use-after-free in __mutex_lock+0x1076/0x11c0
    [  +0.000016] Read of size 8 at addr ffff8881e48e0450 by task kworker/1:0/17
    
    [  +0.000023] CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.2.0-rc6-custom-02495-g8e73ca3be4af #1701
    [  +0.000010] Hardware name: Mellanox Technologies Ltd. MSN2100-CB2FO/SA001017, BIOS 5.6.5 06/07/2016
    [  +0.000016] Workqueue: events_freezable_power_ thermal_zone_device_check
    [  +0.000012] Call Trace:
    [  +0.000021]  dump_stack+0xa9/0x10e
    [  +0.000020]  print_address_description.cold.2+0x9/0x25e
    [  +0.000018]  __kasan_report.cold.3+0x78/0x9d
    [  +0.000016]  kasan_report+0xe/0x20
    [  +0.000016]  __mutex_lock+0x1076/0x11c0
    [  +0.000014]  step_wise_throttle+0x72/0x150
    [  +0.000018]  handle_thermal_trip+0x167/0x760
    [  +0.000019]  thermal_zone_device_update+0x19e/0x5f0
    [  +0.000019]  process_one_work+0x969/0x16f0
    [  +0.000017]  worker_thread+0x91/0xc40
    [  +0.000014]  kthread+0x33d/0x400
    [  +0.000015]  ret_from_fork+0x3a/0x50
    
    [  +0.000020] Allocated by task 1:
    [  +0.000015]  save_stack+0x19/0x80
    [  +0.000015]  __kasan_kmalloc.constprop.4+0xc1/0xd0
    [  +0.000014]  kmem_cache_alloc_trace+0x152/0x320
    [  +0.000015]  thermal_zone_device_register+0x1b4/0x13a0
    [  +0.000015]  mlxsw_thermal_init+0xc92/0x23d0
    [  +0.000014]  __mlxsw_core_bus_device_register+0x659/0x11b0
    [  +0.000013]  mlxsw_core_bus_device_register+0x3d/0x90
    [  +0.000013]  mlxsw_pci_probe+0x355/0x4b0
    [  +0.000014]  local_pci_probe+0xc3/0x150
    [  +0.000013]  pci_device_probe+0x280/0x410
    [  +0.000013]  really_probe+0x26a/0xbb0
    [  +0.000013]  driver_probe_device+0x208/0x2e0
    [  +0.000013]  device_driver_attach+0xfe/0x140
    [  +0.000013]  __driver_attach+0x110/0x310
    [  +0.000013]  bus_for_each_dev+0x14b/0x1d0
    [  +0.000013]  driver_register+0x1c0/0x400
    [  +0.000015]  mlxsw_sp_module_init+0x5d/0xd3
    [  +0.000014]  do_one_initcall+0x239/0x4dd
    [  +0.000013]  kernel_init_freeable+0x42b/0x4e8
    [  +0.000012]  kernel_init+0x11/0x18b
    [  +0.000013]  ret_from_fork+0x3a/0x50
    
    [  +0.000015] Freed by task 581:
    [  +0.000013]  save_stack+0x19/0x80
    [  +0.000014]  __kasan_slab_free+0x125/0x170
    [  +0.000013]  kfree+0xf3/0x310
    [  +0.000013]  thermal_release+0xc7/0xf0
    [  +0.000014]  device_release+0x77/0x200
    [  +0.000014]  kobject_put+0x1a8/0x4c0
    [  +0.000014]  device_unregister+0x38/0xc0
    [  +0.000014]  thermal_zone_device_unregister+0x54e/0x6a0
    [  +0.000014]  mlxsw_thermal_fini+0x184/0x35a
    [  +0.000014]  mlxsw_core_bus_device_unregister+0x10a/0x640
    [  +0.000013]  mlxsw_devlink_core_bus_device_reload+0x92/0x210
    [  +0.000015]  devlink_nl_cmd_reload+0x113/0x1f0
    [  +0.000014]  genl_family_rcv_msg+0x700/0xee0
    [  +0.000013]  genl_rcv_msg+0xca/0x170
    [  +0.000013]  netlink_rcv_skb+0x137/0x3a0
    [  +0.000012]  genl_rcv+0x29/0x40
    [  +0.000013]  netlink_unicast+0x49b/0x660
    [  +0.000013]  netlink_sendmsg+0x755/0xc90
    [  +0.000013]  __sys_sendto+0x3de/0x430
    [  +0.000013]  __x64_sys_sendto+0xe2/0x1b0
    [  +0.000013]  do_syscall_64+0xa4/0x4d0
    [  +0.000013]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
    
    [  +0.000017] The buggy address belongs to the object at ffff8881e48e0008
                   which belongs to the cache kmalloc-2k of size 2048
    [  +0.000012] The buggy address is located 1096 bytes inside of
                   2048-byte region [ffff8881e48e0008, ffff8881e48e0808)
    [  +0.000007] The buggy address belongs to the page:
    [  +0.000012] page:ffffea0007923800 refcount:1 mapcount:0 mapping:ffff88823680d0c0 index:0x0 compound_mapcount: 0
    [  +0.000020] flags: 0x200000000010200(slab|head)
    [  +0.000019] raw: 0200000000010200 ffffea0007682008 ffffea00076ab808 ffff88823680d0c0
    [  +0.000016] raw: 0000000000000000 00000000000d000d 00000001ffffffff 0000000000000000
    [  +0.000007] page dumped because: kasan: bad access detected
    
    [  +0.000012] Memory state around the buggy address:
    [  +0.000012]  ffff8881e48e0300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  +0.000012]  ffff8881e48e0380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  +0.000012] >ffff8881e48e0400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  +0.000008]                                                  ^
    [  +0.000012]  ffff8881e48e0480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  +0.000012]  ffff8881e48e0500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  +0.000007] ==================================================================
    
    Fixes: b1569e99c795 ("ACPI: move thermal trip handling to generic thermal layer")
    Reported-by: Jiri Pirko <jiri@mellanox.com>
    Signed-off-by: Ido Schimmel <idosch@mellanox.com>
    Acked-by: Jiri Pirko <jiri@mellanox.com>
    Signed-off-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 55ebeb4e865d491a318dad93173e7355a28aba80
Author: Sanjay R Mehta <sanju.mehta@amd.com>
Date:   Fri Mar 29 11:32:50 2019 +0000

    ntb: point to right memory window index
    
    [ Upstream commit ae89339b08f3fe02457ec9edd512ddc3d246d0f8 ]
    
    second parameter of ntb_peer_mw_get_addr is pointing to wrong memory
    window index by passing "peer gidx" instead of "local gidx".
    
    For ex, "local gidx" value is '0' and "peer gidx" value is '1', then
    
    on peer side ntb_mw_set_trans() api is used as below with gidx pointing to
    local side gidx which is '0', so memroy window '0' is chosen and XLAT '0'
    will be programmed by peer side.
    
        ntb_mw_set_trans(perf->ntb, peer->pidx, peer->gidx, peer->inbuf_xlat,
                        peer->inbuf_size);
    
    Now, on local side ntb_peer_mw_get_addr() is been used as below with gidx
    pointing to "peer gidx" which is '1', so pointing to memory window '1'
    instead of memory window '0'.
    
        ntb_peer_mw_get_addr(perf->ntb,  peer->gidx, &phys_addr,
                            &peer->outbuf_size);
    
    So this patch pass "local gidx" as parameter to ntb_peer_mw_get_addr().
    
    Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
    Signed-off-by: Jon Mason <jdmason@kudzu.us>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9dabade5c1977fafa1dbfa855fb756f520d25589
Author: Arvind Sankar <nivedita@alum.mit.edu>
Date:   Mon Sep 23 13:17:54 2019 -0400

    x86/purgatory: Disable the stackleak GCC plugin for the purgatory
    
    [ Upstream commit ca14c996afe7228ff9b480cf225211cc17212688 ]
    
    Since commit:
    
      b059f801a937 ("x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS")
    
    kexec breaks if GCC_PLUGIN_STACKLEAK=y is enabled, as the purgatory
    contains undefined references to stackleak_track_stack.
    
    Attempting to load a kexec kernel results in this failure:
    
      kexec: Undefined symbol: stackleak_track_stack
      kexec-bzImage64: Loading purgatory failed
    
    Fix this by disabling the stackleak plugin for the purgatory.
    
    Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: b059f801a937 ("x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS")
    Link: https://lkml.kernel.org/r/20190923171753.GA2252517@rani.riverdale.lan
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 65348659535d23e6fb7a79aa9d54332479cf980e
Author: Fabrice Gasnier <fabrice.gasnier@st.com>
Date:   Wed Sep 18 16:54:21 2019 +0200

    pwm: stm32-lp: Add check in case requested period cannot be achieved
    
    [ Upstream commit c91e3234c6035baf5a79763cb4fcd5d23ce75c2b ]
    
    LPTimer can use a 32KHz clock for counting. It depends on clock tree
    configuration. In such a case, PWM output frequency range is limited.
    Although unlikely, nothing prevents user from requesting a PWM frequency
    above counting clock (32KHz for instance):
    - This causes (prd - 1) = 0xffff to be written in ARR register later in
    the apply() routine.
    This results in badly configured PWM period (and also duty_cycle).
    Add a check to report an error is such a case.
    
    Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
    Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 19b1c70e911c4979a501a56228414cbc4229982d
Author: Trond Myklebust <trondmy@gmail.com>
Date:   Fri Sep 20 07:23:40 2019 -0400

    pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors
    
    [ Upstream commit 9c47b18cf722184f32148784189fca945a7d0561 ]
    
    IF the server rejected our layout return with a state error such as
    NFS4ERR_BAD_STATEID, or even a stale inode error, then we do want
    to clear out all the remaining layout segments and mark that stateid
    as invalid.
    
    Fixes: 1c5bd76d17cca ("pNFS: Enable layoutreturn operation for...")
    Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1c70ae6a91f9a17280476dd8675e4ce60f32eb0b
Author: Trek <trek00@inbox.ru>
Date:   Sat Aug 31 21:25:36 2019 +0200

    drm/amdgpu: Check for valid number of registers to read
    
    [ Upstream commit 73d8e6c7b841d9bf298c8928f228fb433676635c ]
    
    Do not try to allocate any amount of memory requested by the user.
    Instead limit it to 128 registers. Actually the longest series of
    consecutive allowed registers are 48, mmGB_TILE_MODE0-31 and
    mmGB_MACROTILE_MODE0-15 (0x2644-0x2673).
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=111273
    Signed-off-by: Trek <trek00@inbox.ru>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e0af3b19ad77b4a2c53ef05c1c11e2f58462d59c
Author: Felix Kuehling <Felix.Kuehling@amd.com>
Date:   Thu Sep 5 19:22:02 2019 -0400

    drm/amdgpu: Fix KFD-related kernel oops on Hawaii
    
    [ Upstream commit dcafbd50f2e4d5cc964aae409fb5691b743fba23 ]
    
    Hawaii needs to flush caches explicitly, submitting an IB in a user
    VMID from kernel mode. There is no s_fence in this case.
    
    Fixes: eb3961a57424 ("drm/amdgpu: remove fence context from the job")
    Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f7ace7f25214e80b06cead8fcabfb12a6176035c
Author: Florian Westphal <fw@strlen.de>
Date:   Thu Sep 19 16:56:44 2019 +0200

    netfilter: nf_tables: allow lookups in dynamic sets
    
    [ Upstream commit acab713177377d9e0889c46bac7ff0cfb9a90c4d ]
    
    This un-breaks lookups in sets that have the 'dynamic' flag set.
    Given this active example configuration:
    
    table filter {
      set set1 {
        type ipv4_addr
        size 64
        flags dynamic,timeout
        timeout 1m
      }
    
      chain input {
         type filter hook input priority 0; policy accept;
      }
    }
    
    ... this works:
    nft add rule ip filter input add @set1 { ip saddr }
    
    -> whenever rule is triggered, the source ip address is inserted
    into the set (if it did not exist).
    
    This won't work:
    nft add rule ip filter input ip saddr @set1 counter
    Error: Could not process rule: Operation not supported
    
    In other words, we can add entries to the set, but then can't make
    matching decision based on that set.
    
    That is just wrong -- all set backends support lookups (else they would
    not be very useful).
    The failure comes from an explicit rejection in nft_lookup.c.
    
    Looking at the history, it seems like NFT_SET_EVAL used to mean
    'set contains expressions' (aka. "is a meter"), for instance something like
    
     nft add rule ip filter input meter example { ip saddr limit rate 10/second }
     or
     nft add rule ip filter input meter example { ip saddr counter }
    
    The actual meaning of NFT_SET_EVAL however, is
    'set can be updated from the packet path'.
    
    'meters' and packet-path insertions into sets, such as
    'add @set { ip saddr }' use exactly the same kernel code (nft_dynset.c)
    and thus require a set backend that provides the ->update() function.
    
    The only set that provides this also is the only one that has the
    NFT_SET_EVAL feature flag.
    
    Removing the wrong check makes the above example work.
    While at it, also fix the flag check during set instantiation to
    allow supported combinations only.
    
    Fixes: 8aeff920dcc9b3f ("netfilter: nf_tables: add stateful object reference to set elements")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f217883bbc92cfe5b5fcd6cdb2919212a4e1c5f6
Author: Ryan Chen <ryan_chen@aspeedtech.com>
Date:   Mon Aug 19 14:47:38 2019 +0930

    watchdog: aspeed: Add support for AST2600
    
    [ Upstream commit b3528b4874480818e38e4da019d655413c233e6a ]
    
    The ast2600 can be supported by the same code as the ast2500.
    
    Signed-off-by: Ryan Chen <ryan_chen@aspeedtech.com>
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20190819051738.17370-3-joel@jms.id.au
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 520c2a64fc7899fbb9dc369d92fced171a9f0e16
Author: Erqi Chen <chenerqi@gmail.com>
Date:   Wed Aug 28 21:22:45 2019 +0800

    ceph: reconnect connection if session hang in opening state
    
    [ Upstream commit 71a228bc8d65900179e37ac309e678f8c523f133 ]
    
    If client mds session is evicted in CEPH_MDS_SESSION_OPENING state,
    mds won't send session msg to client, and delayed_work skip
    CEPH_MDS_SESSION_OPENING state session, the session hang forever.
    
    Allow ceph_con_keepalive to reconnect a session in OPENING to avoid
    session hang. Also, ensure that we skip sessions in RESTARTING and
    REJECTED states since those states can't be resurrected by issuing
    a keepalive.
    
    Link: https://tracker.ceph.com/issues/41551
    Signed-off-by: Erqi Chen chenerqi@gmail.com
    Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
    Signed-off-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0275113fc09a55ee1f1235173c6d6701744aaf93
Author: Luis Henriques <lhenriques@suse.com>
Date:   Tue Jul 23 16:50:20 2019 +0100

    ceph: fix directories inode i_blkbits initialization
    
    [ Upstream commit 750670341a24cb714e624e0fd7da30900ad93752 ]
    
    When filling an inode with info from the MDS, i_blkbits is being
    initialized using fl_stripe_unit, which contains the stripe unit in
    bytes.  Unfortunately, this doesn't make sense for directories as they
    have fl_stripe_unit set to '0'.  This means that i_blkbits will be set
    to 0xff, causing an UBSAN undefined behaviour in i_blocksize():
    
      UBSAN: Undefined behaviour in ./include/linux/fs.h:731:12
      shift exponent 255 is too large for 32-bit type 'int'
    
    Fix this by initializing i_blkbits to CEPH_BLOCK_SHIFT if fl_stripe_unit
    is zero.
    
    Signed-off-by: Luis Henriques <lhenriques@suse.com>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2bc2a90a083ae13d3f77c4dba3f71c9c7b3340d1
Author: Igor Druzhinin <igor.druzhinin@citrix.com>
Date:   Thu Sep 12 19:31:51 2019 +0100

    xen/pci: reserve MCFG areas earlier
    
    [ Upstream commit a4098bc6eed5e31e0391bcc068e61804c98138df ]
    
    If MCFG area is not reserved in E820, Xen by default will defer its usage
    until Dom0 registers it explicitly after ACPI parser recognizes it as
    a reserved resource in DSDT. Having it reserved in E820 is not
    mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2)
    and firmware is free to keep a hole in E820 in that place. Xen doesn't know
    what exactly is inside this hole since it lacks full ACPI view of the
    platform therefore it's potentially harmful to access MCFG region
    without additional checks as some machines are known to provide
    inconsistent information on the size of the region.
    
    Now xen_mcfg_late() runs after acpi_init() which is too late as some basic
    PCI enumeration starts exactly there as well. Trying to register a device
    prior to MCFG reservation causes multiple problems with PCIe extended
    capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are
    no convenient hooks for us to subscribe to so register MCFG areas earlier
    upon the first invocation of xen_add_device(). It should be safe to do once
    since all the boot time buses must have their MCFG areas in MCFG table
    already and we don't support PCI bus hot-plug.
    
    Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
    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 18dd2b05f349a3b430791b64676374a2d490896b
Author: Chengguang Xu <cgxu519@zoho.com.cn>
Date:   Tue Aug 20 18:03:25 2019 +0800

    9p: avoid attaching writeback_fid on mmap with type PRIVATE
    
    [ Upstream commit c87a37ebd40b889178664c2c09cc187334146292 ]
    
    Currently on mmap cache policy, we always attach writeback_fid
    whether mmap type is SHARED or PRIVATE. However, in the use case
    of kata-container which combines 9p(Guest OS) with overlayfs(Host OS),
    this behavior will trigger overlayfs' copy-up when excute command
    inside container.
    
    Link: http://lkml.kernel.org/r/20190820100325.10313-1-cgxu519@zoho.com.cn
    Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
    Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 07f3596ce34484d99bbd1449381002b09b523528
Author: Lu Shuaibing <shuaibinglu@126.com>
Date:   Thu Jun 13 15:08:54 2019 +0800

    9p: Transport error uninitialized
    
    [ Upstream commit 0ce772fe79b68f83df40f07f28207b292785c677 ]
    
    The p9_tag_alloc() does not initialize the transport error t_err field.
    The struct p9_req_t *req is allocated and stored in a struct p9_client
    variable. The field t_err is never initialized before p9_conn_cancel()
    checks its value.
    
    KUMSAN(KernelUninitializedMemorySantizer, a new error detection tool)
    reports this bug.
    
    ==================================================================
    BUG: KUMSAN: use of uninitialized memory in p9_conn_cancel+0x2d9/0x3b0
    Read of size 4 at addr ffff88805f9b600c by task kworker/1:2/1216
    
    CPU: 1 PID: 1216 Comm: kworker/1:2 Not tainted 5.2.0-rc4+ #28
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    Workqueue: events p9_write_work
    Call Trace:
     dump_stack+0x75/0xae
     __kumsan_report+0x17c/0x3e6
     kumsan_report+0xe/0x20
     p9_conn_cancel+0x2d9/0x3b0
     p9_write_work+0x183/0x4a0
     process_one_work+0x4d1/0x8c0
     worker_thread+0x6e/0x780
     kthread+0x1ca/0x1f0
     ret_from_fork+0x35/0x40
    
    Allocated by task 1979:
     save_stack+0x19/0x80
     __kumsan_kmalloc.constprop.3+0xbc/0x120
     kmem_cache_alloc+0xa7/0x170
     p9_client_prepare_req.part.9+0x3b/0x380
     p9_client_rpc+0x15e/0x880
     p9_client_create+0x3d0/0xac0
     v9fs_session_init+0x192/0xc80
     v9fs_mount+0x67/0x470
     legacy_get_tree+0x70/0xd0
     vfs_get_tree+0x4a/0x1c0
     do_mount+0xba9/0xf90
     ksys_mount+0xa8/0x120
     __x64_sys_mount+0x62/0x70
     do_syscall_64+0x6d/0x1e0
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Freed by task 0:
    (stack is not available)
    
    The buggy address belongs to the object at ffff88805f9b6008
     which belongs to the cache p9_req_t of size 144
    The buggy address is located 4 bytes inside of
     144-byte region [ffff88805f9b6008, ffff88805f9b6098)
    The buggy address belongs to the page:
    page:ffffea00017e6d80 refcount:1 mapcount:0 mapping:ffff888068b63740 index:0xffff88805f9b7d90 compound_mapcount: 0
    flags: 0x100000000010200(slab|head)
    raw: 0100000000010200 ffff888068b66450 ffff888068b66450 ffff888068b63740
    raw: ffff88805f9b7d90 0000000000100001 00000001ffffffff 0000000000000000
    page dumped because: kumsan: bad access detected
    ==================================================================
    
    Link: http://lkml.kernel.org/r/20190613070854.10434-1-shuaibinglu@126.com
    Signed-off-by: Lu Shuaibing <shuaibinglu@126.com>
    [dominique.martinet@cea.fr: grouped the added init with the others]
    Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 448deb13ab9e2ddb3eaa00460fcd7ae0a14686b0
Author: Jia-Ju Bai <baijiaju1990@gmail.com>
Date:   Fri Jul 26 15:48:53 2019 +0800

    fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
    
    [ Upstream commit e2751463eaa6f9fec8fea80abbdc62dbc487b3c5 ]
    
    In encode_attrs(), there is an if statement on line 1145 to check
    whether label is NULL:
        if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL))
    
    When label is NULL, it is used on lines 1178-1181:
        *p++ = cpu_to_be32(label->lfs);
        *p++ = cpu_to_be32(label->pi);
        *p++ = cpu_to_be32(label->len);
        p = xdr_encode_opaque_fixed(p, label->label, label->len);
    
    To fix these bugs, label is checked before being used.
    
    These bugs are found by a static analysis tool STCheck written by us.
    
    Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4753e7a824cbfd91c0a795f0c794e5af3cf80f98
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Tue Jul 2 10:00:41 2019 +0200

    ima: fix freeing ongoing ahash_request
    
    [ Upstream commit 4ece3125f21b1d42b84896c5646dbf0e878464e1 ]
    
    integrity_kernel_read() can fail in which case we forward to call
    ahash_request_free() on a currently running request. We have to wait
    for its completion before we can free the request.
    
    This was observed by interrupting a "find / -type f -xdev -print0 | xargs -0
    cat 1>/dev/null" with ctrl-c on an IMA enabled filesystem.
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b69c3085fcc6839b2c86cab3b7ac9a38495a73ae
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Tue Jul 2 10:00:40 2019 +0200

    ima: always return negative code for error
    
    [ Upstream commit f5e1040196dbfe14c77ce3dfe3b7b08d2d961e88 ]
    
    integrity_kernel_read() returns the number of bytes read. If this is
    a short read then this positive value is returned from
    ima_calc_file_hash_atfm(). Currently this is only indirectly called from
    ima_calc_file_hash() and this function only tests for the return value
    being zero or nonzero and also doesn't forward the return value.
    Nevertheless there's no point in returning a positive value as an error,
    so translate a short read into -EINVAL.
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6df3c66de09de4e5a4e9564e19d156480caf1050
Author: Will Deacon <will.deacon@arm.com>
Date:   Fri Jun 15 11:37:34 2018 +0100

    arm64: cpufeature: Detect SSBS and advertise to userspace
    
    commit d71be2b6c0e19180b5f80a6d42039cc074a693a2 upstream.
    
    Armv8.5 introduces a new PSTATE bit known as Speculative Store Bypass
    Safe (SSBS) which can be used as a mitigation against Spectre variant 4.
    
    Additionally, a CPU may provide instructions to manipulate PSTATE.SSBS
    directly, so that userspace can toggle the SSBS control without trapping
    to the kernel.
    
    This patch probes for the existence of SSBS and advertise the new instructions
    to userspace if they exist.
    
    Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3a0e673305e2d5420b65739fdc068fae0adf734e
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Mon Sep 23 13:51:16 2019 +0200

    cfg80211: initialize on-stack chandefs
    
    commit f43e5210c739fe76a4b0ed851559d6902f20ceb1 upstream.
    
    In a few places we don't properly initialize on-stack chandefs,
    resulting in EDMG data to be non-zero, which broke things.
    
    Additionally, in a few places we rely on the driver to init the
    data completely, but perhaps we shouldn't as non-EDMG drivers
    may not initialize the EDMG data, also initialize it there.
    
    Cc: stable@vger.kernel.org
    Fixes: 2a38075cd0be ("nl80211: Add support for EDMG channels")
    Reported-by: Dmitry Osipenko <digetx@gmail.com>
    Tested-by: Dmitry Osipenko <digetx@gmail.com>
    Link: https://lore.kernel.org/r/1569239475-I2dcce394ecf873376c386a78f31c2ec8b538fa25@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 16c75eb13a72a1e6be761590869b0da647dbe38f
Author: Vasily Gorbik <gor@linux.ibm.com>
Date:   Tue Sep 17 20:04:04 2019 +0200

    s390/cio: avoid calling strlen on null pointer
    
    commit ea298e6ee8b34b3ed4366be7eb799d0650ebe555 upstream.
    
    Fix the following kasan finding:
    BUG: KASAN: global-out-of-bounds in ccwgroup_create_dev+0x850/0x1140
    Read of size 1 at addr 0000000000000000 by task systemd-udevd.r/561
    
    CPU: 30 PID: 561 Comm: systemd-udevd.r Tainted: G    B
    Hardware name: IBM 3906 M04 704 (LPAR)
    Call Trace:
    ([<0000000231b3db7e>] show_stack+0x14e/0x1a8)
     [<0000000233826410>] dump_stack+0x1d0/0x218
     [<000000023216fac4>] print_address_description+0x64/0x380
     [<000000023216f5a8>] __kasan_report+0x138/0x168
     [<00000002331b8378>] ccwgroup_create_dev+0x850/0x1140
     [<00000002332b618a>] group_store+0x3a/0x50
     [<00000002323ac706>] kernfs_fop_write+0x246/0x3b8
     [<00000002321d409a>] vfs_write+0x132/0x450
     [<00000002321d47da>] ksys_write+0x122/0x208
     [<0000000233877102>] system_call+0x2a6/0x2c8
    
    Triggered by:
    openat(AT_FDCWD, "/sys/bus/ccwgroup/drivers/qeth/group",
                    O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 16
    write(16, "0.0.bd00,0.0.bd01,0.0.bd02", 26) = 26
    
    The problem is that __get_next_id in ccwgroup_create_dev might set "buf"
    buffer pointer to NULL and explicit check for that is required.
    
    Cc: stable@vger.kernel.org
    Reviewed-by: Sebastian Ott <sebott@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3f41e88f4bd44284c575ad3fb579581a16b39069
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Sep 19 14:12:34 2019 +0200

    ieee802154: atusb: fix use-after-free at disconnect
    
    commit 7fd25e6fc035f4b04b75bca6d7e8daa069603a76 upstream.
    
    The disconnect callback was accessing the hardware-descriptor private
    data after having having freed it.
    
    Fixes: 7490b008d123 ("ieee802154: add support for atusb transceiver")
    Cc: stable <stable@vger.kernel.org>     # 4.2
    Cc: Alexander Aring <alex.aring@gmail.com>
    Reported-by: syzbot+f4509a9138a1472e7e80@syzkaller.appspotmail.com
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 975859bb69b2e20ebbe4b059f319663ca6c783dc
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Oct 1 17:03:55 2019 +0200

    xen/xenbus: fix self-deadlock after killing user process
    
    commit a8fabb38525c51a094607768bac3ba46b3f4a9d5 upstream.
    
    In case a user process using xenbus has open transactions and is killed
    e.g. via ctrl-C the following cleanup of the allocated resources might
    result in a deadlock due to trying to end a transaction in the xenbus
    worker thread:
    
    [ 2551.474706] INFO: task xenbus:37 blocked for more than 120 seconds.
    [ 2551.492215]       Tainted: P           OE     5.0.0-29-generic #5
    [ 2551.510263] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    [ 2551.528585] xenbus          D    0    37      2 0x80000080
    [ 2551.528590] Call Trace:
    [ 2551.528603]  __schedule+0x2c0/0x870
    [ 2551.528606]  ? _cond_resched+0x19/0x40
    [ 2551.528632]  schedule+0x2c/0x70
    [ 2551.528637]  xs_talkv+0x1ec/0x2b0
    [ 2551.528642]  ? wait_woken+0x80/0x80
    [ 2551.528645]  xs_single+0x53/0x80
    [ 2551.528648]  xenbus_transaction_end+0x3b/0x70
    [ 2551.528651]  xenbus_file_free+0x5a/0x160
    [ 2551.528654]  xenbus_dev_queue_reply+0xc4/0x220
    [ 2551.528657]  xenbus_thread+0x7de/0x880
    [ 2551.528660]  ? wait_woken+0x80/0x80
    [ 2551.528665]  kthread+0x121/0x140
    [ 2551.528667]  ? xb_read+0x1d0/0x1d0
    [ 2551.528670]  ? kthread_park+0x90/0x90
    [ 2551.528673]  ret_from_fork+0x35/0x40
    
    Fix this by doing the cleanup via a workqueue instead.
    
    Reported-by: James Dingwall <james@dingwall.me.uk>
    Fixes: fd8aa9095a95c ("xen: optimize xenbus driver for multiple concurrent xenstore accesses")
    Cc: <stable@vger.kernel.org> # 4.11
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e409b81d9ddb0dd2d70636ca24f4587f65571833
Author: Wanpeng Li <wanpengli@tencent.com>
Date:   Mon Sep 9 09:40:28 2019 +0800

    Revert "locking/pvqspinlock: Don't wait if vCPU is preempted"
    
    commit 89340d0935c9296c7b8222b6eab30e67cb57ab82 upstream.
    
    This patch reverts commit 75437bb304b20 (locking/pvqspinlock: Don't
    wait if vCPU is preempted).  A large performance regression was caused
    by this commit.  on over-subscription scenarios.
    
    The test was run on a Xeon Skylake box, 2 sockets, 40 cores, 80 threads,
    with three VMs of 80 vCPUs each.  The score of ebizzy -M is reduced from
    13000-14000 records/s to 1700-1800 records/s:
    
              Host                Guest                score
    
    vanilla w/o kvm optimizations     upstream    1700-1800 records/s
    vanilla w/o kvm optimizations     revert      13000-14000 records/s
    vanilla w/ kvm optimizations      upstream    4500-5000 records/s
    vanilla w/ kvm optimizations      revert      14000-15500 records/s
    
    Exit from aggressive wait-early mechanism can result in premature yield
    and extra scheduling latency.
    
    Actually, only 6% of wait_early events are caused by vcpu_is_preempted()
    being true.  However, when one vCPU voluntarily releases its vCPU, all
    the subsequently waiters in the queue will do the same and the cascading
    effect leads to bad performance.
    
    kvm optimizations:
    [1] commit d73eb57b80b (KVM: Boost vCPUs that are delivering interrupts)
    [2] commit 266e85a5ec9 (KVM: X86: Boost queue head vCPU to mitigate lock waiter preemption)
    
    Tested-by: loobinliu@tencent.com
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Waiman Long <longman@redhat.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Radim Krčmář <rkrcmar@redhat.com>
    Cc: loobinliu@tencent.com
    Cc: stable@vger.kernel.org
    Fixes: 75437bb304b20 (locking/pvqspinlock: Don't wait if vCPU is preempted)
    Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7ed2867ceb41b7fa881dce0a0984c8bb63ed8cb4
Author: Russell King <rmk+kernel@armlinux.org.uk>
Date:   Sun Sep 22 11:26:58 2019 +0100

    mmc: sdhci-of-esdhc: set DMA snooping based on DMA coherence
    
    commit 121bd08b029e03404c451bb237729cdff76eafed upstream.
    
    We must not unconditionally set the DMA snoop bit; if the DMA API is
    assuming that the device is not DMA coherent, and the device snoops the
    CPU caches, the device can see stale cache lines brought in by
    speculative prefetch.
    
    This leads to the device seeing stale data, potentially resulting in
    corrupted data transfers.  Commonly, this results in a descriptor fetch
    error such as:
    
    mmc0: ADMA error
    mmc0: sdhci: ============ SDHCI REGISTER DUMP ===========
    mmc0: sdhci: Sys addr:  0x00000000 | Version:  0x00002202
    mmc0: sdhci: Blk size:  0x00000008 | Blk cnt:  0x00000001
    mmc0: sdhci: Argument:  0x00000000 | Trn mode: 0x00000013
    mmc0: sdhci: Present:   0x01f50008 | Host ctl: 0x00000038
    mmc0: sdhci: Power:     0x00000003 | Blk gap:  0x00000000
    mmc0: sdhci: Wake-up:   0x00000000 | Clock:    0x000040d8
    mmc0: sdhci: Timeout:   0x00000003 | Int stat: 0x00000001
    mmc0: sdhci: Int enab:  0x037f108f | Sig enab: 0x037f108b
    mmc0: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00002202
    mmc0: sdhci: Caps:      0x35fa0000 | Caps_1:   0x0000af00
    mmc0: sdhci: Cmd:       0x0000333a | Max curr: 0x00000000
    mmc0: sdhci: Resp[0]:   0x00000920 | Resp[1]:  0x001d8a33
    mmc0: sdhci: Resp[2]:   0x325b5900 | Resp[3]:  0x3f400e00
    mmc0: sdhci: Host ctl2: 0x00000000
    mmc0: sdhci: ADMA Err:  0x00000009 | ADMA Ptr: 0x000000236d43820c
    mmc0: sdhci: ============================================
    mmc0: error -5 whilst initialising SD card
    
    but can lead to other errors, and potentially direct the SDHCI
    controller to read/write data to other memory locations (e.g. if a valid
    descriptor is visible to the device in a stale cache line.)
    
    Fix this by ensuring that the DMA snoop bit corresponds with the
    behaviour of the DMA API.  Since the driver currently only supports DT,
    use of_dma_is_coherent().  Note that device_get_dma_attr() can not be
    used as that risks re-introducing this bug if/when the driver is
    converted to ACPI.
    
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4509a19d5082198bc7d520a8b4b5316f94062710
Author: Russell King <rmk+kernel@armlinux.org.uk>
Date:   Sun Sep 22 11:26:53 2019 +0100

    mmc: sdhci: improve ADMA error reporting
    
    commit d1c536e3177390da43d99f20143b810c35433d1f upstream.
    
    ADMA errors are potentially data corrupting events; although we print
    the register state, we do not usefully print the ADMA descriptors.
    Worse than that, we print them by referencing their virtual address
    which is meaningless when the register state gives us the DMA address
    of the failing descriptor.
    
    Print the ADMA descriptors giving their DMA addresses rather than their
    virtual addresses, and print them using SDHCI_DUMP() rather than DBG().
    
    We also do not show the correct value of the interrupt status register;
    the register dump shows the current value, after we have cleared the
    pending interrupts we are going to service.  What is more useful is to
    print the interrupts that _were_ pending at the time the ADMA error was
    encountered.  Fix that too.
    
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 873f49d6a4e8176b2f0f6d3b5540d84b712b064e
Author: Xiaolin Zhang <xiaolin.zhang@intel.com>
Date:   Tue Aug 27 16:39:23 2019 +0800

    drm/i915/gvt: update vgpu workload head pointer correctly
    
    commit 0a3242bdb47713e09cb004a0ba4947d3edf82d8a upstream.
    
    when creating a vGPU workload, the guest context head pointer should
    be updated correctly by comparing with the exsiting workload in the
    guest worklod queue including the current running context.
    
    in some situation, there is a running context A and then received 2 new
    vGPU workload context B and A. in the new workload context A, it's head
    pointer should be updated with the running context A's tail.
    
    v2: walk through guest workload list in backward way.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Xiaolin Zhang <xiaolin.zhang@intel.com>
    Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
    Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 198bc7040c484d4c7be04b4eb64d5c19fbf466ce
Author: Lyude Paul <lyude@redhat.com>
Date:   Fri Sep 13 18:03:50 2019 -0400

    drm/nouveau/kms/nv50-: Don't create MSTMs for eDP connectors
    
    commit 698c1aa9f83b618de79e9e5e19a58f70a4a6ae0f upstream.
    
    On the ThinkPad P71, we have one eDP connector exposed along with 5 DP
    connectors, resulting in a total of 11 TMDS encoders. Since the GPU on
    this system is also capable of MST, we create an additional 4 fake MST
    encoders for each DP port. Unfortunately, we also do this for the eDP
    port as well, resulting in:
    
      1 eDP port: +1 TMDS encoder
                  +4 DPMST encoders
      5 DP ports: +2 TMDS encoders
                  +4 DPMST encoders
                  *5 ports
                  == 35 encoders
    
    Which breaks things, since DRM has a hard coded limit of 32 encoders.
    So, fix this by not creating MSTMs for any eDP connectors. This brings
    us down to 31 encoders, although we can do better.
    
    This fixes driver probing for nouveau on the ThinkPad P71.
    
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7a85c86735516cdb4c44b882244fe48f3608ee7d
Author: Sean Paul <seanpaul@chromium.org>
Date:   Wed Aug 7 14:51:50 2019 -0400

    drm/msm/dsi: Fix return value check for clk_get_parent
    
    commit 5fb9b797d5ccf311ae4aba69e86080d47668b5f7 upstream.
    
    clk_get_parent returns an error pointer upon failure, not NULL. So the
    checks as they exist won't catch a failure. This patch changes the
    checks and the return values to properly handle an error pointer.
    
    Fixes: c4d8cfe516dc ("drm/msm/dsi: add implementation for helper functions")
    Cc: Sibi Sankar <sibis@codeaurora.org>
    Cc: Sean Paul <seanpaul@chromium.org>
    Cc: Rob Clark <robdclark@chromium.org>
    Cc: <stable@vger.kernel.org> # v4.19+
    Signed-off-by: Sean Paul <seanpaul@chromium.org>
    Signed-off-by: Rob Clark <robdclark@chromium.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e45633f49ef5c0b0fcc1a8577c837ed53f374a7
Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
Date:   Wed Oct 2 15:25:42 2019 +0300

    drm/omap: fix max fclk divider for omap36xx
    
    commit e2c4ed148cf3ec8669a1d90dc66966028e5fad70 upstream.
    
    The OMAP36xx and AM/DM37x TRMs say that the maximum divider for DSS fclk
    (in CM_CLKSEL_DSS) is 32. Experimentation shows that this is not
    correct, and using divider of 32 breaks DSS with a flood or underflows
    and sync losts. Dividers up to 31 seem to work fine.
    
    There is another patch to the DT files to limit the divider correctly,
    but as the DSS driver also needs to know the maximum divider to be able
    to iteratively find good rates, we also need to do the fix in the DSS
    driver.
    
    Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
    Cc: Adam Ford <aford173@gmail.com>
    Cc: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20191002122542.8449-1-tomi.valkeinen@ti.com
    Tested-by: Adam Ford <aford173@gmail.com>
    Reviewed-by: Jyri Sarha <jsarha@ti.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90ac4028739c5f002adc82367c3f74ac682087e9
Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Date:   Wed Sep 4 15:17:38 2019 +0530

    perf stat: Fix a segmentation fault when using repeat forever
    
    commit 443f2d5ba13d65ccfd879460f77941875159d154 upstream.
    
    Observe a segmentation fault when 'perf stat' is asked to repeat forever
    with the interval option.
    
    Without fix:
    
      # perf stat -r 0 -I 5000 -e cycles -a sleep 10
      #           time             counts unit events
           5.000211692  3,13,89,82,34,157      cycles
          10.000380119  1,53,98,52,22,294      cycles
          10.040467280       17,16,79,265      cycles
      Segmentation fault
    
    This problem was only observed when we use forever option aka -r 0 and
    works with limited repeats. Calling print_counter with ts being set to
    NULL, is not a correct option when interval is set. Hence avoid
    print_counter(NULL,..)  if interval is set.
    
    With fix:
    
      # perf stat -r 0 -I 5000 -e cycles -a sleep 10
       #           time             counts unit events
           5.019866622  3,15,14,43,08,697      cycles
          10.039865756  3,15,16,31,95,261      cycles
          10.059950628     1,26,05,47,158      cycles
           5.009902655  3,14,52,62,33,932      cycles
          10.019880228  3,14,52,22,89,154      cycles
          10.030543876       66,90,18,333      cycles
           5.009848281  3,14,51,98,25,437      cycles
          10.029854402  3,15,14,93,04,918      cycles
           5.009834177  3,14,51,95,92,316      cycles
    
    Committer notes:
    
    Did the 'git bisect' to find the cset introducing the problem to add the
    Fixes tag below, and at that time the problem reproduced as:
    
      (gdb) run stat -r0 -I500 sleep 1
      <SNIP>
      Program received signal SIGSEGV, Segmentation fault.
      print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
      866           sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
      (gdb) bt
      #0  print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
      #1  0x000000000041860a in print_counters (ts=ts@entry=0x0, argc=argc@entry=2, argv=argv@entry=0x7fffffffd640) at builtin-stat.c:938
      #2  0x0000000000419a7f in cmd_stat (argc=2, argv=0x7fffffffd640, prefix=<optimized out>) at builtin-stat.c:1411
      #3  0x000000000045c65a in run_builtin (p=p@entry=0x6291b8 <commands+216>, argc=argc@entry=5, argv=argv@entry=0x7fffffffd640) at perf.c:370
      #4  0x000000000045c893 in handle_internal_command (argc=5, argv=0x7fffffffd640) at perf.c:429
      #5  0x000000000045c8f1 in run_argv (argcp=argcp@entry=0x7fffffffd4ac, argv=argv@entry=0x7fffffffd4a0) at perf.c:473
      #6  0x000000000045cac9 in main (argc=<optimized out>, argv=<optimized out>) at perf.c:588
      (gdb)
    
    Mostly the same as just before this patch:
    
      Program received signal SIGSEGV, Segmentation fault.
      0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964
      964           sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep);
      (gdb) bt
      #0  0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964
      #1  0x0000000000588047 in perf_evlist__print_counters (evlist=0xbc9b90, config=0xa1f2a0 <stat_config>, _target=0xa1f0c0 <target>, ts=0x0, argc=2, argv=0x7fffffffd670)
          at util/stat-display.c:1172
      #2  0x000000000045390f in print_counters (ts=0x0, argc=2, argv=0x7fffffffd670) at builtin-stat.c:656
      #3  0x0000000000456bb5 in cmd_stat (argc=2, argv=0x7fffffffd670) at builtin-stat.c:1960
      #4  0x00000000004dd2e0 in run_builtin (p=0xa30e00 <commands+288>, argc=5, argv=0x7fffffffd670) at perf.c:310
      #5  0x00000000004dd54d in handle_internal_command (argc=5, argv=0x7fffffffd670) at perf.c:362
      #6  0x00000000004dd694 in run_argv (argcp=0x7fffffffd4cc, argv=0x7fffffffd4c0) at perf.c:406
      #7  0x00000000004dda11 in main (argc=5, argv=0x7fffffffd670) at perf.c:531
      (gdb)
    
    Fixes: d4f63a4741a8 ("perf stat: Introduce print_counters function")
    Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Tested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Cc: stable@vger.kernel.org # v4.2+
    Link: http://lore.kernel.org/lkml/20190904094738.9558-3-srikar@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 22f28afd3d7753d3ea6b79e2fac604a39d2bc350
Author: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Date:   Mon Aug 12 15:13:56 2019 +0200

    watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout
    
    commit 144783a80cd2cbc45c6ce17db649140b65f203dd upstream.
    
    Converting from ms to s requires dividing by 1000, not multiplying. So
    this is currently taking the smaller of new_timeout and 1.28e8,
    i.e. effectively new_timeout.
    
    The driver knows what it set max_hw_heartbeat_ms to, so use that
    value instead of doing a division at run-time.
    
    FWIW, this can easily be tested by booting into a busybox shell and
    doing "watchdog -t 5 -T 130 /dev/watchdog" - without this patch, the
    watchdog fires after 130&127 == 2 seconds.
    
    Fixes: b07e228eee69 "watchdog: imx2_wdt: Fix set_timeout for big timeout values"
    Cc: stable@vger.kernel.org # 5.2 plus anything the above got backported to
    Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20190812131356.23039-1-linux@rasmusvillemoes.dk
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7cf8cc79f93c5b7b410026ce4e3624da8752170
Author: Sumit Saxena <sumit.saxena@broadcom.com>
Date:   Fri Jul 26 00:55:52 2019 +0530

    PCI: Restore Resizable BAR size bits correctly for 1MB BARs
    
    commit d2182b2d4b71ff0549a07f414d921525fade707b upstream.
    
    In a Resizable BAR Control Register, bits 13:8 control the size of the BAR.
    The encoded values of these bits are as follows (see PCIe r5.0, sec
    7.8.6.3):
    
      Value    BAR size
         0     1 MB (2^20 bytes)
         1     2 MB (2^21 bytes)
         2     4 MB (2^22 bytes)
       ...
        43     8 EB (2^63 bytes)
    
    Previously we incorrectly set the BAR size bits for a 1 MB BAR to 0x1f
    instead of 0, so devices that support that size, e.g., new megaraid_sas and
    mpt3sas adapters, fail to initialize during resume from S3 sleep.
    
    Correctly calculate the BAR size bits for Resizable BAR control registers.
    
    Link: https://lore.kernel.org/r/20190725192552.24295-1-sumit.saxena@broadcom.com
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203939
    Fixes: d3252ace0bc6 ("PCI: Restore resized BAR state on resume")
    Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Cc: stable@vger.kernel.org      # v4.19+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 956ce989c41f70f945a36827cf5c74a1439ef5ae
Author: Jon Derrick <jonathan.derrick@intel.com>
Date:   Mon Sep 16 07:54:35 2019 -0600

    PCI: vmd: Fix shadow offsets to reflect spec changes
    
    commit a1a30170138c9c5157bd514ccd4d76b47060f29b upstream.
    
    The shadow offset scratchpad was moved to 0x2000-0x2010. Update the
    location to get the correct shadow offset.
    
    Fixes: 6788958e4f3c ("PCI: vmd: Assign membar addresses from shadow registers")
    Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Cc: stable@vger.kernel.org # v5.2+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 06f250215bebc57a5d90604afff9e4f1b35e2e52
Author: Li RongQing <lirongqing@baidu.com>
Date:   Thu Sep 19 20:04:47 2019 +0800

    timer: Read jiffies once when forwarding base clk
    
    commit e430d802d6a3aaf61bd3ed03d9404888a29b9bf9 upstream.
    
    The timer delayed for more than 3 seconds warning was triggered during
    testing.
    
      Workqueue: events_unbound sched_tick_remote
      RIP: 0010:sched_tick_remote+0xee/0x100
      ...
      Call Trace:
       process_one_work+0x18c/0x3a0
       worker_thread+0x30/0x380
       kthread+0x113/0x130
       ret_from_fork+0x22/0x40
    
    The reason is that the code in collect_expired_timers() uses jiffies
    unprotected:
    
        if (next_event > jiffies)
            base->clk = jiffies;
    
    As the compiler is allowed to reload the value base->clk can advance
    between the check and the store and in the worst case advance farther than
    next event. That causes the timer expiry to be delayed until the wheel
    pointer wraps around.
    
    Convert the code to use READ_ONCE()
    
    Fixes: 236968383cf5 ("timers: Optimize collect_expired_timers() for NOHZ")
    Signed-off-by: Li RongQing <lirongqing@baidu.com>
    Signed-off-by: Liang ZhiCheng <liangzhicheng@baidu.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/1568894687-14499-1-git-send-email-lirongqing@baidu.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 12c6c4a50f66d2fc997e504e5aa942c0ed45177c
Author: Kees Cook <keescook@chromium.org>
Date:   Tue Sep 17 11:00:25 2019 -0700

    usercopy: Avoid HIGHMEM pfn warning
    
    commit 314eed30ede02fa925990f535652254b5bad6b65 upstream.
    
    When running on a system with >512MB RAM with a 32-bit kernel built with:
    
            CONFIG_DEBUG_VIRTUAL=y
            CONFIG_HIGHMEM=y
            CONFIG_HARDENED_USERCOPY=y
    
    all execve()s will fail due to argv copying into kmap()ed pages, and on
    usercopy checking the calls ultimately of virt_to_page() will be looking
    for "bad" kmap (highmem) pointers due to CONFIG_DEBUG_VIRTUAL=y:
    
     ------------[ cut here ]------------
     kernel BUG at ../arch/x86/mm/physaddr.c:83!
     invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
     CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc8 #6
     Hardware name: Dell Inc. Inspiron 1318/0C236D, BIOS A04 01/15/2009
     EIP: __phys_addr+0xaf/0x100
     ...
     Call Trace:
      __check_object_size+0xaf/0x3c0
      ? __might_sleep+0x80/0xa0
      copy_strings+0x1c2/0x370
      copy_strings_kernel+0x2b/0x40
      __do_execve_file+0x4ca/0x810
      ? kmem_cache_alloc+0x1c7/0x370
      do_execve+0x1b/0x20
      ...
    
    The check is from arch/x86/mm/physaddr.c:
    
            VIRTUAL_BUG_ON((phys_addr >> PAGE_SHIFT) > max_low_pfn);
    
    Due to the kmap() in fs/exec.c:
    
                    kaddr = kmap(kmapped_page);
            ...
            if (copy_from_user(kaddr+offset, str, bytes_to_copy)) ...
    
    Now we can fetch the correct page to avoid the pfn check. In both cases,
    hardened usercopy will need to walk the page-span checker (if enabled)
    to do sanity checking.
    
    Reported-by: Randy Dunlap <rdunlap@infradead.org>
    Tested-by: Randy Dunlap <rdunlap@infradead.org>
    Fixes: f5509cc18daa ("mm: Hardened usercopy")
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Link: https://lore.kernel.org/r/201909171056.7F2FFD17@keescook
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e010c98351838230e00359fbd3e37b3444dc09fd
Author: Tom Zanussi <zanussi@kernel.org>
Date:   Sun Sep 1 17:02:01 2019 -0500

    tracing: Make sure variable reference alias has correct var_ref_idx
    
    commit 17f8607a1658a8e70415eef67909f990d13017b5 upstream.
    
    Original changelog from Steve Rostedt (except last sentence which
    explains the problem, and the Fixes: tag):
    
    I performed a three way histogram with the following commands:
    
    echo 'irq_lat u64 lat pid_t pid' > synthetic_events
    echo 'wake_lat u64 lat u64 irqlat pid_t pid' >> synthetic_events
    echo 'hist:keys=common_pid:irqts=common_timestamp.usecs if function == 0xffffffff81200580' > events/timer/hrtimer_start/trigger
    echo 'hist:keys=common_pid:lat=common_timestamp.usecs-$irqts:onmatch(timer.hrtimer_start).irq_lat($lat,pid) if common_flags & 1' > events/sched/sched_waking/trigger
    echo 'hist:keys=pid:wakets=common_timestamp.usecs,irqlat=lat' > events/synthetic/irq_lat/trigger
    echo 'hist:keys=next_pid:lat=common_timestamp.usecs-$wakets,irqlat=$irqlat:onmatch(synthetic.irq_lat).wake_lat($lat,$irqlat,next_pid)' > events/sched/sched_switch/trigger
    echo 1 > events/synthetic/wake_lat/enable
    
    Basically I wanted to see:
    
     hrtimer_start (calling function tick_sched_timer)
    
    Note:
    
      # grep tick_sched_timer /proc/kallsyms
    ffffffff81200580 t tick_sched_timer
    
    And save the time of that, and then record sched_waking if it is called
    in interrupt context and with the same pid as the hrtimer_start, it
    will record the latency between that and the waking event.
    
    I then look at when the task that is woken is scheduled in, and record
    the latency between the wakeup and the task running.
    
    At the end, the wake_lat synthetic event will show the wakeup to
    scheduled latency, as well as the irq latency in from hritmer_start to
    the wakeup. The problem is that I found this:
    
              <idle>-0     [007] d...   190.485261: wake_lat: lat=27 irqlat=190485230 pid=698
              <idle>-0     [005] d...   190.485283: wake_lat: lat=40 irqlat=190485239 pid=10
              <idle>-0     [002] d...   190.488327: wake_lat: lat=56 irqlat=190488266 pid=335
              <idle>-0     [005] d...   190.489330: wake_lat: lat=64 irqlat=190489262 pid=10
              <idle>-0     [003] d...   190.490312: wake_lat: lat=43 irqlat=190490265 pid=77
              <idle>-0     [005] d...   190.493322: wake_lat: lat=54 irqlat=190493262 pid=10
              <idle>-0     [005] d...   190.497305: wake_lat: lat=35 irqlat=190497267 pid=10
              <idle>-0     [005] d...   190.501319: wake_lat: lat=50 irqlat=190501264 pid=10
    
    The irqlat seemed quite large! Investigating this further, if I had
    enabled the irq_lat synthetic event, I noticed this:
    
              <idle>-0     [002] d.s.   249.429308: irq_lat: lat=164968 pid=335
              <idle>-0     [002] d...   249.429369: wake_lat: lat=55 irqlat=249429308 pid=335
    
    Notice that the timestamp of the irq_lat "249.429308" is awfully
    similar to the reported irqlat variable. In fact, all instances were
    like this. It appeared that:
    
      irqlat=$irqlat
    
    Wasn't assigning the old $irqlat to the new irqlat variable, but
    instead was assigning the $irqts to it.
    
    The issue is that assigning the old $irqlat to the new irqlat variable
    creates a variable reference alias, but the alias creation code
    forgets to make sure the alias uses the same var_ref_idx to access the
    reference.
    
    Link: http://lkml.kernel.org/r/1567375321.5282.12.camel@kernel.org
    
    Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
    Cc: linux-rt-users <linux-rt-users@vger.kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: 7e8b88a30b085 ("tracing: Add hist trigger support for variable reference aliases")
    Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 022ca58f109ef7429ef91286cd3a813fbf45dfea
Author: Michael Nosthoff <committed@heine.so>
Date:   Fri Aug 16 09:58:42 2019 +0200

    power: supply: sbs-battery: only return health when battery present
    
    commit fe55e770327363304c4111423e6f7ff3c650136d upstream.
    
    when the battery is set to sbs-mode and  no gpio detection is enabled
    "health" is always returning a value even when the battery is not present.
    All other fields return "not present".
    This leads to a scenario where the driver is constantly switching between
    "present" and "not present" state. This generates a lot of constant
    traffic on the i2c.
    
    This commit changes the response of "health" to an error when the battery
    is not responding leading to a consistent "not present" state.
    
    Fixes: 76b16f4cdfb8 ("power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Michael Nosthoff <committed@heine.so>
    Reviewed-by: Brian Norris <briannorris@chromium.org>
    Tested-by: Brian Norris <briannorris@chromium.org>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5cb6dd823127a449f4082b16b2b6508ff2a6289b
Author: Michael Nosthoff <committed@heine.so>
Date:   Fri Aug 16 09:37:42 2019 +0200

    power: supply: sbs-battery: use correct flags field
    
    commit 99956a9e08251a1234434b492875b1eaff502a12 upstream.
    
    the type flag is stored in the chip->flags field not in the
    client->flags field. This currently leads to never using the ti
    specific health function as client->flags doesn't use that bit.
    So it's always falling back to the general one.
    
    Fixes: 76b16f4cdfb8 ("power: supply: sbs-battery: don't assume MANUFACTURER_DATA formats")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Michael Nosthoff <committed@heine.so>
    Reviewed-by: Brian Norris <briannorris@chromium.org>
    Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fb93ccde081e39631fd16c03d1c9eb0b4bef7edd
Author: Jiaxun Yang <jiaxun.yang@flygoat.com>
Date:   Wed May 29 16:42:59 2019 +0800

    MIPS: Treat Loongson Extensions as ASEs
    
    commit d2f965549006acb865c4638f1f030ebcefdc71f6 upstream.
    
    Recently, binutils had split Loongson-3 Extensions into four ASEs:
    MMI, CAM, EXT, EXT2. This patch do the samething in kernel and expose
    them in cpuinfo so applications can probe supported ASEs at runtime.
    
    Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
    Cc: Huacai Chen <chenhc@lemote.com>
    Cc: Yunqiang Su <ysu@wavecomp.com>
    Cc: stable@vger.kernel.org # v4.14+
    Signed-off-by: Paul Burton <paul.burton@mips.com>
    Cc: linux-mips@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a0dc60ac6bef99fe8c00bbebffa66b704c075d15
Author: Gilad Ben-Yossef <gilad@benyossef.com>
Date:   Mon Jul 29 13:40:18 2019 +0300

    crypto: ccree - use the full crypt length value
    
    commit 7a4be6c113c1f721818d1e3722a9015fe393295c upstream.
    
    In case of AEAD decryption verifcation error we were using the
    wrong value to zero out the plaintext buffer leaving the end of
    the buffer with the false plaintext.
    
    Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
    Fixes: ff27e85a85bb ("crypto: ccree - add AEAD support")
    CC: stable@vger.kernel.org # v4.17+
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f5c087a0d9a0e31b4a97ebba3b5eb263f1a6c24f
Author: Gilad Ben-Yossef <gilad@benyossef.com>
Date:   Tue Jul 2 14:39:19 2019 +0300

    crypto: ccree - account for TEE not ready to report
    
    commit 76a95bd8f9e10cade9c4c8df93b5c20ff45dc0f5 upstream.
    
    When ccree driver runs it checks the state of the Trusted Execution
    Environment CryptoCell driver before proceeding. We did not account
    for cases where the TEE side is not ready or not available at all.
    Fix it by only considering TEE error state after sync with the TEE
    side driver.
    
    Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
    Fixes: ab8ec9658f5a ("crypto: ccree - add FIPS support")
    CC: stable@vger.kernel.org # v4.17+
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 561bf9309209e174035eaee0edfc3247ecfdff76
Author: Horia Geantă <horia.geanta@nxp.com>
Date:   Tue Jul 30 08:48:33 2019 +0300

    crypto: caam - fix concurrency issue in givencrypt descriptor
    
    commit 48f89d2a2920166c35b1c0b69917dbb0390ebec7 upstream.
    
    IV transfer from ofifo to class2 (set up at [29][30]) is not guaranteed
    to be scheduled before the data transfer from ofifo to external memory
    (set up at [38]:
    
    [29] 10FA0004           ld: ind-nfifo (len=4) imm
    [30] 81F00010               <nfifo_entry: ofifo->class2 type=msg len=16>
    [31] 14820004           ld: ccb2-datasz len=4 offs=0 imm
    [32] 00000010               data:0x00000010
    [33] 8210010D    operation: cls1-op aes cbc init-final enc
    [34] A8080B04         math: (seqin + math0)->vseqout len=4
    [35] 28000010    seqfifold: skip len=16
    [36] A8080A04         math: (seqin + math0)->vseqin len=4
    [37] 2F1E0000    seqfifold: both msg1->2-last2-last1 len=vseqinsz
    [38] 69300000   seqfifostr: msg len=vseqoutsz
    [39] 5C20000C      seqstr: ccb2 ctx len=12 offs=0
    
    If ofifo -> external memory transfer happens first, DECO will hang
    (issuing a Watchdog Timeout error, if WDOG is enabled) waiting for
    data availability in ofifo for the ofifo -> c2 ififo transfer.
    
    Make sure IV transfer happens first by waiting for all CAAM internal
    transfers to end before starting payload transfer.
    
    New descriptor with jump command inserted at [37]:
    
    [..]
    [36] A8080A04         math: (seqin + math0)->vseqin len=4
    [37] A1000401         jump: jsl1 all-match[!nfifopend] offset=[01] local->[38]
    [38] 2F1E0000    seqfifold: both msg1->2-last2-last1 len=vseqinsz
    [39] 69300000   seqfifostr: msg len=vseqoutsz
    [40] 5C20000C      seqstr: ccb2 ctx len=12 offs=0
    
    [Note: the issue is present in the descriptor from the very beginning
    (cf. Fixes tag). However I've marked it v4.19+ since it's the oldest
    maintained kernel that the patch applies clean against.]
    
    Cc: <stable@vger.kernel.org> # v4.19+
    Fixes: 1acebad3d8db8 ("crypto: caam - faster aead implementation")
    Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3683dd7074dcda394cc4f976c5ef26fbb9dfb11c
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Wed Sep 4 14:18:09 2019 +0000

    crypto: cavium/zip - Add missing single_release()
    
    commit c552ffb5c93d9d65aaf34f5f001c4e7e8484ced1 upstream.
    
    When using single_open() for opening, single_release() should be
    used instead of seq_release(), otherwise there is a memory leak.
    
    Fixes: 09ae5d37e093 ("crypto: zip - Add Compression/Decompression statistics")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cd8e0a5d94fba7c6032484ac89254940bad9b537
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Fri Sep 6 13:13:06 2019 +1000

    crypto: skcipher - Unmap pages after an external error
    
    commit 0ba3c026e685573bd3534c17e27da7c505ac99c4 upstream.
    
    skcipher_walk_done may be called with an error by internal or
    external callers.  For those internal callers we shouldn't unmap
    pages but for external callers we must unmap any pages that are
    in use.
    
    This patch distinguishes between the two cases by checking whether
    walk->nbytes is zero or not.  For internal callers, we now set
    walk->nbytes to zero prior to the call.  For external callers,
    walk->nbytes has always been non-zero (as zero is used to indicate
    the termination of a walk).
    
    Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Fixes: 5cde0af2a982 ("[CRYPTO] cipher: Added block cipher type")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9349108ae499b352ce1605076a9b74ec450bbb75
Author: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Date:   Tue Jul 23 07:24:01 2019 +0000

    crypto: qat - Silence smp_processor_id() warning
    
    commit 1b82feb6c5e1996513d0fb0bbb475417088b4954 upstream.
    
    It seems that smp_processor_id() is only used for a best-effort
    load-balancing, refer to qat_crypto_get_instance_node(). It's not feasible
    to disable preemption for the duration of the crypto requests. Therefore,
    just silence the warning. This commit is similar to e7a9b05ca4
    ("crypto: cavium - Fix smp_processor_id() warnings").
    
    Silences the following splat:
    BUG: using smp_processor_id() in preemptible [00000000] code: cryptomgr_test/2904
    caller is qat_alg_ablkcipher_setkey+0x300/0x4a0 [intel_qat]
    CPU: 1 PID: 2904 Comm: cryptomgr_test Tainted: P           O    4.14.69 #1
    ...
    Call Trace:
     dump_stack+0x5f/0x86
     check_preemption_disabled+0xd3/0xe0
     qat_alg_ablkcipher_setkey+0x300/0x4a0 [intel_qat]
     skcipher_setkey_ablkcipher+0x2b/0x40
     __test_skcipher+0x1f3/0xb20
     ? cpumask_next_and+0x26/0x40
     ? find_busiest_group+0x10e/0x9d0
     ? preempt_count_add+0x49/0xa0
     ? try_module_get+0x61/0xf0
     ? crypto_mod_get+0x15/0x30
     ? __kmalloc+0x1df/0x1f0
     ? __crypto_alloc_tfm+0x116/0x180
     ? crypto_skcipher_init_tfm+0xa6/0x180
     ? crypto_create_tfm+0x4b/0xf0
     test_skcipher+0x21/0xa0
     alg_test_skcipher+0x3f/0xa0
     alg_test.part.6+0x126/0x2a0
     ? finish_task_switch+0x21b/0x260
     ? __schedule+0x1e9/0x800
     ? __wake_up_common+0x8d/0x140
     cryptomgr_test+0x40/0x50
     kthread+0xff/0x130
     ? cryptomgr_notify+0x540/0x540
     ? kthread_create_on_node+0x70/0x70
     ret_from_fork+0x24/0x50
    
    Fixes: ed8ccaef52 ("crypto: qat - Add support for SRIOV")
    Cc: stable@vger.kernel.org
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 532920b2667814fbdf1220343433f78f86b9cab8
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Mon Aug 5 13:01:50 2019 -0400

    tools lib traceevent: Fix "robust" test of do_generate_dynamic_list_file
    
    commit 82a2f88458d70704be843961e10b5cef9a6e95d3 upstream.
    
    The tools/lib/traceevent/Makefile had a test added to it to detect a failure
    of the "nm" when making the dynamic list file (whatever that is). The
    problem is that the test sorts the values "U W w" and some versions of sort
    will place "w" ahead of "W" (even though it has a higher ASCII value, and
    break the test.
    
    Add 'tr "w" "W"' to merge the two and not worry about the ordering.
    
    Reported-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: David Carrillo-Cisneros <davidcc@google.com>
    Cc: He Kuang <hekuang@huawei.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Michal rarek <mmarek@suse.com>
    Cc: Paul Turner <pjt@google.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Cc: Wang Nan <wangnan0@huawei.com>
    Cc: stable@vger.kernel.org
    Fixes: 6467753d61399 ("tools lib traceevent: Robustify do_generate_dynamic_list_file")
    Link: http://lkml.kernel.org/r/20190805130150.25acfeb1@gandalf.local.home
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4aaea17d3c31464ecd783c9a0f554080d2298c09
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Tue Aug 13 16:01:02 2019 +0200

    can: mcp251x: mcp251x_hw_reset(): allow more time after a reset
    
    commit d84ea2123f8d27144e3f4d58cd88c9c6ddc799de upstream.
    
    Some boards take longer than 5ms to power up after a reset, so allow
    some retries attempts before giving up.
    
    Fixes: ff06d611a31c ("can: mcp251x: Improve mcp251x_hw_reset()")
    Cc: linux-stable <stable@vger.kernel.org>
    Tested-by: Sean Nyekjaer <sean@geanix.com>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9124eac41a672b92c030d95e1fbd079740faab6c
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Tue Sep 24 09:22:51 2019 +0530

    powerpc/book3s64/mm: Don't do tlbie fixup for some hardware revisions
    
    commit 677733e296b5c7a37c47da391fc70a43dc40bd67 upstream.
    
    The store ordering vs tlbie issue mentioned in commit
    a5d4b5891c2f ("powerpc/mm: Fixup tlbie vs store ordering issue on
    POWER9") is fixed for Nimbus 2.3 and Cumulus 1.3 revisions. We don't
    need to apply the fixup if we are running on them
    
    We can only do this on PowerNV. On pseries guest with KVM we still
    don't support redoing the feature fixup after migration. So we should
    be enabling all the workarounds needed, because whe can possibly
    migrate between DD 2.3 and DD 2.2
    
    Fixes: a5d4b5891c2f ("powerpc/mm: Fixup tlbie vs store ordering issue on POWER9")
    Cc: stable@vger.kernel.org # v4.16+
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190924035254.24612-1-aneesh.kumar@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19c12f12093e8bc86994a1480673003c67215e69
Author: Alexey Kardashevskiy <aik@ozlabs.ru>
Date:   Thu Jul 18 15:11:36 2019 +1000

    powerpc/powernv/ioda: Fix race in TCE level allocation
    
    commit 56090a3902c80c296e822d11acdb6a101b322c52 upstream.
    
    pnv_tce() returns a pointer to a TCE entry and originally a TCE table
    would be pre-allocated. For the default case of 2GB window the table
    needs only a single level and that is fine. However if more levels are
    requested, it is possible to get a race when 2 threads want a pointer
    to a TCE entry from the same page of TCEs.
    
    This adds cmpxchg to handle the race. Note that once TCE is non-zero,
    it cannot become zero again.
    
    Fixes: a68bd1267b72 ("powerpc/powernv/ioda: Allocate indirect TCE levels on demand")
    CC: stable@vger.kernel.org # v4.19+
    Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190718051139.74787-2-aik@ozlabs.ru
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 032ce7d766a9846167916cb0713ab91b2de9cbdf
Author: Andrew Donnellan <ajd@linux.ibm.com>
Date:   Fri May 3 17:52:53 2019 +1000

    powerpc/powernv: Restrict OPAL symbol map to only be readable by root
    
    commit e7de4f7b64c23e503a8c42af98d56f2a7462bd6d upstream.
    
    Currently the OPAL symbol map is globally readable, which seems bad as
    it contains physical addresses.
    
    Restrict it to root.
    
    Fixes: c8742f85125d ("powerpc/powernv: Expose OPAL firmware symbol map")
    Cc: stable@vger.kernel.org # v3.19+
    Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190503075253.22798-1-ajd@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ba3ca9fcb0e7ea897f777f10b0a33b4d27e9e658
Author: Santosh Sivaraj <santosh@fossix.org>
Date:   Tue Aug 20 13:43:46 2019 +0530

    powerpc/mce: Schedule work from irq_work
    
    commit b5bda6263cad9a927e1a4edb7493d542da0c1410 upstream.
    
    schedule_work() cannot be called from MCE exception context as MCE can
    interrupt even in interrupt disabled context.
    
    Fixes: 733e4a4c4467 ("powerpc/mce: hookup memory_failure for UE errors")
    Cc: stable@vger.kernel.org # v4.15+
    Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
    Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
    Acked-by: Balbir Singh <bsingharora@gmail.com>
    Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190820081352.8641-2-santosh@fossix.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee6eeeb88e799abd4e3ba42063b97786a212428e
Author: Balbir Singh <bsingharora@gmail.com>
Date:   Tue Aug 20 13:43:47 2019 +0530

    powerpc/mce: Fix MCE handling for huge pages
    
    commit 99ead78afd1128bfcebe7f88f3b102fb2da09aee upstream.
    
    The current code would fail on huge pages addresses, since the shift would
    be incorrect. Use the correct page shift value returned by
    __find_linux_pte() to get the correct physical address. The code is more
    generic and can handle both regular and compound pages.
    
    Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors")
    Signed-off-by: Balbir Singh <bsingharora@gmail.com>
    [arbab@linux.ibm.com: Fixup pseries_do_memory_failure()]
    Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
    Tested-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
    Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
    Cc: stable@vger.kernel.org # v4.15+
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190820081352.8641-3-santosh@fossix.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1284f2073415a4c7b978abeb7e70be845fd501bd
Author: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Date:   Fri Jul 19 10:05:31 2019 +0000

    ASoC: sgtl5000: Improve VAG power and mute control
    
    commit b1f373a11d25fc9a5f7679c9b85799fe09b0dc4a upstream.
    
    VAG power control is improved to fit the manual [1]. This patch fixes as
    minimum one bug: if customer muxes Headphone to Line-In right after boot,
    the VAG power remains off that leads to poor sound quality from line-in.
    
    I.e. after boot:
      - Connect sound source to Line-In jack;
      - Connect headphone to HP jack;
      - Run following commands:
      $ amixer set 'Headphone' 80%
      $ amixer set 'Headphone Mux' LINE_IN
    
    Change VAG power on/off control according to the following algorithm:
      - turn VAG power ON on the 1st incoming event.
      - keep it ON if there is any active VAG consumer (ADC/DAC/HP/Line-In).
      - turn VAG power OFF when there is the latest consumer's pre-down event
        come.
      - always delay after VAG power OFF to avoid pop.
      - delay after VAG power ON if the initiative consumer is Line-In, this
        prevents pop during line-in muxing.
    
    According to the data sheet [1], to avoid any pops/clicks,
    the outputs should be muted during input/output
    routing changes.
    
    [1] https://www.nxp.com/docs/en/data-sheet/SGTL5000.pdf
    
    Cc: stable@vger.kernel.org
    Fixes: 9b34e6cc3bc2 ("ASoC: Add Freescale SGTL5000 codec support")
    Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
    Reviewed-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
    Reviewed-by: Fabio Estevam <festevam@gmail.com>
    Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
    Link: https://lore.kernel.org/r/20190719100524.23300-3-oleksandr.suvorov@toradex.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 50090b75fa89b742e19a5e533c080662a8ca67e3
Author: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Date:   Fri Jul 19 10:05:30 2019 +0000

    ASoC: Define a set of DAPM pre/post-up events
    
    commit cfc8f568aada98f9608a0a62511ca18d647613e2 upstream.
    
    Prepare to use SND_SOC_DAPM_PRE_POST_PMU definition to
    reduce coming code size and make it more readable.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
    Reviewed-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
    Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
    Reviewed-by: Fabio Estevam <festevam@gmail.com>
    Link: https://lore.kernel.org/r/20190719100524.23300-2-oleksandr.suvorov@toradex.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 42b888f63333091a0d12423b46fa8e0a78ec9686
Author: Dmitry Osipenko <digetx@gmail.com>
Date:   Thu May 2 02:38:00 2019 +0300

    PM / devfreq: tegra: Fix kHz to Hz conversion
    
    commit 62bacb06b9f08965c4ef10e17875450490c948c0 upstream.
    
    The kHz to Hz is incorrectly converted in a few places in the code,
    this results in a wrong frequency being calculated because devfreq core
    uses OPP frequencies that are given in Hz to clamp the rate, while
    tegra-devfreq gives to the core value in kHz and then it also expects to
    receive value in kHz from the core. In a result memory freq is always set
    to a value which is close to ULONG_MAX because of the bug. Hence the EMC
    frequency is always capped to the maximum and the driver doesn't do
    anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC
    frequency scaling works properly now.
    
    Cc: <stable@vger.kernel.org> # 4.14+
    Tested-by: Steev Klimaszewski <steev@kali.org>
    Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
    Acked-by: Thierry Reding <treding@nvidia.com>
    Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9f0f39c92e4f50189155dfb13bb5524372e40eba
Author: Mike Christie <mchristi@redhat.com>
Date:   Sun Aug 4 14:10:06 2019 -0500

    nbd: fix max number of supported devs
    
    commit e9e006f5fcf2bab59149cb38a48a4817c1b538b4 upstream.
    
    This fixes a bug added in 4.10 with commit:
    
    commit 9561a7ade0c205bc2ee035a2ac880478dcc1a024
    Author: Josef Bacik <jbacik@fb.com>
    Date:   Tue Nov 22 14:04:40 2016 -0500
    
        nbd: add multi-connection support
    
    that limited the number of devices to 256. Before the patch we could
    create 1000s of devices, but the patch switched us from using our
    own thread to using a work queue which has a default limit of 256
    active works.
    
    The problem is that our recv_work function sits in a loop until
    disconnection but only handles IO for one connection. The work is
    started when the connection is started/restarted, but if we end up
    creating 257 or more connections, the queue_work call just queues
    connection257+'s recv_work and that waits for connection 1 - 256's
    recv_work to be disconnected and that work instance completing.
    
    Instead of reverting back to kthreads, this has us allocate a
    workqueue_struct per device, so we can block in the work.
    
    Cc: stable@vger.kernel.org
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Mike Christie <mchristi@redhat.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit eff3a54aae6815583d139dd22417e3d706ef6490
Author: Jack Wang <jinpu.wang@cloud.ionos.com>
Date:   Mon Oct 7 14:36:53 2019 +0200

    KVM: nVMX: handle page fault in vmread fix
    
    During backport f7eea636c3d5 ("KVM: nVMX: handle page fault in vmread"),
    there was a mistake the exception reference should be passed to function
    kvm_write_guest_virt_system, instead of NULL, other wise, we will get
    NULL pointer deref, eg
    
    kvm-unit-test triggered a NULL pointer deref below:
    [  948.518437] kvm [24114]: vcpu0, guest rIP: 0x407ef9 kvm_set_msr_common: MSR_IA32_DEBUGCTLMSR 0x3, nop
    [  949.106464] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    [  949.106707] PGD 0 P4D 0
    [  949.106872] Oops: 0002 [#1] SMP
    [  949.107038] CPU: 2 PID: 24126 Comm: qemu-2.7 Not tainted 4.19.77-pserver #4.19.77-1+feature+daily+update+20191005.1625+a4168bb~deb9
    [  949.107283] Hardware name: Dell Inc. Precision Tower 3620/09WH54, BIOS 2.7.3 01/31/2018
    [  949.107549] RIP: 0010:kvm_write_guest_virt_system+0x12/0x40 [kvm]
    [  949.107719] Code: c0 5d 41 5c 41 5d 41 5e 83 f8 03 41 0f 94 c0 41 c1 e0 02 e9 b0 ed ff ff 0f 1f 44 00 00 48 89 f0 c6 87 59 56 00 00 01 48 89 d6 <49> c7 00 00 00 00 00 89 ca 49 c7 40 08 00 00 00 00 49 c7 40 10 00
    [  949.108044] RSP: 0018:ffffb31b0a953cb0 EFLAGS: 00010202
    [  949.108216] RAX: 000000000046b4d8 RBX: ffff9e9f415b0000 RCX: 0000000000000008
    [  949.108389] RDX: ffffb31b0a953cc0 RSI: ffffb31b0a953cc0 RDI: ffff9e9f415b0000
    [  949.108562] RBP: 00000000d2e14928 R08: 0000000000000000 R09: 0000000000000000
    [  949.108733] R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffffffffc8
    [  949.108907] R13: 0000000000000002 R14: ffff9e9f4f26f2e8 R15: 0000000000000000
    [  949.109079] FS:  00007eff8694c700(0000) GS:ffff9e9f51a80000(0000) knlGS:0000000031415928
    [  949.109318] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  949.109495] CR2: 0000000000000000 CR3: 00000003be53b002 CR4: 00000000003626e0
    [  949.109671] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [  949.109845] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [  949.110017] Call Trace:
    [  949.110186]  handle_vmread+0x22b/0x2f0 [kvm_intel]
    [  949.110356]  ? vmexit_fill_RSB+0xc/0x30 [kvm_intel]
    [  949.110549]  kvm_arch_vcpu_ioctl_run+0xa98/0x1b30 [kvm]
    [  949.110725]  ? kvm_vcpu_ioctl+0x388/0x5d0 [kvm]
    [  949.110901]  kvm_vcpu_ioctl+0x388/0x5d0 [kvm]
    [  949.111072]  do_vfs_ioctl+0xa2/0x620
    
    Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
    Acked-by: Paolo Bonzini <pbonzini@redhat.com>

commit 21874027e1deba5a5b8edaa6de8e49a4a2dd99b3
Author: Wanpeng Li <wanpengli@tencent.com>
Date:   Wed Sep 18 17:50:10 2019 +0800

    KVM: X86: Fix userspace set invalid CR4
    
    commit 3ca94192278ca8de169d78c085396c424be123b3 upstream.
    
    Reported by syzkaller:
    
            WARNING: CPU: 0 PID: 6544 at /home/kernel/data/kvm/arch/x86/kvm//vmx/vmx.c:4689 handle_desc+0x37/0x40 [kvm_intel]
            CPU: 0 PID: 6544 Comm: a.out Tainted: G           OE     5.3.0-rc4+ #4
            RIP: 0010:handle_desc+0x37/0x40 [kvm_intel]
            Call Trace:
             vmx_handle_exit+0xbe/0x6b0 [kvm_intel]
             vcpu_enter_guest+0x4dc/0x18d0 [kvm]
             kvm_arch_vcpu_ioctl_run+0x407/0x660 [kvm]
             kvm_vcpu_ioctl+0x3ad/0x690 [kvm]
             do_vfs_ioctl+0xa2/0x690
             ksys_ioctl+0x6d/0x80
             __x64_sys_ioctl+0x1a/0x20
             do_syscall_64+0x74/0x720
             entry_SYSCALL_64_after_hwframe+0x49/0xbe
    
    When CR4.UMIP is set, guest should have UMIP cpuid flag. Current
    kvm set_sregs function doesn't have such check when userspace inputs
    sregs values. SECONDARY_EXEC_DESC is enabled on writes to CR4.UMIP
    in vmx_set_cr4 though guest doesn't have UMIP cpuid flag. The testcast
    triggers handle_desc warning when executing ltr instruction since
    guest architectural CR4 doesn't set UMIP. This patch fixes it by
    adding valid CR4 and CPUID combination checking in __set_sregs.
    
    syzkaller source: https://syzkaller.appspot.com/x/repro.c?x=138efb99600000
    
    Reported-by: syzbot+0f1819555fbdce992df9@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
    Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 30fbe0d380aa038b0a629bc9c7f1961d340cd83b
Author: Paul Mackerras <paulus@ozlabs.org>
Date:   Tue Aug 27 11:35:40 2019 +1000

    KVM: PPC: Book3S HV: Don't lose pending doorbell request on migration on P9
    
    commit ff42df49e75f053a8a6b4c2533100cdcc23afe69 upstream.
    
    On POWER9, when userspace reads the value of the DPDES register on a
    vCPU, it is possible for 0 to be returned although there is a doorbell
    interrupt pending for the vCPU.  This can lead to a doorbell interrupt
    being lost across migration.  If the guest kernel uses doorbell
    interrupts for IPIs, then it could malfunction because of the lost
    interrupt.
    
    This happens because a newly-generated doorbell interrupt is signalled
    by setting vcpu->arch.doorbell_request to 1; the DPDES value in
    vcpu->arch.vcore->dpdes is not updated, because it can only be updated
    when holding the vcpu mutex, in order to avoid races.
    
    To fix this, we OR in vcpu->arch.doorbell_request when reading the
    DPDES value.
    
    Cc: stable@vger.kernel.org # v4.13+
    Fixes: 579006944e0d ("KVM: PPC: Book3S HV: Virtualize doorbell facility on POWER9")
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4faa7f05af75f6c74c8ce25259e0d034f87526db
Author: Paul Mackerras <paulus@ozlabs.org>
Date:   Tue Aug 27 11:31:37 2019 +1000

    KVM: PPC: Book3S HV: Check for MMU ready on piggybacked virtual cores
    
    commit d28eafc5a64045c78136162af9d4ba42f8230080 upstream.
    
    When we are running multiple vcores on the same physical core, they
    could be from different VMs and so it is possible that one of the
    VMs could have its arch.mmu_ready flag cleared (for example by a
    concurrent HPT resize) when we go to run it on a physical core.
    We currently check the arch.mmu_ready flag for the primary vcore
    but not the flags for the other vcores that will be run alongside
    it.  This adds that check, and also a check when we select the
    secondary vcores from the preempted vcores list.
    
    Cc: stable@vger.kernel.org # v4.14+
    Fixes: 38c53af85306 ("KVM: PPC: Book3S HV: Fix exclusion between HPT resizing and other HPT updates")
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 577a5119d7af31f77f5c427be9867431df070d0d
Author: Paul Mackerras <paulus@ozlabs.org>
Date:   Tue Aug 13 20:03:49 2019 +1000

    KVM: PPC: Book3S HV: Fix race in re-enabling XIVE escalation interrupts
    
    commit 959c5d5134786b4988b6fdd08e444aa67d1667ed upstream.
    
    Escalation interrupts are interrupts sent to the host by the XIVE
    hardware when it has an interrupt to deliver to a guest VCPU but that
    VCPU is not running anywhere in the system.  Hence we disable the
    escalation interrupt for the VCPU being run when we enter the guest
    and re-enable it when the guest does an H_CEDE hypercall indicating
    it is idle.
    
    It is possible that an escalation interrupt gets generated just as we
    are entering the guest.  In that case the escalation interrupt may be
    using a queue entry in one of the interrupt queues, and that queue
    entry may not have been processed when the guest exits with an H_CEDE.
    The existing entry code detects this situation and does not clear the
    vcpu->arch.xive_esc_on flag as an indication that there is a pending
    queue entry (if the queue entry gets processed, xive_esc_irq() will
    clear the flag).  There is a comment in the code saying that if the
    flag is still set on H_CEDE, we have to abort the cede rather than
    re-enabling the escalation interrupt, lest we end up with two
    occurrences of the escalation interrupt in the interrupt queue.
    
    However, the exit code doesn't do that; it aborts the cede in the sense
    that vcpu->arch.ceded gets cleared, but it still enables the escalation
    interrupt by setting the source's PQ bits to 00.  Instead we need to
    set the PQ bits to 10, indicating that an interrupt has been triggered.
    We also need to avoid setting vcpu->arch.xive_esc_on in this case
    (i.e. vcpu->arch.xive_esc_on seen to be set on H_CEDE) because
    xive_esc_irq() will run at some point and clear it, and if we race with
    that we may end up with an incorrect result (i.e. xive_esc_on set when
    the escalation interrupt has just been handled).
    
    It is extremely unlikely that having two queue entries would cause
    observable problems; theoretically it could cause queue overflow, but
    the CPU would have to have thousands of interrupts targetted to it for
    that to be possible.  However, this fix will also make it possible to
    determine accurately whether there is an unhandled escalation
    interrupt in the queue, which will be needed by the following patch.
    
    Fixes: 9b9b13a6d153 ("KVM: PPC: Book3S HV: Keep XIVE escalation interrupt masked unless ceded")
    Cc: stable@vger.kernel.org # v4.16+
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20190813100349.GD9567@blackberry
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 46cb14a570889a693c4ca24c0a6d4be4dc18f8f4
Author: Vasily Gorbik <gor@linux.ibm.com>
Date:   Thu Sep 19 15:55:17 2019 +0200

    s390/cio: exclude subchannels with no parent from pseudo check
    
    commit ab5758848039de9a4b249d46e4ab591197eebaf2 upstream.
    
    ccw console is created early in start_kernel and used before css is
    initialized or ccw console subchannel is registered. Until then console
    subchannel does not have a parent. For that reason assume subchannels
    with no parent are not pseudo subchannels. This fixes the following
    kasan finding:
    
    BUG: KASAN: global-out-of-bounds in sch_is_pseudo_sch+0x8e/0x98
    Read of size 8 at addr 00000000000005e8 by task swapper/0/0
    
    CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc8-07370-g6ac43dd12538 #2
    Hardware name: IBM 2964 NC9 702 (z/VM 6.4.0)
    Call Trace:
    ([<000000000012cd76>] show_stack+0x14e/0x1e0)
     [<0000000001f7fb44>] dump_stack+0x1a4/0x1f8
     [<00000000007d7afc>] print_address_description+0x64/0x3c8
     [<00000000007d75f6>] __kasan_report+0x14e/0x180
     [<00000000018a2986>] sch_is_pseudo_sch+0x8e/0x98
     [<000000000189b950>] cio_enable_subchannel+0x1d0/0x510
     [<00000000018cac7c>] ccw_device_recognition+0x12c/0x188
     [<0000000002ceb1a8>] ccw_device_enable_console+0x138/0x340
     [<0000000002cf1cbe>] con3215_init+0x25e/0x300
     [<0000000002c8770a>] console_init+0x68a/0x9b8
     [<0000000002c6a3d6>] start_kernel+0x4fe/0x728
     [<0000000000100070>] startup_continue+0x70/0xd0
    
    Cc: stable@vger.kernel.org
    Reviewed-by: Sebastian Ott <sebott@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9aa823b3c0a6997092c5e0f7efc63d27479afb42
Author: Vasily Gorbik <gor@linux.ibm.com>
Date:   Tue Sep 17 22:59:03 2019 +0200

    s390/topology: avoid firing events before kobjs are created
    
    commit f3122a79a1b0a113d3aea748e0ec26f2cb2889de upstream.
    
    arch_update_cpu_topology is first called from:
    kernel_init_freeable->sched_init_smp->sched_init_domains
    
    even before cpus has been registered in:
    kernel_init_freeable->do_one_initcall->s390_smp_init
    
    Do not trigger kobject_uevent change events until cpu devices are
    actually created. Fixes the following kasan findings:
    
    BUG: KASAN: global-out-of-bounds in kobject_uevent_env+0xb40/0xee0
    Read of size 8 at addr 0000000000000020 by task swapper/0/1
    
    BUG: KASAN: global-out-of-bounds in kobject_uevent_env+0xb36/0xee0
    Read of size 8 at addr 0000000000000018 by task swapper/0/1
    
    CPU: 0 PID: 1 Comm: swapper/0 Tainted: G    B
    Hardware name: IBM 3906 M04 704 (LPAR)
    Call Trace:
    ([<0000000143c6db7e>] show_stack+0x14e/0x1a8)
     [<0000000145956498>] dump_stack+0x1d0/0x218
     [<000000014429fb4c>] print_address_description+0x64/0x380
     [<000000014429f630>] __kasan_report+0x138/0x168
     [<0000000145960b96>] kobject_uevent_env+0xb36/0xee0
     [<0000000143c7c47c>] arch_update_cpu_topology+0x104/0x108
     [<0000000143df9e22>] sched_init_domains+0x62/0xe8
     [<000000014644c94a>] sched_init_smp+0x3a/0xc0
     [<0000000146433a20>] kernel_init_freeable+0x558/0x958
     [<000000014599002a>] kernel_init+0x22/0x160
     [<00000001459a71d4>] ret_from_fork+0x28/0x30
     [<00000001459a71dc>] kernel_thread_starter+0x0/0x10
    
    Cc: stable@vger.kernel.org
    Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ddfef75f877bf74271eb8f183d270989a0756b3b
Author: Thomas Huth <thuth@redhat.com>
Date:   Thu Aug 29 14:25:17 2019 +0200

    KVM: s390: Test for bad access register and size at the start of S390_MEM_OP
    
    commit a13b03bbb4575b350b46090af4dfd30e735aaed1 upstream.
    
    If the KVM_S390_MEM_OP ioctl is called with an access register >= 16,
    then there is certainly a bug in the calling userspace application.
    We check for wrong access registers, but only if the vCPU was already
    in the access register mode before (i.e. the SIE block has recorded
    it). The check is also buried somewhere deep in the calling chain (in
    the function ar_translation()), so this is somewhat hard to find.
    
    It's better to always report an error to the userspace in case this
    field is set wrong, and it's safer in the KVM code if we block wrong
    values here early instead of relying on a check somewhere deep down
    the calling chain, so let's add another check to kvm_s390_guest_mem_op()
    directly.
    
    We also should check that the "size" is non-zero here (thanks to Janosch
    Frank for the hint!). If we do not check the size, we could call vmalloc()
    with this 0 value, and this will cause a kernel warning.
    
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    Link: https://lkml.kernel.org/r/20190829122517.31042-1-thuth@redhat.com
    Reviewed-by: Cornelia Huck <cohuck@redhat.com>
    Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
    Reviewed-by: David Hildenbrand <david@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8b41a30f91dbc4dfade46e4cc161cb49561f606f
Author: Vasily Gorbik <gor@linux.ibm.com>
Date:   Tue Aug 13 20:11:08 2019 +0200

    s390/process: avoid potential reading of freed stack
    
    commit 8769f610fe6d473e5e8e221709c3ac402037da6c upstream.
    
    With THREAD_INFO_IN_TASK (which is selected on s390) task's stack usage
    is refcounted and should always be protected by get/put when touching
    other task's stack to avoid race conditions with task's destruction code.
    
    Fixes: d5c352cdd022 ("s390: move thread_info into task_struct")
    Cc: stable@vger.kernel.org # v4.10+
    Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>