--- /dev/null
+From aaa23f86001bdb82d2f937c5c7bce0a1e11a6c5b Mon Sep 17 00:00:00 2001
+From: Chris Wilson <chris@chris-wilson.co.uk>
+Date: Wed, 27 Jun 2018 07:25:32 +0100
+Subject: ALSA: hda - Handle pm failure during hotplug
+
+From: Chris Wilson <chris@chris-wilson.co.uk>
+
+commit aaa23f86001bdb82d2f937c5c7bce0a1e11a6c5b upstream.
+
+Obtaining the runtime pm wakeref can fail, especially in a hotplug
+scenario where i915.ko has been unloaded. If we do not catch the
+failure, we end up with an unbalanced pm.
+
+v2 additions by tiwai:
+hdmi_present_sense() checks the return value and handle only a
+negative error case and bails out only if it's really still suspended.
+Also, snd_hda_power_down() is called at the error path so that the
+refcount is balanced.
+
+Along with it, the spec->pcm_lock is taken outside
+hdmi_present_sense() in the caller side, so that it won't cause
+deadlock at reentrace via runtime resume.
+
+v3 fix by tiwai:
+Missing linux/pm_runtime.h is included.
+
+References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug")
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/pci/hda/patch_hdmi.c | 19 ++++++++++++++-----
+ 1 file changed, 14 insertions(+), 5 deletions(-)
+
+--- a/sound/pci/hda/patch_hdmi.c
++++ b/sound/pci/hda/patch_hdmi.c
+@@ -33,6 +33,7 @@
+ #include <linux/delay.h>
+ #include <linux/slab.h>
+ #include <linux/module.h>
++#include <linux/pm_runtime.h>
+ #include <sound/core.h>
+ #include <sound/jack.h>
+ #include <sound/asoundef.h>
+@@ -764,8 +765,10 @@ static void check_presence_and_report(st
+
+ if (pin_idx < 0)
+ return;
++ mutex_lock(&spec->pcm_lock);
+ if (hdmi_present_sense(get_pin(spec, pin_idx), 1))
+ snd_hda_jack_report_sync(codec);
++ mutex_unlock(&spec->pcm_lock);
+ }
+
+ static void jack_callback(struct hda_codec *codec,
+@@ -1628,21 +1631,23 @@ static void sync_eld_via_acomp(struct hd
+ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
+ {
+ struct hda_codec *codec = per_pin->codec;
+- struct hdmi_spec *spec = codec->spec;
+ int ret;
+
+ /* no temporary power up/down needed for component notifier */
+- if (!codec_has_acomp(codec))
+- snd_hda_power_up_pm(codec);
++ if (!codec_has_acomp(codec)) {
++ ret = snd_hda_power_up_pm(codec);
++ if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) {
++ snd_hda_power_down_pm(codec);
++ return false;
++ }
++ }
+
+- mutex_lock(&spec->pcm_lock);
+ if (codec_has_acomp(codec)) {
+ sync_eld_via_acomp(codec, per_pin);
+ ret = false; /* don't call snd_hda_jack_report_sync() */
+ } else {
+ ret = hdmi_present_sense_via_verbs(per_pin, repoll);
+ }
+- mutex_unlock(&spec->pcm_lock);
+
+ if (!codec_has_acomp(codec))
+ snd_hda_power_down_pm(codec);
+@@ -1654,12 +1659,16 @@ static void hdmi_repoll_eld(struct work_
+ {
+ struct hdmi_spec_per_pin *per_pin =
+ container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
++ struct hda_codec *codec = per_pin->codec;
++ struct hdmi_spec *spec = codec->spec;
+
+ if (per_pin->repoll_count++ > 6)
+ per_pin->repoll_count = 0;
+
++ mutex_lock(&spec->pcm_lock);
+ if (hdmi_present_sense(per_pin, per_pin->repoll_count))
+ snd_hda_jack_report_sync(per_pin->codec);
++ mutex_unlock(&spec->pcm_lock);
+ }
+
+ static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
--- /dev/null
+From c6b17f1020d956f4113d478cae6171b9093817ba Mon Sep 17 00:00:00 2001
+From: Hui Wang <hui.wang@canonical.com>
+Date: Fri, 6 Jul 2018 15:14:11 +0800
+Subject: ALSA: hda/realtek - two more lenovo models need fixup of MIC_LOCATION
+
+From: Hui Wang <hui.wang@canonical.com>
+
+commit c6b17f1020d956f4113d478cae6171b9093817ba upstream.
+
+We have two new lenovo desktop models which need to apply the fixup of
+ALC294_FIXUP_LENOVO_MIC_LOCATION, and they have the same pin cfg as
+the machine with subsystem id:0x17aa3136, now use the pincfg table
+to apply the fixup for them.
+
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Hui Wang <hui.wang@canonical.com>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/pci/hda/patch_realtek.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/sound/pci/hda/patch_realtek.c
++++ b/sound/pci/hda/patch_realtek.c
+@@ -6586,7 +6586,6 @@ static const struct snd_pci_quirk alc269
+ SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+ SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+ SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+- SND_PCI_QUIRK(0x17aa, 0x3136, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+ SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
+ SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
+ SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
+@@ -6770,6 +6769,11 @@ static const struct snd_hda_pin_quirk al
+ {0x1a, 0x02a11040},
+ {0x1b, 0x01014020},
+ {0x21, 0x0221101f}),
++ SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
++ {0x14, 0x90170110},
++ {0x19, 0x02a11020},
++ {0x1a, 0x02a11030},
++ {0x21, 0x0221101f}),
+ SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
+ {0x12, 0x90a60140},
+ {0x14, 0x90170110},
--- /dev/null
+From 24962af7e1041b7e50c1bc71d8d10dc678c556b5 Mon Sep 17 00:00:00 2001
+From: Oscar Salvador <osalvador@suse.de>
+Date: Fri, 13 Jul 2018 16:59:13 -0700
+Subject: fs, elf: make sure to page align bss in load_elf_library
+
+From: Oscar Salvador <osalvador@suse.de>
+
+commit 24962af7e1041b7e50c1bc71d8d10dc678c556b5 upstream.
+
+The current code does not make sure to page align bss before calling
+vm_brk(), and this can lead to a VM_BUG_ON() in __mm_populate() due to
+the requested lenght not being correctly aligned.
+
+Let us make sure to align it properly.
+
+Kees: only applicable to CONFIG_USELIB kernels: 32-bit and configured
+for libc5.
+
+Link: http://lkml.kernel.org/r/20180705145539.9627-1-osalvador@techadventures.net
+Signed-off-by: Oscar Salvador <osalvador@suse.de>
+Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com
+Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
+Acked-by: Kees Cook <keescook@chromium.org>
+Cc: Michal Hocko <mhocko@suse.com>
+Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
+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>
+
+---
+ fs/binfmt_elf.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/fs/binfmt_elf.c
++++ b/fs/binfmt_elf.c
+@@ -1259,9 +1259,8 @@ static int load_elf_library(struct file
+ goto out_free_ph;
+ }
+
+- len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr +
+- ELF_MIN_ALIGN - 1);
+- bss = eppnt->p_memsz + eppnt->p_vaddr;
++ len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr);
++ bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr);
+ if (bss > len) {
+ error = vm_brk(len, bss - len);
+ if (error)
--- /dev/null
+From e70cc2bd579e8a9d6d153762f0fe294d0e652ff0 Mon Sep 17 00:00:00 2001
+From: Vlastimil Babka <vbabka@suse.cz>
+Date: Fri, 13 Jul 2018 16:58:56 -0700
+Subject: fs/proc/task_mmu.c: fix Locked field in /proc/pid/smaps*
+
+From: Vlastimil Babka <vbabka@suse.cz>
+
+commit e70cc2bd579e8a9d6d153762f0fe294d0e652ff0 upstream.
+
+Thomas reports:
+ "While looking around in /proc on my v4.14.52 system I noticed that all
+ processes got a lot of "Locked" memory in /proc/*/smaps. A lot more
+ memory than a regular user can usually lock with mlock().
+
+ Commit 493b0e9d945f (in v4.14-rc1) seems to have changed the behavior
+ of "Locked".
+
+ Before that commit the code was like this. Notice the VM_LOCKED check.
+
+ (vma->vm_flags & VM_LOCKED) ?
+ (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0);
+
+ After that commit Locked is now the same as Pss:
+
+ (unsigned long)(mss->pss >> (10 + PSS_SHIFT)));
+
+ This looks like a mistake."
+
+Indeed, the commit has added mss->pss_locked with the correct value that
+depends on VM_LOCKED, but forgot to actually use it. Fix it.
+
+Link: http://lkml.kernel.org/r/ebf6c7fb-fec3-6a26-544f-710ed193c154@suse.cz
+Fixes: 493b0e9d945f ("mm: add /proc/pid/smaps_rollup")
+Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
+Reported-by: Thomas Lindroth <thomas.lindroth@gmail.com>
+Cc: Alexey Dobriyan <adobriyan@gmail.com>
+Cc: Daniel Colascione <dancol@google.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>
+
+---
+ fs/proc/task_mmu.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/fs/proc/task_mmu.c
++++ b/fs/proc/task_mmu.c
+@@ -831,7 +831,8 @@ static int show_smap(struct seq_file *m,
+ SEQ_PUT_DEC(" kB\nSwap: ", mss->swap);
+ SEQ_PUT_DEC(" kB\nSwapPss: ",
+ mss->swap_pss >> PSS_SHIFT);
+- SEQ_PUT_DEC(" kB\nLocked: ", mss->pss >> PSS_SHIFT);
++ SEQ_PUT_DEC(" kB\nLocked: ",
++ mss->pss_locked >> PSS_SHIFT);
+ seq_puts(m, " kB\n");
+ }
+ if (!rollup_mode) {
--- /dev/null
+From 3f9cdee5929b7d035e86302dcf08fbf3e80b0739 Mon Sep 17 00:00:00 2001
+From: Randy Dunlap <rdunlap@infradead.org>
+Date: Wed, 4 Jul 2018 12:59:16 -0700
+Subject: kbuild: delete INSTALL_FW_PATH from kbuild documentation
+
+From: Randy Dunlap <rdunlap@infradead.org>
+
+commit 3f9cdee5929b7d035e86302dcf08fbf3e80b0739 upstream.
+
+Removed Kbuild documentation for INSTALL_FW_PATH.
+
+The kbuild symbol INSTALL_FW_PATH was removed from Kbuild tools in
+September 2017 (for 4.14) but the symbol was not deleted from
+the kbuild documentation, so do that now.
+
+Fixes: 5620a0d1aacd ("firmware: delete in-kernel firmware")
+Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
+Cc: stable@vger.kernel.org # 4.14+
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Documentation/kbuild/kbuild.txt | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+--- a/Documentation/kbuild/kbuild.txt
++++ b/Documentation/kbuild/kbuild.txt
+@@ -148,15 +148,6 @@ stripped after they are installed. If I
+ the default option --strip-debug will be used. Otherwise,
+ INSTALL_MOD_STRIP value will be used as the options to the strip command.
+
+-INSTALL_FW_PATH
+---------------------------------------------------
+-INSTALL_FW_PATH specifies where to install the firmware blobs.
+-The default value is:
+-
+- $(INSTALL_MOD_PATH)/lib/firmware
+-
+-The value can be overridden in which case the default value is ignored.
+-
+ INSTALL_HDR_PATH
+ --------------------------------------------------
+ INSTALL_HDR_PATH specifies where to install user space headers when
--- /dev/null
+From bb177a732c4369bb58a1fe1df8f552b6f0f7db5f Mon Sep 17 00:00:00 2001
+From: Michal Hocko <mhocko@suse.com>
+Date: Fri, 13 Jul 2018 16:59:20 -0700
+Subject: mm: do not bug_on on incorrect length in __mm_populate()
+
+From: Michal Hocko <mhocko@suse.com>
+
+commit bb177a732c4369bb58a1fe1df8f552b6f0f7db5f upstream.
+
+syzbot has noticed that a specially crafted library can easily hit
+VM_BUG_ON in __mm_populate
+
+ kernel BUG at mm/gup.c:1242!
+ invalid opcode: 0000 [#1] SMP
+ CPU: 2 PID: 9667 Comm: a.out Not tainted 4.18.0-rc3 #644
+ Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
+ RIP: 0010:__mm_populate+0x1e2/0x1f0
+ Code: 55 d0 65 48 33 14 25 28 00 00 00 89 d8 75 21 48 83 c4 20 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 75 18 f1 ff 0f 0b e8 6e 18 f1 ff <0f> 0b 31 db eb c9 e8 93 06 e0 ff 0f 1f 00 55 48 89 e5 53 48 89 fb
+ Call Trace:
+ vm_brk_flags+0xc3/0x100
+ vm_brk+0x1f/0x30
+ load_elf_library+0x281/0x2e0
+ __ia32_sys_uselib+0x170/0x1e0
+ do_fast_syscall_32+0xca/0x420
+ entry_SYSENTER_compat+0x70/0x7f
+
+The reason is that the length of the new brk is not page aligned when we
+try to populate the it. There is no reason to bug on that though.
+do_brk_flags already aligns the length properly so the mapping is
+expanded as it should. All we need is to tell mm_populate about it.
+Besides that there is absolutely no reason to to bug_on in the first
+place. The worst thing that could happen is that the last page wouldn't
+get populated and that is far from putting system into an inconsistent
+state.
+
+Fix the issue by moving the length sanitization code from do_brk_flags
+up to vm_brk_flags. The only other caller of do_brk_flags is brk
+syscall entry and it makes sure to provide the proper length so t here
+is no need for sanitation and so we can use do_brk_flags without it.
+
+Also remove the bogus BUG_ONs.
+
+[osalvador@techadventures.net: fix up vm_brk_flags s@request@len@]
+Link: http://lkml.kernel.org/r/20180706090217.GI32658@dhcp22.suse.cz
+Signed-off-by: Michal Hocko <mhocko@suse.com>
+Reported-by: syzbot <syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com>
+Tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+Reviewed-by: Oscar Salvador <osalvador@suse.de>
+Cc: Zi Yan <zi.yan@cs.rutgers.edu>
+Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Cc: Dan Williams <dan.j.williams@intel.com>
+Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
+Cc: Michael S. Tsirkin <mst@redhat.com>
+Cc: Al Viro <viro@zeniv.linux.org.uk>
+Cc: "Huang, Ying" <ying.huang@intel.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>
+
+---
+ mm/gup.c | 2 --
+ mm/mmap.c | 29 ++++++++++++-----------------
+ 2 files changed, 12 insertions(+), 19 deletions(-)
+
+--- a/mm/gup.c
++++ b/mm/gup.c
+@@ -1222,8 +1222,6 @@ int __mm_populate(unsigned long start, u
+ int locked = 0;
+ long ret = 0;
+
+- VM_BUG_ON(start & ~PAGE_MASK);
+- VM_BUG_ON(len != PAGE_ALIGN(len));
+ end = start + len;
+
+ for (nstart = start; nstart < end; nstart = nend) {
+--- a/mm/mmap.c
++++ b/mm/mmap.c
+@@ -186,8 +186,8 @@ static struct vm_area_struct *remove_vma
+ return next;
+ }
+
+-static int do_brk(unsigned long addr, unsigned long len, struct list_head *uf);
+-
++static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long flags,
++ struct list_head *uf);
+ SYSCALL_DEFINE1(brk, unsigned long, brk)
+ {
+ unsigned long retval;
+@@ -245,7 +245,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
+ goto out;
+
+ /* Ok, looks good - let it rip. */
+- if (do_brk(oldbrk, newbrk-oldbrk, &uf) < 0)
++ if (do_brk_flags(oldbrk, newbrk-oldbrk, 0, &uf) < 0)
+ goto out;
+
+ set_brk:
+@@ -2929,21 +2929,14 @@ static inline void verify_mm_writelocked
+ * anonymous maps. eventually we may be able to do some
+ * brk-specific accounting here.
+ */
+-static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long flags, struct list_head *uf)
++static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long flags, struct list_head *uf)
+ {
+ struct mm_struct *mm = current->mm;
+ struct vm_area_struct *vma, *prev;
+- unsigned long len;
+ struct rb_node **rb_link, *rb_parent;
+ pgoff_t pgoff = addr >> PAGE_SHIFT;
+ int error;
+
+- len = PAGE_ALIGN(request);
+- if (len < request)
+- return -ENOMEM;
+- if (!len)
+- return 0;
+-
+ /* Until we need other flags, refuse anything except VM_EXEC. */
+ if ((flags & (~VM_EXEC)) != 0)
+ return -EINVAL;
+@@ -3015,18 +3008,20 @@ out:
+ return 0;
+ }
+
+-static int do_brk(unsigned long addr, unsigned long len, struct list_head *uf)
+-{
+- return do_brk_flags(addr, len, 0, uf);
+-}
+-
+-int vm_brk_flags(unsigned long addr, unsigned long len, unsigned long flags)
++int vm_brk_flags(unsigned long addr, unsigned long request, unsigned long flags)
+ {
+ struct mm_struct *mm = current->mm;
++ unsigned long len;
+ int ret;
+ bool populate;
+ LIST_HEAD(uf);
+
++ len = PAGE_ALIGN(request);
++ if (len < request)
++ return -ENOMEM;
++ if (!len)
++ return 0;
++
+ if (down_write_killable(&mm->mmap_sem))
+ return -EINTR;
+
--- /dev/null
+From bce73e4842390f7b7309c8e253e139db71288ac3 Mon Sep 17 00:00:00 2001
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Fri, 13 Jul 2018 16:58:52 -0700
+Subject: mm: do not drop unused pages when userfaultd is running
+
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+
+commit bce73e4842390f7b7309c8e253e139db71288ac3 upstream.
+
+KVM guests on s390 can notify the host of unused pages. This can result
+in pte_unused callbacks to be true for KVM guest memory.
+
+If a page is unused (checked with pte_unused) we might drop this page
+instead of paging it. This can have side-effects on userfaultd, when
+the page in question was already migrated:
+
+The next access of that page will trigger a fault and a user fault
+instead of faulting in a new and empty zero page. As QEMU does not
+expect a userfault on an already migrated page this migration will fail.
+
+The most straightforward solution is to ignore the pte_unused hint if a
+userfault context is active for this VMA.
+
+Link: http://lkml.kernel.org/r/20180703171854.63981-1-borntraeger@de.ibm.com
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Cc: Andrea Arcangeli <aarcange@redhat.com>
+Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
+Cc: Janosch Frank <frankja@linux.ibm.com>
+Cc: David Hildenbrand <david@redhat.com>
+Cc: Cornelia Huck <cohuck@redhat.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>
+
+---
+ mm/rmap.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+--- a/mm/rmap.c
++++ b/mm/rmap.c
+@@ -64,6 +64,7 @@
+ #include <linux/backing-dev.h>
+ #include <linux/page_idle.h>
+ #include <linux/memremap.h>
++#include <linux/userfaultfd_k.h>
+
+ #include <asm/tlbflush.h>
+
+@@ -1481,11 +1482,16 @@ static bool try_to_unmap_one(struct page
+ set_pte_at(mm, address, pvmw.pte, pteval);
+ }
+
+- } else if (pte_unused(pteval)) {
++ } else if (pte_unused(pteval) && !userfaultfd_armed(vma)) {
+ /*
+ * The guest indicated that the page content is of no
+ * interest anymore. Simply discard the pte, vmscan
+ * will take care of the rest.
++ * A future reference will then fault in a new zero
++ * page. When userfaultfd is active, we must not drop
++ * this page though, as its main user (postcopy
++ * migration) will not expect userfaults on already
++ * copied pages.
+ */
+ dec_mm_counter(mm, mm_counter(page));
+ /* We have to invalidate as we cleared the pte */
xhci-xhci-mem-off-by-one-in-xhci_stream_id_to_ring.patch
fix-up-non-directory-creation-in-sgid-directories.patch
mm-zero-unavailable-pages-before-memmap-init.patch
+alsa-hda-realtek-two-more-lenovo-models-need-fixup-of-mic_location.patch
+alsa-hda-handle-pm-failure-during-hotplug.patch
+mm-do-not-drop-unused-pages-when-userfaultd-is-running.patch
+fs-proc-task_mmu.c-fix-locked-field-in-proc-pid-smaps.patch
+x86-purgatory-add-missing-force-to-makefile-target.patch
+fs-elf-make-sure-to-page-align-bss-in-load_elf_library.patch
+mm-do-not-bug_on-on-incorrect-length-in-__mm_populate.patch
+tracing-reorder-display-of-tgid-to-be-after-pid.patch
+kbuild-delete-install_fw_path-from-kbuild-documentation.patch
--- /dev/null
+From f8494fa3dd10b52eab47a9666a8bc34719a129aa Mon Sep 17 00:00:00 2001
+From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
+Date: Mon, 25 Jun 2018 17:08:22 -0700
+Subject: tracing: Reorder display of TGID to be after PID
+
+From: Joel Fernandes (Google) <joel@joelfernandes.org>
+
+commit f8494fa3dd10b52eab47a9666a8bc34719a129aa upstream.
+
+Currently ftrace displays data in trace output like so:
+
+ _-----=> irqs-off
+ / _----=> need-resched
+ | / _---=> hardirq/softirq
+ || / _--=> preempt-depth
+ ||| / delay
+ TASK-PID CPU TGID |||| TIMESTAMP FUNCTION
+ | | | | |||| | |
+ bash-1091 [000] ( 1091) d..2 28.313544: sched_switch:
+
+However Android's trace visualization tools expect a slightly different
+format due to an out-of-tree patch patch that was been carried for a
+decade, notice that the TGID and CPU fields are reversed:
+
+ _-----=> irqs-off
+ / _----=> need-resched
+ | / _---=> hardirq/softirq
+ || / _--=> preempt-depth
+ ||| / delay
+ TASK-PID TGID CPU |||| TIMESTAMP FUNCTION
+ | | | | |||| | |
+ bash-1091 ( 1091) [002] d..2 64.965177: sched_switch:
+
+From kernel v4.13 onwards, during which TGID was introduced, tracing
+with systrace on all Android kernels will break (most Android kernels
+have been on 4.9 with Android patches, so this issues hasn't been seen
+yet). From v4.13 onwards things will break.
+
+The chrome browser's tracing tools also embed the systrace viewer which
+uses the legacy TGID format and updates to that are known to be
+difficult to make.
+
+Considering this, I suggest we make this change to the upstream kernel
+and backport it to all Android kernels. I believe this feature is merged
+recently enough into the upstream kernel that it shouldn't be a problem.
+Also logically, IMO it makes more sense to group the TGID with the
+TASK-PID and the CPU after these.
+
+Link: http://lkml.kernel.org/r/20180626000822.113931-1-joel@joelfernandes.org
+
+Cc: jreck@google.com
+Cc: tkjos@google.com
+Cc: stable@vger.kernel.org
+Fixes: 441dae8f2f29 ("tracing: Add support for display of tgid in trace output")
+Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
+Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/trace/trace.c | 8 ++++----
+ kernel/trace/trace_output.c | 5 +++--
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -3363,8 +3363,8 @@ static void print_func_help_header(struc
+
+ print_event_info(buf, m);
+
+- seq_printf(m, "# TASK-PID CPU# %s TIMESTAMP FUNCTION\n", tgid ? "TGID " : "");
+- seq_printf(m, "# | | | %s | |\n", tgid ? " | " : "");
++ seq_printf(m, "# TASK-PID %s CPU# TIMESTAMP FUNCTION\n", tgid ? "TGID " : "");
++ seq_printf(m, "# | | %s | | |\n", tgid ? " | " : "");
+ }
+
+ static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m,
+@@ -3384,9 +3384,9 @@ static void print_func_help_header_irq(s
+ tgid ? tgid_space : space);
+ seq_printf(m, "# %s||| / delay\n",
+ tgid ? tgid_space : space);
+- seq_printf(m, "# TASK-PID CPU#%s|||| TIMESTAMP FUNCTION\n",
++ seq_printf(m, "# TASK-PID %sCPU# |||| TIMESTAMP FUNCTION\n",
+ tgid ? " TGID " : space);
+- seq_printf(m, "# | | | %s|||| | |\n",
++ seq_printf(m, "# | | %s | |||| | |\n",
+ tgid ? " | " : space);
+ }
+
+--- a/kernel/trace/trace_output.c
++++ b/kernel/trace/trace_output.c
+@@ -594,8 +594,7 @@ int trace_print_context(struct trace_ite
+
+ trace_find_cmdline(entry->pid, comm);
+
+- trace_seq_printf(s, "%16s-%-5d [%03d] ",
+- comm, entry->pid, iter->cpu);
++ trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid);
+
+ if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+ unsigned int tgid = trace_find_tgid(entry->pid);
+@@ -606,6 +605,8 @@ int trace_print_context(struct trace_ite
+ trace_seq_printf(s, "(%5d) ", tgid);
+ }
+
++ trace_seq_printf(s, "[%03d] ", iter->cpu);
++
+ if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
+ trace_print_lat_fmt(s, entry);
+
--- /dev/null
+From fa8cbda88db12e632a8987c94b66f5caf25bcec4 Mon Sep 17 00:00:00 2001
+From: Philipp Rudo <prudo@linux.ibm.com>
+Date: Fri, 13 Jul 2018 16:59:09 -0700
+Subject: x86/purgatory: add missing FORCE to Makefile target
+
+From: Philipp Rudo <prudo@linux.ibm.com>
+
+commit fa8cbda88db12e632a8987c94b66f5caf25bcec4 upstream.
+
+- Build the kernel without the fix
+- Add some flag to the purgatories KBUILD_CFLAGS,I used
+ -fno-asynchronous-unwind-tables
+- Re-build the kernel
+
+When you look at makes output you see that sha256.o is not re-build in the
+last step. Also readelf -S still shows the .eh_frame section for
+sha256.o.
+
+With the fix sha256.o is rebuilt in the last step.
+
+Without FORCE make does not detect changes only made to the command line
+options. So object files might not be re-built even when they should be.
+Fix this by adding FORCE where it is missing.
+
+Link: http://lkml.kernel.org/r/20180704110044.29279-2-prudo@linux.ibm.com
+Fixes: df6f2801f511 ("kernel/kexec_file.c: move purgatories sha256 to common code")
+Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
+Acked-by: Dave Young <dyoung@redhat.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: <stable@vger.kernel.org> [4.17+]
+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>
+
+---
+ arch/x86/purgatory/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/x86/purgatory/Makefile
++++ b/arch/x86/purgatory/Makefile
+@@ -6,7 +6,7 @@ purgatory-y := purgatory.o stack.o setup
+ targets += $(purgatory-y)
+ PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
+
+-$(obj)/sha256.o: $(srctree)/lib/sha256.c
++$(obj)/sha256.o: $(srctree)/lib/sha256.c FORCE
+ $(call if_changed_rule,cc_o_c)
+
+ LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib