commit 2272cdd5d5bf42e3721430ae6076656a42043c34
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue May 22 16:58:04 2018 +0200

    Linux 4.9.102

commit 3394ef1a7efc08e3c185ac2446f06284847ccb37
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed May 16 23:18:09 2018 -0400

    x86/bugs: Rename SSBD_NO to SSB_NO
    
    commit 240da953fcc6a9008c92fae5b1f727ee5ed167ab upstream
    
    The "336996 Speculative Execution Side Channel Mitigations" from
    May defines this as SSB_NO, hence lets sync-up.
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b965592a07a248ef254d9d421bd34a6b548db21f
Author: Tom Lendacky <thomas.lendacky@amd.com>
Date:   Thu May 10 22:06:39 2018 +0200

    KVM: SVM: Implement VIRT_SPEC_CTRL support for SSBD
    
    commit bc226f07dcd3c9ef0b7f6236fe356ea4a9cb4769 upstream
    
    Expose the new virtualized architectural mechanism, VIRT_SSBD, for using
    speculative store bypass disable (SSBD) under SVM.  This will allow guests
    to use SSBD on hardware that uses non-architectural mechanisms for enabling
    SSBD.
    
    [ tglx: Folded the migration fixup from Paolo Bonzini ]
    
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b0ef8c72b3d70505ba7fd72af6b1e3fc9b3ae9bc
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 10 20:42:48 2018 +0200

    x86/speculation, KVM: Implement support for VIRT_SPEC_CTRL/LS_CFG
    
    commit 47c61b3955cf712cadfc25635bf9bc174af030ea upstream
    
    Add the necessary logic for supporting the emulated VIRT_SPEC_CTRL MSR to
    x86_virt_spec_ctrl().  If either X86_FEATURE_LS_CFG_SSBD or
    X86_FEATURE_VIRT_SPEC_CTRL is set then use the new guest_virt_spec_ctrl
    argument to check whether the state must be modified on the host. The
    update reuses speculative_store_bypass_update() so the ZEN-specific sibling
    coordination can be reused.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0ec827f974e198c609c2f258a5a1f11f9af48bb2
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sat May 12 20:10:00 2018 +0200

    x86/bugs: Rework spec_ctrl base and mask logic
    
    commit be6fcb5478e95bb1c91f489121238deb3abca46a upstream
    
    x86_spec_ctrL_mask is intended to mask out bits from a MSR_SPEC_CTRL value
    which are not to be modified. However the implementation is not really used
    and the bitmask was inverted to make a check easier, which was removed in
    "x86/bugs: Remove x86_spec_ctrl_set()"
    
    Aside of that it is missing the STIBP bit if it is supported by the
    platform, so if the mask would be used in x86_virt_spec_ctrl() then it
    would prevent a guest from setting STIBP.
    
    Add the STIBP bit if supported and use the mask in x86_virt_spec_ctrl() to
    sanitize the value which is supplied by the guest.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ec90464d96c50f90bfe1bde6dea748a6c962313c
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sat May 12 20:53:14 2018 +0200

    x86/bugs: Remove x86_spec_ctrl_set()
    
    commit 4b59bdb569453a60b752b274ca61f009e37f4dae upstream
    
    x86_spec_ctrl_set() is only used in bugs.c and the extra mask checks there
    provide no real value as both call sites can just write x86_spec_ctrl_base
    to MSR_SPEC_CTRL. x86_spec_ctrl_base is valid and does not need any extra
    masking or checking.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 599288ec9e20d9772e6e8a27aeae021f018c7336
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sat May 12 20:49:16 2018 +0200

    x86/bugs: Expose x86_spec_ctrl_base directly
    
    commit fa8ac4988249c38476f6ad678a4848a736373403 upstream
    
    x86_spec_ctrl_base is the system wide default value for the SPEC_CTRL MSR.
    x86_spec_ctrl_get_default() returns x86_spec_ctrl_base and was intended to
    prevent modification to that variable. Though the variable is read only
    after init and globaly visible already.
    
    Remove the function and export the variable instead.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea99935b633bd4766a679e51b173197c750fb00b
Author: Borislav Petkov <bp@suse.de>
Date:   Sat May 12 00:14:51 2018 +0200

    x86/bugs: Unify x86_spec_ctrl_{set_guest,restore_host}
    
    commit cc69b34989210f067b2c51d5539b5f96ebcc3a01 upstream
    
    Function bodies are very similar and are going to grow more almost
    identical code. Add a bool arg to determine whether SPEC_CTRL is being set
    for the guest or restored to the host.
    
    No functional changes.
    
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b7b84401576d3858e9573d69d8287e182444f8e9
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 10 20:31:44 2018 +0200

    x86/speculation: Rework speculative_store_bypass_update()
    
    commit 0270be3e34efb05a88bc4c422572ece038ef3608 upstream
    
    The upcoming support for the virtual SPEC_CTRL MSR on AMD needs to reuse
    speculative_store_bypass_update() to avoid code duplication. Add an
    argument for supplying a thread info (TIF) value and create a wrapper
    speculative_store_bypass_update_current() which is used at the existing
    call site.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7c0b2dc44956533c5aac95f07575feef7b63344c
Author: Tom Lendacky <thomas.lendacky@amd.com>
Date:   Thu May 17 17:09:18 2018 +0200

    x86/speculation: Add virtualized speculative store bypass disable support
    
    commit 11fb0683493b2da112cd64c9dada221b52463bf7 upstream
    
    Some AMD processors only support a non-architectural means of enabling
    speculative store bypass disable (SSBD).  To allow a simplified view of
    this to a guest, an architectural definition has been created through a new
    CPUID bit, 0x80000008_EBX[25], and a new MSR, 0xc001011f.  With this, a
    hypervisor can virtualize the existence of this definition and provide an
    architectural method for using SSBD to a guest.
    
    Add the new CPUID feature, the new MSR and update the existing SSBD
    support to use this MSR when present.
    
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1189cbf52ad35cfd04a715016200ea81dd4c708f
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed May 9 23:01:01 2018 +0200

    x86/bugs, KVM: Extend speculation control for VIRT_SPEC_CTRL
    
    commit ccbcd2674472a978b48c91c1fbfb66c0ff959f24 upstream
    
    AMD is proposing a VIRT_SPEC_CTRL MSR to handle the Speculative Store
    Bypass Disable via MSR_AMD64_LS_CFG so that guests do not have to care
    about the bit position of the SSBD bit and thus facilitate migration.
    Also, the sibling coordination on Family 17H CPUs can only be done on
    the host.
    
    Extend x86_spec_ctrl_set_guest() and x86_spec_ctrl_restore_host() with an
    extra argument for the VIRT_SPEC_CTRL MSR.
    
    Hand in 0 from VMX and in SVM add a new virt_spec_ctrl member to the CPU
    data structure which is going to be used in later patches for the actual
    implementation.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d0cb78f5e4214db86b12a9448d8ccaa005f43cb9
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed May 9 21:53:09 2018 +0200

    x86/speculation: Handle HT correctly on AMD
    
    commit 1f50ddb4f4189243c05926b842dc1a0332195f31 upstream
    
    The AMD64_LS_CFG MSR is a per core MSR on Family 17H CPUs. That means when
    hyperthreading is enabled the SSBD bit toggle needs to take both cores into
    account. Otherwise the following situation can happen:
    
    CPU0            CPU1
    
    disable SSB
                    disable SSB
                    enable  SSB <- Enables it for the Core, i.e. for CPU0 as well
    
    So after the SSB enable on CPU1 the task on CPU0 runs with SSB enabled
    again.
    
    On Intel the SSBD control is per core as well, but the synchronization
    logic is implemented behind the per thread SPEC_CTRL MSR. It works like
    this:
    
      CORE_SPEC_CTRL = THREAD0_SPEC_CTRL | THREAD1_SPEC_CTRL
    
    i.e. if one of the threads enables a mitigation then this affects both and
    the mitigation is only disabled in the core when both threads disabled it.
    
    Add the necessary synchronization logic for AMD family 17H. Unfortunately
    that requires a spinlock to serialize the access to the MSR, but the locks
    are only shared between siblings.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 53c434e735fffbf8715a1778ce44387131e0b080
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 10 16:26:00 2018 +0200

    x86/cpufeatures: Add FEATURE_ZEN
    
    commit d1035d971829dcf80e8686ccde26f94b0a069472 upstream
    
    Add a ZEN feature bit so family-dependent static_cpu_has() optimizations
    can be built for ZEN.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5a63725cd18fcee2af6ec46ccb856b64ad3077b4
Author: Borislav Petkov <bp@suse.de>
Date:   Thu Sep 7 19:08:21 2017 +0200

    x86/cpu/AMD: Fix erratum 1076 (CPB bit)
    
    commit f7f3dc00f61261cdc9ccd8b886f21bc4dffd6fd9 upstream
    
    CPUID Fn8000_0007_EDX[CPB] is wrongly 0 on models up to B1. But they do
    support CPB (AMD's Core Performance Boosting cpufreq CPU feature), so fix that.
    
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sherry Hurwitz <sherry.hurwitz@amd.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/20170907170821.16021-1-bp@alien8.de
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f69e91f2c4ce59deb66bd30150e5153c08873ae9
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 10 20:21:36 2018 +0200

    x86/cpufeatures: Disentangle SSBD enumeration
    
    commit 52817587e706686fcdb27f14c1b000c92f266c96 upstream
    
    The SSBD enumeration is similarly to the other bits magically shared
    between Intel and AMD though the mechanisms are different.
    
    Make X86_FEATURE_SSBD synthetic and set it depending on the vendor specific
    features or family dependent setup.
    
    Change the Intel bit to X86_FEATURE_SPEC_CTRL_SSBD to denote that SSBD is
    controlled via MSR_SPEC_CTRL and fix up the usage sites.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a7c343228e5c32802431e6cc5b855ae61eb4db72
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 10 19:13:18 2018 +0200

    x86/cpufeatures: Disentangle MSR_SPEC_CTRL enumeration from IBRS
    
    commit 7eb8956a7fec3c1f0abc2a5517dada99ccc8a961 upstream
    
    The availability of the SPEC_CTRL MSR is enumerated by a CPUID bit on
    Intel and implied by IBRS or STIBP support on AMD. That's just confusing
    and in case an AMD CPU has IBRS not supported because the underlying
    problem has been fixed but has another bit valid in the SPEC_CTRL MSR,
    the thing falls apart.
    
    Add a synthetic feature bit X86_FEATURE_MSR_SPEC_CTRL to denote the
    availability on both Intel and AMD.
    
    While at it replace the boot_cpu_has() checks with static_cpu_has() where
    possible. This prevents late microcode loading from exposing SPEC_CTRL, but
    late loading is already very limited as it does not reevaluate the
    mitigation options and other bits and pieces. Having static_cpu_has() is
    the simplest and least fragile solution.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4a58908fa1476c600548f82effc75bcfa890454a
Author: Borislav Petkov <bp@suse.de>
Date:   Wed May 2 18:15:14 2018 +0200

    x86/speculation: Use synthetic bits for IBRS/IBPB/STIBP
    
    commit e7c587da125291db39ddf1f49b18e5970adbac17 upstream
    
    Intel and AMD have different CPUID bits hence for those use synthetic bits
    which get set on the respective vendor's in init_speculation_control(). So
    that debacles like what the commit message of
    
      c65732e4f721 ("x86/cpu: Restore CPUID_8000_0008_EBX reload")
    
    talks about don't happen anymore.
    
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Tested-by: Jörg Otte <jrg.otte@gmail.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Link: https://lkml.kernel.org/r/20180504161815.GG9257@pd.tnic
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 69e9b0b1e04001a743927489bb8b9a10344810d8
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Fri May 11 15:21:01 2018 +0200

    KVM: SVM: Move spec control call after restore of GS
    
    commit 15e6c22fd8e5a42c5ed6d487b7c9fe44c2517765 upstream
    
    svm_vcpu_run() invokes x86_spec_ctrl_restore_host() after VMEXIT, but
    before the host GS is restored. x86_spec_ctrl_restore_host() uses 'current'
    to determine the host SSBD state of the thread. 'current' is GS based, but
    host GS is not yet restored and the access causes a triple fault.
    
    Move the call after the host GS restore.
    
    Fixes: 885f82bfbc6f x86/process: Allow runtime control of Speculative Store Bypass
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Acked-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3a684641619ff0e06b8d4cb8c2ffbef304c9bdb1
Author: Jim Mattson <jmattson@google.com>
Date:   Sun May 13 17:33:57 2018 -0400

    x86/cpu: Make alternative_msr_write work for 32-bit code
    
    commit 5f2b745f5e1304f438f9b2cd03ebc8120b6e0d3b upstream
    
    Cast val and (val >> 32) to (u32), so that they fit in a
    general-purpose register in both 32-bit and 64-bit code.
    
    [ tglx: Made it u32 instead of uintptr_t ]
    
    Fixes: c65732e4f721 ("x86/cpu: Restore CPUID_8000_0008_EBX reload")
    Signed-off-by: Jim Mattson <jmattson@google.com>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6fdd277a9326c5ef3fe94999c9c319ad64333fdd
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Fri May 11 16:50:35 2018 -0400

    x86/bugs: Fix the parameters alignment and missing void
    
    commit ffed645e3be0e32f8e9ab068d257aee8d0fe8eec upstream
    
    Fixes: 7bb4d366c ("x86/bugs: Make cpu_show_common() static")
    Fixes: 24f7fc83b ("x86/bugs: Provide boot parameters for the spec_store_bypass_disable mitigation")
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dbb264a253c8b07259d55fb3373b783fcb641b04
Author: Jiri Kosina <jkosina@suse.cz>
Date:   Thu May 10 22:47:32 2018 +0200

    x86/bugs: Make cpu_show_common() static
    
    commit 7bb4d366cba992904bffa4820d24e70a3de93e76 upstream
    
    cpu_show_common() is not used outside of arch/x86/kernel/cpu/bugs.c, so
    make it static.
    
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit eb7b5624be3e6249a880310be486245db15a5f5c
Author: Jiri Kosina <jkosina@suse.cz>
Date:   Thu May 10 22:47:18 2018 +0200

    x86/bugs: Fix __ssb_select_mitigation() return type
    
    commit d66d8ff3d21667b41eddbe86b35ab411e40d8c5f upstream
    
    __ssb_select_mitigation() returns one of the members of enum ssb_mitigation,
    not ssb_mitigation_cmd; fix the prototype to reflect that.
    
    Fixes: 24f7fc83b9204 ("x86/bugs: Provide boot parameters for the spec_store_bypass_disable mitigation")
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f79f0efe8e1816063f83926c946026d83b9b287f
Author: Borislav Petkov <bp@suse.de>
Date:   Tue May 8 15:43:45 2018 +0200

    Documentation/spec_ctrl: Do some minor cleanups
    
    commit dd0792699c4058e63c0715d9a7c2d40226fcdddc upstream
    
    Fix some typos, improve formulations, end sentences with a fullstop.
    
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f8cd89f5e05d49422315e60ec2db9fcb66d25aca
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed May 9 21:41:38 2018 +0200

    proc: Use underscores for SSBD in 'status'
    
    commit e96f46ee8587607a828f783daa6eb5b44d25004d upstream
    
    The style for the 'status' file is CamelCase or this. _.
    
    Fixes: fae1fa0fc ("proc: Provide details on speculation flaw mitigations")
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bf3da841edae882de545d2d19b1fae205cab8d98
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed May 9 21:41:38 2018 +0200

    x86/bugs: Rename _RDS to _SSBD
    
    commit 9f65fb29374ee37856dbad847b4e121aab72b510 upstream
    
    Intel collateral will reference the SSB mitigation bit in IA32_SPEC_CTL[2]
    as SSBD (Speculative Store Bypass Disable).
    
    Hence changing it.
    
    It is unclear yet what the MSR_IA32_ARCH_CAPABILITIES (0x10a) Bit(4) name
    is going to be. Following the rename it would be SSBD_NO but that rolls out
    to Speculative Store Bypass Disable No.
    
    Also fixed the missing space in X86_FEATURE_AMD_SSBD.
    
    [ tglx: Fixup x86_amd_rds_enable() and rds_tif_to_amd_ls_cfg() as well ]
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 05a85a396f3989e9ac953785d9dccfc7cd0110f2
Author: Kees Cook <keescook@chromium.org>
Date:   Thu May 3 14:37:54 2018 -0700

    x86/speculation: Make "seccomp" the default mode for Speculative Store Bypass
    
    commit f21b53b20c754021935ea43364dbf53778eeba32 upstream
    
    Unless explicitly opted out of, anything running under seccomp will have
    SSB mitigations enabled. Choosing the "prctl" mode will disable this.
    
    [ tglx: Adjusted it to the new arch_seccomp_spec_mitigate() mechanism ]
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 094c2767c4f02c36eabc27309d78b04f4a216e88
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Fri May 4 15:12:06 2018 +0200

    seccomp: Move speculation migitation control to arch code
    
    commit 8bf37d8c067bb7eb8e7c381bdadf9bd89182b6bc upstream
    
    The migitation control is simpler to implement in architecture code as it
    avoids the extra function call to check the mode. Aside of that having an
    explicit seccomp enabled mode in the architecture mitigations would require
    even more workarounds.
    
    Move it into architecture code and provide a weak function in the seccomp
    code. Remove the 'which' argument as this allows the architecture to decide
    which mitigations are relevant for seccomp.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab677c2addbb128f334c4906f27a0285a67d2180
Author: Kees Cook <keescook@chromium.org>
Date:   Thu May 3 14:56:12 2018 -0700

    seccomp: Add filter flag to opt-out of SSB mitigation
    
    commit 00a02d0c502a06d15e07b857f8ff921e3e402675 upstream
    
    If a seccomp user is not interested in Speculative Store Bypass mitigation
    by default, it can set the new SECCOMP_FILTER_FLAG_SPEC_ALLOW flag when
    adding filters.
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c71def81cd07e1bd74da468ae6abe1ce62e3157b
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Fri May 4 09:40:03 2018 +0200

    seccomp: Use PR_SPEC_FORCE_DISABLE
    
    commit b849a812f7eb92e96d1c8239b06581b2cfd8b275 upstream
    
    Use PR_SPEC_FORCE_DISABLE in seccomp() because seccomp does not allow to
    widen restrictions.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 036608d62a838aeb63cae0adaf8ac773cb53148c
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu May 3 22:09:15 2018 +0200

    prctl: Add force disable speculation
    
    commit 356e4bfff2c5489e016fdb925adbf12a1e3950ee upstream
    
    For certain use cases it is desired to enforce mitigations so they cannot
    be undone afterwards. That's important for loader stubs which want to
    prevent a child from disabling the mitigation again. Will also be used for
    seccomp(). The extra state preserving of the prctl state for SSB is a
    preparatory step for EBPF dymanic speculation control.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea055f7d43fb3a9d56e80d0116104555d6dde3f7
Author: Kees Cook <keescook@chromium.org>
Date:   Thu May 3 15:03:30 2018 -0700

    x86/bugs: Make boot modes __ro_after_init
    
    commit f9544b2b076ca90d887c5ae5d74fab4c21bb7c13 upstream
    
    There's no reason for these to be changed after boot.
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0a112f104548667f5618477ff0f2a54ee626addd
Author: Kees Cook <keescook@chromium.org>
Date:   Tue May 1 15:07:31 2018 -0700

    seccomp: Enable speculation flaw mitigations
    
    commit 5c3070890d06ff82eecb808d02d2ca39169533ef upstream
    
    When speculation flaw mitigations are opt-in (via prctl), using seccomp
    will automatically opt-in to these protections, since using seccomp
    indicates at least some level of sandboxing is desired.
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 51ef9af2a35bbc21334c801fd15cbfe01210760f
Author: Kees Cook <keescook@chromium.org>
Date:   Tue May 1 15:31:45 2018 -0700

    proc: Provide details on speculation flaw mitigations
    
    commit fae1fa0fc6cca8beee3ab8ed71d54f9a78fa3f64 upstream
    
    As done with seccomp and no_new_privs, also show speculation flaw
    mitigation state in /proc/$pid/status.
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4272f528da381673a8e7845c93daa88b8aa4f4e9
Author: Kees Cook <keescook@chromium.org>
Date:   Tue May 1 15:19:04 2018 -0700

    nospec: Allow getting/setting on non-current task
    
    commit 7bbf1373e228840bb0295a2ca26d548ef37f448e upstream
    
    Adjust arch_prctl_get/set_spec_ctrl() to operate on tasks other than
    current.
    
    This is needed both for /proc/$pid/status queries and for seccomp (since
    thread-syncing can trigger seccomp in non-current threads).
    
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a078e3e81964c31079627dd32c3ea714d5b1531e
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sun Apr 29 15:26:40 2018 +0200

    x86/speculation: Add prctl for Speculative Store Bypass mitigation
    
    commit a73ec77ee17ec556fe7f165d00314cb7c047b1ac upstream
    
    Add prctl based control for Speculative Store Bypass mitigation and make it
    the default mitigation for Intel and AMD.
    
    Andi Kleen provided the following rationale (slightly redacted):
    
     There are multiple levels of impact of Speculative Store Bypass:
    
     1) JITed sandbox.
        It cannot invoke system calls, but can do PRIME+PROBE and may have call
        interfaces to other code
    
     2) Native code process.
        No protection inside the process at this level.
    
     3) Kernel.
    
     4) Between processes.
    
     The prctl tries to protect against case (1) doing attacks.
    
     If the untrusted code can do random system calls then control is already
     lost in a much worse way. So there needs to be system call protection in
     some way (using a JIT not allowing them or seccomp). Or rather if the
     process can subvert its environment somehow to do the prctl it can already
     execute arbitrary code, which is much worse than SSB.
    
     To put it differently, the point of the prctl is to not allow JITed code
     to read data it shouldn't read from its JITed sandbox. If it already has
     escaped its sandbox then it can already read everything it wants in its
     address space, and do much worse.
    
     The ability to control Speculative Store Bypass allows to enable the
     protection selectively without affecting overall system performance.
    
    Based on an initial patch from Tim Chen. Completely rewritten.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 89c6e9b599c573802de1b2fff6a9ccd99c3c4e57
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sun Apr 29 15:21:42 2018 +0200

    x86/process: Allow runtime control of Speculative Store Bypass
    
    commit 885f82bfbc6fefb6664ea27965c3ab9ac4194b8c upstream
    
    The Speculative Store Bypass vulnerability can be mitigated with the
    Reduced Data Speculation (RDS) feature. To allow finer grained control of
    this eventually expensive mitigation a per task mitigation control is
    required.
    
    Add a new TIF_RDS flag and put it into the group of TIF flags which are
    evaluated for mismatch in switch_to(). If these bits differ in the previous
    and the next task, then the slow path function __switch_to_xtra() is
    invoked. Implement the TIF_RDS dependent mitigation control in the slow
    path.
    
    If the prctl for controlling Speculative Store Bypass is disabled or no
    task uses the prctl then there is no overhead in the switch_to() fast
    path.
    
    Update the KVM related speculation control functions to take TID_RDS into
    account as well.
    
    Based on a patch from Tim Chen. Completely rewritten.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5ed7788df973455378e987fe221bef0661fbe03a
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Feb 14 00:11:04 2017 -0800

    x86/process: Optimize TIF_NOTSC switch
    
    commit 5a920155e388ec22a22e0532fb695b9215c9b34d upstream
    
    Provide and use a toggle helper instead of doing it with a branch.
    
    x86_64: arch/x86/kernel/process.o
    text       data     bss     dec     hex
    3008       8577      16   11601    2d51 Before
    2976       8577      16   11569    2d31 After
    
    i386: arch/x86/kernel/process.o
    text       data     bss     dec     hex
    2925       8673       8   11606    2d56 Before
    2893       8673       8   11574    2d36 After
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Andy Lutomirski <luto@kernel.org>
    Link: http://lkml.kernel.org/r/20170214081104.9244-4-khuey@kylehuey.com
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 439f2ef884306976f22b42f709c1ccdf04278987
Author: Kyle Huey <me@kylehuey.com>
Date:   Tue Feb 14 00:11:03 2017 -0800

    x86/process: Correct and optimize TIF_BLOCKSTEP switch
    
    commit b9894a2f5bd18b1691cb6872c9afe32b148d0132 upstream
    
    The debug control MSR is "highly magical" as the blockstep bit can be
    cleared by hardware under not well documented circumstances.
    
    So a task switch relying on the bit set by the previous task (according to
    the previous tasks thread flags) can trip over this and not update the flag
    for the next task.
    
    To fix this its required to handle DEBUGCTLMSR_BTF when either the previous
    or the next or both tasks have the TIF_BLOCKSTEP flag set.
    
    While at it avoid branching within the TIF_BLOCKSTEP case and evaluating
    boot_cpu_data twice in kernels without CONFIG_X86_DEBUGCTLMSR.
    
    x86_64: arch/x86/kernel/process.o
    text    data    bss     dec      hex
    3024    8577    16      11617    2d61   Before
    3008    8577    16      11601    2d51   After
    
    i386: No change
    
    [ tglx: Made the shift value explicit, use a local variable to make the
    code readable and massaged changelog]
    
    Originally-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Kyle Huey <khuey@kylehuey.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Andy Lutomirski <luto@kernel.org>
    Link: http://lkml.kernel.org/r/20170214081104.9244-3-khuey@kylehuey.com
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fd01e82efa269b7e295533ec7b2d93aa8adf670a
Author: Kyle Huey <me@kylehuey.com>
Date:   Tue Feb 14 00:11:02 2017 -0800

    x86/process: Optimize TIF checks in __switch_to_xtra()
    
    commit af8b3cd3934ec60f4c2a420d19a9d416554f140b upstream
    
    Help the compiler to avoid reevaluating the thread flags for each checked
    bit by reordering the bit checks and providing an explicit xor for
    evaluation.
    
    With default defconfigs for each arch,
    
    x86_64: arch/x86/kernel/process.o
    text       data     bss     dec     hex
    3056       8577      16   11649    2d81 Before
    3024       8577      16   11617    2d61 After
    
    i386: arch/x86/kernel/process.o
    text       data     bss     dec     hex
    2957       8673       8   11638    2d76 Before
    2925       8673       8   11606    2d56 After
    
    Originally-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Kyle Huey <khuey@kylehuey.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Andy Lutomirski <luto@kernel.org>
    Link: http://lkml.kernel.org/r/20170214081104.9244-2-khuey@kylehuey.com
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    
    [dwmw2: backported to make TIF_RDS handling simpler.
            No deferred TR reload.]
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4812ffbbfcac35270b82292e84e8e7187088c8b8
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sun Apr 29 15:20:11 2018 +0200

    prctl: Add speculation control prctls
    
    commit b617cfc858161140d69cc0b5cc211996b557a1c7 upstream
    
    Add two new prctls to control aspects of speculation related vulnerabilites
    and their mitigations to provide finer grained control over performance
    impacting mitigations.
    
    PR_GET_SPECULATION_CTRL returns the state of the speculation misfeature
    which is selected with arg2 of prctl(2). The return value uses bit 0-2 with
    the following meaning:
    
    Bit  Define           Description
    0    PR_SPEC_PRCTL    Mitigation can be controlled per task by
                          PR_SET_SPECULATION_CTRL
    1    PR_SPEC_ENABLE   The speculation feature is enabled, mitigation is
                          disabled
    2    PR_SPEC_DISABLE  The speculation feature is disabled, mitigation is
                          enabled
    
    If all bits are 0 the CPU is not affected by the speculation misfeature.
    
    If PR_SPEC_PRCTL is set, then the per task control of the mitigation is
    available. If not set, prctl(PR_SET_SPECULATION_CTRL) for the speculation
    misfeature will fail.
    
    PR_SET_SPECULATION_CTRL allows to control the speculation misfeature, which
    is selected by arg2 of prctl(2) per task. arg3 is used to hand in the
    control value, i.e. either PR_SPEC_ENABLE or PR_SPEC_DISABLE.
    
    The common return values are:
    
    EINVAL  prctl is not implemented by the architecture or the unused prctl()
            arguments are not 0
    ENODEV  arg2 is selecting a not supported speculation misfeature
    
    PR_SET_SPECULATION_CTRL has these additional return values:
    
    ERANGE  arg3 is incorrect, i.e. it's not either PR_SPEC_ENABLE or PR_SPEC_DISABLE
    ENXIO   prctl control of the selected speculation misfeature is disabled
    
    The first supported controlable speculation misfeature is
    PR_SPEC_STORE_BYPASS. Add the define so this can be shared between
    architectures.
    
    Based on an initial patch from Tim Chen and mostly rewritten.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7a2d2358ba9b6de29be0a98c8290479df32604b6
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Sun Apr 29 15:01:37 2018 +0200

    x86/speculation: Create spec-ctrl.h to avoid include hell
    
    commit 28a2775217b17208811fa43a9e96bd1fdf417b86 upstream
    
    Having everything in nospec-branch.h creates a hell of dependencies when
    adding the prctl based switching mechanism. Move everything which is not
    required in nospec-branch.h to spec-ctrl.h and fix up the includes in the
    relevant files.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99318eca2c7ab3250b9614043b9ac6077ff2cb46
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:25 2018 -0400

    x86/KVM/VMX: Expose SPEC_CTRL Bit(2) to the guest
    
    commit da39556f66f5cfe8f9c989206974f1cb16ca5d7c upstream
    
    Expose the CPUID.7.EDX[31] bit to the guest, and also guard against various
    combinations of SPEC_CTRL MSR values.
    
    The handling of the MSR (to take into account the host value of SPEC_CTRL
    Bit(2)) is taken care of in patch:
    
      KVM/SVM/VMX/x86/spectre_v2: Support the combination of guest and host IBRS
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    
    [dwmw2: Handle 4.9 guest CPUID differences, rename
            guest_cpu_has_ibrs() → guest_cpu_has_spec_ctrl()]
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f854434b37bbf8953900226acd6139081f60d3da
Author: David Woodhouse <dwmw@amazon.co.uk>
Date:   Sun May 20 20:52:05 2018 +0100

    x86/bugs/AMD: Add support to disable RDS on Fam[15,16,17]h if requested
    
    commit 764f3c21588a059cd783c6ba0734d4db2d72822d upstream
    
    AMD does not need the Speculative Store Bypass mitigation to be enabled.
    
    The parameters for this are already available and can be done via MSR
    C001_1020. Each family uses a different bit in that MSR for this.
    
    [ tglx: Expose the bit mask via a variable and move the actual MSR fiddling
            into the bugs code as that's the right thing to do and also required
            to prepare for dynamic enable/disable ]
    
    Suggested-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 99b13116965f16b2e608e7796cd59198eee5bf06
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:23 2018 -0400

    x86/bugs: Whitelist allowed SPEC_CTRL MSR values
    
    commit 1115a859f33276fe8afb31c60cf9d8e657872558 upstream
    
    Intel and AMD SPEC_CTRL (0x48) MSR semantics may differ in the
    future (or in fact use different MSRs for the same functionality).
    
    As such a run-time mechanism is required to whitelist the appropriate MSR
    values.
    
    [ tglx: Made the variable __ro_after_init ]
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19e3a2bec95e966921689ae39117f9dbbaffd99b
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:22 2018 -0400

    x86/bugs/intel: Set proper CPU features and setup RDS
    
    commit 772439717dbf703b39990be58d8d4e3e4ad0598a upstream
    
    Intel CPUs expose methods to:
    
     - Detect whether RDS capability is available via CPUID.7.0.EDX[31],
    
     - The SPEC_CTRL MSR(0x48), bit 2 set to enable RDS.
    
     - MSR_IA32_ARCH_CAPABILITIES, Bit(4) no need to enable RRS.
    
    With that in mind if spec_store_bypass_disable=[auto,on] is selected set at
    boot-time the SPEC_CTRL MSR to enable RDS if the platform requires it.
    
    Note that this does not fix the KVM case where the SPEC_CTRL is exposed to
    guests which can muck with it, see patch titled :
     KVM/SVM/VMX/x86/spectre_v2: Support the combination of guest and host IBRS.
    
    And for the firmware (IBRS to be set), see patch titled:
     x86/spectre_v2: Read SPEC_CTRL MSR during boot and re-use reserved bits
    
    [ tglx: Distangled it from the intel implementation and kept the call order ]
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6f70a553666dd8c4fa370eaaa41380eec593229c
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:21 2018 -0400

    x86/bugs: Provide boot parameters for the spec_store_bypass_disable mitigation
    
    commit 24f7fc83b9204d20f878c57cb77d261ae825e033 upstream
    
    Contemporary high performance processors use a common industry-wide
    optimization known as "Speculative Store Bypass" in which loads from
    addresses to which a recent store has occurred may (speculatively) see an
    older value. Intel refers to this feature as "Memory Disambiguation" which
    is part of their "Smart Memory Access" capability.
    
    Memory Disambiguation can expose a cache side-channel attack against such
    speculatively read values. An attacker can create exploit code that allows
    them to read memory outside of a sandbox environment (for example,
    malicious JavaScript in a web page), or to perform more complex attacks
    against code running within the same privilege level, e.g. via the stack.
    
    As a first step to mitigate against such attacks, provide two boot command
    line control knobs:
    
     nospec_store_bypass_disable
     spec_store_bypass_disable=[off,auto,on]
    
    By default affected x86 processors will power on with Speculative
    Store Bypass enabled. Hence the provided kernel parameters are written
    from the point of view of whether to enable a mitigation or not.
    The parameters are as follows:
    
     - auto - Kernel detects whether your CPU model contains an implementation
              of Speculative Store Bypass and picks the most appropriate
              mitigation.
    
     - on   - disable Speculative Store Bypass
     - off  - enable Speculative Store Bypass
    
    [ tglx: Reordered the checks so that the whole evaluation is not done
            when the CPU does not support RDS ]
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a80714172abca6413d2d6505be64723ae73a903b
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Sat Apr 28 22:34:17 2018 +0200

    x86/cpufeatures: Add X86_FEATURE_RDS
    
    commit 0cc5fa00b0a88dad140b4e5c2cead9951ad36822 upstream
    
    Add the CPU feature bit CPUID.7.0.EDX[31] which indicates whether the CPU
    supports Reduced Data Speculation.
    
    [ tglx: Split it out from a later patch ]
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 24e4dd97af40afa4d45e85a32d9c2cc81425a62e
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:20 2018 -0400

    x86/bugs: Expose /sys/../spec_store_bypass
    
    commit c456442cd3a59eeb1d60293c26cbe2ff2c4e42cf upstream
    
    Add the sysfs file for the new vulerability. It does not do much except
    show the words 'Vulnerable' for recent x86 cores.
    
    Intel cores prior to family 6 are known not to be vulnerable, and so are
    some Atoms and some Xeon Phi.
    
    It assumes that older Cyrix, Centaur, etc. cores are immune.
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cf21f58ae6f264e0a10d9736be97342627cf9837
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:19 2018 -0400

    x86/bugs, KVM: Support the combination of guest and host IBRS
    
    commit 5cf687548705412da47c9cec342fd952d71ed3d5 upstream
    
    A guest may modify the SPEC_CTRL MSR from the value used by the
    kernel. Since the kernel doesn't use IBRS, this means a value of zero is
    what is needed in the host.
    
    But the 336996-Speculative-Execution-Side-Channel-Mitigations.pdf refers to
    the other bits as reserved so the kernel should respect the boot time
    SPEC_CTRL value and use that.
    
    This allows to deal with future extensions to the SPEC_CTRL interface if
    any at all.
    
    Note: This uses wrmsrl() instead of native_wrmsl(). I does not make any
    difference as paravirt will over-write the callq *0xfff.. with the wrmsrl
    assembler code.
    
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0f5dd651397b264903e8becc511af6cf384c273e
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:18 2018 -0400

    x86/bugs: Read SPEC_CTRL MSR during boot and re-use reserved bits
    
    commit 1b86883ccb8d5d9506529d42dbe1a5257cb30b18 upstream
    
    The 336996-Speculative-Execution-Side-Channel-Mitigations.pdf refers to all
    the other bits as reserved. The Intel SDM glossary defines reserved as
    implementation specific - aka unknown.
    
    As such at bootup this must be taken it into account and proper masking for
    the bits in use applied.
    
    A copy of this document is available at
    https://bugzilla.kernel.org/show_bug.cgi?id=199511
    
    [ tglx: Made x86_spec_ctrl_base __ro_after_init ]
    
    Suggested-by: Jon Masters <jcm@redhat.com>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3effee64a9993dc5587fb39f0da4455769e53d26
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:17 2018 -0400

    x86/bugs: Concentrate bug reporting into a separate function
    
    commit d1059518b4789cabe34bb4b714d07e6089c82ca1 upstream
    
    Those SysFS functions have a similar preamble, as such make common
    code to handle them.
    
    Suggested-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 88659d5fd9bea7f6afb227c6d404de750b368b45
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Wed Apr 25 22:04:16 2018 -0400

    x86/bugs: Concentrate bug detection into a separate function
    
    commit 4a28bfe3267b68e22c663ac26185aa16c9b879ef upstream
    
    Combine the various logic which goes through all those
    x86_cpu_id matching structures in one function.
    
    Suggested-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 741c026d1a0c594f7ad509f44488ef29582fed74
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Tue May 1 15:55:51 2018 +0200

    x86/nospec: Simplify alternative_msr_write()
    
    commit 1aa7a5735a41418d8e01fa7c9565eb2657e2ea3f upstream
    
    The macro is not type safe and I did look for why that "g" constraint for
    the asm doesn't work: it's because the asm is more fundamentally wrong.
    
    It does
    
            movl %[val], %%eax
    
    but "val" isn't a 32-bit value, so then gcc will pass it in a register,
    and generate code like
    
            movl %rsi, %eax
    
    and gas will complain about a nonsensical 'mov' instruction (it's moving a
    64-bit register to a 32-bit one).
    
    Passing it through memory will just hide the real bug - gcc still thinks
    the memory location is 64-bit, but the "movl" will only load the first 32
    bits and it all happens to work because x86 is little-endian.
    
    Convert it to a type safe inline function with a little trick which hands
    the feature into the ALTERNATIVE macro.
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 298d5db170f7d8430498417fa96e7472b620dcea
Author: Liu Bo <bo.liu@linux.alibaba.com>
Date:   Wed May 16 01:37:36 2018 +0800

    btrfs: fix reading stale metadata blocks after degraded raid1 mounts
    
    commit 02a3307aa9c20b4f6626255b028f07f6cfa16feb upstream.
    
    If a btree block, aka. extent buffer, is not available in the extent
    buffer cache, it'll be read out from the disk instead, i.e.
    
    btrfs_search_slot()
      read_block_for_search()  # hold parent and its lock, go to read child
        btrfs_release_path()
        read_tree_block()  # read child
    
    Unfortunately, the parent lock got released before reading child, so
    commit 5bdd3536cbbe ("Btrfs: Fix block generation verification race") had
    used 0 as parent transid to read the child block.  It forces
    read_tree_block() not to check if parent transid is different with the
    generation id of the child that it reads out from disk.
    
    A simple PoC is included in btrfs/124,
    
    0. A two-disk raid1 btrfs,
    
    1. Right after mkfs.btrfs, block A is allocated to be device tree's root.
    
    2. Mount this filesystem and put it in use, after a while, device tree's
       root got COW but block A hasn't been allocated/overwritten yet.
    
    3. Umount it and reload the btrfs module to remove both disks from the
       global @fs_devices list.
    
    4. mount -odegraded dev1 and write some data, so now block A is allocated
       to be a leaf in checksum tree.  Note that only dev1 has the latest
       metadata of this filesystem.
    
    5. Umount it and mount it again normally (with both disks), since raid1
       can pick up one disk by the writer task's pid, if btrfs_search_slot()
       needs to read block A, dev2 which does NOT have the latest metadata
       might be read for block A, then we got a stale block A.
    
    6. As parent transid is not checked, block A is marked as uptodate and
       put into the extent buffer cache, so the future search won't bother
       to read disk again, which means it'll make changes on this stale
       one and make it dirty and flush it onto disk.
    
    To avoid the problem, parent transid needs to be passed to
    read_tree_block().
    
    In order to get a valid parent transid, we need to hold the parent's
    lock until finishing reading child.
    
    This patch needs to be slightly adapted for stable kernels, the
    &first_key parameter added to read_tree_block() is from 4.16+
    (581c1760415c4). The fix is to replace 0 by 'gen'.
    
    Fixes: 5bdd3536cbbe ("Btrfs: Fix block generation verification race")
    CC: stable@vger.kernel.org # 4.4+
    Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    [ update changelog ]
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 944e0fc51a89c9827b98813d65dc083274777c7f
Author: David Woodhouse <dwmw@amazon.co.uk>
Date:   Sun May 20 20:51:10 2018 +0100

    x86/amd: don't set X86_BUG_SYSRET_SS_ATTRS when running under Xen
    
    commit def9331a12977770cc6132d79f8e6565871e8e38 upstream
    
    When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set
    on AMD cpus.
    
    This bug/feature bit is kind of special as it will be used very early
    when switching threads. Setting the bit and clearing it a little bit
    later leaves a critical window where things can go wrong. This time
    window has enlarged a little bit by using setup_clear_cpu_cap() instead
    of the hypervisor's set_cpu_features callback. It seems this larger
    window now makes it rather easy to hit the problem.
    
    The proper solution is to never set the bit in case of Xen.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b2d748b3a8d4e936a7e6e5fc9f04e2f9696efcc5
Author: Anand Jain <anand.jain@oracle.com>
Date:   Thu May 17 15:16:51 2018 +0800

    btrfs: fix crash when trying to resume balance without the resume flag
    
    commit 02ee654d3a04563c67bfe658a05384548b9bb105 upstream.
    
    We set the BTRFS_BALANCE_RESUME flag in the btrfs_recover_balance()
    only, which isn't called during the remount. So when resuming from
    the paused balance we hit the bug:
    
     kernel: kernel BUG at fs/btrfs/volumes.c:3890!
     ::
     kernel:  balance_kthread+0x51/0x60 [btrfs]
     kernel:  kthread+0x111/0x130
     ::
     kernel: RIP: btrfs_balance+0x12e1/0x1570 [btrfs] RSP: ffffba7d0090bde8
    
    Reproducer:
      On a mounted filesystem:
    
      btrfs balance start --full-balance /btrfs
      btrfs balance pause /btrfs
      mount -o remount,ro /dev/sdb /btrfs
      mount -o remount,rw /dev/sdb /btrfs
    
    To fix this set the BTRFS_BALANCE_RESUME flag in
    btrfs_resume_balance_async().
    
    CC: stable@vger.kernel.org # 4.4+
    Signed-off-by: Anand Jain <anand.jain@oracle.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 92291247b6069bce1c9c695b0f3496be4303b9fc
Author: Filipe Manana <fdmanana@suse.com>
Date:   Fri May 11 16:42:42 2018 +0100

    Btrfs: fix xattr loss after power failure
    
    commit 9a8fca62aacc1599fea8e813d01e1955513e4fad upstream.
    
    If a file has xattrs, we fsync it, to ensure we clear the flags
    BTRFS_INODE_NEEDS_FULL_SYNC and BTRFS_INODE_COPY_EVERYTHING from its
    inode, the current transaction commits and then we fsync it (without
    either of those bits being set in its inode), we end up not logging
    all its xattrs. This results in deleting all xattrs when replying the
    log after a power failure.
    
    Trivial reproducer
    
      $ mkfs.btrfs -f /dev/sdb
      $ mount /dev/sdb /mnt
    
      $ touch /mnt/foobar
      $ setfattr -n user.xa -v qwerty /mnt/foobar
      $ xfs_io -c "fsync" /mnt/foobar
    
      $ sync
    
      $ xfs_io -c "pwrite -S 0xab 0 64K" /mnt/foobar
      $ xfs_io -c "fsync" /mnt/foobar
      <power failure>
    
      $ mount /dev/sdb /mnt
      $ getfattr --absolute-names --dump /mnt/foobar
      <empty output>
      $
    
    So fix this by making sure all xattrs are logged if we log a file's inode
    item and neither the flags BTRFS_INODE_NEEDS_FULL_SYNC nor
    BTRFS_INODE_COPY_EVERYTHING were set in the inode.
    
    Fixes: 36283bf777d9 ("Btrfs: fix fsync xattr loss in the fast fsync path")
    Cc: <stable@vger.kernel.org> # 4.2+
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 21cc684a31ef5f9290aaef48b1c9146b019d987d
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sun May 13 05:04:29 2018 +0100

    ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions
    
    commit 0d73c3f8e7f6ee2aab1bb350f60c180f5ae21a2c upstream.
    
    Since do_undefinstr() uses get_user to get the undefined
    instruction, it can be called before kprobes processes
    recursive check. This can cause an infinit recursive
    exception.
    Prohibit probing on get_user functions.
    
    Fixes: 24ba613c9d6c ("ARM kprobes: core code")
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b1690451d93fcd8af8edfa3b7fc6b966d330b0a8
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sun May 13 05:04:10 2018 +0100

    ARM: 8770/1: kprobes: Prohibit probing on optimized_callback
    
    commit 70948c05fdde0aac32f9667856a88725c192fa40 upstream.
    
    Prohibit probing on optimized_callback() because
    it is called from kprobes itself. If we put a kprobes
    on it, that will cause a recursive call loop.
    Mark it NOKPROBE_SYMBOL.
    
    Fixes: 0dc016dbd820 ("ARM: kprobes: enable OPTPROBES for ARM 32")
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 70b4b1451086218a32122cf9fc7f92ccfb9ae4dc
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sun May 13 05:03:54 2018 +0100

    ARM: 8769/1: kprobes: Fix to use get_kprobe_ctlblk after irq-disabed
    
    commit 69af7e23a6870df2ea6fa79ca16493d59b3eebeb upstream.
    
    Since get_kprobe_ctlblk() uses smp_processor_id() to access
    per-cpu variable, it hits smp_processor_id sanity check as below.
    
    [    7.006928] BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
    [    7.007859] caller is debug_smp_processor_id+0x20/0x24
    [    7.008438] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.16.0-rc1-00192-g4eb17253e4b5 #1
    [    7.008890] Hardware name: Generic DT based system
    [    7.009917] [<c0313f0c>] (unwind_backtrace) from [<c030e6d8>] (show_stack+0x20/0x24)
    [    7.010473] [<c030e6d8>] (show_stack) from [<c0c64694>] (dump_stack+0x84/0x98)
    [    7.010990] [<c0c64694>] (dump_stack) from [<c071ca5c>] (check_preemption_disabled+0x138/0x13c)
    [    7.011592] [<c071ca5c>] (check_preemption_disabled) from [<c071ca80>] (debug_smp_processor_id+0x20/0x24)
    [    7.012214] [<c071ca80>] (debug_smp_processor_id) from [<c03335e0>] (optimized_callback+0x2c/0xe4)
    [    7.013077] [<c03335e0>] (optimized_callback) from [<bf0021b0>] (0xbf0021b0)
    
    To fix this issue, call get_kprobe_ctlblk() right after
    irq-disabled since that disables preemption.
    
    Fixes: 0dc016dbd820 ("ARM: kprobes: enable OPTPROBES for ARM 32")
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f58b66165d556abcf7eb0375bcc85e9fec2de614
Author: Dexuan Cui <decui@microsoft.com>
Date:   Tue May 15 19:52:50 2018 +0000

    tick/broadcast: Use for_each_cpu() specially on UP kernels
    
    commit 5596fe34495cf0f645f417eb928ef224df3e3cb4 upstream.
    
    for_each_cpu() unintuitively reports CPU0 as set independent of the actual
    cpumask content on UP kernels. This causes an unexpected PIT interrupt
    storm on a UP kernel running in an SMP virtual machine on Hyper-V, and as
    a result, the virtual machine can suffer from a strange random delay of 1~20
    minutes during boot-up, and sometimes it can hang forever.
    
    Protect if by checking whether the cpumask is empty before entering the
    for_each_cpu() loop.
    
    [ tglx: Use !IS_ENABLED(CONFIG_SMP) instead of #ifdeffery ]
    
    Signed-off-by: Dexuan Cui <decui@microsoft.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Josh Poulson <jopoulso@microsoft.com>
    Cc: "Michael Kelley (EOSG)" <Michael.H.Kelley@microsoft.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: stable@vger.kernel.org
    Cc: Rakib Mullick <rakib.mullick@gmail.com>
    Cc: Jork Loeser <Jork.Loeser@microsoft.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: KY Srinivasan <kys@microsoft.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Link: https://lkml.kernel.org/r/KL1P15301MB000678289FE55BA365B3279ABF990@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM
    Link: https://lkml.kernel.org/r/KL1P15301MB0006FA63BC22BEB64902EAA0BF930@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 10b408d6324b60fe2a949c2bac63fe9d5bd00851
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sun May 13 05:04:16 2018 +0100

    ARM: 8771/1: kprobes: Prohibit kprobes on do_undefinstr
    
    commit eb0146daefdde65665b7f076fbff7b49dade95b9 upstream.
    
    Prohibit kprobes on do_undefinstr because kprobes on
    arm is implemented by undefined instruction. This means
    if we probe do_undefinstr(), it can cause infinit
    recursive exception.
    
    Fixes: 24ba613c9d6c ("ARM kprobes: core code")
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dc7de9b203e844ecb143b32cc86a54bb528b8c5d
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Date:   Fri May 4 07:59:58 2018 +0200

    efi: Avoid potential crashes, fix the 'struct efi_pci_io_protocol_32' definition for mixed mode
    
    commit 0b3225ab9407f557a8e20f23f37aa7236c10a9b1 upstream.
    
    Mixed mode allows a kernel built for x86_64 to interact with 32-bit
    EFI firmware, but requires us to define all struct definitions carefully
    when it comes to pointer sizes.
    
    'struct efi_pci_io_protocol_32' currently uses a 'void *' for the
    'romimage' field, which will be interpreted as a 64-bit field
    on such kernels, potentially resulting in bogus memory references
    and subsequent crashes.
    
    Tested-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: <stable@vger.kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Matt Fleming <matt@codeblueprint.co.uk>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-efi@vger.kernel.org
    Link: http://lkml.kernel.org/r/20180504060003.19618-13-ard.biesheuvel@linaro.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7925d9da8d189025b190ad43ff476cba240144f2
Author: Dave Hansen <dave.hansen@linux.intel.com>
Date:   Wed May 9 10:13:58 2018 -0700

    x86/pkeys: Do not special case protection key 0
    
    commit 2fa9d1cfaf0e02f8abef0757002bff12dfcfa4e6 upstream.
    
    mm_pkey_is_allocated() treats pkey 0 as unallocated.  That is
    inconsistent with the manpages, and also inconsistent with
    mm->context.pkey_allocation_map.  Stop special casing it and only
    disallow values that are actually bad (< 0).
    
    The end-user visible effect of this is that you can now use
    mprotect_pkey() to set pkey=0.
    
    This is a bit nicer than what Ram proposed[1] because it is simpler
    and removes special-casing for pkey 0.  On the other hand, it does
    allow applications to pkey_free() pkey-0, but that's just a silly
    thing to do, so we are not going to protect against it.
    
    The scenario that could happen is similar to what happens if you free
    any other pkey that is in use: it might get reallocated later and used
    to protect some other data.  The most likely scenario is that pkey-0
    comes back from pkey_alloc(), an access-disable or write-disable bit
    is set in PKRU for it, and the next stack access will SIGSEGV.  It's
    not horribly different from if you mprotect()'d your stack or heap to
    be unreadable or unwritable, which is generally very foolish, but also
    not explicitly prevented by the kernel.
    
    1. http://lkml.kernel.org/r/1522112702-27853-1-git-send-email-linuxram@us.ibm.com
    
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>p
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Michael Ellermen <mpe@ellerman.id.au>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ram Pai <linuxram@us.ibm.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-mm@kvack.org
    Cc: stable@vger.kernel.org
    Fixes: 58ab9a088dda ("x86/pkeys: Check against max pkey to avoid overflows")
    Link: http://lkml.kernel.org/r/20180509171358.47FD785E@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a8330db3fb9b434471b861927e8e965835005929
Author: Dave Hansen <dave.hansen@linux.intel.com>
Date:   Wed May 9 10:13:51 2018 -0700

    x86/pkeys: Override pkey when moving away from PROT_EXEC
    
    commit 0a0b152083cfc44ec1bb599b57b7aab41327f998 upstream.
    
    I got a bug report that the following code (roughly) was
    causing a SIGSEGV:
    
            mprotect(ptr, size, PROT_EXEC);
            mprotect(ptr, size, PROT_NONE);
            mprotect(ptr, size, PROT_READ);
            *ptr = 100;
    
    The problem is hit when the mprotect(PROT_EXEC)
    is implicitly assigned a protection key to the VMA, and made
    that key ACCESS_DENY|WRITE_DENY.  The PROT_NONE mprotect()
    failed to remove the protection key, and the PROT_NONE->
    PROT_READ left the PTE usable, but the pkey still in place
    and left the memory inaccessible.
    
    To fix this, we ensure that we always "override" the pkee
    at mprotect() if the VMA does not have execute-only
    permissions, but the VMA has the execute-only pkey.
    
    We had a check for PROT_READ/WRITE, but it did not work
    for PROT_NONE.  This entirely removes the PROT_* checks,
    which ensures that PROT_NONE now works.
    
    Reported-by: Shakeel Butt <shakeelb@google.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Michael Ellermen <mpe@ellerman.id.au>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ram Pai <linuxram@us.ibm.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-mm@kvack.org
    Cc: stable@vger.kernel.org
    Fixes: 62b5f7d013f ("mm/core, x86/mm/pkeys: Add execute-only protection keys support")
    Link: http://lkml.kernel.org/r/20180509171351.084C5A71@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 633b4eb03bab15247214eae6a544dabf01688511
Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date:   Tue Apr 24 11:18:49 2018 +0200

    s390: remove indirect branch from do_softirq_own_stack
    
    commit 9f18fff63cfd6f559daa1eaae60640372c65f84b upstream.
    
    The inline assembly to call __do_softirq on the irq stack uses
    an indirect branch. This can be replaced with a normal relative
    branch.
    
    Cc: stable@vger.kernel.org # 4.16
    Fixes: f19fbd5ed6 ("s390: introduce execute-trampolines for branches")
    Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c79b01b8d4cb7c37c5da2299152c2ca9f22acc76
Author: Julian Wiedmann <jwi@linux.ibm.com>
Date:   Wed May 2 08:28:34 2018 +0200

    s390/qdio: don't release memory in qdio_setup_irq()
    
    commit 2e68adcd2fb21b7188ba449f0fab3bee2910e500 upstream.
    
    Calling qdio_release_memory() on error is just plain wrong. It frees
    the main qdio_irq struct, when following code still uses it.
    
    Also, no other error path in qdio_establish() does this. So trust
    callers to clean up via qdio_free() if some step of the QDIO
    initialization fails.
    
    Fixes: 779e6e1c724d ("[S390] qdio: new qdio driver.")
    Cc: <stable@vger.kernel.org> #v2.6.27+
    Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a03e14f09b40a1a10ce464d906814bb85ecd71ab
Author: Hendrik Brueckner <brueckner@linux.ibm.com>
Date:   Thu May 3 15:56:15 2018 +0200

    s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero
    
    commit 4bbaf2584b86b0772413edeac22ff448f36351b1 upstream.
    
    Correct a trinity finding for the perf_event_open() system call with
    a perf event attribute structure that uses a frequency but has the
    sampling frequency set to zero.  This causes a FP divide exception during
    the sample rate initialization for the hardware sampling facility.
    
    Fixes: 8c069ff4bd606 ("s390/perf: add support for the CPU-Measurement Sampling Facility")
    Cc: stable@vger.kernel.org # 3.14+
    Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 252bbeb9688a3c6ede9ea997e93ecb5d05e60209
Author: Julian Wiedmann <jwi@linux.ibm.com>
Date:   Wed May 2 08:48:43 2018 +0200

    s390/qdio: fix access to uninitialized qdio_q fields
    
    commit e521813468f786271a87e78e8644243bead48fad upstream.
    
    Ever since CQ/QAOB support was added, calling qdio_free() straight after
    qdio_alloc() results in qdio_release_memory() accessing uninitialized
    memory (ie. q->u.out.use_cq and q->u.out.aobs). Followed by a
    kmem_cache_free() on the random AOB addresses.
    
    For older kernels that don't have 6e30c549f6ca, the same applies if
    qdio_establish() fails in the DEV_STATE_ONLINE check.
    
    While initializing q->u.out.use_cq would be enough to fix this
    particular bug, the more future-proof change is to just zero-alloc the
    whole struct.
    
    Fixes: 104ea556ee7f ("qdio: support asynchronous delivery of storage blocks")
    Cc: <stable@vger.kernel.org> #v3.2+
    Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 270693b978f345c34509676c0729d72c19b6d87e
Author: Pavel Tatashin <pasha.tatashin@oracle.com>
Date:   Fri May 18 16:09:13 2018 -0700

    mm: don't allow deferred pages with NEED_PER_CPU_KM
    
    commit ab1e8d8960b68f54af42b6484b5950bd13a4054b upstream.
    
    It is unsafe to do virtual to physical translations before mm_init() is
    called if struct page is needed in order to determine the memory section
    number (see SECTION_IN_PAGE_FLAGS).  This is because only in mm_init()
    we initialize struct pages for all the allocated memory when deferred
    struct pages are used.
    
    My recent fix in commit c9e97a1997 ("mm: initialize pages on demand
    during boot") exposed this problem, because it greatly reduced number of
    pages that are initialized before mm_init(), but the problem existed
    even before my fix, as Fengguang Wu found.
    
    Below is a more detailed explanation of the problem.
    
    We initialize struct pages in four places:
    
    1. Early in boot a small set of struct pages is initialized to fill the
       first section, and lower zones.
    
    2. During mm_init() we initialize "struct pages" for all the memory that
       is allocated, i.e reserved in memblock.
    
    3. Using on-demand logic when pages are allocated after mm_init call
       (when memblock is finished)
    
    4. After smp_init() when the rest free deferred pages are initialized.
    
    The problem occurs if we try to do va to phys translation of a memory
    between steps 1 and 2.  Because we have not yet initialized struct pages
    for all the reserved pages, it is inherently unsafe to do va to phys if
    the translation itself requires access of "struct page" as in case of
    this combination: CONFIG_SPARSE && !CONFIG_SPARSE_VMEMMAP
    
    The following path exposes the problem:
    
      start_kernel()
       trap_init()
        setup_cpu_entry_areas()
         setup_cpu_entry_area(cpu)
          get_cpu_gdt_paddr(cpu)
           per_cpu_ptr_to_phys(addr)
            pcpu_addr_to_page(addr)
             virt_to_page(addr)
              pfn_to_page(__pa(addr) >> PAGE_SHIFT)
    
    We disable this path by not allowing NEED_PER_CPU_KM with deferred
    struct pages feature.
    
    The problems are discussed in these threads:
      http://lkml.kernel.org/r/20180418135300.inazvpxjxowogyge@wfg-t540p.sh.intel.com
      http://lkml.kernel.org/r/20180419013128.iurzouiqxvcnpbvz@wfg-t540p.sh.intel.com
      http://lkml.kernel.org/r/20180426202619.2768-1-pasha.tatashin@oracle.com
    
    Link: http://lkml.kernel.org/r/20180515175124.1770-1-pasha.tatashin@oracle.com
    Fixes: 3a80a7fa7989 ("mm: meminit: initialise a subset of struct pages if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set")
    Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Steven Sistare <steven.sistare@oracle.com>
    Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Fengguang Wu <fengguang.wu@intel.com>
    Cc: Dennis Zhou <dennisszhou@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 96c83fb2de4d45a9da51668e4a2f9aa0ac2c74ba
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Tue May 15 01:59:47 2018 +1000

    powerpc/powernv: Fix NVRAM sleep in invalid context when crashing
    
    commit c1d2a31397ec51f0370f6bd17b19b39152c263cb upstream.
    
    Similarly to opal_event_shutdown, opal_nvram_write can be called in
    the crash path with irqs disabled. Special case the delay to avoid
    sleeping in invalid context.
    
    Fixes: 3b8070335f75 ("powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops")
    Cc: stable@vger.kernel.org # v3.2
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 895c53e10b91432d0e9a9662448f0c7fc40f79e1
Author: Alexander Monakov <amonakov@ispras.ru>
Date:   Sat Apr 28 16:56:06 2018 +0300

    i2c: designware: fix poll-after-enable regression
    
    commit 06cb616b1bca7080824acfedb3d4c898e7a64836 upstream.
    
    Not all revisions of DW I2C controller implement the enable status register.
    On platforms where that's the case (e.g. BG2CD and SPEAr ARM SoCs), waiting
    for enable will time out as reading the unimplemented register yields zero.
    
    It was observed that reading the IC_ENABLE_STATUS register once suffices to
    avoid getting it stuck on Bay Trail hardware, so replace polling with one
    dummy read of the register.
    
    Fixes: fba4adbbf670 ("i2c: designware: must wait for enable")
    Signed-off-by: Alexander Monakov <amonakov@ispras.ru>
    Tested-by: Ben Gardner <gardner.ben@gmail.com>
    Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f32bb2aad27e5dac434a8fa1e12b1d6c25fe49f8
Author: Florian Westphal <fw@strlen.de>
Date:   Tue Apr 10 09:30:27 2018 +0200

    netfilter: nf_tables: can't fail after linking rule into active rule list
    
    commit 569ccae68b38654f04b6842b034aa33857f605fe upstream.
    
    rules in nftables a free'd using kfree, but protected by rcu, i.e. we
    must wait for a grace period to elapse.
    
    Normal removal patch does this, but nf_tables_newrule() doesn't obey
    this rule during error handling.
    
    It calls nft_trans_rule_add() *after* linking rule, and, if that
    fails to allocate memory, it unlinks the rule and then kfree() it --
    this is unsafe.
    
    Switch order -- first add rule to transaction list, THEN link it
    to public list.
    
    Note: nft_trans_rule_add() uses GFP_KERNEL; it will not fail so this
    is not a problem in practice (spotted only during code review).
    
    Fixes: 0628b123c96d12 ("netfilter: nfnetlink: add batch support and use it from nf_tables")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1af681da78b748eba17ad244d08e8bbe1980bf5c
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Wed May 9 14:36:09 2018 -0400

    tracing/x86/xen: Remove zero data size trace events trace_xen_mmu_flush_tlb{_all}
    
    commit 45dd9b0666a162f8e4be76096716670cf1741f0e upstream.
    
    Doing an audit of trace events, I discovered two trace events in the xen
    subsystem that use a hack to create zero data size trace events. This is not
    what trace events are for. Trace events add memory footprint overhead, and
    if all you need to do is see if a function is hit or not, simply make that
    function noinline and use function tracer filtering.
    
    Worse yet, the hack used was:
    
     __array(char, x, 0)
    
    Which creates a static string of zero in length. There's assumptions about
    such constructs in ftrace that this is a dynamic string that is nul
    terminated. This is not the case with these tracepoints and can cause
    problems in various parts of ftrace.
    
    Nuke the trace events!
    
    Link: http://lkml.kernel.org/r/20180509144605.5a220327@gandalf.local.home
    
    Cc: stable@vger.kernel.org
    Fixes: 95a7d76897c1e ("xen/mmu: Use Xen specific TLB flush instead of the generic one.")
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 20a30619b3315c1f11565cfbc0dbe2ea92a8a003
Author: Waiman Long <Waiman.Long@hpe.com>
Date:   Wed Dec 14 15:04:10 2016 -0800

    signals: avoid unnecessary taking of sighand->siglock
    
    commit c7be96af89d4b53211862d8599b2430e8900ed92 upstream.
    
    When running certain database workload on a high-end system with many
    CPUs, it was found that spinlock contention in the sigprocmask syscalls
    became a significant portion of the overall CPU cycles as shown below.
    
      9.30%  9.30%  905387  dataserver  /proc/kcore 0x7fff8163f4d2
      [k] _raw_spin_lock_irq
                |
                ---_raw_spin_lock_irq
                   |
                   |--99.34%-- __set_current_blocked
                   |          sigprocmask
                   |          sys_rt_sigprocmask
                   |          system_call_fastpath
                   |          |
                   |          |--50.63%-- __swapcontext
                   |          |          |
                   |          |          |--99.91%-- upsleepgeneric
                   |          |
                   |          |--49.36%-- __setcontext
                   |          |          ktskRun
    
    Looking further into the swapcontext function in glibc, it was found that
    the function always call sigprocmask() without checking if there are
    changes in the signal mask.
    
    A check was added to the __set_current_blocked() function to avoid taking
    the sighand->siglock spinlock if there is no change in the signal mask.
    This will prevent unneeded spinlock contention when many threads are
    trying to call sigprocmask().
    
    With this patch applied, the spinlock contention in sigprocmask() was
    gone.
    
    Link: http://lkml.kernel.org/r/1474979209-11867-1-git-send-email-Waiman.Long@hpe.com
    Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
    Acked-by: Oleg Nesterov <oleg@redhat.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Stas Sergeev <stsp@list.ru>
    Cc: Scott J Norton <scott.norton@hpe.com>
    Cc: Douglas Hatch <doug.hatch@hpe.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Mel Gorman <mgorman@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c8b8d37c85805ebc47a3e6a5f799bad4de8328e
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Wed Jan 10 17:10:12 2018 +1100

    powerpc: Don't preempt_disable() in show_cpuinfo()
    
    commit 349524bc0da698ec77f2057cf4a4948eb6349265 upstream.
    
    This causes warnings from cpufreq mutex code. This is also rather
    unnecessary and ineffective. If we really want to prevent concurrent
    unplug, we could take the unplug read lock but I don't see this being
    critical.
    
    Fixes: cd77b5ce208c ("powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo")
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Acked-by: Michal Suchanek <msuchanek@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9488d11728a6d945ce589cac6b6760cdb361e9c6
Author: Andre Przywara <andre.przywara@arm.com>
Date:   Fri May 11 15:20:14 2018 +0100

    KVM: arm/arm64: VGIC/ITS: protect kvm_read_guest() calls with SRCU lock
    
    commit bf308242ab98b5d1648c3663e753556bef9bec01 upstream.
    
    kvm_read_guest() will eventually look up in kvm_memslots(), which requires
    either to hold the kvm->slots_lock or to be inside a kvm->srcu critical
    section.
    In contrast to x86 and s390 we don't take the SRCU lock on every guest
    exit, so we have to do it individually for each kvm_read_guest() call.
    
    Provide a wrapper which does that and use that everywhere.
    
    Note that ending the SRCU critical section before returning from the
    kvm_read_guest() wrapper is safe, because the data has been *copied*, so
    we don't need to rely on valid references to the memslot anymore.
    
    Cc: Stable <stable@vger.kernel.org> # 4.8+
    Reported-by: Jan Glauber <jan.glauber@caviumnetworks.com>
    Signed-off-by: Andre Przywara <andre.przywara@arm.com>
    Acked-by: Christoffer Dall <christoffer.dall@arm.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad04996f0bb0a2bfc8468c04dacc40aed76de8ae
Author: Kamal Dasu <kdasu.kdev@gmail.com>
Date:   Thu Apr 26 14:48:01 2018 -0400

    spi: bcm-qspi: Always read and set BSPI_MAST_N_BOOT_CTRL
    
    commit 602805fb618b018b7a41fbb3f93c1992b078b1ae upstream.
    
    Always confirm the BSPI_MAST_N_BOOT_CTRL bit when enabling
    or disabling BSPI transfers.
    
    Fixes: 4e3b2d236fe00 ("spi: bcm-qspi: Add BSPI spi-nor flash controller driver")
    Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1c384327383de13223186ec138c57cb49fa1efea
Author: Kamal Dasu <kdasu.kdev@gmail.com>
Date:   Thu Apr 26 14:48:00 2018 -0400

    spi: bcm-qspi: Avoid setting MSPI_CDRAM_PCS for spi-nor master
    
    commit 5eb9a07a4ae1008b67d8bcd47bddb3dae97456b7 upstream.
    
    Added fix for probing of spi-nor device non-zero chip selects. Set
    MSPI_CDRAM_PCS (peripheral chip select) with spi master for MSPI
    controller and not for MSPI/BSPI spi-nor master controller. Ensure
    setting of cs bit in chip select register on chip select change.
    
    Fixes: fa236a7ef24048 ("spi: bcm-qspi: Add Broadcom MSPI driver")
    Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a436539bc16fdc6cb69cfa069ca0388df8d53d4b
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Thu Apr 19 19:53:32 2018 +0300

    spi: pxa2xx: Allow 64-bit DMA
    
    commit efc4a13724b852ddaa3358402a8dec024ffbcb17 upstream.
    
    Currently the 32-bit device address only is supported for DMA. However,
    starting from Intel Sunrisepoint PCH the DMA address of the device FIFO
    can be 64-bit.
    
    Change the respective variable to be compatible with DMA engine
    expectations, i.e. to phys_addr_t.
    
    Fixes: 34cadd9c1bcb ("spi: pxa2xx: Add support for Intel Sunrisepoint")
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c5d8237ef6067635ed5cb6b787540c52afe6bc8f
Author: Wenwen Wang <wang6495@umn.edu>
Date:   Sat May 5 13:38:03 2018 -0500

    ALSA: control: fix a redundant-copy issue
    
    commit 3f12888dfae2a48741c4caa9214885b3aaf350f9 upstream.
    
    In snd_ctl_elem_add_compat(), the fields of the struct 'data' need to be
    copied from the corresponding fields of the struct 'data32' in userspace.
    This is achieved by invoking copy_from_user() and get_user() functions. The
    problem here is that the 'type' field is copied twice. One is by
    copy_from_user() and one is by get_user(). Given that the 'type' field is
    not used between the two copies, the second copy is *completely* redundant
    and should be removed for better performance and cleanup. Also, these two
    copies can cause inconsistent data: as the struct 'data32' resides in
    userspace and a malicious userspace process can race to change the 'type'
    field between the two copies to cause inconsistent data. Depending on how
    the data is used in the future, such an inconsistency may cause potential
    security risks.
    
    For above reasons, we should take out the second copy.
    
    Signed-off-by: Wenwen Wang <wang6495@umn.edu>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e303276bbd9e2c603eee7a5ca14362493728d589
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Tue May 8 09:27:46 2018 +0200

    ALSA: hda: Add Lenovo C50 All in one to the power_save blacklist
    
    commit c8beccc19b92f5172994c0732db689c08f4f98e5 upstream.
    
    Power-saving is causing loud plops on the Lenovo C50 All in one, add it
    to the blacklist.
    
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1572975
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 639a74bf5f4da1c64884ff157ec62fed2798d5d0
Author: Federico Cuello <fedux@fedux.com.ar>
Date:   Wed May 9 00:13:38 2018 +0200

    ALSA: usb: mixer: volume quirk for CM102-A+/102S+
    
    commit 21493316a3c4598f308d5a9fa31cc74639c4caff upstream.
    
    Currently it's not possible to set volume lower than 26% (it just mutes).
    
    Also fixes this warning:
    
      Warning! Unlikely big volume range (=9472), cval->res is probably wrong.
      [13] FU [PCM Playback Volume] ch = 2, val = -9473/-1/1
    
    , and volume works fine for full range.
    
    Signed-off-by: Federico Cuello <fedux@fedux.com.ar>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0471d407998b58d1f1cbb4f594fc63f9bf0ec7bb
Author: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Date:   Tue May 15 17:57:23 2018 -0600

    usbip: usbip_host: fix bad unlock balance during stub_probe()
    
    commit c171654caa875919be3c533d3518da8be5be966e upstream.
    
    stub_probe() calls put_busid_priv() in an error path when device isn't
    found in the busid_table. Fix it by making put_busid_priv() safe to be
    called with null struct bus_id_priv pointer.
    
    This problem happens when "usbip bind" is run without loading usbip_host
    driver and then running modprobe. The first failed bind attempt unbinds
    the device from the original driver and when usbip_host is modprobed,
    stub_probe() runs and doesn't find the device in its busid table and calls
    put_busid_priv(0 with null bus_id_priv pointer.
    
    usbip-host 3-10.2: 3-10.2 is not in match_busid table...  skip!
    
    [  367.359679] =====================================
    [  367.359681] WARNING: bad unlock balance detected!
    [  367.359683] 4.17.0-rc4+ #5 Not tainted
    [  367.359685] -------------------------------------
    [  367.359688] modprobe/2768 is trying to release lock (
    [  367.359689]
    ==================================================================
    [  367.359696] BUG: KASAN: null-ptr-deref in print_unlock_imbalance_bug+0x99/0x110
    [  367.359699] Read of size 8 at addr 0000000000000058 by task modprobe/2768
    
    [  367.359705] CPU: 4 PID: 2768 Comm: modprobe Not tainted 4.17.0-rc4+ #5
    
    Fixes: 22076557b07c ("usbip: usbip_host: fix NULL-ptr deref and use-after-free errors") in usb-linus
    Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f2a6d5f19450086e5cbdac7168d3fc75af32becf
Author: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Date:   Mon May 14 20:49:58 2018 -0600

    usbip: usbip_host: fix NULL-ptr deref and use-after-free errors
    
    commit 22076557b07c12086eeb16b8ce2b0b735f7a27e7 upstream.
    
    usbip_host updates device status without holding lock from stub probe,
    disconnect and rebind code paths. When multiple requests to import a
    device are received, these unprotected code paths step all over each
    other and drive fails with NULL-ptr deref and use-after-free errors.
    
    The driver uses a table lock to protect the busid array for adding and
    deleting busids to the table. However, the probe, disconnect and rebind
    paths get the busid table entry and update the status without holding
    the busid table lock. Add a new finer grain lock to protect the busid
    entry. This new lock will be held to search and update the busid entry
    fields from get_busid_idx(), add_match_busid() and del_match_busid().
    
    match_busid_show() does the same to access the busid entry fields.
    
    get_busid_priv() changed to return the pointer to the busid entry holding
    the busid lock. stub_probe(), stub_disconnect() and stub_device_rebind()
    call put_busid_priv() to release the busid lock before returning. This
    changes fixes the unprotected code paths eliminating the race conditions
    in updating the busid entries.
    
    Reported-by: Jakub Jirasek
    Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 59ad4f5342dadadbcf9fd67f29fd6a8ed70ab125
Author: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Date:   Mon Apr 30 16:17:20 2018 -0600

    usbip: usbip_host: run rebind from exit when module is removed
    
    commit 7510df3f29d44685bab7b1918b61a8ccd57126a9 upstream.
    
    After removing usbip_host module, devices it releases are left without
    a driver. For example, when a keyboard or a mass storage device are
    bound to usbip_host when it is removed, these devices are no longer
    bound to any driver.
    
    Fix it to run device_attach() from the module exit routine to restore
    the devices to their original drivers. This includes cleanup changes
    and moving device_attach() code to a common routine to be called from
    rebind_store() and usbip_host_exit().
    
    Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 58c9c70cb7e10599f44a996cc4b481fc5c02ea4f
Author: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Date:   Mon Apr 30 16:17:19 2018 -0600

    usbip: usbip_host: delete device from busid_table after rebind
    
    commit 1e180f167d4e413afccbbb4a421b48b2de832549 upstream.
    
    Device is left in the busid_table after unbind and rebind. Rebind
    initiates usb bus scan and the original driver claims the device.
    After rescan the device should be deleted from the busid_table as
    it no longer belongs to usbip_host.
    
    Fix it to delete the device after device_attach() succeeds.
    
    Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dbab65be6bdea68b6a201d03334b44a02860dd2c
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Wed Apr 11 18:13:30 2018 -0600

    usbip: usbip_host: refine probe and disconnect debug msgs to be useful
    
    commit 28b68acc4a88dcf91fd1dcf2577371dc9bf574cc upstream.
    
    Refine probe and disconnect debug msgs to be useful and say what is
    in progress.
    
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>